Skip to content

Commit 372a327

Browse files
committed
cleaner autocast logic, benchmark.md with flag instructions
1 parent 68018b0 commit 372a327

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

docs/benchmark.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,18 @@ Launch the `benchmark.py` script to append benchmark results to the existing [be
108108
python ./scripts/benchmark.py
109109
```
110110

111-
Lauch the `benchmark_quality.py` script to compare the output of single-precision and half-precision models:
111+
Here are the following flags that can be set on the `benchmark.py` script:
112+
* `--samples` sets the sample size for which to run a benchmark and is passed as a comma separated list of values such as `1,2,4,8,16`. Default is `1`.
113+
* `--steps` sets the number of inference steps and is passed as an integer value, eg: `50`. Default is `40`.
114+
* `--repeats` sets the number of times to repeat each run with a given set of parameter value before reporting their average inference latencies. It is passed as an integer value, eg: `2`. Default is `3`.
115+
* `--autocast` sets whether or not to add cuda autocast runs to the benchmark (respectively `yes` and `no`). Default is `no`.
116+
117+
An example of running the benchmark script options set:
118+
```
119+
python ./scripts/benchmark.py --samples=1,2,4 --steps=50 --repeats=3 --autocast=no
120+
```
121+
122+
Launch the `benchmark_quality.py` script to compare the output of single-precision and half-precision models:
112123
```
113124
python ./scripts/benchmark_quality.py
114125
```

scripts/benchmark.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,9 @@ def run_benchmark_grid(grid, n_repeats, num_inference_steps):
181181
device_desc = get_device_description()
182182
for n_samples in grid["n_samples"]:
183183
for precision in grid["precision"]:
184-
use_autocast = False
185184
if precision == "half":
186185
for autocast in grid["autocast"]:
187-
if autocast == "yes":
188-
use_autocast = True
186+
use_autocast = (autocast == "yes")
189187
for backend in grid["backend"]:
190188
try:
191189
new_log = run_benchmark(

0 commit comments

Comments
 (0)