IlyasMoutawwakil HF staff commited on
Commit
10c3b6b
·
1 Parent(s): 7b9f0a8

add more options

Browse files
Files changed (2) hide show
  1. app.py +13 -11
  2. config_store.py +10 -0
app.py CHANGED
@@ -1,10 +1,17 @@
1
  import os
2
  import time
3
- import signal # noqa
4
  import traceback
5
 
 
 
 
 
 
 
 
6
  import gradio as gr
7
  from huggingface_hub import create_repo, whoami
 
8
  from optimum_benchmark.backends.openvino.utils import TASKS_TO_OVMODEL
9
  from optimum_benchmark.backends.transformers_utils import TASKS_TO_MODEL_LOADERS
10
  from optimum_benchmark import (
@@ -17,12 +24,6 @@ from optimum_benchmark import (
17
  )
18
  from optimum_benchmark.logging_utils import setup_logging
19
 
20
- from config_store import (
21
- get_process_config,
22
- get_inference_config,
23
- get_openvino_config,
24
- get_pytorch_config,
25
- )
26
 
27
  DEVICE = "cpu"
28
  LAUNCHER = "process"
@@ -46,7 +47,7 @@ def run_benchmark(kwargs, oauth_token: gr.OAuthToken):
46
  token = oauth_token.token
47
 
48
  create_repo(repo_id, token=token, repo_type="dataset", exist_ok=True)
49
- gr.Info(f'Created repository "{repo_id}" on the Hub.')
50
 
51
  configs = {
52
  "process": {},
@@ -70,7 +71,7 @@ def run_benchmark(kwargs, oauth_token: gr.OAuthToken):
70
 
71
  for key in configs.keys():
72
  for k, v in configs[key].items():
73
- if "kwargs" in k:
74
  configs[key][k] = eval(v)
75
 
76
  configs["process"] = ProcessConfig(**configs.pop("process"))
@@ -169,7 +170,7 @@ def build_demo():
169
  process_config = get_process_config()
170
 
171
  with gr.Row():
172
- with gr.Accordion(label="Scenario Config", open=False, visible=True):
173
  inference_config = get_inference_config()
174
 
175
  with gr.Row() as backend_configs:
@@ -224,10 +225,11 @@ def build_demo():
224
  return demo
225
 
226
 
 
 
227
  if __name__ == "__main__":
228
  os.environ["LOG_TO_FILE"] = "0"
229
  os.environ["LOG_LEVEL"] = "INFO"
230
  setup_logging(level="INFO", prefix="MAIN-PROCESS")
231
 
232
- demo = build_demo()
233
  demo.queue(max_size=10).launch()
 
1
  import os
2
  import time
 
3
  import traceback
4
 
5
+ from config_store import (
6
+ get_process_config,
7
+ get_inference_config,
8
+ get_openvino_config,
9
+ get_pytorch_config,
10
+ )
11
+
12
  import gradio as gr
13
  from huggingface_hub import create_repo, whoami
14
+ from optimum_benchmark.launchers.device_isolation_utils import * # noqa
15
  from optimum_benchmark.backends.openvino.utils import TASKS_TO_OVMODEL
16
  from optimum_benchmark.backends.transformers_utils import TASKS_TO_MODEL_LOADERS
17
  from optimum_benchmark import (
 
24
  )
25
  from optimum_benchmark.logging_utils import setup_logging
26
 
 
 
 
 
 
 
27
 
28
  DEVICE = "cpu"
29
  LAUNCHER = "process"
 
47
  token = oauth_token.token
48
 
49
  create_repo(repo_id, token=token, repo_type="dataset", exist_ok=True)
50
+ gr.Info(f'Created repository "{repo_id}" where results will be pushed.')
51
 
52
  configs = {
53
  "process": {},
 
71
 
72
  for key in configs.keys():
73
  for k, v in configs[key].items():
74
+ if k in ["input_shapes", "generate_kwargs", "numactl_kwargs"]:
75
  configs[key][k] = eval(v)
76
 
77
  configs["process"] = ProcessConfig(**configs.pop("process"))
 
170
  process_config = get_process_config()
171
 
172
  with gr.Row():
173
+ with gr.Accordion(label="Inference Config", open=False, visible=True):
174
  inference_config = get_inference_config()
175
 
176
  with gr.Row() as backend_configs:
 
225
  return demo
226
 
227
 
228
+ demo = build_demo()
229
+
230
  if __name__ == "__main__":
231
  os.environ["LOG_TO_FILE"] = "0"
232
  os.environ["LOG_LEVEL"] = "INFO"
233
  setup_logging(level="INFO", prefix="MAIN-PROCESS")
234
 
 
235
  demo.queue(max_size=10).launch()
config_store.py CHANGED
@@ -52,6 +52,16 @@ def get_inference_config():
52
  label="inference.memory",
53
  info="Measures the peak memory consumption",
54
  ),
 
 
 
 
 
 
 
 
 
 
55
  }
56
 
57
 
 
52
  label="inference.memory",
53
  info="Measures the peak memory consumption",
54
  ),
55
+ "inference.input_shapes": gr.Textbox(
56
+ label="inference.input_shapes",
57
+ value="{'batch_size': 1, 'sequence_length': 128}",
58
+ info="Input shapes to use for the benchmark",
59
+ ),
60
+ "inference.generate_kwargs": gr.Textbox(
61
+ label="inference.generate_kwargs",
62
+ value="{'max_new_tokens': 32, 'min_new_tokens': 32}",
63
+ info="Additional python dict of kwargs to pass to the generate function",
64
+ ),
65
  }
66
 
67