superbench-config.mdx 12.9 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.8
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
### `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:
141
    model-benchmarks:foo:
142
143
144
      models:
        - resnet50
      parameters: *param
145
    model-benchmarks:bar:
146
147
148
149
150
151
152
153
154
      models:
        - vgg19
      parameters: *param
```

The above configuration equals to the following:
```yaml {6-9,13-16}
superbench:
  benchmarks:
155
    model-benchmarks:foo:
156
157
158
159
160
161
      models:
        - resnet50
      parameters:
        num_warmup: 16
        num_steps: 128
        batch_size: 128
162
    model-benchmarks:bar:
163
164
165
166
167
168
169
170
171
172
173
174
      models:
        - vgg19
      parameters:
        num_warmup: 16
        num_steps: 128
        batch_size: 128
```

### `superbench.benchmarks`

Mappings of `${benchmark_name}: Benchmark`.

175
There are three types of benchmarks,
176
177
178
[micro-benchmark](./user-tutorial/benchmarks/micro-benchmarks.md),
[model-benchmark](./user-tutorial/benchmarks/model-benchmarks.md),
and [docker-benchmark](./user-tutorial/benchmarks/docker-benchmarks.md).
179
180
181
182
183
184
Each benchmark has its own unique name listed in docs.

`${benchmark_name}` can be one of the followings:
* `${benchmark_unique_name}`, it can be the exact same as benchmark's own unique name;
* `${benchmark_unique_name}:${annotation}`, or if there's a need to run one benchmark with different settings,
  an annotation separated by `:` can be appended after benchmark's unique name.
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205

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
206
  timeout: int
207
208
209
210
211
  modes: [ Mode ]
  frameworks: [ enum ]
  parameters:
    run_count: int
    duration: int
212
    log_raw_data: bool
213
214
215
216
217
218
    ${argument}: bool | str | int | float | list
```

#### Model-Benchmark

```yaml
219
model-benchmarks:${annotation}:
220
  enable: bool
221
  timeout: int
222
223
224
225
226
227
  modes: [ Mode ]
  frameworks: [ enum ]
  models: [ enum ]
  parameters:
    run_count: int
    duration: int
228
    log_raw_data: bool
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
    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
247
  timeout: 120
248
249
250
251
252
253
254
255
256
257
258
259
260
261
  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
262
model-benchmarks:resnet:
263
  enable: true
264
  timeout: 1800
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
  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`

296
297
298
299
300
301
### `timeout`

Set the timeout value in seconds, the benchmarking will stop early if timeout is triggerred.

* default value: none

302
303
304
305
306
307
308
309
310
311
312
313
### `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.

314
* accepted values: `[ onnxruntime | pytorch | tf1 | tf2 | none ]`
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
* 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.

339
There have four common parameters for all benchmarks:
340
341
342
* run_count: how many times do user want to run this benchmark, default value is 1.
* duration: the elapsed time of benchmark in seconds. It can work for all model-benchmark. But for micro-benchmark, benchmark authors should consume it by themselves.
* log_raw_data: log raw data into file instead of saving it into result object, default value is `False`.  Benchmarks who have large raw output may want to set it as `True`, such as `nccl-bw`/`rccl-bw`.
343
* log_flushing: real-time log flushing, default value is `False`.
344
345
346
347
348
349
350
351

For Model-Benchmark, there have some parameters that can control the elapsed time.
* duration: the elapsed time of benchmark in seconds.
* num_warmup: the number of warmup step.
* num_steps: the number of test step.

If `duration > 0` and `num_warmup + num_steps > 0`, then benchmark will take the least as the elapsed time. Otherwise only one of them will take effect.

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
## `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` |    ✓    |          ✓          |   ✓   |
400
| `node_num` |    ✘    |          ✓          |   ✓   |
401
| `prefix`   |    ✓    |          ✘          |   ✘   |
402
| `env`      |    ✓    |          ✓          |   ✓   |
403
404
| `mca`      |    ✘    |          ✘          |   ✓   |
| `parallel` |    ✓    |          ✘          |   ✘   |
405
| `pattern`  |    ✘    |          ✘          |   ✓   |
406
407
408
409
410
411
412
413
414
415
416
417
418

* 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`

419
Node number to run in the mode. Defaults to all nodes provided by host file in the run.
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
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`

440
441
442
443
444
445
Environment variables to use in the mode, in a flatten key-value dictionary.
The value needs to be string, any integer or boolean values need to be enclosed in quotes.

Formatted string is also supported in value, available variables include:
+ `proc_rank`
+ `proc_num`
446
447
448
449
450
451
452
453
454
455
456
457
458

### `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`
459
460
461
462
463
464
465

### `pattern`

Pattern variables to run benchmarks with nodes in specified traffic pattern combination, in a flatten key-value dictionary.
Only available for `mpi` mode.

Available variables in formatted string includes:
466
+ `type(str)`: the traffic pattern type, required.
467
    * accepted values: `all-nodes`, `pair-wise`, `k-batch`, `topo-aware`
468
469
470
471
472
473
+ `mpi_pattern(bool)`: generate pattern config file in `./output/mpi_pattern.txt` for diagnosis, required.
+ `batch(int)`: the scale of batch, required in `k-batch` pattern.
+ `ibstat(str)`: the path of ibstat output, wil be auto-generated in `./output/ibstat_file.txt` if not specified, optional in `topo-aware` pattern
+ `ibnetdiscover(str)`: the path of ibnetdiscover output `ibnetdiscover_file.txt`, required in `topo-aware` pattern.
+ `min_dist(int)`: minimum distance of VM pair, required in `topo-aware` pattern.
+ `max_dist(int)`: maximum distance of VM pair, required in `topo-aware` pattern.