Repository navigation
ggml-hrx: document what a wrong workload-parameter list actually does (silent stale grid) - #168
Conversation
… (silent stale grid) The recipe said "list the parameters that change the grid" without saying what a miss costs, and a miss is not an error: launch_fn runs once per executable cache entry, the key holds only the workload parameters, so an unlisted parameter read by the launch function freezes the first case's grid for every later case and the kernel quietly covers less than it was asked to. Written from the V4.1 indexer gate (gpu-kernels #46), where n_stream was left out: test-backend-ops -o LIGHTNING_INDEXER -b HRX0 gave 4/12 - all ns=1 cases green, all ns=4 cases wrong by one stream plane (inf mismatch: HRX0=0.943650 CPU=-inf; ERR = 2.909230024) - while the same kernel driven straight through hipModuleLaunchKernel is correct at 4 streams to 3.9e-03. That is why the standalone harness missed it and the suite did not.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
At a1f71838. One file, ggml/src/ggml-hrx/hip/README.md, +19 −1. No CI in this repo, so this is the review.
A documentation PR that earns its place: it names a trap that cost a real debugging session, and it names it where the next person writing a dispatch will be looking (both in the "how to add a kernel" list, as a cross-reference, and as its own section).
The mechanism is stated precisely enough to be actionable: launch_fn runs once per executable-cache entry, not once per dispatch, and the key is the workload-parameter list and nothing else — so a launch function that reads a parameter the list omits gets the first case's grid for every later case. No error, no log line, output silently short.
And the evidence is the part I checked, because it is checkable against the PR it cites. It reports n_stream left out of the DeepSeek-V4.1 indexer giving test-backend-ops -o LIGHTNING_INDEXER -b HRX0 → 4/12, every ns=1 case passing and every ns=4 case wrong by a whole stream plane, with inf mismatch: HRX0=0.943650 CPU=-inf where an untouched element met a -inf mask row. The kernel in question is gpu-kernels #46, and reading that PR confirms the fix is exactly this: p.emplace("n_stream", n_stream) is now in integer_parameters, with a comment at that line recalling the 1-stream grid on 4-stream cases. So the doc and the code agree, and the doc is describing an incident rather than inventing one.
The closing sentence is the most useful in the section — "a standalone harness cannot see this: only a suite that runs the op at two different grid sizes can" — because it tells you why the existing per-op test could pass while the op was wrong, and it argues for keeping the stream/batch cases in test-backend-ops rather than trimming them as redundant.
tprs-ready applied.
ggml-hrx: document what a wrong workload-parameter list actually does (silent stale grid)
Docs only, one file (
ggml/src/ggml-hrx/hip/README.md), no code change.The authoring recipe already said "The executable cache key holds only the workload parameters, so list the parameters
that change the grid there and nothing else." What it did not say is what a miss costs, and the cost is not an
error:
launch_fnruns once per executable cache entry, not once per dispatch, so a parameter the launch function readsbut the list omits freezes the first case's grid for every later case with that key. No log line, no failure — the
kernel simply covers less of the output than it was asked to.
That is not hypothetical: it is what the DeepSeek-V4.1 lightning-indexer kernel did (published as
1bit-MONSTER/gpu-kernels#46), where
n_streamsizesworkgroup_count.yand was left out of the list:Streams 1-3 were never written. The same kernel, same code object, driven directly through
hipModuleLaunchKernelat4 streams is correct to
max |diff| 3.906e-03(≈1 ulp, f32 accumulation order) — so a standalone harness structurallycannot catch this class, and only a suite that runs the op at two different grid sizes can.
test-backend-opsdoes thatfor every op with a stream/batch axis; the new paragraph says so, next to the existing "fused registrations come first"
trap, so the next author knows which test is load-bearing.
No behaviour changes: the sentence in step 2 gains a pointer, and the trap gets one paragraph with the measurement that
motivated it.