Skip to content

Commit 4f1f3ce

Browse files
committed
DOC: matmul-params README, improve
1 parent b2a0acb commit 4f1f3ce

2 files changed

Lines changed: 64 additions & 57 deletions

File tree

‎examples/matmul-params/README.md‎

Lines changed: 63 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,20 @@ $ bx bench bench_matmul.py $QUICK
3939
```text
4040
measuring bench_matmul.py on /home/br/temp/bex
4141
precision: 2 processes x 2 values (config: /home/br/temp/bex/benchx.conf.json)
42+
caveats: dirty-benchmark-tree, dirty-subject-tree
4243
case median mean ± sd min .. max n status
4344
-------------------------------- -------- ------------------- -------------------- - -------
44-
bench_matmul [n=10, xp='numpy'] 2.617 us 2.616 us ± 41.2 ns 2.578 us .. 2.653 us 4 success
45-
bench_matmul [n=10, xp='torch'] 2.681 us 2.675 us ± 70.97 ns 2.602 us .. 2.737 us 4 success
46-
bench_matmul [n=50, xp='numpy'] 15.45 us 15.44 us ± 27.2 ns 15.41 us .. 15.47 us 4 success
47-
bench_matmul [n=50, xp='torch'] 6.402 us 6.424 us ± 203.4 ns 6.201 us .. 6.691 us 4 success
48-
bench_matmul [n=100, xp='numpy'] 42.8 us 45.09 us ± 4.753 us 42.55 us .. 52.21 us 4 success
49-
bench_matmul [n=100, xp='torch'] 15.77 us 15.8 us ± 221.6 ns 15.59 us .. 16.09 us 4 success
50-
bench_matmul [n=200, xp='numpy'] 135.1 us 140 us ± 14.18 us 129.4 us .. 160.5 us 4 success
51-
bench_matmul [n=200, xp='torch'] 94.48 us 94.46 us ± 1.85 us 92.8 us .. 96.09 us 4 success
52-
53-
16 result(s) -> /home/br/temp/bex/out/bench-20261130T082456Z (order sha256:6acc0eac83bd)
45+
bench_matmul [n=10, xp='numpy'] 2.612 us 2.647 us ± 99.43 ns 2.572 us .. 2.793 us 4 success
46+
bench_matmul [n=10, xp='torch'] 2.784 us 2.772 us ± 103.2 ns 2.65 us .. 2.871 us 4 success
47+
bench_matmul [n=50, xp='numpy'] 15.37 us 15.42 us ± 240.6 ns 15.22 us .. 15.71 us 4 success
48+
bench_matmul [n=50, xp='torch'] 6.533 us 6.502 us ± 86.06 ns 6.376 us .. 6.567 us 4 success
49+
bench_matmul [n=100, xp='numpy'] 42.39 us 42.4 us ± 214.4 ns 42.21 us .. 42.61 us 4 success
50+
bench_matmul [n=100, xp='torch'] 15.84 us 15.89 us ± 178.2 ns 15.75 us .. 16.13 us 4 success
51+
bench_matmul [n=200, xp='numpy'] 131.7 us 143.1 us ± 25.6 us 127.8 us .. 181.2 us 4 success
52+
bench_matmul [n=200, xp='torch'] 95.36 us 95.49 us ± 2.644 us 93.15 us .. 98.09 us 4 success
53+
54+
16 result(s) -> /home/br/temp/bex/out/bench-20261130T094305Z (order sha256:b414dd788b58)
55+
run-key: bench-20261130T094305Z
5456
/home/br/temp/bex/out/home/store.parquet: ingested 16, duplicate 0
5557
```
5658

@@ -60,7 +62,9 @@ from the benchmarking run.
6062

6163
As usual (see the [basic tutorial](https://benchx.dev/examples/pyperf-suite/)),
6264
bare result files are in `out/`, and `out/home/store.parquet` is the store.
63-
Note that `bx` reports twice as many results as rows: each case also records `load-average`.
65+
Note that `bx` reports twice as many results as rows: each case also records `load-average`---
66+
roughly, the *load average* is how many processes were running or waiting for a CPU over at the start of the benchmark
67+
run. A value well above the CPU core count means the machine was busy, so the timings may be noisy.
6468

6569

6670
### Choosing cases
@@ -99,17 +103,18 @@ $ bx head
99103
```
100104

101105
```text
102-
/home/ev-br/proj/quansight/benchx/examples/matmul-params/out/home/store.parquet: 12 result(s); latest 10, newest first
103-
11 2026-11-26 18:10:17 bench-20261126T180958Z bench_matmul load-average success 14.72 1 3c940c24e7 local/qgpu3
104-
10 2026-11-26 18:10:17 bench-20261126T180958Z bench_matmul wall-time success 2.80957e-05 s 3c940c24e7 local/qgpu3
105-
9 2026-11-26 18:10:16 bench-20261126T180958Z bench_matmul load-average success 13.91 1 3c940c24e7 local/qgpu3
106-
8 2026-11-26 18:10:16 bench-20261126T180958Z bench_matmul wall-time success 4.42941e-05 s 3c940c24e7 local/qgpu3
107-
7 2026-11-26 18:10:03 bench-20261126T180958Z bench_matmul load-average success 0.35 1 3c940c24e7 local/qgpu3
108-
6 2026-11-26 18:10:03 bench-20261126T180958Z bench_matmul wall-time success 0.000446515 s 3c940c24e7 local/qgpu3
109-
5 2026-11-26 18:10:03 bench-20261126T180958Z bench_matmul load-average success 0.35 1 3c940c24e7 local/qgpu3
110-
4 2026-11-26 18:10:03 bench-20261126T180958Z bench_matmul wall-time success 1.05347e-05 s 3c940c24e7 local/qgpu3
111-
3 2026-11-26 18:09:59 bench-20261126T180958Z bench_matmul load-average success 0.29 1 3c940c24e7 local/qgpu3
112-
2 2026-11-26 18:09:59 bench-20261126T180958Z bench_matmul wall-time success 2.14621e-06 s 3c940c24e7 local/qgpu3
106+
/home/br/temp/bex/out/home/store.parquet: 16 result(s); latest 10, newest first
107+
row started run-key workload quantity status median revision project
108+
15 2026-11-30 10:09:35 bench-20261130T100917Z bench_matmul load-average success 0.7 directory- local/gonzales
109+
14 2026-11-30 10:09:35 bench-20261130T100917Z bench_matmul wall-time success [dirty-subject-tree, dirty-benchmark-tree] 9.68303e-05 s directory- local/gonzales
110+
13 2026-11-30 10:09:34 bench-20261130T100917Z bench_matmul load-average success 0.7 directory- local/gonzales
111+
12 2026-11-30 10:09:34 bench-20261130T100917Z bench_matmul wall-time success [dirty-subject-tree, dirty-benchmark-tree] 0.000140487 s directory- local/gonzales
112+
11 2026-11-30 10:09:29 bench-20261130T100917Z bench_matmul load-average success 0.68 directory- local/gonzales
113+
10 2026-11-30 10:09:29 bench-20261130T100917Z bench_matmul wall-time success [dirty-subject-tree, dirty-benchmark-tree] 1.57617e-05 s directory- local/gonzales
114+
9 2026-11-30 10:09:28 bench-20261130T100917Z bench_matmul load-average success 0.68 directory- local/gonzales
115+
8 2026-11-30 10:09:28 bench-20261130T100917Z bench_matmul wall-time success [dirty-subject-tree, dirty-benchmark-tree] 4.2506e-05 s directory- local/gonzales
116+
7 2026-11-30 10:09:23 bench-20261130T100917Z bench_matmul load-average success 0.65 directory- local/gonzales
117+
6 2026-11-30 10:09:23 bench-20261130T100917Z bench_matmul wall-time success [dirty-subject-tree, dirty-benchmark-tree] 6.44393e-06 s directory- local/gonzales
113118
```
114119

115120
The *run key* is listed in the fourth column of the output.
@@ -179,23 +184,24 @@ round 4/5 xp='torch': 8 result(s)
179184
round 4/5 xp='numpy': 8 result(s)
180185
round 5/5 xp='numpy': 8 result(s)
181186
round 5/5 xp='torch': 8 result(s)
182-
run compare-20261130T084946Z profile variants baseline 'numpy' contender 'torch' [local-only]
183-
caveats: baseline: dirty-benchmark-tree, baseline: dirty-subject-tree, contender: dirty-benchmark-tree, contender: dirty-subject-tree
187+
run-key compare-20261130T095855Z profile variants baseline 'numpy' contender 'torch' [local-only]
188+
caveats: baseline: dirty-benchmark-tree, dirty-subject-tree
189+
contender: dirty-benchmark-tree, dirty-subject-tree
184190
185-
IMPROVED (2)
186-
bench_matmul [n=50] wall-time effect -61.85% noise 1.26% rounds=5
187-
bench_matmul [n=100] wall-time effect -65.60% noise 1.51% rounds=5
191+
IMPROVED (3)
192+
bench_matmul [n=50] wall-time effect -62.84% noise 1.15% rounds=5
193+
bench_matmul [n=100] wall-time effect -62.84% noise 4.98% rounds=5
194+
bench_matmul [n=200] wall-time effect -38.61% noise 3.37% rounds=5
188195
189-
NO CHANGE DETECTED (2)
190-
bench_matmul [n=10] wall-time effect +1.48% noise 2.42% rounds=5
191-
bench_matmul [n=200] wall-time effect -23.74% noise 7.63% rounds=5
196+
NO CHANGE DETECTED (1)
197+
bench_matmul [n=10] wall-time effect -1.37% noise 4.04% rounds=5
192198
```
193199

194200
The result is one unit per size, with numpy as the *baseline* and torch as the *contender*: the effect is
195201
torch's median time relative to numpy's, so `REGRESSED` means torch took longer, and the noise is taken
196202
across the five rounds. The units are grouped by verdict.
197203

198-
On one specific laptop, the report was that `torch` is slower than `numpy` at N=10 and N=50, and is much faster at N=100.
204+
On one specific laptop, the report was that `torch` is on par with `numpy` at N=10 and is faster for larger N.
199205
In general, for our quick-and-dirty setting, `$QUICK`, results are expected to show fairly wild variations or even be borderline
200206
noise. A real comparison will need to use at least the default settings or actually larger number of rounds and values.
201207

@@ -219,45 +225,46 @@ $ bx compare --run $RUN --profile variants --vary xp --baseline "'numpy'" --tabl
219225

220226
```text
221227
bx compare --run $RUN --profile variants --vary xp --baseline "'numpy'" --tables --all
222-
run compare-20261130T084946Z profile variants baseline 'numpy' contender 'torch' [local-only]
223-
caveats: baseline: dirty-benchmark-tree, baseline: dirty-subject-tree, contender: dirty-benchmark-tree, contender: dirty-subject-tree
228+
run-key compare-20261130T095855Z profile variants baseline 'numpy' contender 'torch' [local-only]
229+
caveats: baseline: dirty-benchmark-tree, dirty-subject-tree
230+
contender: dirty-benchmark-tree, dirty-subject-tree
224231
225-
IMPROVED (2)
226-
bench_matmul [n=50] wall-time effect -61.85% noise 1.26% rounds=5
227-
bench_matmul [n=100] wall-time effect -65.60% noise 1.51% rounds=5
232+
IMPROVED (3)
233+
bench_matmul [n=50] wall-time effect -62.84% noise 1.15% rounds=5
234+
bench_matmul [n=100] wall-time effect -62.84% noise 4.98% rounds=5
235+
bench_matmul [n=200] wall-time effect -38.61% noise 3.37% rounds=5
228236
229-
NO CHANGE DETECTED (2)
230-
bench_matmul [n=10] wall-time effect +1.48% noise 2.42% rounds=5
231-
bench_matmul [n=200] wall-time effect -23.74% noise 7.63% rounds=5
237+
NO CHANGE DETECTED (1)
238+
bench_matmul [n=10] wall-time effect -1.37% noise 4.04% rounds=5
232239
233240
For local/gonzales xp='numpy' [dirty tree] (5 rounds):
234241
bench_matmul ok
235242
===== ============
236243
n
237244
----- ------------
238-
10 2.71±0.2μs
239-
50 16.7±1μs
240-
100 46.3±5μs
241-
200 148±20μs
245+
10 2.95±0.2μs
246+
50 17.1±2μs
247+
100 48.9±5μs
248+
200 157±20μs
242249
===== ============
243250
244251
For local/gonzales xp='torch' [dirty tree] (5 rounds):
245252
bench_matmul ok
246-
===== =============
247-
n
248-
----- -------------
249-
10 2.81±0.04μs
250-
50 6.45±0.07μs
251-
100 16.1±0.3μs
252-
200 100.0±30μs
253-
===== =============
253+
===== ============
254+
n
255+
----- ------------
256+
10 2.84±0.1μs
257+
50 6.53±0.2μs
258+
100 16.3±4μs
259+
200 96.0±2μs
260+
===== ============
254261
255262
| Change | Before ['numpy'] | After ['torch'] | Ratio | Noise | Verdict | Benchmark (Parameter) |
256263
|----------|--------------------|-------------------|---------|---------|--------------------|-------------------------|
257-
| | 2.71±0.2μs | 2.81±0.04μs | 1.03 | 2.42% | no change detected | bench_matmul(10) |
258-
| - | 16.7±1μs | 6.45±0.07μs | 0.39 | 1.26% | improved | bench_matmul(50) |
259-
| - | 46.3±5μs | 16.1±0.3μs | 0.35 | 1.51% | improved | bench_matmul(100) |
260-
| | 148±20μs | 100.0±30μs | 0.67 | 7.63% | no change detected | bench_matmul(200) |
264+
| | 2.95±0.2μs | 2.84±0.1μs | 0.96 | 4.04% | no change detected | bench_matmul(10) |
265+
| - | 17.1±2μs | 6.53±0.2μs | 0.38 | 1.15% | improved | bench_matmul(50) |
266+
| - | 48.9±5μs | 16.3±4μs | 0.33 | 4.98% | improved | bench_matmul(100) |
267+
| - | 157±20μs | 96.0±2μs | 0.61 | 3.37% | improved | bench_matmul(200) |
261268
```
262269

263270
which first repeats the same information it gave without `--tables`, and then emits
@@ -270,7 +277,7 @@ Above we used `bx compare` in the so-called *measure mode*, where it ran the ben
270277
manual, way is to run a loop over `bx bench` calls and then invoke `bx compare` in the *read mode*, as before.
271278

272279
For the first step, we need to handle alternating the sides manually: Each call runs one library,
273-
with `--filter`, as one side of a session; we also need to specify the same run key for all calls,
280+
with `--filter`, as one side of the session; we also need to specify the same run key for all calls,
274281
via the `--run-key` argument.
275282

276283
The previous `bx compare` call sequence used the `--rounds` argument to arrange the individual calls into

‎examples/matmul-params/bench_matmul.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Example: one benchmark function, six cases (3 sizes x 2 array libraries).
1+
"""Example: one benchmark function, eight cases (4 sizes x 2 array libraries).
22
33
bx bench bench_matmul.py # every combination
44
bx bench bench_matmul.py bench_matmul # the same, by name

0 commit comments

Comments
 (0)