LLM: change the color of peak diff (#9836)

This commit is contained in:
WeiguangHan 2024-01-04 19:30:32 +08:00 committed by GitHub
parent 38c05be1c0
commit ad6b182916

View file

@ -21,12 +21,12 @@ import sys
import argparse
import pandas as pd
def highlight_vals(val, max=3.0):
def highlight_vals(val, max=3.0, color1='red', color2='green'):
if isinstance(val, float):
if val > max:
return 'background-color: %s' % 'green'
return 'background-color: %s' % color2
elif val <= -max:
return 'background-color: %s' % 'red'
return 'background-color: %s' % color1
else:
return ''
@ -153,14 +153,18 @@ def main():
diffs_within_normal_range = is_diffs_within_normal_range(diff1, diff2, threshold=highlight_threshold)
subset=['diff1(%)','diff2(%)','best diff1(%)','best diff2(%)']
subset1=['diff1(%)','diff2(%)']
subset2=['best diff1(%)','best 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}', 'peak mem (GB)': '{:.2f}',
'best 1': '{:.2f}', 'best diff1(%)': '{:.2f}', 'best 2': '{:.2f}', 'best diff2(%)': '{:.2f}'}
styled_df = latest_csv.style.format(columns).applymap(lambda val: highlight_vals(val, max=3.0, color1='red', color2='green'), subset=subset1)
styled_df = styled_df.applymap(lambda val: highlight_vals(val, max=3.0, color1='yellow'), subset=subset2)
html_output = styled_df.set_table_attributes("border=1").render()
with open(daily_html, 'w') as f:
f.write(latest_csv.style.format(columns).applymap(lambda val: highlight_vals(val, max=highlight_threshold), subset)
.set_table_attributes("border=1").render())
f.write(html_output)
else:
latest_csv.to_html(daily_html)