meg-huggingface commited on
Commit
cbc5c2e
1 Parent(s): 211db76

Trying python version of API

Browse files
Files changed (1) hide show
  1. benchmark.py +36 -0
benchmark.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+
3
+ from optimum_benchmark.experiment import launch, ExperimentConfig
4
+ from optimum_benchmark.backends.pytorch.config import PyTorchConfig
5
+ from optimum_benchmark.launchers.torchrun.config import TorchrunConfig
6
+ from optimum_benchmark.benchmarks.inference.config import InferenceConfig
7
+
8
+ if __name__ == "__main__":
9
+ parser = argparse.ArgumentParser(description='Run optimum-benchmark')
10
+ parser.add_argument('--config-name', dest='experiment_name', type=str,
11
+ help='experiment name (text classification, etc.)')
12
+ parser.add_argument('--backend-model', dest='backend_model', type=str,
13
+ help='model name')
14
+ parser.add_argument('--hydra-run-dir', dest='run_dir', type=str)
15
+
16
+ args = parser.parse_args()
17
+ backend_model = args.backend_model
18
+ run_dir = args.run_dir
19
+ experiment_name = args.experiment_name
20
+
21
+ launcher_config = TorchrunConfig(nproc_per_node=2)
22
+ benchmark_config = InferenceConfig(latency=True, memory=True)
23
+ backend_config = PyTorchConfig(model=backend_model)
24
+ experiment_config = ExperimentConfig(
25
+ experiment_name=experiment_name,
26
+ benchmark=benchmark_config,
27
+ launcher=launcher_config,
28
+ backend=backend_config,
29
+ )
30
+
31
+ benchmark_report = launch(experiment_config)
32
+
33
+ # push artifacts to the hub
34
+ experiment_config.push_to_hub("EnergyStarAI/benchmarksDebug")
35
+ benchmark_report.push_to_hub("EnergyStarAI/benchmarksDebug")
36
+