Skip to content

ggml-hrx: document what a wrong workload-parameter list actually does (silent stale grid) - #168

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
1bit/hrx-workload-params-docs
Nov 1, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
1bit/hrx-workload-params-docs

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

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_fn runs once per executable cache entry, not once per dispatch, so a parameter the launch function reads
but 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_stream sizes workgroup_count.y and was left out of the list:

test-backend-ops -o LIGHTNING_INDEXER -b HRX0     (fork 4a58da9b0, gfx1151, no-SVM env trio from #715)
  ns=1 cases: all pass
  ns=4 cases: inf mismatch: HRX0=0.943650 CPU=-inf   /   ERR = 2.909230024 > 0.000001000
  4/12 tests passed

Streams 1-3 were never written. The same kernel, same code object, driven directly through hipModuleLaunchKernel at
4 streams is correct to max |diff| 3.906e-03 (≈1 ulp, f32 accumulation order) — so a standalone harness structurally
cannot catch this class, and only a suite that runs the op at two different grid sizes can. test-backend-ops does that
for 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.

… (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 bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@bong-water-water-bong bong-water-water-bong added the tprs-ready TPRS: review verdict READY posted by the standing reviewer; merge gate satisfied label Nov 1, 2026
@bong-water-water-bong
bong-water-water-bong merged commit 3721f9e into 1bit/hrx-vulkan-patched Nov 1, 2026
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/hrx-workload-params-docs branch November 12, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tprs-ready TPRS: review verdict READY posted by the standing reviewer; merge gate satisfied

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant