@@ -86,36 +86,6 @@ def parse_args() -> Any:
86
86
action = ValidateDir ,
87
87
help = "the directory to keep the benchmark results" ,
88
88
)
89
- parser .add_argument (
90
- "--repo" ,
91
- type = str ,
92
- required = True ,
93
- help = "which GitHub repo this workflow run belongs to" ,
94
- )
95
- parser .add_argument (
96
- "--head-branch" ,
97
- type = str ,
98
- required = True ,
99
- help = "the head branch that runs" ,
100
- )
101
- parser .add_argument (
102
- "--workflow-name" ,
103
- type = str ,
104
- required = True ,
105
- help = "the name of the benchmark workflow" ,
106
- )
107
- parser .add_argument (
108
- "--workflow-run-id" ,
109
- type = int ,
110
- required = True ,
111
- help = "the id of the benchmark workflow" ,
112
- )
113
- parser .add_argument (
114
- "--workflow-run-attempt" ,
115
- type = int ,
116
- required = True ,
117
- help = "which retry of the workflow this is" ,
118
- )
119
89
parser .add_argument (
120
90
"--benchmark-configs" ,
121
91
type = str ,
@@ -153,9 +123,10 @@ def extract_android_benchmark_results(
153
123
# This is to handle the case where there is no benchmark results
154
124
warning (f"Fail to load the benchmark results from { artifact_s3_url } " )
155
125
return []
126
+ return []
156
127
157
128
158
- def initialize_ios_metadata (test_name : str ) -> Dict [str , any ]:
129
+ def initialize_ios_metadata (test_name : str ) -> Dict [str , Any ]:
159
130
"""
160
131
Extract the benchmark metadata from the test name, for example:
161
132
test_forward_llama2_pte_iOS_17_2_1_iPhone15_4
@@ -364,14 +335,7 @@ def transform(
364
335
app_type : str ,
365
336
benchmark_results : List ,
366
337
benchmark_config : Dict [str , str ],
367
- repo : str ,
368
- head_branch : str ,
369
- workflow_name : str ,
370
- workflow_run_id : int ,
371
- workflow_run_attempt : int ,
372
338
job_name : str ,
373
- job_id : int ,
374
- schema_version : str ,
375
339
) -> List :
376
340
"""
377
341
Transform the benchmark results into the format writable into the benchmark database
@@ -381,87 +345,51 @@ def transform(
381
345
for r in benchmark_results :
382
346
r ["deviceInfo" ]["device" ] = job_name
383
347
384
- if schema_version == "v2" :
385
- # TODO (huydhn): Clean up this branch after ExecuTorch dashboard migrates to v3
386
- return [
387
- {
388
- # GH-info to identify where the benchmark is run
389
- "repo" : repo ,
390
- "head_branch" : head_branch ,
391
- "workflow_id" : workflow_run_id ,
392
- "run_attempt" : workflow_run_attempt ,
393
- "job_id" : job_id ,
394
- # The model
395
- "name" : f"{ r ['benchmarkModel' ]['name' ]} { r ['benchmarkModel' ].get ('backend' , '' )} " .strip (),
396
- "dtype" : (
397
- r ["benchmarkModel" ]["quantization" ]
398
- if r ["benchmarkModel" ]["quantization" ]
399
- else "unknown"
400
- ),
401
- # The metric value
402
- "metric" : r ["metric" ],
403
- "actual" : r ["actualValue" ],
404
- "target" : r ["targetValue" ],
405
- # The device
406
- "device" : r ["deviceInfo" ]["device" ],
407
- "arch" : r ["deviceInfo" ].get ("os" , "" ),
408
- # Not used here, just set it to something unique here
409
- "filename" : workflow_name ,
410
- "test_name" : app_type ,
411
- "runner" : job_name ,
412
- }
413
- for r in benchmark_results
414
- ]
415
- elif schema_version == "v3" :
416
- v3_benchmark_results = []
417
- # From https://github.com/pytorch/pytorch/wiki/How-to-integrate-with-PyTorch-OSS-benchmark-database
418
- return [
419
- {
420
- "benchmark" : {
421
- "name" : "ExecuTorch" ,
422
- "mode" : "inference" ,
423
- "extra_info" : {
424
- "app_type" : app_type ,
425
- # Just keep a copy of the benchmark config here
426
- "benchmark_config" : json .dumps (benchmark_config ),
427
- },
428
- },
429
- "model" : {
430
- "name" : benchmark_config .get ("model" , r ["benchmarkModel" ]["name" ]),
431
- "type" : "OSS model" ,
432
- "backend" : benchmark_config .get (
433
- "config" , r ["benchmarkModel" ].get ("backend" , "" )
434
- ),
348
+ # From https://github.com/pytorch/pytorch/wiki/How-to-integrate-with-PyTorch-OSS-benchmark-database
349
+ return [
350
+ {
351
+ "benchmark" : {
352
+ "name" : "ExecuTorch" ,
353
+ "mode" : "inference" ,
354
+ "extra_info" : {
355
+ "app_type" : app_type ,
356
+ # Just keep a copy of the benchmark config here
357
+ "benchmark_config" : json .dumps (benchmark_config ),
435
358
},
436
- "metric" : {
437
- "name" : r ["metric" ],
438
- "benchmark_values" : [r ["actualValue" ]],
439
- "target_value" : r ["targetValue" ],
440
- "extra_info" : {
441
- "method" : r .get ("method" , "" ),
442
- },
359
+ },
360
+ "model" : {
361
+ "name" : benchmark_config .get ("model" , r ["benchmarkModel" ]["name" ]),
362
+ "type" : "OSS model" ,
363
+ "backend" : benchmark_config .get (
364
+ "config" , r ["benchmarkModel" ].get ("backend" , "" )
365
+ ),
366
+ },
367
+ "metric" : {
368
+ "name" : r ["metric" ],
369
+ "benchmark_values" : [r ["actualValue" ]],
370
+ "target_value" : r ["targetValue" ],
371
+ "extra_info" : {
372
+ "method" : r .get ("method" , "" ),
443
373
},
444
- "runners" : [
445
- {
446
- "name" : r ["deviceInfo" ]["device" ],
447
- "type" : r ["deviceInfo" ]["os" ],
448
- "avail_mem_in_gb" : r ["deviceInfo" ].get ("availMem" , "" ),
449
- "total_mem_in_gb" : r ["deviceInfo" ].get ("totalMem" , "" ),
450
- }
451
- ],
452
- }
453
- for r in benchmark_results
454
- ]
374
+ },
375
+ "runners" : [
376
+ {
377
+ "name" : r ["deviceInfo" ]["device" ],
378
+ "type" : r ["deviceInfo" ]["os" ],
379
+ "avail_mem_in_gb" : r ["deviceInfo" ].get ("availMem" , "" ),
380
+ "total_mem_in_gb" : r ["deviceInfo" ].get ("totalMem" , "" ),
381
+ }
382
+ ],
383
+ }
384
+ for r in benchmark_results
385
+ ]
455
386
456
387
457
388
def main () -> None :
458
389
args = parse_args ()
459
390
460
391
# Across all devices, keeping both schemas for now until ExecuTorch dashboard migrates to v3
461
- all_benchmark_results = {
462
- "v2" : [],
463
- "v3" : [],
464
- }
392
+ all_benchmark_results = []
465
393
benchmark_config = {}
466
394
467
395
with open (args .artifacts ) as f :
@@ -482,7 +410,7 @@ def main() -> None:
482
410
benchmark_config = read_benchmark_config (
483
411
artifact_s3_url , args .benchmark_configs
484
412
)
485
-
413
+ benchmark_results = []
486
414
if app_type == "ANDROID_APP" :
487
415
benchmark_results = extract_android_benchmark_results (
488
416
job_name , artifact_type , artifact_s3_url
@@ -494,32 +422,17 @@ def main() -> None:
494
422
)
495
423
496
424
if benchmark_results :
497
- for schema in all_benchmark_results .keys ():
498
- results = transform (
499
- app_type ,
500
- benchmark_results ,
501
- benchmark_config ,
502
- args .repo ,
503
- args .head_branch ,
504
- args .workflow_name ,
505
- args .workflow_run_id ,
506
- args .workflow_run_attempt ,
507
- job_name ,
508
- extract_job_id (args .artifacts ),
509
- schema ,
510
- )
511
- all_benchmark_results [schema ].extend (results )
512
-
513
- for schema in all_benchmark_results .keys ():
514
- if not all_benchmark_results .get (schema ):
515
- continue
516
-
517
- output_dir = os .path .join (args .output_dir , schema )
518
- os .makedirs (output_dir , exist_ok = True )
425
+ results = transform (
426
+ app_type , benchmark_results , benchmark_config , job_name
427
+ )
428
+ all_benchmark_results .extend (results )
519
429
430
+ # add v3 in case we have higher version of schema
431
+ output_dir = os .path .join (args .output_dir , "v3" )
432
+ os .makedirs (output_dir , exist_ok = True )
520
433
output_file = os .path .basename (args .artifacts )
521
434
with open (f"{ output_dir } /{ output_file } " , "w" ) as f :
522
- json .dump (all_benchmark_results [ schema ] , f )
435
+ json .dump (all_benchmark_results , f )
523
436
524
437
525
438
if __name__ == "__main__" :
0 commit comments