5656 "INTEGER" , "INTEGER"
5757]
5858
59- # Legacy aliases for backward compatibility
60- DB_FIELDS = LLAMA_BENCH_DB_FIELDS
61- DB_TYPES = LLAMA_BENCH_DB_TYPES
62-
6359assert len (LLAMA_BENCH_DB_FIELDS ) == len (LLAMA_BENCH_DB_TYPES )
6460assert len (TEST_BACKEND_OPS_DB_FIELDS ) == len (TEST_BACKEND_OPS_DB_TYPES )
6561
7571 "backend_name" , "op_name" , "op_params" , "test_mode"
7672]
7773
78- # Legacy alias for backward compatibility
79- KEY_PROPERTIES = LLAMA_BENCH_KEY_PROPERTIES
80-
81- # Properties that are boolean and are converted to Yes/No for the table (llama-bench):
74+ # Properties that are boolean and are converted to Yes/No for the table:
8275LLAMA_BENCH_BOOL_PROPERTIES = ["embeddings" , "cpu_strict" , "use_mmap" , "no_kv_offload" , "flash_attn" ]
83-
84- # Properties that are boolean and are converted to Yes/No for the table (test-backend-ops):
8576TEST_BACKEND_OPS_BOOL_PROPERTIES = ["supported" , "passed" ]
8677
87- # Legacy alias for backward compatibility
88- BOOL_PROPERTIES = LLAMA_BENCH_BOOL_PROPERTIES
89-
9078# Header names for the table (llama-bench):
9179LLAMA_BENCH_PRETTY_NAMES = {
9280 "cpu_info" : "CPU" , "gpu_info" : "GPU" , "backends" : "Backends" , "n_gpu_layers" : "GPU layers" ,
10492 "flops" : "FLOPS" , "bandwidth_gb_s" : "Bandwidth (GB/s)" , "memory_kb" : "Memory (KB)" , "n_runs" : "Runs"
10593}
10694
107- # Legacy alias for backward compatibility
108- PRETTY_NAMES = LLAMA_BENCH_PRETTY_NAMES
109-
11095DEFAULT_SHOW_LLAMA_BENCH = ["model_type" ] # Always show these properties by default.
11196DEFAULT_HIDE_LLAMA_BENCH = ["model_filename" ] # Always hide these properties by default.
11297
11398DEFAULT_SHOW_TEST_BACKEND_OPS = ["backend_name" , "op_name" ] # Always show these properties by default.
11499DEFAULT_HIDE_TEST_BACKEND_OPS = ["error_message" ] # Always hide these properties by default.
115100
116- # Legacy aliases for backward compatibility
117- DEFAULT_SHOW = DEFAULT_SHOW_LLAMA_BENCH
118- DEFAULT_HIDE = DEFAULT_HIDE_LLAMA_BENCH
119101GPU_NAME_STRIP = ["NVIDIA GeForce " , "Tesla " , "AMD Radeon " ] # Strip prefixes for smaller tables.
120102MODEL_SUFFIX_REPLACE = {" - Small" : "_S" , " - Medium" : "_M" , " - Large" : "_L" }
121103
122104DESCRIPTION = """Creates tables from llama-bench or test-backend-ops data written to multiple JSON/CSV files, a single JSONL file or SQLite database. Example usage (Linux):
123105
124106For llama-bench:
125107$ git checkout master
126- $ make clean && make llama-bench
108+ $ cmake -B ${BUILD_DIR} ${CMAKE_OPTS} && cmake --build ${BUILD_DIR} -t llama-bench -j $(nproc)
127109$ ./llama-bench -o sql | sqlite3 llama-bench.sqlite
128110$ git checkout some_branch
129- $ make clean && make llama-bench
111+ $ cmake -B ${BUILD_DIR} ${CMAKE_OPTS} && cmake --build ${BUILD_DIR} -t llama-bench -j $(nproc)
130112$ ./llama-bench -o sql | sqlite3 llama-bench.sqlite
131113$ ./scripts/compare-llama-bench.py
132114
133115For test-backend-ops:
134116$ git checkout master
135- $ make clean && make test-backend-ops
117+ $ cmake -B ${BUILD_DIR} ${CMAKE_OPTS} && cmake --build ${BUILD_DIR} -t test-backend-ops -j $(nproc)
136118$ ./test-backend-ops perf --output sql | sqlite3 test-backend-ops.sqlite
137119$ git checkout some_branch
138- $ make clean && make test-backend-ops
120+ $ cmake -B ${BUILD_DIR} ${CMAKE_OPTS} && cmake --build ${BUILD_DIR} -t test-backend-ops -j $(nproc)
139121$ ./test-backend-ops perf --output sql | sqlite3 test-backend-ops.sqlite
140122$ ./scripts/compare-llama-bench.py --tool test-backend-ops -i test-backend-ops.sqlite
141123
180162help_s = (
181163 "Columns to add to the table. "
182164 "Accepts a comma-separated list of values. "
183- f"Legal values: { ', ' .join (KEY_PROPERTIES [:- 3 ])} . "
165+ f"Legal values: { ', ' .join (LLAMA_BENCH_KEY_PROPERTIES [:- 3 ])} . "
184166 "Defaults to model name (model_type) and CPU and/or GPU name (cpu_info, gpu_info) "
185167 "plus any column where not all data points are the same. "
186168 "If the columns are manually specified, then the results for each unique combination of the "
@@ -245,8 +227,10 @@ def __init__(self, tool: str = "llama-bench"):
245227 # Set schema-specific properties based on tool
246228 if self .tool == "llama-bench" :
247229 self .check_keys = set (LLAMA_BENCH_KEY_PROPERTIES + ["build_commit" , "test_time" , "avg_ts" ])
248- else : # test-backend-ops
230+ elif self . tool == " test-backend-ops" :
249231 self .check_keys = set (TEST_BACKEND_OPS_KEY_PROPERTIES + ["build_commit" , "test_time" ])
232+ else :
233+ assert False
250234
251235 def _builds_init (self ):
252236 self .build_len = self .build_len_min
@@ -721,12 +705,14 @@ def get_flops_unit_name(flops_values: list) -> str:
721705 pretty_names = LLAMA_BENCH_PRETTY_NAMES
722706 default_show = DEFAULT_SHOW_LLAMA_BENCH
723707 default_hide = DEFAULT_HIDE_LLAMA_BENCH
724- else : # test-backend-ops
708+ elif tool == " test-backend-ops" :
725709 key_properties = TEST_BACKEND_OPS_KEY_PROPERTIES
726710 bool_properties = TEST_BACKEND_OPS_BOOL_PROPERTIES
727711 pretty_names = TEST_BACKEND_OPS_PRETTY_NAMES
728712 default_show = DEFAULT_SHOW_TEST_BACKEND_OPS
729713 default_hide = DEFAULT_HIDE_TEST_BACKEND_OPS
714+ else :
715+ assert False
730716
731717# If the user provided columns to group the results by, use them:
732718if known_args .show is not None :
@@ -756,7 +742,7 @@ def get_flops_unit_name(flops_values: list) -> str:
756742 if row_full [i ] != rows_full [0 ][i ]:
757743 properties_different .append (kp_i )
758744 break
759- else : # test-backend-ops
745+ elif tool == " test-backend-ops" :
760746 # For test-backend-ops, check all key properties
761747 for i , kp_i in enumerate (key_properties ):
762748 if kp_i in default_show :
@@ -765,6 +751,8 @@ def get_flops_unit_name(flops_values: list) -> str:
765751 if row_full [i ] != rows_full [0 ][i ]:
766752 properties_different .append (kp_i )
767753 break
754+ else :
755+ assert False
768756
769757 show = []
770758
@@ -783,8 +771,10 @@ def get_flops_unit_name(flops_values: list) -> str:
783771 if prop in show :
784772 index_default += 1
785773 show = show [:index_default ] + default_show + show [index_default :]
786- else : # test-backend-ops
774+ elif tool == " test-backend-ops" :
787775 show = default_show + properties_different
776+ else :
777+ assert False
788778
789779 for prop in default_hide :
790780 try :
@@ -825,7 +815,7 @@ def get_flops_unit_name(flops_values: list) -> str:
825815 # Regular columns test name avg t/s values Speedup
826816 # VVVVVVVVVVVVV VVVVVVVVV VVVVVVVVVVVVVV VVVVVVV
827817 table .append (list (row [:- 5 ]) + [test_name ] + list (row [- 2 :]) + [float (row [- 1 ]) / float (row [- 2 ])])
828- else : # test-backend-ops
818+ elif tool == " test-backend-ops" :
829819 # Determine the primary metric by checking rows until we find one with valid data
830820 if rows_show :
831821 primary_metric = "FLOPS" # Default to FLOPS
@@ -869,9 +859,11 @@ def get_flops_unit_name(flops_values: list) -> str:
869859 # Fallback if no valid data is available
870860 baseline_str = "N/A"
871861 compare_str = "N/A"
872- speedup = 1.0
862+ speedup = float ( 'nan' )
873863
874864 table .append (list (row [:- 4 ]) + [baseline_str , compare_str , speedup ])
865+ else :
866+ assert False
875867
876868# Some a-posteriori fixes to make the table contents prettier:
877869for bool_property in bool_properties :
@@ -907,8 +899,10 @@ def get_flops_unit_name(flops_values: list) -> str:
907899headers = [pretty_names .get (p , p ) for p in show ]
908900if tool == "llama-bench" :
909901 headers += ["Test" , f"t/s { name_baseline } " , f"t/s { name_compare } " , "Speedup" ]
910- else : # test-backend-ops
902+ elif tool == " test-backend-ops" :
911903 headers += [f"{ primary_metric } { name_baseline } " , f"{ primary_metric } { name_compare } " , "Speedup" ]
904+ else :
905+ assert False
912906
913907if known_args .plot :
914908 def create_performance_plot (table_data : list [list [str ]], headers : list [str ], baseline_name : str , compare_name : str , output_file : str , plot_x_param : str , log_scale : bool = False , tool_type : str = "llama-bench" , metric_name : str = "t/s" ):
@@ -925,7 +919,7 @@ def create_performance_plot(table_data: list[list[str]], headers: list[str], bas
925919 plot_x_label = plot_x_param
926920
927921 if plot_x_param not in ["n_prompt" , "n_gen" , "n_depth" ]:
928- pretty_name = PRETTY_NAMES .get (plot_x_param , plot_x_param )
922+ pretty_name = LLAMA_BENCH_PRETTY_NAMES .get (plot_x_param , plot_x_param )
929923 if pretty_name in data_headers :
930924 plot_x_index = data_headers .index (pretty_name )
931925 plot_x_label = pretty_name
0 commit comments