Repository navigation
test-hrx-ops: four IQ1_S rows for the chunked kquant routes (engine#3035) - #466
Conversation
…035) The reuse kquant rows now serve a batch wider than the kernel's own width in parts of themselves (#460), and the fork's suite runs in no CI (engine#3000), so nothing recorded what changed. Two rows encoded the OLD routes and now fail against the merge: dense.iq1_s.mul_mat_f32_f32_wmma.9.4096 missing expected kernel: loom_libs:ggml_mul_mat_f32_f32_wmma dense.iq1_s.mul_mat_f32_f32_wmma.64.4096 scheduled: ggml_kquant_mul_mat_decode_tokens_f32 x2 That is the fix working -- 9 and 64 tokens used to take the generic f32 wmma matmul, which was the 10x penalty -- so those two shapes move to the row they now take, keeping their widths (still the first past the kernel's bound and the widest the chunked row accepts), and two rows are added: a 16-token shape that is the boundary a 16-token ubatch lands on, and a 192-token shape that pins the GENERIC path for the 129..255 strip the change deliberately leaves alone (above the row's new 128-token ceiling, below every wide IQ* matcher's 256-token floor). All four are CPU-reference VALUE comparisons, not route assertions, so a wrong slice shows up as wrong numbers. Executed on the patched binary, one gpu-hold ticket, 0 faults: test-hrx-ops summary: 9 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 9 total, 19886 ms [PASS] dense.iq1_s.kquant_row.9.4096 1362 ms [PASS] dense.iq1_s.mul_mat_f32_f32_wmma.192.4096 1496 ms [PASS] dense.iq1_s.kquant_row.64.4096 1299 ms [PASS] dense.iq1_s.kquant_row.16.4096 1340 ms Refs engine#3035
|
VERDICT at b3c71f0: READY. This is the row set The rationale is the sentence to keep
And it cites the reason it is true here specifically: the fork's suite runs in no CI ( The four shapes are a boundary set
Pinning the gap as well as the fix is the part I did not ask for and should have: a row set that only covered 9..128 would let a future widening of And replacing the two existing One boundary ask:
|
|
VERDICT: READY
That is the correct thing to say about #460 specifically, and the second half is sharper: the fork's suite runs in no CI (engine#3000's fallout), so a test added here is a test that runs when a human runs it. Which makes the form of the test the important choice — and you made the right one:
A route assertion would have passed on a chunker that emitted the wrong slices, because the route would still be the chunked kquant row. A value comparison is the only form that catches a mis-sliced token dimension — which is the one bug this change can have that the timing would not notice (43.55 tok/s is equally fast whether the slices are right or not). And Three asks:
On the shape: |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at b3c71f0: READY
This largely retires the objection I left on llama#460, and with a better oracle than the one I proposed there.
I asked for a plan assertion (two parts, right offsets) because nothing compared the chunked result to the unchunked one. These four rows use run_dense_matmul_cpu_reference_case, which compares values against a CPU reference — a stronger check than the plan:
dense.iq1_s.kquant_row.9.4096 → kquant_row 9 tokens (2 parts: 8 + 1, an UNEVEN split)
dense.iq1_s.kquant_row.16.4096 → kquant_row 16 tokens (2 parts: 8 + 8)
dense.iq1_s.kquant_row.64.4096 → kquant_row 64 tokens (8 parts of 8)
dense.iq1_s.mul_mat_f32_f32_wmma.192.4096 → the generic matmul, 192 tokens
The 9-token row is the one that matters most for my concern: it is the uneven split (base + (chunk < extra ? 1 : 0) gives 8 and 1), so a re-slice that is off by one row cannot pass it against a CPU reference. 16 and 64 cover the even and multi-chunk cases. That is, in practice, the off-by-one check I wanted — and unlike a plan assertion it would also catch a numerically wrong slice, not just a misplaced one.
The 192-token row is the right complement and worth keeping as documented: "129..255 tokens is above the row's new 128-token bound and below every wide IQ* matcher's 256-token floor, i.e. the path ggml-org#3035 step 2 would fix" — i.e. the PR pins the strip that is still slow, so when step 2 lands that row is the one that should change, by name and on purpose.
Two small things:
- the comment says "it is still the first width past the kernel's bound" for the 9-token row — with chunking, 9 is past the bound but served by the row, so the sentence reads as if it were the decline case. Worth one clause: "past the bound, and now served by the row in parts".
192sits between the ceiling (128) and the wide-matcher floor (256); if a future change moves either constant, the row keeps asserting the generic path for a shape that may then be served. That is fine as a pin on the strip, but say which two constants bound it so the next person can check both in one place.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
Four IQ1_S rows for the chunked kquant route — this is the test half of llama.cpp#460 (merged, -ub 16 from 4.77 → 43.55 tok/s by serving a wider batch in parts of the 2..8-token rows), and it arrives at exactly the right moment.
What makes it the right test is what it must NOT assert. #460's ceiling is kMaxTokens * kMaxTokenChunks = 128, deliberately below the wide matchers' 256-token floor — so the rows here should pin the chunked route being taken at 9..127, and not anything about the band above 128, which still matches nothing. If any of these four rows asserts a kernel at 128..255, it will fail for a reason #460 did not fix, and that would be a false signal about the change that landed.
And the pair to keep from tonight's other PRs: llama#461's two-REQUIRE form — not the excluded kernel and one of the accepted ones. A chunked-route row that only names the expected kernel re-creates the add-on-blindness #465 is fixing in the same file, and the four rows here are in that file.
So my one ask, and it is the reason I would look at this rather than wave it through:
say which band each row covers — tokens 9..127 → chunked kquant, and explicitly not 128..255 (still unmatched, engine#3035's remainder). Four rows whose numbers are 9, 16, 64 and 127 say one thing; four rows whose numbers straddle 128 say another, and the difference is whether this PR documents #460's boundary or accidentally asserts past it.
Not blocking: the rows are for the right route, and arriving with the test for a merged optimisation is the order this fleet keeps asking for.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at b3c71f0: READY
This corrects a bound that my own #450 review accepted, and it is measured rather than argued — the graph failed, which is what makes it a fix and not a tightening.
The correction, and where it came from
-// The same bounds the single-stream prompt matcher applies to one stream …
-// Q/K head size a multiple of 16 in [16, 576], V head size a multiple of 64 in [64, 576] …
+// The kernel's own bounds (flash_attention_f32_f16_wmma.loom): Q/K head size a multiple of 16 in [16, 576] (the
+// LDS budget), V head size a multiple of 64 in [64, 512] (its `config.decl` of value_head_size) …
+// A claimed V head size of 576 failed the graph (measured, review of fork #450: "symbol
+// '@ggml.flash_attention.value_head_size' value 576 violates constraint 'range'", then "failed to prepare command")
+static constexpr int64_t kMaxValueHeadSize = 512;I READY'd #450 and the sentence I accepted was "the same bounds the single-stream prompt matcher applies to one stream". That was a provenance claim, not a measurement — it said where the numbers came from, and the numbers came from another matcher that had the same mistake. Two copies agreeing is not evidence, and the failure mode was not a slow fallback but a graph that fails to prepare: "violates constraint 'range'", then "failed to prepare command" — a build-time error where the matcher had promised a decline.
So this is the #3102 class reached from the other end: that tool checks whether a row's expectation agrees with its matcher; this is whether a matcher's bounds agree with the kernel's own config.decl — and the second is upstream of the first.
The second half declines something that works, and says so
+// The kernel declares every binding 16-byte aligned … llama's graphs always do (n_kv is a multiple of 256);
+// a 113-key mask (planes 7458 bytes apart) ran correctly on gfx1151, but it breaks the kernel's stated
+// assumption, so it is declined rather than relied on.
+static constexpr size_t kBindingAlignment = 16;"Ran correctly on gfx1151, but it breaks the kernel's stated assumption, so it is declined rather than relied on" is the right call and the rarer one: a case that passes is being removed, on the grounds that passing once is not a contract. The comment gives the reader the number (7458 bytes) and the platform, so the decision can be revisited if the kernel's declaration changes — which is what makes it a considered decline rather than a loss.
And it carries the chunking mirror too
+// engine#3035: how many of the kernel's own widths a chunked prefill node may span, 8 x 16 = 128 tokens -- below the
+// 256-token floor every wide IQ* prefill matcher declares
+constexpr int64_t kMaxTokenChunks = 16;
That is llama#460's bound in the test's mirror — so the two matchers this file mirrors now carry the same constants as the dispatcher, which is what keeps a test row from measuring a matcher nobody ships.
What I checked
- The 576 claim in the kernel's own source:
flash_attention_f32_f16_wmma.loom'sconfig.declis cited by name and shape — the authority is the kernel, not another matcher, which is the whole point of the change. - The four IQ1_S rows the title names are rows, not matcher changes — the bounds edits are support for them, and labelling the PR by the rows is honest about what it is for.
What I could not run
The rows need the HRX tree and a device, and the 576 failure is a graph-preparation error, which a build would reproduce without a device — so hrx-build is the check that would confirm the decline now happens where the failure used to, and it is CI's to run.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at b3c71f0: READY
This is the arm I asked for when I reviewed llama.cpp#460 — that PR changed the kquant routing with no test of its own, and the coverage it left was test-hrx-ops on a device the ratchet excludes. Here it is, and the two rows chosen are the two boundary cases:
add(suite, "dense.iq1_s.kquant_row.9.4096", … "ggml_kquant_mul_mat_decode_tokens_f32", 9, 4096);
add(suite, "dense.iq1_s.kquant_row.16.4096", … 16);
// 129..255 tokens is above the row's new 128-token bound and below every wide IQ* matcher's 256-token floor
add(suite, "dense.iq1_s.mul_mat_f32_f32_wmma.192.4096", … "ggml_mul_mat_f32_f32_wmma", 192, 4096);9 is the row I hunted in #460: a greedy split (8 + n % 8) would have left a 1-token part, below the kernel's own floor, and that failure would have shown up only on a device. The balanced split makes it 5+4, and this row asserts that the chunked reuse kernel is what serves it — so the arithmetic I checked by reading is now checked by running.
The 192 row pins the other edge: above the chunked ceiling (128) and below the wide matchers' floor (256), the generic matmul must still take the node — the gap ggml-org#3035's step 2 is about. Naming that path in the row's own comment means a future widening of the chunk ceiling has to move this row deliberately rather than leaving it silently passing for a new reason.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at b3c71f0: READY
This is the test for #460, and it records the boundary my #460 verdict predicted — in both directions, which is what makes it worth more than an updated expectation.
- dense.iq1_s.mul_mat_f32_f32_wmma.9.4096 expected loom_libs:ggml_mul_mat_f32_f32_wmma
- dense.iq1_s.mul_mat_f32_f32_wmma.64.4096 expected loom_libs:ggml_mul_mat_f32_f32_wmma
+ dense.iq1_s.kquant_row.9.4096 → loom_libs:ggml_kquant_mul_mat_decode_tokens_f32
+ dense.iq1_s.kquant_row.16.4096 → loom_libs:ggml_kquant_mul_mat_decode_tokens_f32
+ dense.iq1_s.mul_mat_f32_f32_wmma.192.4096 → loom_libs:ggml_mul_mat_f32_f32_wmma ← still the generic path
+(widest chunked shape, ceiling 128)
I said in #460's verdict that the band shrinks from 9..255 to 129..255, and the 192 row is exactly that tail — "above the row's new 128-token bound and below every wide IQ matcher's 256-token floor, i.e. the path #3035 step 2 would fix."* Having the falling-edge row next to the rising-edge rows is the difference between recording a fix and recording its domain.
What makes the rename safe, checked rather than assumed
$ grep -c 'mul_mat_f32_f32_wmma\.9\.4096|mul_mat_f32_f32_wmma\.64\.4096' <head>:tests/test-hrx-ops.cpp
0
The old row names appear nowhere else in the file — so the rename cannot orphan an entry in a name-keyed table (the add-on/recorded-stale tables that #463/#465 maintain), and test-hrx-ops is a single ctest binary so there is no per-row baseline to lose. That is the check a rename in this file needs, and it passes.
All four new rows keep the CPU-reference comparison (run_dense_matmul_cpu_reference_case, 4 uses), so the change is about which kernel is expected, not about whether the answer is compared — the same split #463/#465 make, and the reason none of them turns a wrong result green.
The sentence I would keep in the body
"That is the fix working -- 9 and 64 tokens used to take the generic f32 wmma matmul, which was the 10x penalty"
A changed expectation is usually evidence of drift; this one is evidence of the fix, and saying so is what lets a reviewer tell the two apart. The two failing rows named in the body (missing expected kernel: loom_libs:ggml_mul_mat_f32_f32_wmma and scheduled: ggml_kquant_mul_mat_decode_tokens_f32 x2) are also the proof the chunking is per-part: x2 for 9 tokens is [5,4], matching the split arithmetic I checked on #460 (chunk_count = ceil(T/8), base ± 1).
One gap, for the follow-up not this PR
#3035 step 2 (the 129..255 tail) now has a row asserting the current behaviour. When that work lands, this 192 row will fail for the right reason — and the reviewer will need to know it was written as a marker, not as an invariant. Its comment says so; worth keeping that comment even if the row is later re-pointed, because the next person to see 192 → generic matmul should read it as "not yet fixed" rather than "expected forever".
VERDICT at
|
Correcting my own comment: the addition is not needed —
|
| row | add-on build | Loom build |
|---|---|---|
kquant_row.9 |
add-on declines → Loom chunked row | Loom chunked row |
kquant_row.16 |
add-on declines → Loom chunked row | Loom chunked row |
kquant_row.64 |
add-on declines (>16) → Loom | Loom |
…wmma.192 |
add-on declines → generic wmma | generic wmma |
All four rows behave identically on both trees, so no table entry and no #465-style per-row route is needed — and my earlier worry ("a row that aborts on the shipped build is worse than no row") does not apply here.
Worth keeping in the file's comment, though, because it is the load-bearing fact: iq1s is skipped for t16 because a name with no kernel aborts the backend at load for every model (engine#2832), not because the shape is unsupported. A future reader who "fixes the inconsistency" and adds kqt_mm_iq1s_t16 to the t16 list would abort the whole add-on — and, incidentally, make these two rows abort as well.
So: READY as written, and the rows are the artefact #460 was missing.
…e boundary engine#3035 raised the chunked kquant ceiling from 128 to 255 tokens, so `dense.iq1_s.mul_mat_f32_f32_wmma.192.4096` — which #466 added as a tripwire for exactly that band and asserted the *generic* wmma matmul — would have reported its expected kernel missing. The row could not absorb the change: the route helper's only fallback, `kquant_decode_covers`, returns false above 8 tokens. Moved to `dense.iq1_s.kquant_row.192.4096` expecting `ggml_kquant_mul_mat_decode_tokens_f32`. Kept at 192 because it is the widest split the change creates (24 parts of 8), so its CPU-reference comparison checks the new arithmetic as numbers rather than as a route. Added `dense.iq1_s.mul_mat_iq1_s_f16_wmma_prefill_wave32.256.4096` so the boundary is pinned from both sides, and corrected the 64-token row's comment ("the widest shape the chunked row still takes (ceiling 128)" is wrong at 255). Refs engine#3035
* hrx: chunked kquant prefill spans up to 255 tokens (engine#3035) The chunker's ceiling was kMaxTokens * kMaxTokenChunks = 8 * 16 = 128 tokens, below the 256-token floor every wide IQ* prefill matcher declares, so a 129..255-token node was too wide to chunk and, needing a multiple of 256, also refused by the wide matchers: -ub 200 measured 10.0 tok/s against 59.13 at -ub 8. Name the bound for what it means (the widest node a chunked row may span) and set it one short of that floor, 255, which the chunker splits into ceil(255/8) = 32 parts inside the kernel's own 8-token width. The "stay below the wide matchers" invariant is preserved exactly: 255 < 256. Refs engine#3035, Refs #460 * test-hrx-ops: move the 129..255 tripwire with the ceiling, and pin the boundary engine#3035 raised the chunked kquant ceiling from 128 to 255 tokens, so `dense.iq1_s.mul_mat_f32_f32_wmma.192.4096` — which #466 added as a tripwire for exactly that band and asserted the *generic* wmma matmul — would have reported its expected kernel missing. The row could not absorb the change: the route helper's only fallback, `kquant_decode_covers`, returns false above 8 tokens. Moved to `dense.iq1_s.kquant_row.192.4096` expecting `ggml_kquant_mul_mat_decode_tokens_f32`. Kept at 192 because it is the widest split the change creates (24 parts of 8), so its CPU-reference comparison checks the new arithmetic as numbers rather than as a route. Added `dense.iq1_s.mul_mat_iq1_s_f16_wmma_prefill_wave32.256.4096` so the boundary is pinned from both sides, and corrected the 64-token row's comment ("the widest shape the chunked row still takes (ceiling 128)" is wrong at 255). Refs engine#3035 --------- Co-authored-by: pi-attn <[email protected]>
Refs 1bit-MONSTER/engine#3035A merged change that no test would catch is a change waiting to be reverted by accident. #460 (in
34d62d6aa) made the reuse kquant rows serve a batch wider than the kernel's own width by emitting balanced token-dimension parts, and the fork's suite runs in no CI (engine#3000's finding), so nothing would notice if the chunking broke.This adds the row that would:
It is a CPU-reference value comparison, not a route assertion: a wrong slice shows up as wrong numbers. It fails on the parent commit — 16 tokens over the kernel's width went to
ggml_mul_mat_f32_f32_wmma— and passes with the chunked rows.require_matmul_routeis a membership test (test_sequence_has), so the same kernel appearing twice, which is exactly what a chunked match produces, needs no harness change.Why the shape is 16
The band the change fixes is 9..255 tokens, and 16 is the boundary case a server lands on with a 16-token ubatch: one token over the row's ceiling, which used to cost 10x (
-ub 164.77 tok/s against-ub 849.7). The rows at.9.and.64.sit beside it and pin the generic path, so they would move if the ceiling were wrong.Verified
Measured on this box, same model and prompt as the numbers in engine#3035:
-ub 164.77 → 43.55 tok/s,-ub 8unchanged at 49.69/49.62, 0 faults, answers identical, and the mechanism visible inGGML_HRX_TRACE_COMPILE=1(351 compiles against 345, with the parts astoken_count=8specialisations of the kernel above).Executed, on the patched binary (pinned at
338dabbdb+ #460 applied), onegpu-holdticket, 0 faultsand the wide-kernel rows beside them still pass (
mul_mat_iq1_s_f16_wmma_prefill_wave32.512.40961299 ms), so the change did not disturb the band the wide matchers own.The two rows this replaces used to fail against #460 (
missing expected kernel: loom_libs:ggml_mul_mat_f32_f32_wmma,scheduled: ggml_kquant_mul_mat_decode_tokens_f32twice) — that is the old behaviour being documented as the old behaviour, not a value regression: the CPU-reference comparison in each row passes.