-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmlperf_datacenter.py
More file actions
2421 lines (2092 loc) · 92.9 KB
/
mlperf_datacenter.py
File metadata and controls
2421 lines (2092 loc) · 92.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""MLPerf Inference Datacenter Results Dashboard.
This module provides functionality to load, process, and visualize
MLPerf Inference v5.1 Datacenter benchmark results.
"""
import os
from typing import Optional
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
import plotly.io as pio
import streamlit as st
if "plotly_white_light" not in pio.templates:
_light_hover = go.layout.Template(
layout=go.Layout(
hoverlabel={
"bgcolor": "white",
"font_color": "#262730",
"bordercolor": "#d1d5db",
},
),
)
pio.templates["plotly_white_light"] = pio.templates["plotly_white"]
pio.templates["plotly_white_light"].layout.update(_light_hover.layout)
pio.templates.default = "plotly_white_light"
from dashboard_styles import (
generate_color_palette,
get_mlperf_dashboard_css,
get_mlperf_table_tooltip_css,
)
@st.cache_data(ttl=300)
def load_mlperf_data(file_path: str) -> pd.DataFrame:
"""Load and parse MLPerf Inference Datacenter results CSV.
The CSV has a complex multi-row header structure that needs special handling.
Supports both the new standard CSV format and legacy UTF-16 TSV format.
Args:
file_path: Path to the MLPerf CSV file
Returns:
Parsed DataFrame with flattened column names
"""
# Try different encodings and delimiters to handle various CSV/TSV exports
# New format: UTF-8 with comma delimiters (standard CSV)
# Legacy format: UTF-16 with tab delimiters (TSV)
encodings = [
"utf-8",
"utf-16",
"utf-16-le",
"utf-16-be",
"latin-1",
"iso-8859-1",
"cp1252",
]
delimiters = [",", "\t"] # Try comma first (standard CSV)
raw_df = None
successful_encoding = None
successful_delimiter = None
for encoding in encodings:
for delimiter in delimiters:
try:
raw_df = pd.read_csv(
file_path, header=None, encoding=encoding, sep=delimiter
)
# Verify it actually parsed correctly (should have multiple columns)
if (
raw_df.shape[1] > 15
): # Should have at least 15 metadata columns + metric columns
successful_encoding = encoding
successful_delimiter = delimiter
break # Success!
except (UnicodeDecodeError, UnicodeError, pd.errors.ParserError):
continue # Try next combination
if successful_encoding is not None:
break # Found a working combination
if raw_df is None or successful_encoding is None:
raise ValueError("Could not read file with any encoding/delimiter combination")
# Extract header rows (rows 0-4 contain header information)
# Row 0: Benchmark/Model/Scenario/Units labels (not useful)
# Row 1: "Inference" repeated
# Row 2: Model names
# Row 3: Scenarios
# Row 4: Units
# Extract header rows for building column names
header_row = raw_df.iloc[4].fillna("") # Row 4 has metadata column names
# Row 2 has model names but with merged cells (NaN for subsequent columns)
# We need to forward-fill to propagate model names across their scenarios
model_row = raw_df.iloc[2].copy()
model_row = model_row.ffill() # Forward fill NaN values
scenario_row = raw_df.iloc[3].fillna("")
units_row = raw_df.iloc[4].fillna("") # Row 4 also has units for metric columns
# Read the actual data starting from row 5 (0-indexed) using the same encoding and delimiter
# Use header=None to avoid treating first data row as column names
df = pd.read_csv(
file_path,
skiprows=5,
header=None,
encoding=successful_encoding,
sep=successful_delimiter,
)
# Create meaningful column names by combining model + scenario + units
new_columns = []
for i in range(len(df.columns)):
if i < 15: # First 15 columns are metadata - use names from header row
col_name = header_row.iloc[i]
# Handle NaN or empty column names
if pd.isna(col_name) or col_name == "":
new_columns.append(f"col_{i}")
else:
new_columns.append(str(col_name))
else:
# For metric columns, combine model + scenario + unit
model = str(model_row.iloc[i]) if pd.notna(model_row.iloc[i]) else ""
scenario = (
str(scenario_row.iloc[i]) if pd.notna(scenario_row.iloc[i]) else ""
)
unit = str(units_row.iloc[i]) if pd.notna(units_row.iloc[i]) else ""
# Only create combined name if we have both model and scenario
if model and scenario and model != "nan" and scenario != "nan":
new_columns.append(f"{model}_{scenario}_{unit}")
else:
new_columns.append(f"col_{i}")
df.columns = new_columns
# Make duplicate column names unique by adding suffixes
# This is necessary because some metadata columns appear multiple times (e.g., Accelerator, Availability)
new_col_names = list(df.columns)
seen: dict[str, int] = {}
for i, col in enumerate(new_col_names):
if col in seen:
# This is a duplicate, add suffix
seen[col] += 1
new_col_names[i] = f"{col}.{seen[col]}"
else:
seen[col] = 0
df.columns = new_col_names
# Clean up the dataframe
# The CSV structure has rows in groups of 4 for each system:
# Row 1: System metadata (Public ID, Organization, etc.)
# Row 2: # of Processors
# Row 3: # of Accelerators
# Row 4: Avg. Result at System Name (contains actual benchmark values)
if "Public ID" in df.columns:
# DON'T remove NaN rows yet - we need them to identify result rows
# Identify system rows (have actual Public IDs like "5.1-0001")
system_rows_mask = df["Public ID"].str.match(r"^\d+\.\d+-\d+$", na=False)
# Identify result rows (contain "Avg. Result" in ANY column)
# Check all non-metric columns for "Avg. Result" text
result_rows_mask = pd.Series([False] * len(df), index=df.index, dtype=bool)
for col in df.columns[
:17
]: # Check metadata columns (includes column 15/16 where "Avg. Result" appears)
if df[col].dtype == "object":
mask = df[col].astype(str).str.contains("Avg. Result", na=False)
result_rows_mask = (result_rows_mask | mask).astype(bool) # type: ignore[assignment]
# Get metric columns
metric_cols = [
col
for col in df.columns
if "_Samples/s" in col or "_Queries/s" in col or "_Tokens/s" in col
]
# Copy metric values from result rows to their corresponding system rows
# v5.0: result row is 2 rows after system row
# v5.1: result row is 3 rows after system row
system_indices = df[system_rows_mask].index.tolist()
result_indices = df[result_rows_mask].index.tolist()
for sys_idx, res_idx in zip(system_indices, result_indices):
# Check if result row is at expected offset (+2 or +3 rows)
if res_idx in [sys_idx + 2, sys_idx + 3]:
# Copy metric values from result row to system row
for col in metric_cols:
df.loc[sys_idx, col] = df.loc[res_idx, col]
# NOW filter to only keep system rows
df = df[system_rows_mask].copy()
# Convert numeric columns
# First remove commas from number strings (e.g., "1,642.22" -> "1642.22")
for col in df.columns:
if "_Samples/s" in col or "_Queries/s" in col or "_Tokens/s" in col:
# Remove commas if the column is string type
if df[col].dtype == "object":
df[col] = df[col].astype(str).str.replace(",", "", regex=False)
df[col] = pd.to_numeric(df[col], errors="coerce")
# Extract accelerator count and node count
# NOTE: '# of Accelerators' in MLPerf data is PER NODE, not total
if "# of Accelerators" in df.columns:
df["accelerators_per_node"] = pd.to_numeric(
df["# of Accelerators"], errors="coerce"
)
if "# of Nodes" in df.columns:
df["node_count"] = pd.to_numeric(df["# of Nodes"], errors="coerce")
# Default to 1 node if missing
df["node_count"] = df["node_count"].fillna(1)
else:
df["node_count"] = 1
# Calculate total accelerators across all nodes
if "accelerators_per_node" in df.columns and "node_count" in df.columns:
df["accelerator_count"] = df["accelerators_per_node"] * df["node_count"]
# Normalize column names across different MLPerf versions
# Remove "(click + for details)" suffixes and standardize column names
column_mappings = {
"System Name (click + for details)": "System Name",
"Accelerator (click + for details)": "Accelerator",
"Processor (click + for details)": "Processor",
"Sum of # of Processors ": "# of Processors ",
"Sum of # of Processors": "# of Processors ",
}
df = df.rename(columns=column_mappings)
# Handle duplicate column names (can occur after renaming)
# Keep the first occurrence and drop subsequent duplicates
if df.columns.duplicated().any():
# Find duplicate columns
duplicate_mask = df.columns.duplicated(keep="first")
df.columns[duplicate_mask].tolist()
# Drop duplicate columns
df = df.loc[:, ~duplicate_mask]
# Handle CPU runs where Accelerator is N/A or missing
# For CPU runs, use system name as the accelerator with "cpu-" prefix
if "Accelerator" in df.columns and "System Name" in df.columns:
cpu_mask = (
df["Accelerator"].isna()
| (df["Accelerator"] == "N/A")
| (df["Accelerator"] == "")
| (df["Accelerator"].astype(str).str.strip() == "")
)
if cpu_mask.any():
# Create CPU accelerator names based on system name
df.loc[cpu_mask, "Accelerator"] = "cpu-" + df.loc[
cpu_mask, "System Name"
].astype(str)
# Normalize units for LLM models
# MLPerf CSVs have inconsistent unit labels - some LLM models use "Samples/s" or "Queries/s"
# when they should use "Tokens/s" (since LLMs generate text tokens, not samples)
llm_models = [
"llama",
"deepseek",
"gpt",
"mistral",
"mixtral",
"falcon",
"qwen",
"yi",
]
# Build column rename mapping for LLM columns with wrong units
column_renames = {}
for col in df.columns:
# Check if this is a metric column with wrong units
if "_Samples/s" in col or "_Queries/s" in col:
# Extract model name (first part before underscore)
model_name = col.split("_")[0].lower()
# Check if this is an LLM model
if any(llm in model_name for llm in llm_models):
# Replace wrong unit with Tokens/s
if "_Samples/s" in col:
new_col = col.replace("_Samples/s", "_Tokens/s")
column_renames[col] = new_col
elif "_Queries/s" in col:
new_col = col.replace("_Queries/s", "_Tokens/s")
column_renames[col] = new_col
# Apply column renames if any were found
if column_renames:
df = df.rename(columns=column_renames)
return df
def extract_benchmarks_and_scenarios(df: pd.DataFrame) -> dict[str, list[str]]:
"""Extract available benchmarks and their scenarios from column names.
Args:
df: MLPerf DataFrame
Returns:
Dictionary mapping benchmark names to list of available scenarios
"""
benchmarks: dict[str, list[str]] = {}
for col in df.columns:
if "_Offline_" in col or "_Server_" in col or "_Interactive_" in col:
# Extract model name and scenario
parts = col.split("_")
if len(parts) >= 2:
# Model name might have dashes or numbers
model_parts = []
for part in parts:
if part in ["Offline", "Server", "Interactive"]:
break
model_parts.append(part)
model = "-".join(model_parts)
if "Offline" in col:
scenario = "Offline"
elif "Server" in col:
scenario = "Server"
elif "Interactive" in col:
scenario = "Interactive"
else:
continue
if model not in benchmarks:
benchmarks[model] = []
if scenario not in benchmarks[model]:
benchmarks[model].append(scenario)
return benchmarks
def render_mlperf_filters(
df: pd.DataFrame, mlperf_versions: dict, selected_version: str
) -> tuple[pd.DataFrame, dict]:
"""Render smart cascading filter UI and return filtered dataframe.
Filters are hierarchical:
0. Version (independent)
1. Benchmark (first layer)
2. Scenario (based on selected benchmarks)
3. Organization (based on benchmark-scenario)
4. Accelerator (based on org)
5. # of Accelerators (based on accelerator)
Only "available" entries are shown (preview data excluded).
Args:
df: MLPerf DataFrame
mlperf_versions: Dict mapping version labels to CSV file paths
selected_version: Currently selected version
Returns:
Tuple of (filtered_df, filter_selections)
"""
st.markdown("### Filter your data")
# Initialize session state for filter management
if "mlperf_filters_initialized" not in st.session_state:
st.session_state.mlperf_filters_initialized = True
st.session_state.mlperf_filter_change_key = 0
st.session_state.mlperf_filters_were_cleared = False
# Filter out preview data - only show available entries
# df_available = df[df['Availability'] == 'available'].copy()
df_available = df.copy()
# Create columns for filters - add version filter as first column
filter_row0_col1, filter_row0_col2, filter_row0_col3 = st.columns(3)
filter_col1, filter_col2, filter_col3 = st.columns(3)
filter_col4, filter_col5, filter_col6 = st.columns([1, 1, 1])
# FILTER 0: MLPerf Version (independent filter)
with filter_row0_col1:
version_selector = st.selectbox(
"0️⃣ Select MLPerf Version",
options=list(mlperf_versions.keys()),
index=list(mlperf_versions.keys()).index(selected_version),
key="mlperf_version_filter",
help="Choose which MLPerf Inference version results to display",
)
# If version changed, trigger reload
if version_selector != selected_version:
st.session_state.mlperf_version = version_selector
st.rerun()
# Get benchmarks and scenarios from column names
benchmarks_dict = extract_benchmarks_and_scenarios(df_available)
all_benchmarks = sorted(benchmarks_dict.keys())
# FILTER 1: MLC Model (First layer - no dependencies)
with filter_col1:
# Determine baseline defaults
baseline_models = []
preferred_models = ["llama3.1-8b-datacenter"]
for model in preferred_models:
if model in all_benchmarks:
baseline_models.append(model)
if not baseline_models:
baseline_models = (
all_benchmarks[:2] if len(all_benchmarks) > 2 else all_benchmarks
)
# Store baseline in session state on first run
if "mlperf_baseline_models" not in st.session_state:
st.session_state.mlperf_baseline_models = baseline_models
# Determine current defaults based on state
if st.session_state.get(
"mlperf_clear_all_filters", False
) or st.session_state.get("mlperf_filters_were_cleared", False):
default_model = all_benchmarks[0] if all_benchmarks else None
elif st.session_state.get("mlperf_reset_to_defaults", False):
default_model = (
st.session_state.mlperf_baseline_models[0]
if st.session_state.mlperf_baseline_models
else all_benchmarks[0]
)
elif st.session_state.get("mlperf_select_all_orgs", False):
# Preserve current selection when "Select All Orgs" is clicked
preserved = st.session_state.get("mlperf_preserved_models", baseline_models)
default_model = preserved[0] if preserved else baseline_models[0]
elif st.session_state.get("theme_change_only", False):
# Preserve current selection during theme changes
preserved = st.session_state.get("mlperf_preserved_models", baseline_models)
default_model = preserved[0] if preserved else baseline_models[0]
else:
default_model = baseline_models[0] if baseline_models else all_benchmarks[0]
# Get the index of the default model
default_idx = (
all_benchmarks.index(default_model)
if default_model in all_benchmarks
else 0
)
selected_benchmark: Optional[str] = st.selectbox(
"1️⃣ Select MLC Model",
options=all_benchmarks,
index=default_idx,
key=f"mlperf_bench_filter_{st.session_state.mlperf_filter_change_key}",
help="Select which MLC (MLCommons) model to analyze",
)
# Convert to list for compatibility with rest of code
selected_benchmarks = [selected_benchmark] if selected_benchmark else []
# Determine available scenarios based on selected benchmarks
available_scenarios: list[str]
if selected_benchmarks:
scenarios_set = set()
for bench in selected_benchmarks:
if bench in benchmarks_dict:
scenarios_set.update(benchmarks_dict[bench])
available_scenarios = sorted(scenarios_set)
else:
available_scenarios = []
# FILTER 2: Scenario (Second layer - depends on benchmarks)
with filter_col2:
if available_scenarios:
# Determine baseline defaults
baseline_scenarios = []
preferred_scenarios = ["Offline", "Server"]
for scenario in preferred_scenarios:
if scenario in available_scenarios:
baseline_scenarios.append(scenario)
if not baseline_scenarios:
baseline_scenarios = (
available_scenarios[:1] if available_scenarios else []
)
# Store baseline in session state on first run
if "mlperf_baseline_scenarios" not in st.session_state:
st.session_state.mlperf_baseline_scenarios = baseline_scenarios
# Determine current defaults based on state
if st.session_state.get(
"mlperf_clear_all_filters", False
) or st.session_state.get("mlperf_filters_were_cleared", False):
default_scenarios = []
elif st.session_state.get("mlperf_reset_to_defaults", False):
default_scenarios = [
s
for s in st.session_state.mlperf_baseline_scenarios
if s in available_scenarios
]
elif st.session_state.get("mlperf_select_all_orgs", False):
# Preserve current selection when "Select All Orgs" is clicked
preserved = st.session_state.get(
"mlperf_preserved_scenarios", baseline_scenarios
)
default_scenarios = [s for s in preserved if s in available_scenarios]
elif st.session_state.get("theme_change_only", False):
# Preserve current selection during theme changes
preserved = st.session_state.get(
"mlperf_preserved_scenarios", baseline_scenarios
)
default_scenarios = [s for s in preserved if s in available_scenarios]
else:
default_scenarios = baseline_scenarios
selected_scenarios: list[str] = st.multiselect(
"2️⃣ Select Scenario(s)",
options=available_scenarios,
default=default_scenarios,
key=f"mlperf_scenario_filter_{st.session_state.mlperf_filter_change_key}",
help="Offline=batch, Server=online, Interactive=single-stream",
)
else:
st.multiselect(
"2️⃣ Select Scenario(s)",
options=[],
default=[],
key=f"mlperf_scenario_filter_{st.session_state.mlperf_filter_change_key}",
disabled=True,
help="Select MLC models first",
)
selected_scenarios = []
# Determine which systems have data for selected benchmark-scenario combinations
systems_with_data: set[str] = set()
if selected_benchmarks and selected_scenarios:
for bench in selected_benchmarks:
for scenario in selected_scenarios:
# Find column for this benchmark-scenario
matching_cols = [
col
for col in df_available.columns
if bench in col and scenario in col
]
if matching_cols:
metric_col = matching_cols[0]
# Get systems that have non-null data for this metric
systems_with_data.update(
df_available[df_available[metric_col].notna()][
"Organization"
].unique()
)
available_orgs = sorted([org for org in systems_with_data if pd.notna(org)])
# FILTER 3: Organization (Third layer - depends on benchmark + scenario)
with filter_col3:
if available_orgs:
# Determine baseline defaults
baseline_orgs = []
preferred_orgs = ["RedHat"]
for org in preferred_orgs:
if org in available_orgs:
baseline_orgs.append(org)
if not baseline_orgs:
baseline_orgs = (
available_orgs[:5] if len(available_orgs) > 5 else available_orgs
)
# Store baseline in session state on first run
if "mlperf_baseline_orgs" not in st.session_state:
st.session_state.mlperf_baseline_orgs = baseline_orgs
# Determine current defaults based on state
if st.session_state.get(
"mlperf_clear_all_filters", False
) or st.session_state.get("mlperf_filters_were_cleared", False):
default_orgs = []
elif st.session_state.get("mlperf_reset_to_defaults", False):
default_orgs = [
o
for o in st.session_state.mlperf_baseline_orgs
if o in available_orgs
]
elif st.session_state.get("mlperf_select_all_orgs", False):
default_orgs = available_orgs # Select all organizations for current model-scenario
elif st.session_state.get("theme_change_only", False):
# Preserve current selection during theme changes
preserved = st.session_state.get("mlperf_preserved_orgs", baseline_orgs)
default_orgs = [o for o in preserved if o in available_orgs]
else:
default_orgs = baseline_orgs
selected_orgs: list[str] = st.multiselect(
"3️⃣ Select Organization(s)",
options=available_orgs,
default=default_orgs,
key=f"mlperf_org_filter_{st.session_state.mlperf_filter_change_key}",
help="Vendors with data for selected models",
)
else:
st.multiselect(
"3️⃣ Select Organization(s)",
options=[],
default=[],
key=f"mlperf_org_filter_{st.session_state.mlperf_filter_change_key}",
disabled=True,
help="Select MLC models and scenarios first",
)
selected_orgs = []
# Apply filters so far to get available accelerators
filtered_so_far = df_available.copy()
if selected_orgs:
filtered_so_far = filtered_so_far[
filtered_so_far["Organization"].isin(selected_orgs)
]
# Get accelerators that have data for the selected MLC models and scenarios
accelerators_with_data: set[str] = set()
if selected_benchmarks and selected_scenarios:
for bench in selected_benchmarks:
for scenario in selected_scenarios:
# Find column for this benchmark-scenario
matching_cols = [
col
for col in df_available.columns
if bench in col and scenario in col
]
if matching_cols:
metric_col = matching_cols[0]
# Get accelerators from filtered data that have non-null data for this metric
valid_rows = filtered_so_far[filtered_so_far[metric_col].notna()]
accelerators_with_data.update(valid_rows["Accelerator"].unique())
available_accelerators = sorted(
[acc for acc in accelerators_with_data if pd.notna(acc) and acc != ""]
)
else:
# Fallback to all accelerators if no models/scenarios selected
available_accelerators = sorted(
[
acc
for acc in filtered_so_far["Accelerator"].unique()
if pd.notna(acc) and acc != ""
]
)
# FILTER 4: Accelerator (Fourth layer - depends on organization)
with filter_col4:
if available_accelerators:
# Determine baseline defaults
baseline_accelerators = []
preferred_accelerators = ["NVIDIA L40S", "NVIDIA H100-SXM-80GB"]
for acc in preferred_accelerators:
if acc in available_accelerators:
baseline_accelerators.append(acc)
if not baseline_accelerators:
baseline_accelerators = (
available_accelerators[:5]
if len(available_accelerators) > 5
else available_accelerators
)
# Store baseline in session state on first run
if "mlperf_baseline_accelerators" not in st.session_state:
st.session_state.mlperf_baseline_accelerators = baseline_accelerators
# Determine current defaults based on state
if st.session_state.get(
"mlperf_clear_all_filters", False
) or st.session_state.get("mlperf_filters_were_cleared", False):
default_accelerators = []
elif st.session_state.get("mlperf_reset_to_defaults", False):
default_accelerators = [
a
for a in st.session_state.mlperf_baseline_accelerators
if a in available_accelerators
]
elif st.session_state.get("theme_change_only", False):
# Preserve current selection during theme changes
preserved = st.session_state.get(
"mlperf_preserved_accelerators", baseline_accelerators
)
default_accelerators = [
a for a in preserved if a in available_accelerators
]
elif selected_orgs:
# Auto-select all available accelerators when organization(s) are selected
default_accelerators = available_accelerators
else:
default_accelerators = baseline_accelerators
selected_accelerators: list[str] = st.multiselect(
"4️⃣ Select Accelerator(s)",
options=available_accelerators,
default=default_accelerators,
key=f"mlperf_acc_filter_{st.session_state.mlperf_filter_change_key}",
help="GPU/accelerator types",
)
else:
st.multiselect(
"4️⃣ Select Accelerator(s)",
options=[],
default=[],
key=f"mlperf_acc_filter_{st.session_state.mlperf_filter_change_key}",
disabled=True,
help="Select organizations first",
)
selected_accelerators = []
# Apply accelerator filter
if selected_accelerators:
filtered_so_far = filtered_so_far[
filtered_so_far["Accelerator"].isin(selected_accelerators)
]
# Get available accelerator counts that have data for selected MLC models and scenarios
acc_counts_with_data: set[float] = set()
if (
selected_benchmarks
and selected_scenarios
and "accelerator_count" in filtered_so_far.columns
):
for bench in selected_benchmarks:
for scenario in selected_scenarios:
# Find column for this benchmark-scenario
matching_cols = [
col
for col in df_available.columns
if bench in col and scenario in col
]
if matching_cols:
metric_col = matching_cols[0]
# Get accelerator counts from filtered data that have non-null data for this metric
valid_rows = filtered_so_far[filtered_so_far[metric_col].notna()]
acc_counts_with_data.update(
valid_rows["accelerator_count"].dropna().unique()
)
available_acc_counts = sorted([int(c) for c in acc_counts_with_data if c > 0])
elif "accelerator_count" in filtered_so_far.columns:
# Fallback to all counts if no models/scenarios selected
available_acc_counts = sorted(
[
int(c)
for c in filtered_so_far["accelerator_count"].dropna().unique()
if c > 0
]
)
else:
available_acc_counts = []
# FILTER 5: # of Accelerators (Fifth layer - depends on accelerator)
with filter_col5:
if available_acc_counts:
# Determine baseline defaults
baseline_acc_counts = []
preferred_counts = [1]
for count in preferred_counts:
if count in available_acc_counts:
baseline_acc_counts.append(count)
if not baseline_acc_counts:
baseline_acc_counts = available_acc_counts
# Store baseline in session state on first run
if "mlperf_baseline_acc_counts" not in st.session_state:
st.session_state.mlperf_baseline_acc_counts = baseline_acc_counts
# Determine current defaults based on state
if st.session_state.get(
"mlperf_clear_all_filters", False
) or st.session_state.get("mlperf_filters_were_cleared", False):
default_acc_counts = []
elif st.session_state.get("mlperf_reset_to_defaults", False):
default_acc_counts = [
c
for c in st.session_state.mlperf_baseline_acc_counts
if c in available_acc_counts
]
elif st.session_state.get("theme_change_only", False):
# Preserve current selection during theme changes
preserved = st.session_state.get(
"mlperf_preserved_acc_counts", baseline_acc_counts
)
default_acc_counts = [c for c in preserved if c in available_acc_counts]
elif selected_orgs:
# Auto-select all available accelerator counts when organization(s) are selected
default_acc_counts = available_acc_counts
else:
default_acc_counts = baseline_acc_counts
selected_acc_counts: list[int] = st.multiselect(
"5️⃣ Select Total # of Accelerators",
options=available_acc_counts,
default=default_acc_counts,
key=f"mlperf_acc_count_filter_{st.session_state.mlperf_filter_change_key}",
help="Total GPUs across all nodes (# of Nodes × Accelerators per node)",
)
else:
st.multiselect(
"5️⃣ Select Total # of Accelerators",
options=[],
default=[],
key=f"mlperf_acc_count_filter_{st.session_state.mlperf_filter_change_key}",
disabled=True,
help="Select accelerators first",
)
selected_acc_counts = []
# Store current selections (to preserve them for "Select All Orgs" and theme changes)
st.session_state.mlperf_preserved_models = selected_benchmarks
st.session_state.mlperf_preserved_scenarios = selected_scenarios
st.session_state.mlperf_preserved_orgs = selected_orgs
st.session_state.mlperf_preserved_accelerators = selected_accelerators
st.session_state.mlperf_preserved_acc_counts = selected_acc_counts
# FILTER CONTROL BUTTONS
with filter_col6:
btn_col1, btn_col2, btn_col3 = st.columns(3)
with btn_col1:
if st.button(
"🌐 Select All Orgs",
help="Select all organizations for the current model-scenario combination",
key="mlperf_select_all_orgs_btn",
):
st.session_state.mlperf_clear_all_filters = False
st.session_state.mlperf_filters_were_cleared = False
st.session_state.mlperf_reset_to_defaults = False
st.session_state.mlperf_select_all_orgs = True
st.session_state.mlperf_filter_change_key += 1
st.rerun()
with btn_col2:
if st.button(
"🔄 Reset to defaults",
help="Reset filters to system defaults",
key="mlperf_reset_btn",
):
st.session_state.mlperf_clear_all_filters = False
st.session_state.mlperf_filters_were_cleared = False
st.session_state.mlperf_reset_to_defaults = True
st.session_state.mlperf_select_all_orgs = False
st.session_state.mlperf_filter_change_key += 1
st.rerun()
with btn_col3:
if st.button(
"🧹 Clear all filters",
help="Clear all filter selections",
key="mlperf_clear_btn",
):
st.session_state.mlperf_clear_all_filters = True
st.session_state.mlperf_filters_were_cleared = True
st.session_state.mlperf_select_all_orgs = False
st.session_state.mlperf_filter_change_key += 1
st.rerun()
# Apply all filters
filtered_df = df_available.copy()
if selected_orgs:
filtered_df = filtered_df[filtered_df["Organization"].isin(selected_orgs)]
if selected_accelerators:
filtered_df = filtered_df[
filtered_df["Accelerator"].isin(selected_accelerators)
]
# For accelerator count filtering, exclude CPU runs (they don't have accelerator counts)
if selected_acc_counts and "accelerator_count" in filtered_df.columns:
# Identify CPU runs
cpu_mask = (
filtered_df["Accelerator"].astype(str).str.startswith("cpu-", na=False)
)
# Apply count filter only to non-CPU runs
non_cpu_filtered = filtered_df[
~cpu_mask & filtered_df["accelerator_count"].isin(selected_acc_counts)
]
# Include all CPU runs regardless of count filter
cpu_runs = filtered_df[cpu_mask]
# Combine them
filtered_df = pd.concat([non_cpu_filtered, cpu_runs], ignore_index=False)
filter_selections = {
"benchmarks": selected_benchmarks,
"scenarios": selected_scenarios,
"organizations": selected_orgs,
"accelerators": selected_accelerators,
"acc_counts": selected_acc_counts,
"availability": ["available"], # Always filter to available only
}
# Reset state flags after processing
if st.session_state.get("mlperf_clear_all_filters", False):
st.session_state.mlperf_clear_all_filters = False
if st.session_state.get("mlperf_reset_to_defaults", False):
st.session_state.mlperf_reset_to_defaults = False
if st.session_state.get("mlperf_select_all_orgs", False):
st.session_state.mlperf_select_all_orgs = False
if st.session_state.get("theme_change_only", False):
st.session_state.theme_change_only = False
return filtered_df, filter_selections
def create_benchmark_comparison_chart(
df: pd.DataFrame, benchmark: str, scenario: str, filter_selections: dict
) -> Optional[go.Figure]:
"""Create bar chart comparing systems on a specific benchmark and scenario.
Args:
df: Filtered MLPerf DataFrame
benchmark: Benchmark name
scenario: Scenario name
filter_selections: Dictionary of filter selections
Returns:
Plotly figure or None if no data
"""
# Find the column for this benchmark + scenario
matching_cols = [col for col in df.columns if benchmark in col and scenario in col]
if not matching_cols:
return None
# Use the first matching column
metric_col = matching_cols[0]
# Extract unit from column name
unit = metric_col.split("_")[-1] if "_" in metric_col else "Performance"
# Prepare data for plotting
system_col = "System Name"
# Select columns, handling cases where '# of Accelerators' might not exist
cols_to_include = [system_col, "Accelerator", "Organization", metric_col]
if "# of Accelerators" in df.columns:
cols_to_include.insert(3, "# of Accelerators")
if "# of Nodes" in df.columns:
cols_to_include.insert(3, "# of Nodes")
plot_df = df[cols_to_include].copy()
# Fill missing columns
if "# of Accelerators" not in plot_df.columns:
plot_df["# of Accelerators"] = None
if "# of Nodes" not in plot_df.columns:
plot_df["# of Nodes"] = None
# Only drop rows where the actual metric is missing
plot_df = plot_df.dropna(subset=[metric_col])
plot_df = plot_df[plot_df[metric_col] > 0]
# For CPU runs, fill in '# of Accelerators' with a display value
cpu_mask = plot_df["Accelerator"].astype(str).str.startswith("cpu-", na=False)
if cpu_mask.any():
plot_df["# of Accelerators"] = plot_df["# of Accelerators"].astype(object)
plot_df.loc[cpu_mask, "# of Accelerators"] = "N/A (CPU)"
if plot_df.empty:
return None
# Create unique identifier for each system-organization combination
# This prevents stacking when multiple orgs use the same system name
plot_df["System_Display"] = (
plot_df[system_col] + " (" + plot_df["Organization"] + ")"
)
# Sort by performance
plot_df = plot_df.sort_values(metric_col, ascending=False)
# Show all systems (removed top 20 limit - chart is scrollable)
# Chart height dynamically adjusts: max(400, len(plot_df) * 25)
# Generate unique colors for all organizations
unique_orgs = sorted(plot_df["Organization"].unique())
colors = generate_color_palette(len(unique_orgs))
color_map = dict(zip(unique_orgs, colors))
# Create bar chart with hover_data for proper data alignment
fig = px.bar(
plot_df,
x=metric_col,
y="System_Display",
color="Organization",
color_discrete_map=color_map,
hover_data={
"Organization": True,
"Accelerator": True,