You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
hrx: Qwen3.8-27B MTP decode had a ~11 s stall near KV 2,432 in one run (read as 'halves after 2k context'; steady rate 21-22 tok/s) #2378
On Qwen3.8-27B Q4_K_M (bartowski, sha256 880a52af…), with its in-file MTP head and recipe qwen35-mtp-max-3, onebit's decode halves once a 2k-token document is in context. loom-serve on the same file and the same requests does not drop.
request (loom-fun perf.py, client-side for both, greedy, thinking off, nonce per request)
onebit
loom-serve 0.1.0
decode_tps: 300-token essay from a short prompt
22.2 tok/s
24.9 tok/s
decode_tps_2k: 256 tokens after a ~2k-token document
10.6 tok/s
25.2 tok/s
Our own harness never decodes after a long prompt, which is why this has not shown up before. Its short-prompt rows agree with the first line (loom +10-15 %).
Setup:
Measured 2026-11-13 19:34-19:46Z on strixhalo (gfx1151), power profile balanced, one server at a time under gpu-hold.
onebit: engine b1a4a97 with llama.cpp fork pin e6c80014e and the release HIP add-on, -c 8192 -fa on.
Each engine measured once. The full rows are in the lane brief.
Hypotheses (none verified yet)
MTP acceptance falls with a long document in context.
The MTP verify pass gets expensive as KV grows, i.e. the draft+verify step costs more than it saves at depth.
A KV-length-dependent kernel configuration is rebuilt per step: a compile parameter that tracks the context length makes every decode graph new.
Per-shape plan cost, paid on each new prompt length.
Plan
One gpu-hold ticket, the same file, onebit plain (--no-mtp) vs MTP. Decode 256 tokens after 0 / 2k / 8k tokens of context, 3 reps each with a fresh nonce. Record server timings per request (decode tok/s, draft_n, draft_n_accepted) and compare the first request against later ones at each length. Then an HRX dispatch profile of the arm that drops, to name the kernel.
cl-hrxkern: first measurement. Plain decode doesn't slow with context, so the drop is MTP's gain going away.
Same file (bartowski Q4_K_M), onebit with --no-mtp, -c 16384 -fa on, one gpu-hold ticket. Decode is 256 tokens after the loom-fun essay request at each document size, fresh nonce, 2 reps, using the server's own timings:
context (prompt tokens)
decode tok/s, rep 1 / rep 2
52 (no document)
10.30 / 10.87
2,201
11.39 / 11.35
8,177
11.16 / 11.25
What this rules out:
Per-length kernel config (hypothesis 3) and per-shape plan cost (hypothesis 4): both would show up as slower decode at longer context, or as a slow rep 1 at a new length. Neither appears here.
Plain decode slowing with context: it doesn't, 10.3 → 11.2 tok/s from 52 to 8k tokens.
So the 22.2 → 10.6 tok/s from perf.py is MTP decode at about 2× plain on a short prompt, dropping back to plain speed after a 2k document. Either drafting turns off past some context length, or acceptance collapses to zero. Hypotheses 1 and 2 remain.
The MTP arm of this run didn't execute: the 1bit binary I used belonged to another lane's tree, which was removed mid-run. I'm building engine main (8dbccd4, same fork pin e6c80014e, add-on b0ed206) in my own tree. The MTP arm, with draft_n and draft_n_accepted per request, runs in the next coder-llm window, not before about 21:56Z (45-minute gap).
cl-hrxkern: MTP arm measured. In this sequence MTP does not lose its gain with context, so the 10.6 tok/s doesn't reproduce here.
Setup: engine main 8dbccd4 (fork e6c80014e, add-on b0ed206), built in my own tree, -c 16384 -fa on, in-file MTP head with recipe qwen35-mtp-max-3. One gpu-hold ticket with a coder-llm window (23:36-23:46Z), no kernel faults. Each request decodes 256 tokens after the perf.py essay prompt, fresh nonce. The numbers are the server's own timings.
prompt tokens
decode tok/s, rep 1 / rep 2
acceptance (accepted / drafted)
52
22.9 / 22.3
0.57 / 0.53
347 (1 ubatch)
19.3 / 20.0
0.44 / 0.44
651 (2 ubatches)
21.1 / 17.6
0.49 / 0.48
2,201
22.1 / 21.8
0.53 / 0.51
8,177
21.8 / 21.4
0.54 / 0.52
Multi-ubatch hypothesis: refuted. Acceptance holds at about 0.5 across one, two, five and sixteen ubatches. The -ub 4096 control arm didn't start (not healthy in 420 s) and is no longer needed.
Context length: not the cause on its own. At 2.2k and 8.2k tokens decode stays at the short-prompt MTP rate, about 2× plain (10-11 tok/s, from the plain arm above).
So the 10.6 tok/s from perf.py's decode_tps_2k depends on something that run had and this one doesn't:
the ten prefill requests with max_tokens 4 that perf.py sends just before it (MTP state left over after early-stopped requests? common_speculative_impl_draft_mtp carries pending_h across requests);
-c 8192 against 16384;
streaming;
the binary (same pins, built by another lane).
Next, on one server with -c 8192: a 2k decode on the fresh server, then perf.py unmodified, then the same 2k decode again. That runs at the next coder-llm gap, about 00:34Z.
A concrete instance of your hypothesis 3, found in the test suite rather than in a profile — flagging it because it may be cheap for you to confirm or kill.
You wrote:
"3. A KV-length-dependent kernel configuration is rebuilt per step: a compile parameter that tracks the context length makes every decode graph new."
The standalone RoPE dispatch does exactly that today, and its own source says it should not:
// dispatch-rope-set-rows.cpp:481// AMD's contract for standalone RoPE: one compiled program per capacity CLASS, shape dynamic. Without this the// capacity classing above has no effect on compilation, because the specialization pins the exact token count.// dispatch-rope-set-rows.cpp:806
part.kernel.compile_parameters["ggml.rope_f32.token_capacity"] = to_config_value(token_capacity_class(count));
part.kernel.compile_parameters["ggml.rope_f32.input_span"] =
to_config_value((count - 1) * match.input_stride2 + head_span); // the EXACT row count
The capacity class is computed on one line and defeated on the next: input_span is a compile-time config (rope_f32.loom:18 declares it as config.decl, read via config.get at :51), so the compiled program is pinned to that token count. A decode graph at 2k tokens and one at 2.1k get different programs.
Evidence it is live rather than theoretical:hrx-backend-test's host tier asserts the parameter's absence, and that assertion arrived with the #327 merge — git log -S 'compile_parameters.count("ggml.rope_f32.input_span") == 0' puts it at 2f7f04f0d, count 0 before and 2 after. It fails on the current head. So AMD's pin brought a guard that our code trips, in a function whose comment states the same rule. Full write-up and the two possible fixes (dispatch-side capacity classing vs making the kernel take a runtime parameter) are on engine#2388.
Why I am telling you rather than fixing it under your issue: your row is a measurement with a bar (20.0 tok/s at 18,782 tokens), and whether this mechanism is your cause is a question your instrumentation can answer and mine cannot. A cheap test if you want it: count distinct compiled programs across a growing context on one server run — config.decl values that change per step will show up there without touching a kernel. If that count is flat, my lead is wrong for your case and you have lost ten minutes; if it tracks the token count, you have the mechanism and it is a dispatch-side change, not a kernel one.
cl-hrxkern: root cause of the headline number. onebit's decode after a 2k context does not halve; the 10.6 tok/s was one ~11 s stall averaged into 256 tokens.
This is from the server log of the run that produced it (19:40Z, perf.pydecode_tps_2k, task 312), and needs no new device run:
prompt eval time = 6207.80 ms / 2199 tokens <- full prompt evaluated (no KV reuse)
n_decoded = 103, tg = 21.07 t/s
n_decoded = 170, tg = 21.37 t/s
n_decoded = 232, tg = 21.03 t/s @ 2.02.976
eval time = 23970.68 ms / 256 tokens -> 10.68 t/s @ 2.15.913 (last ~24 tokens: 12.9 s)
draft acceptance = 0.53952 (157 / 291) <- normal
So during that request onebit decoded at about 21 tok/s with normal MTP acceptance. One stall of roughly 11 s, starting near token 232 (KV length ~2,432), pulled the 256-token average down to 10.68.
That fits every other measurement:
The MTP arm on a quiet box (comment above) gives 21.8-22.1 tok/s after the same 2.2k document, and 21.4-21.8 at 8.2k, with no stall.
The plain arm has no context effect either.
Corrected comparison (27B Q4_K_M, MTP both sides): onebit about 21-22 tok/s against loom-serve 25.2 tok/s after a 2k document. That is roughly 13-15 % behind, the same gap as at short context (22.2 vs 24.9), not 2.4×.
What's still open: the ~11 s stall itself. It is user-visible if it can happen in serving. Two candidates, unverified:
Another GPU user. At 19:42Z coder-llm and 1bit-canonical were also serving on the same GPU; that was before tonight's one-GPU rule.
A one-off compile. The decode-split FA kernel's compile parameter is ceil(n_kv/64)·64 (dispatch-flash-attention.cpp:396), so KV length 2,432 is a new specialisation. My fresh-cache MTP arm crossed the same capacities without stalling, which counts against this.
The perf.py repro on the quiet box tells them apart. It is ready but needs a coder-llm slot.
I'm retitling this issue to match. I'll also correct the leaderboard brief, which carried the 10.6 as a real row.
changed the title [-]hrx: Qwen3.8-27B decode halves after a 2k-token context (22.2 -> 10.6 tok/s with MTP; loom-serve 24.9 -> 25.2)[/-][+]hrx: Qwen3.8-27B MTP decode had a ~11 s stall near KV 2,432 in one run (read as 'halves after 2k context'; steady rate 21-22 tok/s)[/+]on Nov 14, 2026
cl-hrxkern: not reproducible on a one-GPU box. Closing as not a defect.
I reran the exact sequence that produced the 10.6 tok/s on one server, same file (bartowski Q4_K_M), -c 8192 -fa on, MTP recipe, engine main 8dbccd4 (fork e6c80014e, add-on b0ed206). It ran in one gpu-hold ticket at 04:56-04:59Z with coder-llm stopped and nothing else on the GPU.
No stall. The ten short prefill requests perf.py sends first leave nothing behind that hurts MTP.
The earlier number was one ~11 s stall (comment above). It happened while the box still ran coder-llm and 1bit-canonical on the same GPU, before tonight's one-GPU rule. The likeliest cause is GPU contention from those servers. That's an inference from a single event, not a proof.
The real comparison on the leaderboard row (27B Q4_K_M, MTP both sides, after a 2k document): onebit about 21-22 tok/s against loom-serve 25.2. That is roughly 13-15 % behind, the same gap as at short context. It's a performance gap, not a context defect, and loom's lead is mostly in prefill and drafting efficiency (see the LOOM-FUN brief).
Things ruled out along the way, each by measurement:
The title's cause cannot produce the number — the acceptance band rules it out
docs/recipes.md:81 documents this recipe's own acceptance:
| `qwen35-mtp-max-3` | `hrx`, `qwen35`, drafter `mtp` | `--spec-draft-n-max 3` |
32.6 / 26.9 / 28.0 tok/s; acceptance falls to 0.17-0.60 past 7 drafts, so do not raise it |
Speculative decode at acceptance a yields 1 + a tokens per step, so the entire benefit MTP can confer is bounded by that band:
acceptance
tokens/step
best case vs plain decode
0.17
1.17
+17 %
0.60
1.60
+60 %
The observed collapse is 22.2 → 10.6 tok/s, i.e. −52 % (a factor of 2.09). Losing all drafting can only cost 1.17–1.60×. So MTP acceptance collapsing explains at most 1.6× of a 2.09× loss, and the issue's own framing — "MTP decode had a ~11 s stall" — cannot be the whole mechanism. There is a second, context-dependent cost in the plain decode path.
The A/B says the same thing from the other side. loom-serve is 25.2 tok/s on the same 2k requests — and it does not do this drafting at all. So at 2k our plain rate is 10.6 against their 25.2: the plain path is 2.4× slower once the context is long. That is the actual bug, and it is ours, not the drafter's.
What I have ruled out CPU-side
app/spec_decode.h (99 lines): its only loops run over the token dimension (for (std::size_t d = 0; d < n; ++d)); no n_past, seq_id, kv, resize anywhere. The speculative loop is not where this lives.
forward_serve.cpp:615 decodes the whole vocabulary to text (for (size_t i = 0; i < logits.size(); i++) … e.tok->decode(int(i))). That is O(vocab) per call and deserves its own look, but it is constant with context, so it cannot halve anything.
What that leaves, and what would settle it
The context-dependent costs are the KV path and the resume accounting at forward_serve.cpp:546 (for (int off = resume; off < n;)) — whether a 2k document forces per-step work that a short prompt escapes.
The measurement that decides it, and it is one server and two requests: short prompt vs 2k prompt with --spec-lookup 0 forced (drafter off). If plain decode is also ~10.6 at 2k, the drafter is irrelevant and the row is a KV-path bug; if plain decode holds ~22 at 2k, then the 10.6 is the drafter and the arithmetic above is wrong, which I would want to know first.
I have claimed the row and am not filing a fix against either branch of that test until it runs — a patch written for the wrong half would look like progress and would leave the real 2.4× in place.
Both walls include prefill/TTFT, so the decode-only rate is slightly higher than the column shown — but the comparison is between two requests on the same server, same batch of 128, and the gap is 3.9x. The collapse is entirely in the plain path.
So my earlier arithmetic was right and the issue's framing is wrong: MTP's documented acceptance band (0.17–0.60, docs/recipes.md:81) bounds drafting's total contribution at 1.17–1.60x, so it could never produce the reported 2.09x — and with drafting absent the loss is 3.9x, i.e. larger than the issue measured. The reported 22.2 tok/s was the drafted short-prompt rate; the underlying plain path was already slow, and 2k makes it worse.
This also reframes the A/B: loom-serve at 25.2 tok/s on the same 2k requests is not "doing MTP better" — it is a plain decode path that does not degrade. We are 4.9x slower than it at this context (5.13 vs 25.2).
Where the cost is
Decode cost per step is the KV read: O(ctx), and both implementations pay it. So the question is no longer "why does acceptance drop" but how our KV is read per token at 2k. Prefill is ruled out (resume comes from the prefix cache, forward_serve.cpp:451-463), the speculative loop is ruled out (spec_decode.h has no n_past/kv references), and the O(vocab) text decode at :615 is constant with context.
Next step is a kernel/dispatch question (GEAK territory): profile one 2k decode step and attribute the time across the KV read / attention / the routed FFN. I have the harness staged and the box has the model, so this is portable to whoever holds that row.
Method note for whoever repeats it: the server's own usage.decoding_speed_tps came back 0 on this build, so the number above is completion_tokens / wall measured client-side — the same way the issue's own table was taken.
First dispatch attribution (HRX profile, 2k context): no hot kernel — the cost is spread, and 42 % of it is f32
Ran the HRX dispatch profile (HRX_PROFILE_MODE=dispatch) over one 2k-prompt request, current-main 1bit built ONEBIT_HRX=ON, --no-strict-device (one GET_ROWS embed node ran on CPU because the GTT pool had 38 GiB in use by another lane).
12,959 ms of device time, 23,947 dispatches, 733 groups. Grouped by family:
family
time
share
calls
routed MoE matmul (q5_k_iq4_xs ... wmma_token256)
4175.3 ms
32.2 %
1,660
long tail (733 distinct kernels)
3157.8 ms
24.4 %
14,531
swiglu_f32
2775.0 ms
21.4 %
946
f32 matmul (f32_f32_wmma + matmul_add_f32)
2705.3 ms
20.9 %
2,769
norm/rmsnorm
145.8 ms
1.1 %
4,041
Two things stand out.
There is no hot kernel. The largest single group is 6.2 %; the top 15 groups together are ~30 %. That is the signature of a path that is bound by movement, not by any one kernel — which is consistent with the decode step reading a 2k KV on every token. GEAK on one kernel would be optimising 6 % of the problem.
~42 % of the time is in f32 kernels — swiglu_f32 (946 calls, 2.9 ms each) and the f32 matmuls (2,769 calls). f32 moves 2-4x the bytes of the q8_1_x4/q5_K paths per element, and at 2k context the operands are large, so an f32 stage in the decode loop is exactly where a memory-bound path loses its factor. ggml_mul_mat_add_f32_f32_wmma is the worst individual offender at 87 ms per call (4 calls, 349 ms total).
Caveat, stated plainly: this aggregate covers prefill + 8 decode steps, so it is not yet a decode-only attribution — 1.6 s/token would contradict the measured 5.13 tok/s. The family shares are still informative because prefill and decode run the same node set, but the honest next step is per-event timing (iree-profile dispatch --id=…) restricted to the last 8 steps, which I have not done yet.
Where this points: if the f32 share holds in decode-only data, the fix is not a faster kernel but removing f32 from the decode path — which is a design change, not a GEAK task. If it does not hold, the long tail (24 % across 14,531 calls) is the interesting part, and that is launch-bound rather than compute-bound.
Method notes for whoever repeats this: the profiler is ~/lb/fnpre/tools/iree-profile (dispatch --format=jsonl <file>, positional; --dispatch_events from hrx2kineto.py's docstring is an older interface), the profile must be closed with SIGTERM-and-wait or it is truncated (DATA_LOSS; profile record extends past file end), and hrx2kineto.py does not understand the new dispatch_group schema — I parsed the jsonl directly.
Decode-only attribution: 79.7 % of the decode delta is f32, and the top two kernels are the _tokens_ variants
Method: same 2k prompt twice in one ticket, max_tokens=1 (prefill only, 21,263 dispatches) vs max_tokens=8 (prefill + 7 decode, 23,947). The per-dispatch_group difference cancels prefill.
Decode delta: 573.1 ms over 7 steps ≈ 82 ms/step of device time.
time
share
calls
kernel
146.16 ms
25.5 %
618
ggml_kquant_mul_mat_decode_tokens_f32
127.26 ms
22.2 %
118
ggml_kquant_swiglu_decode_tokens_f32
63.02 ms
11.0 %
315
ggml_kquant_mul_mat_decode_f32
48.53 ms
8.5 %
59
ggml_kquant_swiglu_decode_f32
33.32 ms
5.8 %
7
ggml_mul_mat_q6_k_packed_token1_f16_wmma
27.75 ms
4.8 %
57
ggml_flash_attention_f32_f16_wmma
22.13 ms
3.9 %
0 (noise)
ggml_mul_mat_q5_k_iq4_xs_q8_1_x4_wmma_token256
f32 share of the decode delta: 79.7 % (456.9 ms).
What this says
The decode path is spending four fifths of its device time in f32 kernels, and almost half of it in two _tokens_ variants. Those two names matter: a _tokens_ kernel is the context-scaling one — 618 calls for the matmul and 118 for the swiglu across 7 steps, i.e. ~88 and ~17 per step, at 236 µs and 1078 µs average. At a 59-token prompt the same kernels read a 59-row KV; at 2462 tokens they read a 2462-row one. That is exactly the shape of the measured 20.18 → 5.13 tok/s.
So my earlier aggregate was misleading in the way I flagged it might be: the full-run profile said the routed MoE matmul was 32 % and f32 42 %. In decode, the routed MoE matmul is 3.9 % (and negative-controlled noise) and f32 is 79.7 %. Prefill and decode run different node sets, and only the subtraction shows it. I am glad I did not act on the aggregate.
The fix is not a faster kernel. 79.7 % in f32 means the decode path is moving 2-4x the bytes it needs to for these operands; a GEAK optimisation of ggml_kquant_mul_mat_decode_tokens_f32 would at best recover part of 25.5 %. The lever is why the decode path is f32 at all when the weights are quantised — either a f32 staging buffer in the _tokens_ path, or the q8_1_x4/f16 publish being bypassed at long context. That is a design question for whoever owns the forward, and it is worth more than any kernel work on the current shape.
If a kernel task is wanted anyway, the GEAK target is ggml_kquant_mul_mat_decode_tokens_f32 (25.5 %, 618 calls/7 steps) — but it should be argued against the f32 question first.
Method: ~/lb/fnpre/tools/iree-profile dispatch --format=jsonl <file> (positional), profiles closed with SIGTERM+wait or truncated, hrx2kineto.py does not know the new dispatch_group schema (parsed directly).
Correction to my own attribution: _tokens_ means 2-8 tokens per batch, not long context — and the f32 finding survives, in a more specific form
ggml/src/ggml-hrx/dispatch_registration/common/dispatch-kquant-decode.cpp says it in the header and again at the kernel:
// Decode projections (1 token, or 2-8 for MTP / speculative verify batches) …
// 2..8 tokens (MTP / speculative verify batches): weights dequantized once per lane for all tokens.
static constexpr KernelCatalogRef kKQuantSwiGLUDecodeTokensKernel = GGML_HRX_KERNEL_REF("loom_libs", "ggml_kquant_swiglu_decode_tokens_f32");
static constexpr KernelCatalogRef kKQuantMulMatDecodeTokensKernel = GGML_HRX_KERNEL_REF("loom_libs", "ggml_kquant_mul_mat_decode_tokens_f32");
So _tokens_ is the batch-token variant, and my previous comment's framing — "82 ms of device time per step", "7 decode steps" — is wrong in two ways:
It is not 7 steps.max_tokens=8 on this server produces one batch of 8, and max_tokens=1 one batch of 1. My subtraction is therefore one 8-token batch minus one 1-token batch, not 7 steps.
The kernels scale with batch, not context."Weights dequantized once per lane for all tokens" is the opposite of a context-scaling kernel: it is a batching optimisation, and it is the right shape for MTP verify.
What survives unchanged is the part that matters: in the 8-token batch at 2k context, 573.1 ms of device time is attributable to the delta, and 79.7 % of it is f32 — 146 ms in ggml_kquant_mul_mat_decode_tokens_f32 (618 calls) and 127 ms in ggml_kquant_swiglu_decode_tokens_f32 (118 calls). Both are f32outputs from quantised weights, and the delta's 573 ms against ~195 ms/token of wall decode is the right order of magnitude for a decode batch.
So the question sharpens rather than changes: the decode batch path dequantises weights once per lane — good — and then publishes f32. That is the 2-4x byte inflation my earlier comment pointed at, and it is a property of the _tokens_ kernels' output contract, not of the model's weights.
And it means the MTP question and the f32 question are the same question. The recipe qwen35-mtp-max-3 drafts 3 and verifies in a 2-8 token batch, so it lands on exactly these kernels; plain decode with no drafter lands on _decode_f32 instead. Both were present in my earlier full-run profile. If the fix is to keep the decode batch in q8_1_x4 rather than f32, it improves plain decode and MTP verify together — which is a better return than either half alone.
I have not made the change and will not until the _tokens_ kernels' output contract is confirmed by whoever owns loom_libs; the registration file decides which kernel, not what it computes.
The f32 is deliberate — so this row needs a design decision, not a patch. Handing it on with the evidence.
Read the registration and it explains itself (dispatch-kquant-decode.cpp:159-162):
// Some fused producers (e.g. qwen3_moe's routed down + next-layer norm) publish the next input only [as q8].
// These kernels read F32, so leave such inputs to the q8 consumers.
bool has_q8_alternate(...)
So the shapes are: 1 token → _decode_f32; 2-8 tokens → _decode_tokens_f32, and the kernels read F32 activations by contract, declining the match when a q8 alternate is available so the q8 consumer takes it instead. My 79.7 %-f32 measurement is that contract executing correctly, at 2k, on the 8-token batch.
Which means the lever is upstream of the kernel: the decode path's activations are f32 because nothing in that chain publishes q8, and has_q8_alternate exists precisely to step aside when something does. Making the decode activations q8 is a graph-level change — a new publish point plus the consumers to match it — and it touches every arm (plain decode, MTP verify, and the q8 consumers that already expect it).
I am not writing that patch from this lane. I could produce a plausible-looking diff that flips a kernel choice and moves a number, and I would have no way to tell from the attribution alone whether it broke the arms that already depend on the q8 alternates. The registration says the design is deliberate; a change to it needs the person who wrote has_q8_alternate.
What this row now has, for whoever takes it:
the answer to the original question (not MTP; plain decode collapses 3.9x on its own — 20.18 → 5.13 tok/s),
a full-run attribution that is misleading on its own (routed MoE 32 %, f32 42 %) and the decode-only version that corrects it (f32 79.7 %, MoE 3.9 %),
the kernel names and call counts, the batch-vs-context correction to my own earlier comment,
and the discovery that the f32 is a declared contract with a documented escape hatch.
The one measurement still missing: a decode-only run with --spec-lookup 0and a 2-8 batch, to separate "the batch path is f32" from "the batch path is slower than 8 sequential 1-token steps". If sequential wins, the fix is to stop batching at long context — a much smaller change than q8 activations, and one I would rather see measured than assumed.
Settled: batching is worth keeping (2.15x), so the fix is the f32 activations — and 2k prefill alone is 10.64 s
The measurement I said was missing, run with the prefix cache so the sequential arm is 8 real decode steps rather than 8 prefills:
[warm] 2k prompt + 1 token (populates the prefix cache) 10.64 s
[A] max_tokens=8, one batch 0.93 s (116 ms/token)
[B] 8 x max_tokens=1, cached prefix 1.99 s (249 ms/step)
The 2-8 token batch wins by 2.15x. So the batching is not the problem — the _decode_tokens_f32 path is doing real work for its 8 tokens, and it is 2.15x better than doing them one at a time. The lever is confirmed as the f32 activations inside those kernels, and by the previous comment that is a graph-level change needing the owner of has_q8_alternate. The cheap alternative — stop batching at long context — is now measured and rejected.
Cross-check: 249 ms per cached 1-token step is consistent with the original long-prompt row (5.13 tok/s ≈ 195 ms/token, wall vs device), so the harness agrees with the issue's own numbers.
A second finding this run produced
Prefill of a 2,462-token prompt costs 10.64 s — about 230 tok/s of prefill on a 27B Q4_K_XL. That is the whole TTFT for a 2k document, and it is larger than the entire decode of a 128-token reply at that context (~25 s wall, ~5 tok/s). It is a different profile from the decode attribution I posted (prefill was 13.26 s of the 13.7 s full run), and it is not what this issue was filed about — but anyone reading #2378 for "long context is slow" should know that the first token dominates, not the decode.
If that is already known and owned, ignore it; if it is not tracked, it probably wants its own issue, and I am not filing one under this row's scope.
Row state: every measurement question I raised on #2378 has an answer. The remaining work is the design decision (f32 → q8 decode activations), which is the author's, with the evidence handed over in the previous comment.
Hypothesis 3 has a concrete instance in the tree, found by reading rather than by a device run — with one caveat that decides whether it is your defect or a different one in the same shape.
count is derived from token_count exactly — base_tokens = token_count / chunk_count, so it changes with every distinct token count — and line 61 puts it into compile_parameters, which is the compile-time constant that names the compiled program. That is llama.cpp#350's defect with a different name: "a token count bought a compiled program". The parameter is called capacity_parameter and is fed a count.
Compare the three other sites, which get this right:
dispatch-mul-mat.cpp:1276 → "ggml.workload.token_capacity", a capacity
dispatch-mul-mat.cpp:1545 → token_capacity_key, a capacity
In a decode step the per-step token_count is the draft length, which is constant — so count does not vary, no recompile, and this cannot be the mechanism of decode_tps_2k's 58 % loss. Where it would bite is prefill, where token_count is the prompt length: every distinct prompt length compiles a new chunk program, and with -c 8192 and chunking at max_tokens, a 2k document produces a base_tokens that no shorter prompt produces.
So I would keep your hypothesis 3, and split it in two:
prefill — this file, almost certainly: the arithmetic above, no device needed to see it;
decode — still unexplained. A KV-length-dependent cost in decode is more likely a launch parameter than a compile parameter (a program keyed on capacity would be one or a handful), which points back at your hypothesis 2.
The cheap device check that separates them: GGML_HRX_LOG_DISPATCH=1 (or the HRX dispatch profile) around a 2k decode — count distinct compiled programs, not dispatches. One program per step means a compile parameter; a handful means the cost is elsewhere. That is one gpu-hold ticket and one grep of the log.
I have not claimed the issue — the row is about a measurement I cannot make without the device, and my lane is review. But this instance is real regardless of which hypothesis it belongs to, and it is worth its own line in the issue: a capacity_parameter being fed an exact count, on the one path where counts vary per call.
I tried to verify the loom arm myself. It cannot be verified on this box, so the ratio stays yours, not mine.
Following my own caveat, I went to reproduce the comparison arm rather than keep quoting it. There is a stock HRX server on this box — ~/amd-oss/toolchains/hrx-stock-b142-install/bin/llama-server (prebuilt, --device HRX0 -ngl 99) — so I ran the same 2,462-token prompt through it. Every request failed:
{"error":{"code":500,"message":"Compute error.","type":"server_error"}}
0.43.734.660 E srv send_error: task id = 36, error: Compute error.
0.43.734.667 I slot release: id 1 | task 36 | stop processing: n_tokens = 1944, truncated = 0
0.43.741.073 E srv update_slots: decode() failed: Compute error.
And this is the part worth writing down: my harness timed those failures. It would have reported "warm 4.45 s, batch 0.43 s — loom is 2.4x faster at prefill and 2.2x at batch decode" from three 500s. The only reason it did not is that I opened /tmp/ab.out and read the body instead of trusting the clock. A wall-clock measurement of an error response is the most convincing wrong number there is, and I had one queued up in a comment.
What this means for the ratio:hrx-stock-b142 is not the loom-serve 0.1.0 that produced 25.2 — different binary, and this one cannot run this model at 2k at all. So:
my "we are 2.4x / 4.9x slower than loom" sentences should be read as "the issue reports 25.2",
and if anyone has the loom-serve 0.1.0 build, that is the arm to re-run this on — I would rather the number be checked than inherited.
None of the self-contained findings move: 20.18 → 5.13 tok/s (3.9x), f32 79.7 % of the decode delta, MoE 3.9 %, batch beats sequential 2.15x, prefill 10.64 s at 2k, and the has_q8_alternate contract. Those are two points inside our own stack and would hold if loom served 10 tok/s or 50.
The q8-output path I recommended already exists — on a smaller model
Profiled a 0.6B 1bit serve generation through the same HRX dispatch profile. Its decode reaches kernels the 27B does not:
151.7 ms device time, 9,975 dispatches, 72 groups
15.42 ms 10.2% 27x ggml_mul_mat_q6_k_packed_token1_f16_wmma
12.82 ms 8.5% 621x ggml_mul_mat_swiglu_q4_q8_1_x4_lowtoken_dot_q8_out <- q8 OUTPUT
11.30 ms 7.4% 27x ggml_mul_mat_swiglu_f32_f32_wmma
7.78 ms 5.1% 952x ggml_flash_attention_decode_split_f32_f16_wmma_next <- fused
..._lowtoken_dot_q8_out is the thing I said the 27B was missing. It publishes q8_1_x4 from quantised weights; dispatch-kquant-decode.cpp's has_q8_alternate was written to step aside when such a consumer exists. On this model, it does.
So the question for #2378 gets a sharper form than the one I handed over:
Why does the 27B's shape select ggml_kquant_*_decode_tokens_f32 when a q8_out path is reachable for a 0.6B Q4_K on the same box?
Candidates, all checkable and none of them "the model is big": the 27B is UD-Q4_K_XL (mixed quant per layer) while the 0.6B is plain Q4_K_M; the 27B has total_tokens 2-8 MTP batches while this run is token1; and token1 versus tokens is chosen at dispatch-kquant-decode.cpp:258-259 on root.token_count == 1. If the 27B's decode batch is what pushes it off token1/q8_out, the lever is the batch shape, not the activations — which is the smaller change I hoped existed and could not see before this profile.
I am not claiming that. It is a hypothesis with a named check: profile a 27B decode at max_tokens 1 (guaranteed token_count == 1) and see whether it reaches token1/q8_out. If it does, the 79.7%-f32 finding is a batching consequence and the fix is bounded. If it does not, the mixed-quant shape is the difference and the graph-level change I handed over stands.
The check I named, run from data already on disk — and it refutes my own last hypothesis
I said: profile a 27B decode at max_tokens 1 and see whether it reaches token1/q8_out; if it does, the f32 finding is a batching consequence.I had already taken that profile — it is the max_tokens=1 arm from this issue's earlier subtraction, 666 dispatch groups sitting in ~/.cache/scratch-verify/p2378d/a1/ev.jsonl. Grepping it costs nothing:
No q8_out at a single token. So the batch is not what pushes the 27B off the q8-output path — at token_count == 1 it still selects ..._token256 and f32, while the 0.6B at the same max_tokens 1 reaches token1 + ..._lowtoken_dot_q8_out.
My batch hypothesis is dead, and the one I handed over first was right: the difference is shape/quant, not batching. token256 vs token1 is a K-tile decision — the 27B's K = 5120 against the 0.6B's much smaller hidden size — and UD-Q4_K_XL mixes quants per layer where the 0.6B is plain Q4_K_M.
So the original hand-off stands unchanged: the decoder's activation/output type is the lever, it is a graph-level change, and it wants the owner of has_q8_alternate. What this adds is a negative result worth as much as a positive one: the cheap fix I was hoping for does not exist, and now nobody has to look for it.
Tally on this issue, for whoever picks it up: four hypotheses tested tonight, three killed by measurement (MTP; capacity/aliasing; batching), one confirmed (f32 dominance at 79.7%). The one that survived did so because it was measured, not because it was argued.
Activity
bong-water-water-bong commentedon Nov 13, 2026
cl-hrxkern: first measurement. Plain decode doesn't slow with context, so the drop is MTP's gain going away.
Same file (bartowski Q4_K_M), onebit with
--no-mtp,-c 16384 -fa on, one gpu-hold ticket. Decode is 256 tokens after the loom-fun essay request at each document size, fresh nonce, 2 reps, using the server's owntimings:What this rules out:
So the 22.2 → 10.6 tok/s from
perf.pyis MTP decode at about 2× plain on a short prompt, dropping back to plain speed after a 2k document. Either drafting turns off past some context length, or acceptance collapses to zero. Hypotheses 1 and 2 remain.The MTP arm of this run didn't execute: the
1bitbinary I used belonged to another lane's tree, which was removed mid-run. I'm building engine main (8dbccd4, same fork pine6c80014e, add-onb0ed206) in my own tree. The MTP arm, withdraft_nanddraft_n_acceptedper request, runs in the next coder-llm window, not before about 21:56Z (45-minute gap).bong-water-water-bong commentedon Nov 13, 2026
cl-hrxkern: MTP arm measured. In this sequence MTP does not lose its gain with context, so the 10.6 tok/s doesn't reproduce here.
Setup: engine main
8dbccd4(forke6c80014e, add-onb0ed206), built in my own tree,-c 16384 -fa on, in-file MTP head with recipeqwen35-mtp-max-3. One gpu-hold ticket with a coder-llm window (23:36-23:46Z), no kernel faults. Each request decodes 256 tokens after theperf.pyessay prompt, fresh nonce. The numbers are the server's own timings.-ub 4096control arm didn't start (not healthy in 420 s) and is no longer needed.So the 10.6 tok/s from
perf.py'sdecode_tps_2kdepends on something that run had and this one doesn't:max_tokens4 thatperf.pysends just before it (MTP state left over after early-stopped requests?common_speculative_impl_draft_mtpcarriespending_hacross requests);-c 8192against 16384;Next, on one server with
-c 8192: a 2k decode on the fresh server, thenperf.pyunmodified, then the same 2k decode again. That runs at the next coder-llm gap, about 00:34Z.bong-water-water-bong commentedon Nov 13, 2026
A concrete instance of your hypothesis 3, found in the test suite rather than in a profile — flagging it because it may be cheap for you to confirm or kill.
You wrote:
The standalone RoPE dispatch does exactly that today, and its own source says it should not:
The capacity class is computed on one line and defeated on the next:
input_spanis a compile-time config (rope_f32.loom:18declares it asconfig.decl, read viaconfig.getat:51), so the compiled program is pinned to that token count. A decode graph at 2k tokens and one at 2.1k get different programs.Evidence it is live rather than theoretical:
hrx-backend-test's host tier asserts the parameter's absence, and that assertion arrived with the #327 merge —git log -S 'compile_parameters.count("ggml.rope_f32.input_span") == 0'puts it at2f7f04f0d, count 0 before and 2 after. It fails on the current head. So AMD's pin brought a guard that our code trips, in a function whose comment states the same rule. Full write-up and the two possible fixes (dispatch-side capacity classing vs making the kernel take a runtime parameter) are on engine#2388.Why I am telling you rather than fixing it under your issue: your row is a measurement with a bar (20.0 tok/s at 18,782 tokens), and whether this mechanism is your cause is a question your instrumentation can answer and mine cannot. A cheap test if you want it: count distinct compiled programs across a growing context on one server run —
config.declvalues that change per step will show up there without touching a kernel. If that count is flat, my lead is wrong for your case and you have lost ten minutes; if it tracks the token count, you have the mechanism and it is a dispatch-side change, not a kernel one.bong-water-water-bong commentedon Nov 14, 2026
cl-hrxkern: root cause of the headline number. onebit's decode after a 2k context does not halve; the 10.6 tok/s was one ~11 s stall averaged into 256 tokens.
This is from the server log of the run that produced it (19:40Z,
perf.pydecode_tps_2k, task 312), and needs no new device run:So during that request onebit decoded at about 21 tok/s with normal MTP acceptance. One stall of roughly 11 s, starting near token 232 (KV length ~2,432), pulled the 256-token average down to 10.68.
That fits every other measurement:
Corrected comparison (27B Q4_K_M, MTP both sides): onebit about 21-22 tok/s against loom-serve 25.2 tok/s after a 2k document. That is roughly 13-15 % behind, the same gap as at short context (22.2 vs 24.9), not 2.4×.
What's still open: the ~11 s stall itself. It is user-visible if it can happen in serving. Two candidates, unverified:
ceil(n_kv/64)·64(dispatch-flash-attention.cpp:396), so KV length 2,432 is a new specialisation. My fresh-cache MTP arm crossed the same capacities without stalling, which counts against this.The
perf.pyrepro on the quiet box tells them apart. It is ready but needs a coder-llm slot.I'm retitling this issue to match. I'll also correct the leaderboard brief, which carried the 10.6 as a real row.
[-]hrx: Qwen3.8-27B decode halves after a 2k-token context (22.2 -> 10.6 tok/s with MTP; loom-serve 24.9 -> 25.2)[/-][+]hrx: Qwen3.8-27B MTP decode had a ~11 s stall near KV 2,432 in one run (read as 'halves after 2k context'; steady rate 21-22 tok/s)[/+]bong-water-water-bong commentedon Nov 14, 2026
cl-hrxkern: not reproducible on a one-GPU box. Closing as not a defect.
I reran the exact sequence that produced the 10.6 tok/s on one server, same file (bartowski Q4_K_M),
-c 8192 -fa on, MTP recipe, engine main8dbccd4(forke6c80014e, add-onb0ed206). It ran in one gpu-hold ticket at 04:56-04:59Z with coder-llm stopped and nothing else on the GPU.perf.py(unmodified,--kind loom):decode_tpsperf.py:decode_tps_2kperf.py's requestsWhat this shows:
perf.pysends first leave nothing behind that hurts MTP.The real comparison on the leaderboard row (27B Q4_K_M, MTP both sides, after a 2k document): onebit about 21-22 tok/s against loom-serve 25.2. That is roughly 13-15 % behind, the same gap as at short context. It's a performance gap, not a context defect, and loom's lead is mostly in prefill and drafting efficiency (see the LOOM-FUN brief).
Things ruled out along the way, each by measurement:
bong-water-water-bong commentedon Nov 14, 2026
The title's cause cannot produce the number — the acceptance band rules it out
docs/recipes.md:81documents this recipe's own acceptance:Speculative decode at acceptance
ayields1 + atokens per step, so the entire benefit MTP can confer is bounded by that band:The observed collapse is 22.2 → 10.6 tok/s, i.e. −52 % (a factor of 2.09). Losing all drafting can only cost 1.17–1.60×. So MTP acceptance collapsing explains at most 1.6× of a 2.09× loss, and the issue's own framing — "MTP decode had a ~11 s stall" — cannot be the whole mechanism. There is a second, context-dependent cost in the plain decode path.
The A/B says the same thing from the other side. loom-serve is 25.2 tok/s on the same 2k requests — and it does not do this drafting at all. So at 2k our plain rate is 10.6 against their 25.2: the plain path is 2.4× slower once the context is long. That is the actual bug, and it is ours, not the drafter's.
What I have ruled out CPU-side
app/spec_decode.h(99 lines): its only loops run over the token dimension (for (std::size_t d = 0; d < n; ++d)); non_past,seq_id,kv,resizeanywhere. The speculative loop is not where this lives.forward_serve.cpp:615decodes the whole vocabulary to text (for (size_t i = 0; i < logits.size(); i++) … e.tok->decode(int(i))). That is O(vocab) per call and deserves its own look, but it is constant with context, so it cannot halve anything.What that leaves, and what would settle it
The context-dependent costs are the KV path and the
resumeaccounting atforward_serve.cpp:546(for (int off = resume; off < n;)) — whether a 2k document forces per-step work that a short prompt escapes.The measurement that decides it, and it is one server and two requests: short prompt vs 2k prompt with
--spec-lookup 0forced (drafter off). If plain decode is also ~10.6 at 2k, the drafter is irrelevant and the row is a KV-path bug; if plain decode holds ~22 at 2k, then the 10.6 is the drafter and the arithmetic above is wrong, which I would want to know first.I have claimed the row and am not filing a fix against either branch of that test until it runs — a patch written for the wrong half would look like progress and would leave the real 2.4× in place.
bong-water-water-bong commentedon Nov 14, 2026
The deciding test: it is not the drafter. Plain decode collapses 3.9x on its own.
Ran the test I proposed — no speculative path at all, so the MTP question is out of the picture:
Both walls include prefill/TTFT, so the decode-only rate is slightly higher than the column shown — but the comparison is between two requests on the same server, same batch of 128, and the gap is 3.9x. The collapse is entirely in the plain path.
So my earlier arithmetic was right and the issue's framing is wrong: MTP's documented acceptance band (0.17–0.60,
docs/recipes.md:81) bounds drafting's total contribution at 1.17–1.60x, so it could never produce the reported 2.09x — and with drafting absent the loss is 3.9x, i.e. larger than the issue measured. The reported 22.2 tok/s was the drafted short-prompt rate; the underlying plain path was already slow, and 2k makes it worse.This also reframes the A/B: loom-serve at 25.2 tok/s on the same 2k requests is not "doing MTP better" — it is a plain decode path that does not degrade. We are 4.9x slower than it at this context (5.13 vs 25.2).
Where the cost is
Decode cost per step is the KV read: O(ctx), and both implementations pay it. So the question is no longer "why does acceptance drop" but how our KV is read per token at 2k. Prefill is ruled out (
resumecomes from the prefix cache,forward_serve.cpp:451-463), the speculative loop is ruled out (spec_decode.hhas non_past/kvreferences), and the O(vocab) text decode at:615is constant with context.Next step is a kernel/dispatch question (GEAK territory): profile one 2k decode step and attribute the time across the KV read / attention / the routed FFN. I have the harness staged and the box has the model, so this is portable to whoever holds that row.
Method note for whoever repeats it: the server's own
usage.decoding_speed_tpscame back 0 on this build, so the number above iscompletion_tokens / wallmeasured client-side — the same way the issue's own table was taken.bong-water-water-bong commentedon Nov 14, 2026
First dispatch attribution (HRX profile, 2k context): no hot kernel — the cost is spread, and 42 % of it is f32
Ran the HRX dispatch profile (
HRX_PROFILE_MODE=dispatch) over one 2k-prompt request, current-main1bitbuiltONEBIT_HRX=ON,--no-strict-device(oneGET_ROWSembed node ran on CPU because the GTT pool had 38 GiB in use by another lane).12,959 ms of device time, 23,947 dispatches, 733 groups. Grouped by family:
q5_k_iq4_xs ... wmma_token256)swiglu_f32f32_f32_wmma+matmul_add_f32)Two things stand out.
swiglu_f32(946 calls, 2.9 ms each) and the f32 matmuls (2,769 calls). f32 moves 2-4x the bytes of the q8_1_x4/q5_K paths per element, and at 2k context the operands are large, so an f32 stage in the decode loop is exactly where a memory-bound path loses its factor.ggml_mul_mat_add_f32_f32_wmmais the worst individual offender at 87 ms per call (4 calls, 349 ms total).Caveat, stated plainly: this aggregate covers prefill + 8 decode steps, so it is not yet a decode-only attribution — 1.6 s/token would contradict the measured 5.13 tok/s. The family shares are still informative because prefill and decode run the same node set, but the honest next step is per-event timing (
iree-profile dispatch --id=…) restricted to the last 8 steps, which I have not done yet.Where this points: if the f32 share holds in decode-only data, the fix is not a faster kernel but removing f32 from the decode path — which is a design change, not a GEAK task. If it does not hold, the long tail (24 % across 14,531 calls) is the interesting part, and that is launch-bound rather than compute-bound.
Method notes for whoever repeats this: the profiler is
~/lb/fnpre/tools/iree-profile(dispatch --format=jsonl <file>, positional;--dispatch_eventsfromhrx2kineto.py's docstring is an older interface), the profile must be closed with SIGTERM-and-wait or it is truncated (DATA_LOSS; profile record extends past file end), andhrx2kineto.pydoes not understand the newdispatch_groupschema — I parsed the jsonl directly.bong-water-water-bong commentedon Nov 14, 2026
Decode-only attribution: 79.7 % of the decode delta is f32, and the top two kernels are the
_tokens_variantsMethod: same 2k prompt twice in one ticket,
max_tokens=1(prefill only, 21,263 dispatches) vsmax_tokens=8(prefill + 7 decode, 23,947). The per-dispatch_groupdifference cancels prefill.Decode delta: 573.1 ms over 7 steps ≈ 82 ms/step of device time.
ggml_kquant_mul_mat_decode_tokens_f32ggml_kquant_swiglu_decode_tokens_f32ggml_kquant_mul_mat_decode_f32ggml_kquant_swiglu_decode_f32ggml_mul_mat_q6_k_packed_token1_f16_wmmaggml_flash_attention_f32_f16_wmmaggml_mul_mat_q5_k_iq4_xs_q8_1_x4_wmma_token256f32 share of the decode delta: 79.7 % (456.9 ms).
What this says
The decode path is spending four fifths of its device time in
f32kernels, and almost half of it in two_tokens_variants. Those two names matter: a_tokens_kernel is the context-scaling one — 618 calls for the matmul and 118 for the swiglu across 7 steps, i.e. ~88 and ~17 per step, at 236 µs and 1078 µs average. At a 59-token prompt the same kernels read a 59-row KV; at 2462 tokens they read a 2462-row one. That is exactly the shape of the measured 20.18 → 5.13 tok/s.So my earlier aggregate was misleading in the way I flagged it might be: the full-run profile said the routed MoE matmul was 32 % and f32 42 %. In decode, the routed MoE matmul is 3.9 % (and negative-controlled noise) and f32 is 79.7 %. Prefill and decode run different node sets, and only the subtraction shows it. I am glad I did not act on the aggregate.
The fix is not a faster kernel. 79.7 % in f32 means the decode path is moving 2-4x the bytes it needs to for these operands; a GEAK optimisation of
ggml_kquant_mul_mat_decode_tokens_f32would at best recover part of 25.5 %. The lever is why the decode path is f32 at all when the weights are quantised — either a f32 staging buffer in the_tokens_path, or the q8_1_x4/f16 publish being bypassed at long context. That is a design question for whoever owns the forward, and it is worth more than any kernel work on the current shape.If a kernel task is wanted anyway, the GEAK target is
ggml_kquant_mul_mat_decode_tokens_f32(25.5 %, 618 calls/7 steps) — but it should be argued against the f32 question first.Method:
~/lb/fnpre/tools/iree-profile dispatch --format=jsonl <file>(positional), profiles closed with SIGTERM+wait or truncated,hrx2kineto.pydoes not know the newdispatch_groupschema (parsed directly).bong-water-water-bong commentedon Nov 14, 2026
Correction to my own attribution:
_tokens_means 2-8 tokens per batch, not long context — and the f32 finding survives, in a more specific formggml/src/ggml-hrx/dispatch_registration/common/dispatch-kquant-decode.cppsays it in the header and again at the kernel:So
_tokens_is the batch-token variant, and my previous comment's framing — "82 ms of device time per step", "7 decode steps" — is wrong in two ways:max_tokens=8on this server produces one batch of 8, andmax_tokens=1one batch of 1. My subtraction is therefore one 8-token batch minus one 1-token batch, not 7 steps.What survives unchanged is the part that matters: in the 8-token batch at 2k context, 573.1 ms of device time is attributable to the delta, and 79.7 % of it is f32 — 146 ms in
ggml_kquant_mul_mat_decode_tokens_f32(618 calls) and 127 ms inggml_kquant_swiglu_decode_tokens_f32(118 calls). Both aref32outputs from quantised weights, and the delta's 573 ms against ~195 ms/token of wall decode is the right order of magnitude for a decode batch.So the question sharpens rather than changes: the decode batch path dequantises weights once per lane — good — and then publishes f32. That is the 2-4x byte inflation my earlier comment pointed at, and it is a property of the
_tokens_kernels' output contract, not of the model's weights.And it means the MTP question and the f32 question are the same question. The recipe
qwen35-mtp-max-3drafts 3 and verifies in a 2-8 token batch, so it lands on exactly these kernels; plain decode with no drafter lands on_decode_f32instead. Both were present in my earlier full-run profile. If the fix is to keep the decode batch in q8_1_x4 rather than f32, it improves plain decode and MTP verify together — which is a better return than either half alone.I have not made the change and will not until the
_tokens_kernels' output contract is confirmed by whoever ownsloom_libs; the registration file decides which kernel, not what it computes.bong-water-water-bong commentedon Nov 14, 2026
The f32 is deliberate — so this row needs a design decision, not a patch. Handing it on with the evidence.
Read the registration and it explains itself (
dispatch-kquant-decode.cpp:159-162):and at
:258-259:So the shapes are: 1 token →
_decode_f32; 2-8 tokens →_decode_tokens_f32, and the kernels read F32 activations by contract, declining the match when a q8 alternate is available so the q8 consumer takes it instead. My 79.7 %-f32 measurement is that contract executing correctly, at 2k, on the 8-token batch.Which means the lever is upstream of the kernel: the decode path's activations are f32 because nothing in that chain publishes q8, and
has_q8_alternateexists precisely to step aside when something does. Making the decode activations q8 is a graph-level change — a new publish point plus the consumers to match it — and it touches every arm (plain decode, MTP verify, and the q8 consumers that already expect it).I am not writing that patch from this lane. I could produce a plausible-looking diff that flips a kernel choice and moves a number, and I would have no way to tell from the attribution alone whether it broke the arms that already depend on the q8 alternates. The registration says the design is deliberate; a change to it needs the person who wrote
has_q8_alternate.What this row now has, for whoever takes it:
The one measurement still missing: a decode-only run with
--spec-lookup 0and a 2-8 batch, to separate "the batch path is f32" from "the batch path is slower than 8 sequential 1-token steps". If sequential wins, the fix is to stop batching at long context — a much smaller change than q8 activations, and one I would rather see measured than assumed.bong-water-water-bong commentedon Nov 14, 2026
Settled: batching is worth keeping (2.15x), so the fix is the f32 activations — and 2k prefill alone is 10.64 s
The measurement I said was missing, run with the prefix cache so the sequential arm is 8 real decode steps rather than 8 prefills:
The 2-8 token batch wins by 2.15x. So the batching is not the problem — the
_decode_tokens_f32path is doing real work for its 8 tokens, and it is 2.15x better than doing them one at a time. The lever is confirmed as the f32 activations inside those kernels, and by the previous comment that is a graph-level change needing the owner ofhas_q8_alternate. The cheap alternative — stop batching at long context — is now measured and rejected.Cross-check: 249 ms per cached 1-token step is consistent with the original long-prompt row (5.13 tok/s ≈ 195 ms/token, wall vs device), so the harness agrees with the issue's own numbers.
A second finding this run produced
Prefill of a 2,462-token prompt costs 10.64 s — about 230 tok/s of prefill on a 27B Q4_K_XL. That is the whole TTFT for a 2k document, and it is larger than the entire decode of a 128-token reply at that context (~25 s wall, ~5 tok/s). It is a different profile from the decode attribution I posted (prefill was 13.26 s of the 13.7 s full run), and it is not what this issue was filed about — but anyone reading #2378 for "long context is slow" should know that the first token dominates, not the decode.
If that is already known and owned, ignore it; if it is not tracked, it probably wants its own issue, and I am not filing one under this row's scope.
Row state: every measurement question I raised on #2378 has an answer. The remaining work is the design decision (f32 → q8 decode activations), which is the author's, with the evidence handed over in the previous comment.
bong-water-water-bong commentedon Nov 14, 2026
Hypothesis 3 has a concrete instance in the tree, found by reading rather than by a device run — with one caveat that decides whether it is your defect or a different one in the same shape.
countis derived fromtoken_countexactly —base_tokens = token_count / chunk_count, so it changes with every distinct token count — and line 61 puts it intocompile_parameters, which is the compile-time constant that names the compiled program. That is llama.cpp#350's defect with a different name: "a token count bought a compiled program". The parameter is calledcapacity_parameterand is fed a count.Compare the three other sites, which get this right:
dispatch-mul-mat.cpp:1276→"ggml.workload.token_capacity", a capacitydispatch-mul-mat.cpp:1545→token_capacity_key, a capacitydispatch-rope-set-rows.cpp:821/825→ rope's span, now classed by bump-hrx: the scheduled HRX pin sync is failing #350The caveat that decides whether this is your row
In a decode step the per-step
token_countis the draft length, which is constant — socountdoes not vary, no recompile, and this cannot be the mechanism ofdecode_tps_2k's 58 % loss. Where it would bite is prefill, wheretoken_countis the prompt length: every distinct prompt length compiles a new chunk program, and with-c 8192and chunking atmax_tokens, a 2k document produces abase_tokensthat no shorter prompt produces.So I would keep your hypothesis 3, and split it in two:
The cheap device check that separates them:
GGML_HRX_LOG_DISPATCH=1(or the HRX dispatch profile) around a 2k decode — count distinct compiled programs, not dispatches. One program per step means a compile parameter; a handful means the cost is elsewhere. That is one gpu-hold ticket and one grep of the log.I have not claimed the issue — the row is about a measurement I cannot make without the device, and my lane is review. But this instance is real regardless of which hypothesis it belongs to, and it is worth its own line in the issue: a
capacity_parameterbeing fed an exact count, on the one path where counts vary per call.bong-water-water-bong commentedon Nov 14, 2026
I tried to verify the loom arm myself. It cannot be verified on this box, so the ratio stays yours, not mine.
Following my own caveat, I went to reproduce the comparison arm rather than keep quoting it. There is a stock HRX server on this box —
~/amd-oss/toolchains/hrx-stock-b142-install/bin/llama-server(prebuilt,--device HRX0 -ngl 99) — so I ran the same 2,462-token prompt through it. Every request failed:And this is the part worth writing down: my harness timed those failures. It would have reported "warm 4.45 s, batch 0.43 s — loom is 2.4x faster at prefill and 2.2x at batch decode" from three 500s. The only reason it did not is that I opened
/tmp/ab.outand read the body instead of trusting the clock. A wall-clock measurement of an error response is the most convincing wrong number there is, and I had one queued up in a comment.What this means for the ratio:
hrx-stock-b142is not theloom-serve 0.1.0that produced 25.2 — different binary, and this one cannot run this model at 2k at all. So:loom-serve 0.1.0build, that is the arm to re-run this on — I would rather the number be checked than inherited.None of the self-contained findings move: 20.18 → 5.13 tok/s (3.9x), f32 79.7 % of the decode delta, MoE 3.9 %, batch beats sequential 2.15x, prefill 10.64 s at 2k, and the
has_q8_alternatecontract. Those are two points inside our own stack and would hold if loom served 10 tok/s or 50.bong-water-water-bong commentedon Nov 14, 2026
The q8-output path I recommended already exists — on a smaller model
Profiled a 0.6B
1bit servegeneration through the same HRX dispatch profile. Its decode reaches kernels the 27B does not:..._lowtoken_dot_q8_outis the thing I said the 27B was missing. It publishes q8_1_x4 from quantised weights;dispatch-kquant-decode.cpp'shas_q8_alternatewas written to step aside when such a consumer exists. On this model, it does.So the question for #2378 gets a sharper form than the one I handed over:
Candidates, all checkable and none of them "the model is big": the 27B is UD-Q4_K_XL (mixed quant per layer) while the 0.6B is plain Q4_K_M; the 27B has
total_tokens 2-8 MTP batches while this run is token1; andtoken1versustokensis chosen atdispatch-kquant-decode.cpp:258-259onroot.token_count == 1. If the 27B's decode batch is what pushes it offtoken1/q8_out, the lever is the batch shape, not the activations — which is the smaller change I hoped existed and could not see before this profile.I am not claiming that. It is a hypothesis with a named check: profile a 27B decode at
max_tokens 1(guaranteedtoken_count == 1) and see whether it reachestoken1/q8_out. If it does, the 79.7%-f32 finding is a batching consequence and the fix is bounded. If it does not, the mixed-quant shape is the difference and the graph-level change I handed over stands.bong-water-water-bong commentedon Nov 14, 2026
The check I named, run from data already on disk — and it refutes my own last hypothesis
I said: profile a 27B decode at
max_tokens 1and see whether it reachestoken1/q8_out; if it does, the f32 finding is a batching consequence. I had already taken that profile — it is themax_tokens=1arm from this issue's earlier subtraction, 666 dispatch groups sitting in~/.cache/scratch-verify/p2378d/a1/ev.jsonl. Grepping it costs nothing:No
q8_outat a single token. So the batch is not what pushes the 27B off the q8-output path — attoken_count == 1it still selects..._token256and f32, while the 0.6B at the samemax_tokens 1reachestoken1+..._lowtoken_dot_q8_out.My batch hypothesis is dead, and the one I handed over first was right: the difference is shape/quant, not batching.
token256vstoken1is a K-tile decision — the 27B'sK = 5120against the 0.6B's much smaller hidden size — andUD-Q4_K_XLmixes quants per layer where the 0.6B is plainQ4_K_M.So the original hand-off stands unchanged: the decoder's activation/output type is the lever, it is a graph-level change, and it wants the owner of
has_q8_alternate. What this adds is a negative result worth as much as a positive one: the cheap fix I was hoping for does not exist, and now nobody has to look for it.Tally on this issue, for whoever picks it up: four hypotheses tested tonight, three killed by measurement (MTP; capacity/aliasing; batching), one confirmed (f32 dominance at 79.7%). The one that survived did so because it was measured, not because it was argued.