Skip to content

The guards covered the runs a human started, and not one of the checks - #118

Merged
feitreim merged 3 commits into
mainfrom
ci-modal-run-wrapper
Jul 29, 2026
Merged

feitreim merged 3 commits into
mainfrom
ci-modal-run-wrapper

Conversation

@feitreim

@feitreim feitreim commented Jul 29, 2026 •

Copy link
Copy Markdown
Owner

cuda.yml and gpu.yml called modal run directly. #99's wedge watchdog and
#115's completion sentinel therefore covered runs a human or an agent started
by hand and nothing that ran as a check — which is the wrong half. A wedged
CI container rides its timeout= on a B200 with nobody watching, and a stopped
one is whatever the client decides to return that day. Every performance number
in this repo's recent history came through green checks on the unguarded path.

Found and written down by #115, left outside its scope. This is that scope.

The change

Three steps, one command each:

- run: scripts/modal-run build          # cuda.yml
- run: scripts/modal-run regcount       # cuda.yml
- run: scripts/modal-run device_tests   # gpu.yml

It is the only command in the step, so the wrapper's exit code is the step's
and GitHub reports it verbatim. No ||, no set +e, no continue-on-error
anywhere in either file — 2, 3 and 4 are each red.

The fork skip (head.repo.full_name == github.repository) is untouched on all
three jobs, and pull_request_target is still unused.

The three failures that are not your diff

2 (spend limit), 3 (a wedge this wrapper stopped) and 4 (a run that ended
without finishing) share a property: none of them is the entry point failing,
and all of them read from the check list exactly like a broken diff. So the
wrapper now emits a ::error:: annotation for each when GITHUB_ACTIONS is
set — the diagnosis lands on the check, where the reader who never opens the
log is looking.

The spend limit is the one that has actually cost diagnosis time: it fails
every entry point at once, in seconds, and a build check red in fifteen
seconds is indistinguishable from a broken build until you read the log. Its
annotation says so in the first clause. No retry on any of them — a retry
loop on 2 spends the rest of the workspace's day discovering the same thing.

Nine lines in scripts/modal-run (annotate, three calls), gated on
GITHUB_ACTIONS so a laptop sees only the prose it already saw.

The graces stay at 300 / 1200, and the measurement says something better

MODAL_RUN_STARTUP_GRACE and MODAL_RUN_SILENCE_GRACE budget silence, not
elapsed time
— every line the client prints (Created objects, the mount
tree, the NVIDIA banner) resets the clock. A cold start costs wall time without
consuming a grace, which is why one pair of values works on a laptop and on a
runner, and why CI's colder profile is not by itself a reason to raise them.

Measured on this branch, from the runner's per-line timestamps — one warm run of
each of the three entry points CI invokes:

build regcount device_tests budget
first line the watchdog reads as alive 6.5 s 7.3 s 9.2 s —
longest silence before it 3.1 s 2.9 s 4.4 s 300 s
longest silence anywhere 58.9 s 55.7 s 35.8 s 1200 s
sentinel / total 219 / 221 s 183 / 184 s 95 / 97 s its timeout=

Two orders of magnitude on the startup budget, and the longest quiet stretch
anywhere — the sm_100a codegen, which prints nothing while it works — is a
twentieth of the silence budget.

The more useful finding is structural. SILENCE_GRACE is 1200 s and these three
entry points carry timeout= of 900, 900 and 1200 (#99), so in CI the silence
watchdog dead-heats with Modal's own clock: a run that starts and then hangs is
killed by the function timeout at the same moment or sooner. STARTUP_GRACE
does all the work here — which is the right shape, because a container that
never reaches Python is precisely the failure timeout= cannot see.

So the change these numbers support is a lower silence budget in CI, not a
higher one. Not done here: one warm sample per entry point is not enough to
tighten a guard on, the cold case is unmeasured, and bench — the quiet 16384³
sweep #99 sized 1200 against — is run by no workflow, so moving the shared
default would trade a CI saving for a laptop false positive. It is written into
CI.md as the next thing rather than guessed at here.

Evidence

All four exit paths, watched. Against a stub modal on PATH, with
GITHUB_ACTIONS=true:

stub behaviour exit annotation
prints the sentinel 0 none
finishes, no sentinel 4 The run did not complete -- this is not a pass
exceeded its spend limit 2 Modal spend limit -- this is not your diff
silent before Python (STARTUP_GRACE=3) 3 Container wedged -- stopped rather than billed out, and it modal app stopped the id it had scraped
silent after $ (SILENCE_GRACE=3) 3 same, worded said nothing for 3s

With GITHUB_ACTIONS unset, the annotation count is 0 and the prose is
unchanged.

Real CI on this branch — all three jobs, for real (detail in the two
comments below):

job run result through
build 30446128587, 30446560958 ✓ 3m53s, ✓ 2m59s scripts/modal-run build
regcount same two runs ✓ 3m25s, ✓ 3m23s scripts/modal-run regcount
device-tests 30446600218, dispatched on this branch ✓ 1m54s on a B200 scripts/modal-run device_tests

Every one of them shows the wrapper's own $ modal run modal_app.py::… echo as
the first line of the step and == modal_app: entry point completed == as the
last — so the runner invokes scripts/modal-run directly (100755 in the index
survives checkout: no python3, no chmod step), the app id is scraped from
line one and would be there for a modal app stop, and 0 was returned on
positive evidence rather than on the client's opinion.

The tier 3 run was dispatched with --ref ci-modal-run-wrapper rather than
-f ref=…, deliberately: workflow_dispatch takes the workflow definition
from the ref it is dispatched on, so -f ref=refs/pull/118/merge would have run
main's gpu.yml — the unguarded one — against this tree and proved nothing
about this diff.

And the label gate is intact: the same push that triggered the second cuda run
also fired gpu on synchronize, which skipped with no B200 allocated.

What is not observed: a real 2, 3 or 4 in CI. Those are stub-verified locally
(table above) and their code path from there is one sys.exit. The graces are
env-overridable precisely so a future reader can make the watchdog fire in a
workflow on purpose.

Also

CI.md: the wrapper is no longer a subsection of "running tier 3 by hand" —
it is how every Modal invocation in the repo happens, so it is its own section,
and tiers 2 and 3 each say the guard covers them. The paragraph #115 left
saying CI bypasses both guards is replaced by one saying what CI does with the
exit codes and annotations.

Not touched: modal_app.py, any Rust, examples/. README.md:18 still
says modal run modal_app.py::regcount in prose and modal_app.py's docstring
lists a dozen modal run lines; both are outside this PR's files and neither
is a guard, but they now describe the second-best way to run this repo.

feitreim added 2 commits July 29, 2026 07:03
`cuda.yml` and `gpu.yml` called `modal run` directly, so #99's wedge watchdog
and #115's completion sentinel protected only runs a human started by hand.
Every performance number in this repo's recent history came through green
checks on the unguarded path.

The three jobs now call `scripts/modal-run` as the only command in their step,
so its exit code is the step's: 2 (spend limit), 3 (a wedge it stopped) and 4
(a run that ended without finishing) are each red, and nothing remaps them.

The wrapper also annotates those three when GITHUB_ACTIONS is set. They share a
property that makes them worth naming on the check rather than burying in a
log: none of them is the entry point failing, and all of them read from the
check list like a broken diff. The spend limit most of all -- it fails every
entry point at once, in seconds. No retry.

The graces keep their defaults. They budget *silence*, not elapsed time --
every client line resets the clock -- so a cold start costs wall time without
consuming one. `build` is 155-221 s warm and ~7.5 min cold (#99), and all of
that cold build is after Python is alive, printing `Compiling`, under the
1200 s silence budget; 300 s of startup silence is sized against the failure
itself, a container that said nothing for twenty-six minutes.

CI.md moves the wrapper out from under "running it by hand" -- it is now how
every Modal invocation here happens -- and tiers 2 and 3 say the guard covers
them.
The first run of this branch: build reaches its first `$ ` line 6.5 s in
having never been silent for more than 3.1 s, against a 300 s startup budget;
the longest quiet stretch anywhere in either job is 58.9 s of sm_100a codegen
against 1200 s. And in tier 2 the silence budget cannot bind at all -- the
entry point's own timeout=900 is shorter. Tier 3 is where a tighter value would
buy something and is the tier with no measurement here, so it keeps #99's.

Also: CI installs modal unpinned and drew 1.5.3, where #103's three exit-code
behaviours were measured on 1.5.1. That is the argument for the sentinel in one
line.
@feitreim

Copy link
Copy Markdown
Owner Author

Tier 2 ran on this branch, through the wrapper

Run 30446128587 — build ✓ 3m53s, regcount ✓ 3m25s. Both steps were
scripts/modal-run … and both exited 0, which by construction means the
container printed the sentinel. First line of each step:

$ modal run modal_app.py::build
✓ Initialized. View run at https://modal.com/apps/feitreim/main/ap-2tjmKnYkcKFlIoiPs1GmIz

and the last three:

+218.8s  == modal_app: entry point completed ==
+220.7s  ✓ App completed. View run at https://modal.com/apps/feitreim/main/ap-2tjmKnYkcKFlIoiPs1GmIz

So: the runner invokes scripts/modal-run directly (no python3, no chmod —
100755 in the index survives checkout), the wrapper's own $ echo appears,
the app id is scraped from line one and would be there for a modal app stop,
and the sentinel is seen. That is every mechanical assumption in the change,
observed rather than argued.

The grace values, measured rather than chosen

From the per-line timestamps in the GitHub log:

build regcount budget
first line the watchdog counts as alive 6.5 s ($ cargo clippy …) 7.3 s ($ env … cargo oxide build …) —
longest silence before it 3.1 s 2.9 s 300 s
longest silence anywhere 58.9 s 55.7 s 1200 s
sentinel / total 219 / 221 s 183 / 184 s timeout=900

Two orders of magnitude of headroom on startup, and the longest quiet stretch
in either job — the sm_100a codegen, which prints nothing while it works — is
a twentieth of the silence budget. 221 s also lands exactly at the top of #99's
155–221 s warm band, so this was a warm-image run and the cold case is the one
still argued rather than measured: it is chattier, not quieter, since a cold
image build streams its own progress and every line resets the clock.

Worth noting what the silence budget can even do in tier 2: nothing. The entry
point's own timeout=900 is shorter than 1200 s, so a run that starts and then
hangs dies on Modal's clock first. Tightening 1200 would only change tier 3 —
the tier with no measurement here — so it keeps #99's value.

One more argument for the sentinel, from the log

pip install modal is unpinned and the runner drew 1.5.3. #103's three
exit-code behaviours were measured on 1.5.1. A gate built on the client's
exit code is a gate that can change between two pushes without either of them
touching this repo; a line the container prints cannot.

Tier 3

Dispatching gpu.yml against this branch — comment to follow with what it did.

A dispatched gpu.yml run on this branch: first alive line at +9.2 s after 4.4 s
of silence, sentinel at +95 s, 97 s in the step. With that, all three entry
points CI invokes are measured, and the shape is clear -- SILENCE_GRACE (1200)
is at or above each one's own timeout= (900/900/1200), so it dead-heats with
Modal's clock and STARTUP_GRACE is what covers the failure timeout= cannot see.
A lower silence budget is what these numbers argue for; not on one warm sample
each.
@feitreim

Copy link
Copy Markdown
Owner Author

Tier 3 ran too, on a real B200

Dispatched against this branch — gh workflow run gpu.yml --ref ci-modal-run-wrapper, so the definition under test is this PR's and not
main's. Run 30446600218: device-tests ✓ 1m54s.

+  0.0s  $ modal run modal_app.py::device_tests
+  0.9s  ✓ Initialized. View run at https://modal.com/apps/feitreim/main/ap-GMdrf132ssjfIBTmHkl5Cl
+  9.2s     Compiling proc-macro2 v1.0.107        <- first line the watchdog reads as alive
+ 95.2s  == modal_app: entry point completed ==
+ 97.2s  ✓ App completed.

So all three jobs are observed, not argued. Updated table, all warm runs:

build regcount device_tests budget
first "alive" line 6.5 s 7.3 s 9.2 s —
longest silence before it 3.1 s 2.9 s 4.4 s 300 s
longest silence anywhere 58.9 s 55.7 s 35.8 s 1200 s
sentinel / total 219 / 221 s 183 / 184 s 95 / 97 s its timeout=

What the measurement changed my mind about

Not the values — the reason for them. SILENCE_GRACE is 1200 s and these
three entry points carry timeout= of 900, 900 and 1200 (#99). The silence
watchdog therefore dead-heats with Modal's own clock in every CI job: a run that
starts and then hangs is killed by the function timeout at the same moment or
sooner. In CI it is STARTUP_GRACE that does all the work, which is the right
shape, because a container that never reaches Python is exactly the failure
timeout= cannot see — and 300 s against a worst observed 4.4 s covers it with
two orders of magnitude to spare.

Which means the change these numbers would actually support is a lower silence
budget, not a higher one: 1200 → something that stops a post-start hang at a
fraction of the timeout instead of tying with it, worth GPU-minutes on tier 3.
Not done here. One warm sample per entry point is not enough to tighten a
guard on, the cold case is unmeasured, and bench — the quiet 16384³ sweep #99
sized 1200 against — is not run by any workflow, so tightening the shared
default would trade a real CI saving for a laptop false-positive. Written into
CI.md as the next thing rather than guessed at here.

Two other things the run confirmed

gpu.yml's label gate still holds: the push that triggered this branch's second
cuda run also fired gpu on synchronize, and it skipped — 30446560988,
device-tests skipped, no B200 allocated. The gpu-ci + same-repo condition is
untouched and still the only automatic route to a GPU.

And tier 2 is now green twice on this branch (30446128587, 30446560958), so the
wrapper path is not a one-run fluke.

@feitreim
feitreim merged commit c465370 into main Jul 29, 2026
4 checks passed
feitreim added a commit that referenced this pull request Jul 29, 2026
…and the epilogue was never gemm_ws's problem (#118) (#119)

`.x8` LDTM and `stmatrix.x4` on `gemm_ws`, plus the two `no drain` controls the
ladder is subtracted from, and the result is a lever that pays and a hypothesis
that dies.

The levers. Against #116's `staged`, `.x8` is +15.7% / +6.2% / +3.0% at
4096/8192/16384 cubed and `.x4` is +1.2% / +0.0% / +0.1% — the same clean null
it was on `gemm_cg2`. They do not compose here: `staged8` and `staged84` are
within 1.1% and trade places between sessions, and the register column said so
in advance, `.x4` recovering 2 registers (94 -> 92) where on `gemm_cg2` it
recovered 14 (94 -> 80) and that recovery *was* the composition gain. Best rung
is +19.4% / +9.5% / +5.2% over the shipped register epilogue, 0.615 -> 0.726,
0.782 -> 0.856, 0.810 -> 0.852 of cuBLASLt. Zero spill in every rung; 94 is the
largest count in the file against a reachable 255.

#117's mechanism predicted the shortfall and got it. `.x8` removes a latency
the drain never overlaps; this kernel already overlaps it, so `.x8` is worth
67%, 72% and 83% of what it was worth on `gemm_cg2`. By `whole - no drain` the
same epilogue is exposed at 8.62 us a tile here against #114's 20.43, and its
LDTM half at 3.20 against #117's 8.07 — 40-47%, which is what warp
specialization and the accumulator ping-pong buy, stated as a number for the
first time.

"Twice the LDTM (16 against 8)" is true of the PTX and false of the work. Every
census column doubles, not just LDTM, because `gemm_ws` emits its epilogue at
two call sites (`Ws::work` and `Ws::finish`) where the fused job has one. The
bands are `RegTile<32, 64>` in both files.

The floor is the finding. `gemm_ws_no_drain` — the shipped kernel with the
epilogue deleted, the probe that put `gemm_cg2` at 1850 TF/s against the
library's 1808 — reaches 0.829 / 0.923 / 0.888 of cuBLASLt, and at 8192 and
16384 cubed it is *slower than `gemm`'s complete `staged84` launch*. Best
against best is -9.7% / -9.4% / -6.9%; deleting the epilogue outright recovers
12.7 / 7.2 / 3.9 of those points. So no, `gemm_ws` does not beat `gemm`, and it
could not have: #112's 7.3% closes to 6.9% after both kernels spent everything
#116 and #117 found. The deficit is the multiply and the operand stream at one
CTA an SM. #112 blamed the peer CTA and #114 refuted it; `gemm_ws.rs` blamed the
missing peer CTA and this refutes that, by deleting the epilogue and losing
anyway. The stale paragraph is corrected in place rather than removed.

Residency counted, not queried (#77): two new census rungs at this kernel's own
131 176 B and 147 584 B read 1 resident, 1 holding at both, closing the gap the
`cg2 512` rung left at a 32 B plan (1 holding, 2 resident, 100.9 us parked in a
blocking alloc; 0.9 us here).

No default moved. `staged8` is the rung to ship on `gemm_ws` — `.x4` is a null
here alone and in composition — and that is a change worth making on its own.
feitreim added a commit that referenced this pull request Jul 29, 2026
…ce (#119) (#120)

`gemm`'s default epilogue becomes `staged84` and `gemm_ws`'s becomes `staged8`.
#116, #117 and #118 each ended by saying the rung was worth shipping and that
shipping it belonged in its own change; this is that change and it is the whole
of it. No rung added, none deleted, nothing retuned — every entry point still
launches and is still on the correctness gate.

The two differ on purpose. `.x8` costs +52 and +50 registers identically; what
differs is what `.x4` hands back — 14 on `gemm_cg2` (94 -> 80) and 2 on
`gemm_ws` (94 -> 92) — and that recovery IS the composition gain. There the
pair is +5.1% at 16384^3 against `.x8` alone's +3.6%; here `staged8` and
`staged84` land inside 1.1% and trade places between sessions, so the tie goes
to the rung with less surface.

Confirmed in one container with cuBLASLt re-measured in it (#109's lesson):
`gemm` 0.1432 -> 0.1044, 0.7584 -> 0.6684 and 5.5157 -> 5.0132 ms, which is
+37.2% / +13.5% / +10.0% and 0.583 -> 0.801, 0.827 -> 0.939 and 0.871 -> 0.958
of the library. `gemm_ws` +19.6% / +8.7% / +6.3% and 0.599 -> 0.717,
0.790 -> 0.858, 0.812 -> 0.863. Both reproduce their published ratios; the
16384^3 rows moved because the denominator did.

The constants that describe the shipped launch moved with it: `main.rs` reports
114 816 B and 147 584 B, and `CTAS_PER_SM` does not move on either kernel
because the tensor-memory term of `min(512 / columns, shared per SM / plan)`
binds at both envelopes. `regcount`'s occupancy gate gained
`gemm_cg2_staged_x8x4` and reads 166 / 42 / 80 against a ceiling of 255.

Deliberately unmoved: the ablation cube, `bench --case epilogue` and
`bench --case staged` stay built at `lcf`, and `ws_bench` table 1 now NAMES
`lcf` on both sides rather than taking `gemm`'s default, so its one variable is
still where the overlap comes from.
feitreim added a commit that referenced this pull request Jul 29, 2026
#121)

* The 1.02 ceiling is an 8192-cubed fact, and the residual is stmatrix's

Nothing measured. Everything re-measured. `bench residual` re-runs #114's ceiling,
the shipped rung and cuBLASLt beside each other in one container, twice, and then
opens the residual epilogue with a doubling ladder that deletes nothing.

**The framing survives at 8192^3 and only there.** `no drain / cuBLASLt` is
1.024 and 1.018 in two fresh containers, so #114's 1.02 reproduces after both of
the changes that could have invalidated it, and the epilogue is 127-136% of the
6.5% gap. At 16384^3 the same ratio is 0.993 and 0.984 -- the epilogue-free
kernel LOSES -- so 10-23% of that gap is not epilogue. At 4096^3 it is
0.955/0.988 and the rest is the wave, which is a different mechanism and is
reported as one. Below 2048^3 cuBLASLt's own MINIMUM moves 23-26% between two
calls in one session, so no ratio there is a measurement.

**What is inside the ~7.3 us/tile, at 8192^3, both sessions:**

| | us/tile | share | lever |
| --- | ---: | ---: | --- |
| `cvt` + `stmatrix` | 3.8-4.1 | 55-64% | **none identified** |
| `ld.shared` + `st.global` | 2.0-2.3 | 31-36% | a TMA store, ~+2.7% |
| LDTM after `.x8` | 0.09 / -0.04 | 0% | spent by #117 |
| unattributed | 0.8-1.5 | 9-20% | -- |

The instrument is `Tile::drain_staged_twice`, which ADDS one link of the chain
per rung rather than removing one, because an epilogue nobody observes is one
the compiler may delete. The census says every rung stepped by exactly one pass
and that the second `.x8` LDTM survived CSE despite being spelled `_pure`.

**Two negative results, each retiring a lever.** `s84 hot` deletes the
epilogue's entire HBM traffic and is worth -2.3% to +1.8%: the stores are not
bandwidth-bound, so #15's "hand the write to a TMA engine so it stops pressing
on memory" has no pressure to relieve -- what is left to buy is the issue, and
that is a smaller and different claim. And `.x8` on the REGISTER drain
(`gemm_cg2_lcf8`, new, on the correctness gate, 166 registers byte-identical to
`gemm_cg2`) is a clean null at -1.1% to +5.8%, against +23.6/+8.6/+3.6% on the
staged path -- the scattered stores were already covering the LDTM latency.

**One positive one.** That null is the arm #116's A/B never had, and it re-prices
the shared round trip at #117's LDTM width: `staged8` beats `lcf8` by
**+12.6%/+12.8%** at 8192^3 where #116 measured +4.2% at `.x1`. The hop is worth
three times what it was measured at, because recoalescing only gets paid once
the drain has stopped waiting sixteen times a band.

**And a control this file has never taken.** Table 6 takes the same
`whole - no drain` subtraction twice in one container: it reproduces to 1-5% at
8192^3, 0.4-7% at 4096^3, and **39-46% at 16384^3**. Every 16384^3 epilogue
figure above it -- #116's 16.34, #117's 5.81, #118's 2.91 -- is inside that band
and none of them carries it. It is also why `staged8` and `staged84` trading
places here does not contradict #117 so much as locate it: that +1.5-point
composition gain was a 16384^3 row.

New: `Tile::drain_staged_twice`, `Tile::drain::<WIDE>`, five entry points
(`lcf8`, `s84 hot`, `s84 2g/2m/2x`), `bench --case residual`, six tables. No
default, constant or shipped kernel moved; `lcf8` is on the correctness gate and
the four probes say UNCHECKED in their own labels. `build`, `regcount`
(occupancy gate green, 80/87/125/102 and 166) and `examples` all pass.

* and the cvt travels with the stmatrix, so the column says so
feitreim added a commit that referenced this pull request Jul 29, 2026
#122) (#122)

#121 took the first reproducibility control on `whole - no drain` and it came back
39-46% at 16384^3 against 1-5% at 8192^3, with #116's 16.34 us/tile, #117's 5.81
and #118's 2.91 all inside the band. This is what the band is.

**It is error propagation, and the arithmetic reaches backwards with nothing
measured.** A difference carries its arms' error divided by its own share of them.
Reconstructed from #121's own printed table 6: share 17.9% / 7.8% / 5.3% at
4096/8192/16384^3, so 1/s of 5.6 / 12.9 / 19.0, and against arms that repeat to
0.86+0.58% / 0.15+0.10% / 0.45+2.11% that predicts 8.1% / 3.2% / **49%** against
#121's observed 7% / 1% / **46%**. The launches were never the problem -- they
repeat to 0.1-2.1% everywhere. The epilogue is per output tile and the launch is
per tile times K, so the share falls as 1/K by construction. **The instrument did
not degrade at 16384^3; it never worked there.**

Three things it is not, each checked: sampling (`min` of 30 is the same estimator
at every size and the arms repeat to 0.10% at 8192^3), the wave (8192^2 and
16384^2 are both 98.8% full and every comparison holds the grid fixed between its
arms), and -- against the hypothesis -- **adding rather than deleting**.
`drain_staged_twice` retires the dead-code hazard, which is real and different,
but one added link is a *smaller* share than the whole epilogue, so the ladder is
more amplified. #121's own 16384^3 ladder row is +4.01 and -2.69 for one quantity.

**And a second term nobody could see, because `bench` sorted the order away.**
`Timings` now keeps launch order; `drift` is the second fifteen launches over the
first. At 16384^3 and nowhere in the sweep, all six arms over two containers, the
device is **+6.85 to +11.33% slower by the end of a call** -- essentially the whole
of its 18-23% in-call spread -- where every other size drifts *negative*. Not the
problem size: `16384^2 x k1024` has the same tiles, items, C and wave and drifts
-1.0 to +0.6%. It is the duration, 154 ms of continuous 1.1 PFLOP/s against 16.
A 16384^3 `min` is a boost-clock reading from a call whose last launches run 10%
slower, which is also the mechanism under cuBLASLt's 1.15-1.19 max/min there.

**The fix is `bench repro`: same output geometry, shorter reduction.** K is the one
axis the epilogue's cost does not sit on, so shortening it holds the tiles, the
waves, the items, the C traffic and the epilogue total and moves only the launch
it is a fraction of. Four whole measurements per arm, round-robin so every pair is
adjacent in time, and the spread the amplification *predicts* printed beside the
one it got. One `ld.shared` + `st.global.v4` pass, two containers:

| shape | us/tile | s | observed | predicted | session to session |
| --- | ---: | ---: | ---: | ---: | ---: |
| 8192^2 x k1024 | **2.34 / 2.34** | 10.8% | 17 / 17% | 16 / 18% | **0.0%** |
| 8192^3 | 2.07 / 2.29 | 2.2% | 33 / 18% | 41 / 30% | 10.6% |
| 16384^2 x k1024 | **2.11 / 2.12** | 10.8% | 5 / 8% | 12 / 13% | **0.5%** |
| 16384^3 | 3.01 / 3.82 | 1.6% | **167 / 111%** | 235 / 177% | **26.9%** |

`predicted` tracks `observed` across a twentyfold range and bounds it above in
nine rows of ten. The 16384^2 number nobody could measure is **2.11 us/tile**,
reproduced to 0.5%; #121's ladder put it at 0.45 and 4.22. The us/tile is flat in
K (2.34/2.42/2.07 and 2.34/2.61/2.29 over an eightfold range), which is what makes
the substitution legal and is the design's own check.

**`staged8` and `staged84` are not tied, and the sign is the geometry's.** At
8192^2 `staged8` leads by 1.4-2.4% in four cells, no range reaching 1.000; at
16384^2 `staged84` leads by 0.4-1.0%, same sign both containers. The full-depth
rows do not merely fail to order them -- 16384^3 centres on `staged8` ahead by
1.4-2.3 us/tile where the shortened row says `staged84` ahead by 0.07-0.20, and
both its ranges straddle. **So #120's default is right for a reason its own row
could not carry**, and #121's advice to break the tie at 8192^3 would have broken
it the other way. Not a request to move the default.

New: `Timings::spread` / `Timings::drift` and the launch order behind them, `bench
repro`, rule 5 in the module docs, a section in README §7. Nothing measured is
inherited; no default, constant or kernel moved; `gemm.rs` untouched. `build` green
twice, `bench --case repro` run in two containers at 96 s of GPU each.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant