"git@developer.sourcefind.cn:yangql/googletest.git" did not exist on "5b3d27729b118f2c8b5e74039409db0c517651fa"
superbench-config.mdx 10.3 KB
Newer Older
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
---
id: superbench-config
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';


# SuperBench Config File

[YAML](https://yaml.org/spec/1.2/spec.html) format configuration file is an efficient method to take full advantage of SuperBench.
You can put it in any place and specify the path to config file through `-c /path/to/config.yaml` in `sb` CLI.

This document covers schema of SuperBench configuration YAML file.
You can learn YAML basics from [Learn YAML in Y minutes](https://learnxinyminutes.com/docs/yaml/).
SuperBench configuration supports most of the YAML features, including anchors and aliases, merge key, etc.

## Conventions

Here lists syntax conventions used in this document:

* The schema and example are in YAML format.

* In YAML mappings which use a colon `:` to mark `key: value` pair.

  The left side of colon is a literal keyword defined in configuration,
  if it is surrounded by `${}`, like `${name}`, then the key is a string that can be defined by user.

  The right side of colon is a data type, which may be Python built-in types (like `string`, `dict`),
  or a rich structure defined in this document (first character capitalized).

* The notation `[ datatype ]` indicates a YAML sequence of the mentioned data type.
  For example, `[ string ]` is a list of strings.

* The notation `|` indicates there are multiple optional data types.
  For example, `string | [ string ]` means either a string or a list of strings is allowed.

## Configuration Schema

The configuration file describes all benchmarks running by SuperBench.
There will be one or more benchmarks, each benchmark has its own settings and parameters.
One benchmark may have one or more modes, which indicates how to run benchmarks in all given machines.

Here is an overview of SuperBench configuration structure:

<Tabs
  defaultValue='schema'
  values={[
    {label: 'Schema', value: 'schema'},
    {label: 'Example', value: 'example'},
  ]
}>
<TabItem value='schema'>

```yaml
version: string
superbench:
  enable: string | [ string ]
59
60
61
62
  monitor:
    enable: bool
    sample_duration: int
    sample_interval: int
63
64
65
66
67
68
69
70
71
72
  var:
    ${var_name}: dict
  benchmarks:
    ${benchmark_name}: Benchmark
```

</TabItem>
<TabItem value='example'>

```yaml
73
version: v0.3
74
75
superbench:
  enable: benchmark_1
76
77
78
79
  monitor:
    enable: false
    sample_duration: 10
    sample_interval: 1
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
  var:
    var_1: value
  benchmarks:
    benchmark_1:
      enable: true
      modes:
      - name: local
```

</TabItem>
</Tabs>

### `version`

Version of the configuration file.
Lower version `sb` CLI may not understand higher version config.

### `superbench`

SuperBench configuration for all benchmarks.

### `superbench.enable`

Enable which benchmark to run, could be one or multiple benchmarks' name.
If not specified, will use [`${benchmark_name}.enable`](#enable) in each benchmark as default.

* value from: benchmark names defined in `superbench.benchmarks`
* default value: `null`

109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
### `superbench.monitor`

Enable monitor to collect system metrics periodically, currently only support CUDA platform. There are three settings:

#### `enable`

Whether enable the monitor module or not.

#### `sample_duration`

Calculate the average metrics during sample_duration seconds, such as CPU usage and NIC bandwidth.

#### `sample_interval`

Do sampling every sample_interval seconds.

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
### `superbench.var`

User-defined variables to be used in the configuration.
Leveraging YAML [anchors and aliases](https://yaml.org/spec/1.2/spec.html#id2765878),
common settings can be defined here to avoid config duplication.

Here is a usage example:

```yaml {3-6,11,15}
superbench:
  var:
    common_param: &param
      num_warmup: 16
      num_steps: 128
      batch_size: 128
  benchmarks:
    foo_models:
      models:
        - resnet50
      parameters: *param
    bar_models:
      models:
        - vgg19
      parameters: *param
```

The above configuration equals to the following:
```yaml {6-9,13-16}
superbench:
  benchmarks:
    foo_models:
      models:
        - resnet50
      parameters:
        num_warmup: 16
        num_steps: 128
        batch_size: 128
    bar_models:
      models:
        - vgg19
      parameters:
        num_warmup: 16
        num_steps: 128
        batch_size: 128
```

### `superbench.benchmarks`

Mappings of `${benchmark_name}: Benchmark`.

175
176
There are three types of benchmarks, micro-benchmark, model-benchmark and docker-benchmark.
For micro-benchmark and docker-benchmark, `${benchmark_name}` should be the exact same as provided benchmarks' name.
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
For model-benchmark, `${benchmark_name}` should be in `${name}_models` format,
each model-benchmark can have a customized name while ending with `_models`.

See [`Benchmark` Schema](#benchmark-schema) for benchmark definition.

## `Benchmark` Schema

Definition for each benchmark, here is an overview of `Benchmark` configuration structure:

<Tabs
  defaultValue='schema'
  values={[
    {label: 'Schema', value: 'schema'},
    {label: 'Example', value: 'example'},
  ]
}>
<TabItem value='schema'>

#### Micro-Benchmark

```yaml
${benchmark_name}:
  enable: bool
  modes: [ Mode ]
  frameworks: [ enum ]
  parameters:
    run_count: int
    duration: int
    ${argument}: bool | str | int | float | list
```

#### Model-Benchmark

```yaml
${name}_models:
  enable: bool
  modes: [ Mode ]
  frameworks: [ enum ]
  models: [ enum ]
  parameters:
    run_count: int
    duration: int
    num_warmup: int
    num_steps: int
    sample_count: int
    batch_size: int
    precision: [ enum ]
    model_action: [ enum ]
    pin_memory: bool
    ${argument}: bool | str | int | float | list
```

</TabItem>
<TabItem value='example'>

#### Micro-Benchmark

```yaml
kernel-launch:
  enable: true
  modes:
    - name: local
      proc_num: 8
      prefix: CUDA_VISIBLE_DEVICES={proc_rank}
      parallel: yes
  parameters:
    num_warmup: 100
    num_steps: 2000000
    interval: 2000
```

#### Model-Benchmark

```yaml
resnet_models:
  enable: true
  modes:
    - name: torch.distributed
      proc_num: 8
      node_num: 1
  frameworks:
    - pytorch
  models:
    - resnet50
    - resnet101
    - resnet152
  parameters:
    duration: 0
    num_warmup: 16
    num_steps: 128
    batch_size: 128
    precision:
      - float32
      - float16
    model_action:
      - train
```

</TabItem>
</Tabs>

### `enable`

Enable current benchmark or not, can be overwritten by [`superbench.enable`](#superbenchenable).

* default value: `true`

### `modes`

A list of modes in which the benchmark runs.
Currently only one mode is supported for each benchmark.

See [`Mode` Schema](#mode-schema) for mode definition.

### `frameworks`

A list of frameworks in which the benchmark runs.
Some benchmarks can support multiple frameworks while others only support one.

296
* accepted values: `[ onnxruntime | pytorch | tf1 | tf2 | none ]`
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
* default value: `[ none ]`

### `models`

A list of models to run, only supported in model-benchmark.

* accepted values:
  ```yaml
  # pytorch framework
  [ alexnet | densenet121 | densenet169 | densenet201 | densenet161 | googlenet | inception_v3 |
    mnasnet0_5 | mnasnet0_75 | mnasnet1_0 | mnasnet1_3 | mobilenet_v2 |
    resnet18 | resnet34 | resnet50 | resnet101 | resnet152 |
    resnext50_32x4d | resnext101_32x8d | wide_resnet50_2 | wide_resnet101_2 |
    shufflenet_v2_x0_5 | shufflenet_v2_x1_0 | shufflenet_v2_x1_5 | shufflenet_v2_x2_0 |
    squeezenet1_0 | squeezenet1_1 |
    vgg11 | vgg11_bn | vgg13 | vgg13_bn | vgg16 | vgg16_bn | vgg19_bn | vgg19 |
    bert-base | bert-large | gpt2-small | gpt2-medium | gpt2-large | gpt2-xl ]
  ```
* default value: `[ ]`

### `parameters`

Parameters for benchmark to use, varying for different benchmarks.

## `Mode` Schema

Definition for each benchmark mode, here is an overview of `Mode` configuration structure:

<Tabs
  defaultValue='schema'
  values={[
    {label: 'Schema', value: 'schema'},
    {label: 'Example', value: 'example'},
  ]
}>
<TabItem value='schema'>

```yaml
name: enum
proc_num: int
node_num: int
env: dict
mca: dict
prefix: str
parallel: bool
```

</TabItem>
<TabItem value='example'>

```yaml
name: local
proc_num: 8
prefix: CUDA_VISIBLE_DEVICES={proc_rank}
parallel: yes
```

</TabItem>
</Tabs>

### `name`

Mode name to use. Here lists available modes:
+ `local`: run benchmark as local process.
+ `torch.distributed`: launch benchmark through [PyTorch DDP](https://pytorch.org/docs/stable/distributed.html#launch-utility), each process will run on one GPU.
+ `mpi`: launch benchmark through MPI, the benchmark implementation could leverage MPI interface.

Some attributes may only be suitable for specific mode.

|            | `local` | `torch.distributed` | `mpi` |
| ---------: | :-----: | :-----------------: | :---: |
| `proc_num` |    ✓    |          ✓          |   ✓   |
| `node_num` |    ✘    |          ✓          |   ✘   |
| `prefix`   |    ✓    |          ✘          |   ✘   |
| `env`      |    ✘    |          ✘          |   ✓   |
| `mca`      |    ✘    |          ✘          |   ✓   |
| `parallel` |    ✓    |          ✘          |   ✘   |

* accepted values: `local | torch.distributed | mpi`
* default value: `local`

### `proc_num`

Process number to run per node.
Each process will run an individual benchmark, how processes communicate depends on the mode.

* default value: `1`

### `node_num`

Node number to run in the mode. Defaults to all nodes in the run.
Will be ignored in `local` mode.

For example, assuming you are running model benchmark on 4 nodes,
`proc_num: 8, node_num: 1` will run 8-GPU distributed training on each node,
while `proc_num: 8, node_num: null` will run 32-GPU distributed training on all nodes.

* default value: `null`

### `prefix`

Command prefix to use in the mode, in Python formatted string.

Available variables in formatted string includes:
+ `proc_rank`
+ `proc_num`

So `prefix: CUDA_VISIBLE_DEVICES={proc_rank}` will be expressed as `CUDA_VISIBLE_DEVICES=0`, `CUDA_VISIBLE_DEVICES=1`, etc.

### `env`

Environment variables to use in the mode,
in a flatten key-value dictionary.

### `mca`

MCA (Modular Component Architecture) frameworks, components, or modules to use in MPI,
in a flatten key-value dictionary.
Only available for `mpi` mode.

### `parallel`

Whether run benchmarks in parallel (all ranks at the same time) or in sequence (one rank at a time).
Only available for `local` mode.

* default value: `yes`