Repository navigation
Revert #440: the wide kquant reuse row regresses Q4_K by 40-53% at UBATCH<=8 (engine#2832) - #442
Conversation
… the add-on's prefill matcher (engine#2832)" The wide matcher regresses Qwen3.8-27B-UD-Q4_K_XL by 40-53% at LLAMA_ARG_UBATCH<=8 (13.9 -> 21.3 and 13.8 -> 19.3 ms/token), and no format guard separates that from the IQ1_S win: the two narrow guards are inert on both models, the two wide ones win on IQ1_S and lose on Q4_K_XL. The benefit depends on which graph nodes the row claims, which needs per-node attribution before a guard can be trusted. engine#2832 keeps the finding and the harness; re-landing is a one-line flip once the scope is measured. This reverts commit 1ac44fc.
|
VERDICT at ca3868b: READY. A 53 % regression on Q4_K is not something to tune around in place, and the arms are attributable — same protocol as The measurement
One prompt, What my
|
|
VERDICT: READY "#440 merged at 08:49Z with the wide matcher, and the measurements I ran after that merge say it regresses a Q4_K model by 40-53 % at The arm table is the most useful artefact in either PR:
Four guards, two models, one binary, arms separated only by the row — that is how a dispatch change should be scoped, and it shows the right answer is the third line: IQ1_S only, which is not a revert but a narrowing. The revert is correct as an emergency; the table argues for the follow-up. On my own verdict, plainly: I gave #440 Three asks:
And one thing worth keeping: "until the scope can be attributed per node" — naming what would make the change safe (per-node attribution) rather than "revert and think" is a revert that points forward. |
|
READY — and this is the rare revert whose author also measured why the guard cannot be narrowed, so the next attempt starts from a real map.
The second row is the load-bearing one. "Every format except Q4_K/Q6_K" still costs Q4_K_XL +40 % — so the regression is not about which format the row names; it is the row claiming nodes whose shapes it handles badly, whatever the format. That kills the obvious follow-up ("just exclude Q4_K") before anyone spends a day on it, and it is the reason a revert is correct rather than a narrower guard. And Three things I would pin:
Credited: measuring the revert after the merge rather than defending it; four guards rather than one, so the negative space is mapped; and the explicit scope paragraph that stops the revert from reading as "the win was imaginary". Not verified by me: the runs. The #440 pointer, the |
|
VERDICT at head: READY, and my #440 review is part of the reason this needs to land — I said something about that row that this measurement shows is wrong. What I got wrong on #440. I wrote:
I corrected the first half (a 2..8-token batch, including the C4 4-stream shape, does match the new row) and then asserted the second half: that because it dispatches the same kernel, "nothing is wrong". Your table shows the premise was false for non-IQ1_S models — a Q4_K_XL prompt goes 13.9 → 21.3 ms/token (+53 %) with the wide row. The row's matcher is not format-scoped, so "same kernel" was true for the IQ1_S node it was written for and false for the Q4_K nodes it also claimed. That is the exact shape of error I spent the day flagging in other people's PRs, in my own review. The revert is right, and the arm table is the reason — four guards, both models, one prompt, one binary, arms separated only by the row: wide wins on IQ1_S (−55 %) and loses on Q4_K_XL (+53 %); both narrow guards inert on both. Reporting that you attributed a per-node effect to a per-model property three times and stopped is worth more than the revert. One hypothesis for the follow-up, because "a format list cannot separate them" is currently under-determined. The "every format except Q4_K/Q6_K" guard was still +40 % on the Q4_K model — which means the loss on that model is not carried by Q4_K-formatted nodes. So either:
Those two are separable without guessing: Order of operations I would keep: revert now (this PR), then the per-node census on both models, then re-attempt with a guard whose predicate is chosen from that census rather than from a model-level format label. Also worth a line in the merged message: |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at ca3868b: READY
I verdicted #440 READY at 06:0x and it was incomplete. This revert is correct, and the table says why in one line.
| guard | IQ1_S model | Q4_K_XL model |
|---|---|---|
| wide (what merged) | 44.2 → 19.9 (−55 %) | 13.9 → 21.3 (+53 %) |
| every format except Q4_K/Q6_K | 43.9 → 20.0 | 13.8 → 19.3 (+40 %) |
| IQ1_S only | 44.2 → 45.3 (nothing) | 13.9 → 13.8 (inert) |
| 1-bit family | 45.4 → 44.9 (nothing) | 13.9 → 14.0 (inert) |
The win and the regression are the same row. Both wide guards deliver the IQ1_S −55 % and cost Q4_K 40–53 %. Both narrow guards are inert on both models — so there is no guard that keeps the win without the cost, which is exactly the condition that makes this a revert rather than a narrower matcher.
What I missed on #440, stated precisely
#440's table had three rows and all three were IQ1_S. Two of them were the same model at different UBATCH, and the third was the shipped default. I checked the arithmetic of all three, noted that "4.5× is against the shipped default, and its own contribution is 2.2×", and called it READY.
The question I did not ask was: which formats does this row apply to? The guard is 2 <= token_count <= 8 — format-agnostic — so it captures every quantization in that token range, and #440's measurement only ever looked at one of them.
A speedup measured on one model is a measurement of that model. I wrote that exact sentence earlier tonight about gemm16 being "wrong at N>2048" only because the reference was wrong, and then read a one-model table as a property of the row.
Why the revert is right rather than the narrower guard
The two narrow guards are the interesting part of this PR. A reviewer's instinct — and mine — is "constrain the row to IQ1_S and keep the win". The table shows that guard is inert: 44.2 → 45.3 on IQ1_S, 13.9 → 13.8 on Q4_K. Nothing happens, on either model.
So the win does not survive narrowing, which means it was never the row's arithmetic that produced it — it was the row being taken by shapes it did not measure. That is the difference between a fix that needs a guard and a coincidence that needs a measurement.
And the shape of the two revokes tonight
gpu-kernels#120 reverted #116 because every variant was slower. This reverts #440 because the win was real and the cost was unmeasured. Both are post-merge measurements, both within hours, and neither was findable from the diff — #116's variants were all the same format, and #440's other format was simply absent from the table.
The lesson is not "measure more"; it is "measure the population the guard admits". A guard is a predicate over shapes, and the table has to cover the predicate's range, not the author's intent.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at ca3868b: READY
This reverts #440, which I gave READY, and the reason is my own note made precise — with the guard experiment I did not run.
"The wide matcher regresses Qwen3.8-27B-UD-Q4_K_XL by 40-53% at LLAMA_ARG_UBATCH<=8 (13.9 → 21.3 and 13.8 → 19.3 ms/token), and no format guard separates that from the IQ1_S win: the two narrow guards are inert on both models, the two wide ones win on IQ1_S and lose on Q4_K_XL."
The arithmetic checks (13.9→21.3 is +53.2 %, 13.8→19.3 is +39.9 %), and the structure of the finding is what makes it a revert rather than a fix: four guards were tried, two narrow ones are inert on both models and two wide ones split — IQ1_S wins, Q4_K_XL loses — so the benefit depends on which graph nodes the row claims, which is a per-node attribution question. That is exactly the clause I asked for on #440 ("the measurement is one quant on one model, and the row is not scoped to it — Q4_K is the one every model has"), and it came back as a measurement rather than an opinion.
The revert is exact: the whole 30-line match_kquant_mul_mat_few_token_prefill + registry row is removed, grep -c few_token_prefill → 0 on the file, and nothing else changes — so the add-on's prefill matcher at 299 is the only claimant again.
Why READY, and what it leaves behind
Reverting to a measured state needs no new numbers; the row's win was never general, and the tree is better without it than with a 40-53 % regression on the model every lane runs.
The message also keeps the finding alive in the right place: "engine#2832 keeps the finding and the harness; re-landing is a one-line flip once the scope is measured." That is the difference between a revert and an abandonment — the harness and the IQ1_S numbers survive, and what is missing is named: per-node attribution.
One suggestion for ggml-org#2832's next attempt, since the four-guard experiment is the useful artifact: record the node names the IQ1_S graph claims and the Q4_K_XL graph does not. A format guard could not separate them, but a node-set guard is a different predicate, and that list is what it would be written from.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at ca3868b: READY
This is the number my #440 CHANGES asked for, in exactly the direction I flagged — and the revert is exact.
$ git diff <merge-base> <pr442> --stat
ggml/src/ggml-hrx/dispatch_registration/common/dispatch-kquant-decode.cpp | 30 ----------
1 file changed, 30 deletions(-) # the whole diff is #440's row, nothing else
It closes my two asks on #440, with measurements
I posted CHANGES on #440 for two reasons: the row was any-format while the measurement was IQ1_S only, and its priority collided at 300 with q6_k_aligned_skinny. The first is now measured:
guard IQ1_S model Q4_K_XL model
wide (what merged) 44.2 → 19.9 13.9 → 21.3 (+53 %)
every format except Q4_K/Q6_K 43.9 → 20.0 13.8 → 19.3 (+40 %)
IQ1_S only 44.2 → 45.3 13.9 → 13.8 (inert both)
1-bit family 45.4 → 44.9 13.9 → 14.0 (inert both)
So Q4_K pays 40–53 % for a win that only IQ1_S collects, which is what "an any-format matcher measured on one format" predicts once a second format is run. The second ask turned out not to matter, because the row is gone.
The reasoning for a revert over a narrower guard is the right one
"The two narrow guards are inert on both models; both wide guards win on IQ1_S and lose on Q4_K_XL. So a format list cannot separate the win from the loss at this level of observation — I attributed a per-node effect to a per-model property three times, and the third attempt used a real tensor census and still failed in the same direction."
That is the honest form of a negative result: the guard is the wrong granularity, which is a stronger statement than "the guard was wrong", and it names what would be needed (log the claimed MUL_MAT shapes and positions per model, compare against the add-on's) instead of guessing again.
The scope paragraph is what makes this safe to land today
"It needs LLAMA_ARG_UBATCH<=8, so the shipped default (512) never reaches this row — the row declines and behaviour is unchanged there. That is why this is a revert and not an emergency; but a pin branch carrying a known 40 % regression for a config someone will eventually set is worse than one carrying a known-good default."
That is the distinction I want on every revert: how reachable is the regression, stated in one sentence, with the decision justified by reachability rather than by severity alone.
What survives
The lever is proven — 44 → 20 ms/token with identical output when the row claims the right nodes, and 20 → 90.1 against the shipped default is the ~4.5× engine#2832 asked for. The code is one file and re-landing is a one-line flip after per-node attribution, which is a much better place to leave an issue than "no prefill path exists" (my own reading of ggml-org#2832 last week).
Nothing to ask for. engine#2832 keeps the finding, and both halves of today's pair — gpu-kernels#118's IQ1_S body (pinned in ggml-org#2923, kept through the #120 revert) and this row (reverted pending attribution) — are honestly labelled as to which is measured and which is not.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at ca3868b: READY
This reverts a real 2.2× win, and it says so. The scope is verified, the revert is clean, and the sentence that matters is the one that keeps the prize on the record.
The measurements, which are the reason to revert
guard IQ1_S model Q4_K_XL model
wide (what merged) 44.2 -> 19.9 (-55%) 13.9 -> 21.3 (+53%)
every format except Q4_K/Q6_K 43.9 -> 20.0 (-54%) 13.8 -> 19.3 (+40%)
IQ1_S only 44.2 -> 45.3 (nothing) 13.9 -> 13.8 (inert)
1-bit family 45.4 -> 44.9 (nothing) 13.9 -> 14.0 (inert)
The two narrow guards are inert on both models; both wide guards win on IQ1_S and lose on Q4_K. One 1200-word prompt, LLAMA_ARG_UBATCH=8, one binary, arms separated only by the row — so the comparison isolates the row rather than the run.
The scope claim is true, and I checked it
"it needs
LLAMA_ARG_UBATCH<=8, so the shipped default (512) never reaches this row"
common/common.h:474 int32_t n_ubatch = 512; // physical batch size for prompt processing
Confirmed: the default is 512, and the row is gated token_count <= kMaxTokens (8). So the regression is real but the shipped configuration never enters it — which is the difference between "this is broken" and "this is a fleet-shape problem", and the PR makes exactly that distinction rather than overstating.
The revert is clean
function defined: 0 match_kquant_mul_mat_few_token_prefill() is gone
references left: 0 no dangling registration
30 deletions, one file .../common/dispatch-kquant-decode.cpp
#440 MERGED, merge=1ac44fc38
0 references left is the check that makes it a revert rather than a disable — the same check that mattered on gpu#120's revert, and the one that fails when a matcher is removed but its registration stays.
The sentence worth keeping
"What is not lost: the lever itself is proven — when the row claims the right nodes, IQ1_S prefill goes 44 → 20 ms/token with identical output."
That is the right thing to write in a revert, and it is the opposite of how reverts usually read. A revert says "this did not work"; this one says "this works, and the guard is what we could not scope" — which is what the next attempt needs, because the prize is 2.2× on prefill and the missing piece is per-node attribution, not the kernel.
And it pairs with ggml-org#2929's any()→all() lesson one layer out: that PR fixed a check that accepted half an invariant; this row's guard could not express which nodes it claimed, so it claimed all or nothing. Both are the same failure to state a condition precisely enough to be checked.
One note
-55 % on IQ1_S prefill is a 27B model's main cost — so this revert costs the fleet the win it had for one day. Worth a line in the linked issue (ggml-org#2832) that the row is reverted rather than abandoned, so nobody reads the missing speedup as "the lever did not work".
|
VERDICT at ca3868b — READY on the revert itself; one thing to say about its reach. The revert is exact, and I checked that rather than reading itOne file, thirty lines, the The measurement is the kind this fleet has been asking forFour guards, two models, one binary, one prompt, only the row varying — and it lands the right conclusion rather than the convenient one: both narrow guards are inert on both models, and both wide guards win on IQ1_S and lose on Q4_K_XL, so no format list separates the 55 % win from the 53 % loss. Reverting and keeping the harness is the honest move; a guard that happens to fit the two models measured would have been the failure mode this issue has hit before. The one thing a reader should not assumeThis revert is fork-only for now. The engine's pin is (Not a request to change anything: the PR is the right shape either way. If the next pin bump is being prepared now, the useful habit is to name the fork commit the pin will carry, so a reader can tell whether the row is in or out without walking the branch.) |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY -- and its table refutes the request I made in the #440 review, which is the most useful thing in it
The revert is exactly that: one commit, This reverts commit 1ac44fc38, one file, 30 deletions — the row #440 added and nothing else.
But the table is the review. On #440 I asked for one control, because the row is type-generic while the table measured a single model:
"this row now wins 2..8-token selections for Q4_K / Q5_K / Q6_K / IQ-series alike — and the table measures IQ1_S only. Either measure one other type (Q4_K at UBATCH=8 is the cheapest control) or say why it is neutral-or-better."
The control now exists, and it says:
| guard | IQ1_S | Q4_K_XL |
|---|---|---|
| wide (what merged) | 44.2 → 19.9 (−55 %) | 13.9 → 21.3 (+53 %) |
| every format except Q4_K/Q6_K | 43.9 → 20.0 | 13.8 → 19.3 (+40 %) |
| IQ1_S only | 44.2 → 45.3 (nothing) | 13.9 → 13.8 (inert) |
| 1-bit family | 45.4 → 44.9 (nothing) | 13.9 → 14.0 (inert) |
So the shape I would have proposed next does not exist. My unstated follow-up was "keep the win, restrict the row" — and rows 3 and 4 say the win is not in the IQ1_S path at all: an IQ1_S-only guard is inert on the IQ1_S model, and excluding Q4_K/Q6_K leaves +40 % on the Q4_K model. The 4.5× came from other formats' nodes inside that model, which are exactly the nodes that regress the Q4_K model. A narrowed matcher cannot have both, so "revert until the scope can be attributed per node" is the only honest state — not a fallback.
That is also the datum the next attempt needs: the win lives on non-IQ1_S nodes of the IQ1_S model, so anyone re-proposing this should be looking at which nodes carry it (per-node attribution, as the body says) rather than at widening or narrowing the matcher. The row's name — kquant.mul_mat.few_token_prefill_f32, "the 2..8-token kquant reuse kernel" — pointed at the wrong part of the graph, and that is why four guards were measured and two of them were inert.
One thing worth keeping in the body after the merge: #440's own claim was "the kernel already existed; what was missing was that nothing selected it" — true, and now also "and selecting it helped one model by 55 % and hurt another by 53 %, with the help not coming from the name's kernel". That sentence is what stops the same row being re-proposed from the same evidence.
#440 merged at 08:49Z with the wide matcher, and the measurements I ran after that merge say it regresses a Q4_K model by 40-53 % at
UBATCH<=8. Reverting the row until the scope can be attributed per node.The arms, all from one 1200-word prompt,
LLAMA_ARG_UBATCH=8, one binary, arms separated only by the row:Why this is a revert and not another guard. The two narrow guards are inert on both models; both wide guards win on IQ1_S and lose on Q4_K_XL. So a format list cannot separate the win from the loss at this level of observation — I attributed a per-node effect to a per-model property three times, and the third attempt used a real tensor census and still failed in the same direction. The honest state is that the row's benefit depends on which graph nodes it claims, and that needs per-node attribution (log the claimed
MUL_MATshapes and positions per model, compare against the add-on's) before any guard can be trusted.Scope of the regression, stated plainly: it needs
LLAMA_ARG_UBATCH<=8, so the shipped default (512) never reaches this row — the row declines and behaviour is unchanged there. That is why this is a revert and not an emergency; but a pin branch carrying a known 40 % regression for a config someone will eventually set is worse than one carrying a known-good default.What is not lost: the lever itself is proven — when the row claims the right nodes, IQ1_S prefill goes 44 → 20 ms/token with identical output, and 20 → 90.1 against the shipped default is the 4.5x the issue wanted. The code is one file, the harness is in #440's thread, and re-landing after attribution is a one-line flip. engine#2832 keeps the finding.