-
Notifications
You must be signed in to change notification settings - Fork 1
/
add_results_summary.py
315 lines (282 loc) · 10.6 KB
/
add_results_summary.py
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
import json
import os
import time
import sys
sys.path.insert(0, os.path.join("inference", "tools", "submission"))
import submission_checker as checker # noqa
with open('summary_results.json') as f:
data = json.load(f)
#print(models_all)
#print(platforms)
def get_header():
css = """
/* General table styles */
table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
border: none;
}
table.titlebarcontainer,.titlebar {
text-align: center !important;
}
td.headerbar {
text-align: center;
font-size: x-large;
}
th, td {
padding: 8px;
text-align: left;
vertical-align: top;
}
/* Styling for the first table to make it stand out */
table:first-of-type {
background-color: #e8e8e8; /* Light grey background */
color: #333; /* Darker text for contrast */
font-weight: bold; /* Makes text bold */
}
/* Styling inner tables to have borders */
table table {
border: 1px solid #ccc;
}
/* More specific styling for headers and rows of inner tables */
table table th, table table td {
border: 1px solid #ccc;
}
th {
background-color: #f4f4f4;
}
tr:nth-child(even) {
background-color: #f9f9f9;
}
tr:nth-child(odd) {
background-color: #ffffff;
}
/* Adjust column widths if necessary */
th:nth-child(1), td:nth-child(1) { width: 20%; }
th:nth-child(2), td:nth-child(2) { width: 30%; }
"""
html_header = f"""
<head>
<style type="text/css">
{css}
</style>
</head>
"""
return html_header
def get_header_table(system_json):
submitter = system_json.get('submitter')
system_name = system_json.get('system_name')
html = f"""
<div class="resultpage">
<div class="titlebarcontainer">
<div class="logo">
<a href="/" style="border: none"><img src="" alt="" /></a>
</div>
<div class="titlebar">
<h1 class="title">MLPerf Inference v4.1</h1>
<p style="font-size: smaller">Copyright 2019-2024 MLCommons</p>
</div>
</div>
<table class="titlebarcontainer">
<tr>
<td class="headerbar" rowspan="2">
<p>{submitter} </p>
<p>{system_name} </p>
</td>
</tr>
</table>
<table class="datebar">
<tbody>
<tr>
<th id="license_num"><a href="">MLPerf Inference Category:</a></th>
<td id="license_num_val">Datacenter</td>
<th id="test_date"><a href="">MLPerf Inference Division:</a></th>
<td id="test_date_val">Closed</td>
</tr>
<tr>
<th id="tester"><a href="">Submitted by:</a></th>
<td id="tester_val">{submitter}</td>
<th id="sw_avail"><a href="">Availability:</a></th>
<td id="sw_avail_val">Available as of Aug 2024</td>
</tr>
</tbody>
</table>
"""
return html
def get_system_json(path):
#import requests
# Send a GET request to the URL
#response = requests.get(url)
with open(path, "r") as f:
data = json.load(f)
# Check if the request was successful
#if response.status_code == 200:
# # Parse the JSON content
# data = response.json()
return data
def get_accelerator_details_table(system_json):
table = '<h3>Accelerator Details</h3><table>'
for key,value in system_json.items():
if not key.startswith("accelerator"):
continue
table += f"""<tr><td>{key}</td><td>{value}</td></tr>"""
table += "</table>"
return table
def get_cpu_details_table(system_json):
table = '<h3>Processor and Memory Details</h3><table>'
hardware_fields = [ "processor", "cpu", "memory" ]
for key,value in system_json.items():
if any (a in key for a in hardware_fields) and "accelerator" not in key:
table += f"""<tr><td>{key}</td><td>{value}</td></tr>"""
table += "</table>"
return table
def get_network_details_table(system_json):
table = '<h3>Network and Interconnect Details</h3><table>'
hardware_fields = [ "network", "nics" ]
for key,value in system_json.items():
if any (a in key for a in hardware_fields) and "accelerator" not in key:
table += f"""<tr><td>{key}</td><td>{value}</td></tr>"""
table += "</table>"
return table
def get_hardware_details_table(system_json):
table = '<h3>Other Hardware Details</h3><table>'
hardware_fields = [ "hardware", "disk", "cooling", "power", "hw_" ]
for key,value in system_json.items():
if any (a in key for a in hardware_fields) and "accelerator" not in key:
table += f"""<tr><td>{key}</td><td>{value}</td></tr>"""
table += "</table>"
return table
def get_software_details_table(system_json):
table = '<h3>Software Details</h3><table>'
software_fields = [ "software", "framework", "firmware", "sw_", "operating_" ]
for key,value in system_json.items():
if any (a in key for a in software_fields):
table += f"""<tr><td>{key}</td><td>{value}</td></tr>"""
table += "</table>"
return table
# Initialize a dictionary to organize the data by 'Details'
tables = {}
# Populate the dictionary with data
for entry in data:
details = entry['Details']
if details not in tables:
tables[details] = {}
categories = [ "edge", "datacenter" ]
for category in categories:
if category not in entry['Suite']:
continue
if category not in tables[details]:
tables[details][category] = {}
if entry['Category'] not in tables[details][category]:
tables[details][category][entry['Category']] = {}
if entry['Model'] not in tables[details][category][entry['Category']]:
tables[details][category][entry['Category']] [entry['Model']] = {}
if entry['Scenario'] not in tables[details][category][entry['Category']][entry['Model']]:
tables[details][category][entry['Category']][entry['Model']][entry['Scenario']] = entry
# Now you can format each group in 'tables' as a markdown table
for details, entries in tables.items():
out = f"## {details}"
models_edge = [ "gptj-99", "gptj-99.9", "bert-99", "bert-99.9", "stable-diffusion-xl", "retinanet", "resnet", "3d-unet-99", "3d-unet-99.9" ]
if "datacenter" in entries:
models = [ "llama2-70b-99", "llama2-70b-99.9", "gptj-99", "gptj-99.9", "bert-99", "bert-99.9", "stable-diffusion-xl", "dlrm-v2-99", "dlrm-v2-99.9", "retinanet", "resnet", "3d-unet-99", "3d-unet-99.9" ]
html_table_head = f"""
<h3>Results Table</h3>
<table>
<tr>
<th rowspan="2">Model</th>
<th rowspan="2">Accuracy Target</th>
<th colspan="2">Server</th>
<th colspan="2">Offline</th>
</tr>
<tr>
<td>Metric</td>
<td>Performance</td>
<td>Metric</td>
<td>Performance</td>
</tr>
"""
for category in entries:
for division, data in entries[category].items():
html_table = html_table_head
hardware_details = ''
for model in models:
if model in data:
html_table += f"""<tr><td>{model}</td>"""
if "closed" in division:
version = data[model]["Offline"]["version"]
acc_target = checker.MODEL_CONFIG[version]["accuracy-target"][model]
i = 0
acc_targets = []
key = None
for item in acc_target:
if i%2 == 0:
key = item
else:
acc_targets.append( (key, item))
i+=1
else:
acc_targets = []
acc_targets_list = []
for item in acc_targets:
acc_targets_list.append(f"""{item[0]}: {round(item[1], 4)}""")
acc_targets_string = ", ".join(acc_targets_list)
html_table += f"""<td>{acc_targets_string}</td>"""
if "Server" in data[model]:
html_table += f"""<td>{data[model]["Server"]["Performance_Units"]}</td> <td>{data[model]["Server"]["Performance_Result"]}</td>"""
else:
html_table += "<td></td><td></td>"
if "Offline" in data[model]:
details_split = details.split("/")
details_split[9] = "systems"
system = os.path.sep.join(details_split[7:11])
#details_split[0] = "https://raw.githubusercontent.com"
#system = details.replace("github.com", "raw.githubusercontent.com").replace("tree/", "refs/heads/").replace("results/", "systems/")
system_json_path = f"""{system}.json"""
system_json = get_system_json(system_json_path)
header_table = get_header_table(system_json)
accelerator_details = get_accelerator_details_table(system_json)
cpu_details = get_cpu_details_table(system_json)
hardware_details = get_hardware_details_table(system_json)
software_details = get_software_details_table(system_json)
network_details = get_network_details_table(system_json)
html_table += f"""<td>{data[model]["Offline"]['Performance_Units']}</td> <td>{data[model]["Offline"]["Performance_Result"]}</td>"""
else:
html_table += "<td></td><td></td>"
else:
pass
#html_table += "<td></td> <td></td>"
#html_table += "<td></td> <td></td>"
#html_table += "</tr>"
html_table += "</table>"
sut_name = os.path.basename(details)
tmp_path = os.path.dirname(details)
tmp_path = os.path.dirname(tmp_path)
submitter = os.path.basename(tmp_path)
out_path = os.path.join(division, submitter, "results", sut_name, "summary", "README.md")
os.makedirs(os.path.dirname(out_path), exist_ok=True)
html_table = f"""
{header_table}
<table>
<tr><td>{accelerator_details}</td> <td>{cpu_details}</td> </tr>
<tr><td >{hardware_details}</td> <td>{network_details}</td> </tr>
<tr><td colspan="2">{software_details}</td> </tr>
</table>
{html_table}
"""
with open(out_path, "w") as f:
f.write(html_table)
html_out_path = os.path.join(division, submitter, "results", sut_name, "summary", "summary.html")
html_header = get_header()
html = f"""
<html>
{html_header}
<body>
{html_table}
</body>
</html>
"""
with open(html_out_path, "w") as f:
f.write(html)
print(html_table)
#sys.exit()