From e9299adb3b91ed17aa604d83f06c82963f07fbb3 Mon Sep 17 00:00:00 2001 From: WeiguangHan Date: Thu, 7 Dec 2023 19:02:41 +0800 Subject: [PATCH] LLM: Highlight some values in the html (#9635) * highlight some values in the html * revert the llm_performance_tests.yml --- python/llm/dev/benchmark/all-in-one/run.py | 1 + python/llm/test/benchmark/csv_to_html.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/python/llm/dev/benchmark/all-in-one/run.py b/python/llm/dev/benchmark/all-in-one/run.py index bcae312b..bc267208 100644 --- a/python/llm/dev/benchmark/all-in-one/run.py +++ b/python/llm/dev/benchmark/all-in-one/run.py @@ -401,6 +401,7 @@ def run_transformer_int4_gpu(repo_id, result[in_out].append([model.first_cost, model.rest_cost_mean, model.encoder_time, actual_in_len, actual_out_len]) except RuntimeError: + traceback.print_exc() pass del model torch.xpu.empty_cache() diff --git a/python/llm/test/benchmark/csv_to_html.py b/python/llm/test/benchmark/csv_to_html.py index a4bd58d9..94969c5c 100644 --- a/python/llm/test/benchmark/csv_to_html.py +++ b/python/llm/test/benchmark/csv_to_html.py @@ -21,6 +21,12 @@ import sys import argparse import pandas as pd +def highlight_vals(val, max=-3.0, color='yellow'): + if val < max: + return 'background-color: %s' % color + else: + return '' + def main(): parser = argparse.ArgumentParser(description="convert .csv file to .html file") parser.add_argument("-f", "--folder_path", type=str, dest="folder_path", @@ -74,7 +80,14 @@ def main(): latest_csv.insert(loc=6,column='diff2(%)',value=diff2) daily_html=csv_files[0].split(".")[0]+".html" - latest_csv.to_html(daily_html) + + subset=['diff1(%)','diff2(%)'] + columns={'1st token avg latency (ms)': '{:.2f}', '2+ avg latency (ms/token)': '{:.2f}', 'last1': '{:.2f}', 'diff1(%)': '{:.2f}', + 'last2': '{:.2f}', 'diff2(%)': '{:.2f}', 'encoder time (ms)': '{:.2f}'} + + with open(daily_html, 'w') as f: + f.write(latest_csv.style.format(columns).applymap(highlight_vals, subset) + .set_table_attributes("border=1").render()) if __name__ == "__main__": sys.exit(main()) \ No newline at end of file