Repository navigation
ggml-hrx: run prompt batches above 512 tokens (engine #389) - #101
Conversation
Every -ub above 512 failed the first prompt batch of a Qwen3.5/3.6 (qwen35)
model with GGML_STATUS_FAILED (llama_decode ret -3). The HRX log line that
names the cause, "graph_compute: unsupported HRX node 2: L2_NORM
output=f32[128,16,1024,1] ... consumers=[GATED_DELTA_NET]", was hidden
because llama-bench drops every log line without -v.
Root cause: fused-context-claim.h claims L2_NORM / SOFTPLUS /
GATED_DELTA_NET for HRX at any token count, but the gated-delta-net
matchers only took token_count <= 512, so the scheduler placed a node that
no matcher could execute and the whole graph failed. SSM_CONV above 512
tokens had no HRX path either (its rollback/generic Loom kernels declare
n_t <= 512), so it went to the CPU: 97 graph splits per ubatch.
- ubatch-token-limits.h (new): shared bounds. The GDN WMMA kernels walk
16-token chunks with fixed LDS (token_count range up to 1048576), so the
GDN matchers now take up to 65536 tokens.
- dispatch-ssm-conv-chunked.{h,cpp} (new): a conv prefill above 512 tokens
runs as a chain of <= 512-token llm_ssm_conv_dconv4_silu_rollback_f32
dispatches per sequence; each passes its final 3-row conv history to the
next through a ping-pong transient, the last writes the cache slots. No
kernel change.
- fused-context-claim.h: the GDN claims carry the same bound; SSM_CONV fed
by CONCAT(state, x^T) is claimed up to it, so the graph stays on HRX
(27B ub 1024: 97 -> 1 graph split).
- graph-executor.cpp / ggml-hrx.cpp: the two early returns that could fail
without a message now log one, and an empty status prints a fallback.
- llama-bench: without -v, error-level log lines still reach stderr.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The SSM_CONV claim from the previous commit keyed on "fed by CONCAT", which Mamba/Mamba2 (Zamba2, Jamba, Granite-hybrid, Nemotron-H) graphs also build; they add a conv bias before SILU, which the CONCAT prefill matcher does not take, so above 512 tokens those nodes would be claimed with no matcher and fail the graph. A claim cannot see consumers, so it now also requires the names the delta-net conv builder gives these tensors (conv_input-N, conv_output_raw-N: qwen3next, qwen35, qwen35moe). Other conv layouts keep the standalone test and fall back to the CPU above 512 tokens, as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…n HRX
At -ub 4096 the 27B prefill matmuls go to the CPU (the prefill matmul
matchers stop at 2048 tokens: 712 graph splits), so the qkv projection
that the conv window transposes became a split input, the CONCAT matcher
no longer saw TRANSPOSE(x), and the claimed SSM_CONV failed the graph
("unsupported HRX node 11: SSM_CONV output=f32[10240,4096,1,1]").
fused_context_claim(op, supported) now also asks the backend's own
supports_op about the conv's x producer; the per-op claim in
device_supports_op passes it in. When x leaves HRX the conv falls back to
the CPU with it instead of failing.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
At -ub 4096 the next failure after the conv was the KV-cache SET_ROWS
(rows f32 [1024, 4096] into the f16 cache): the cache lives in HRX memory,
so the node cannot fall back to another backend, and the set_rows matcher
rejects token_count > 2048 (ggml.set_rows.token_capacity range [1, 2048]):
"SET_ROWS matcher rejected node: shape or rows layout is unsupported".
dispatch-row-chunks.{h,cpp} (new) splits a row-wise dispatch into equal
chunks of at most N rows over offset row/index bindings; the plain
SET_ROWS matcher takes up to kUbatchMaxTokens rows and uses it above 2048.
The fused ROPE+SET_ROWS matcher keeps its 2048 bound. The shared bound in
ubatch-token-limits.h is renamed kUbatchMaxTokens, as it now covers more
than the linear-attention matchers.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…unks A conv prefill of one sequence with one cache slot, 8192..10240 channels and a multiple of 512 tokens now runs AMD's 512-token pair per chunk (llm_ssm_conv_snapshot_window_tail_f32 + llm_ssm_conv_dconv4_silu_prefill _512_wg1024) instead of the token-serial rollback kernel. The snapshot kernel already writes the chunk's last 3 x rows as the conv history, so the chain passes it to the next chunk through a ping-pong transient and the last chunk writes the real cache. Partial ubatches and multi-sequence batches keep the rollback chain. No kernel change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Note on the |
|
Sharper statement of the one unverified line, after checking every recorded The description says Why nothing was caught: every recorded ub4096 failure used
One caution for anyone reading So the accurate version of that row is: |
ggml-hrx: run prompt batches above 512 tokens (engine #389)
Fixes #389.
Every
-ubabove 512 failed the first prompt batch of a Qwen3.5/3.6 (qwen35)model with
GGML_STATUS_FAILED(llama_decoderet-3).Root cause
fused-context-claim.hclaimedL2_NORM/SOFTPLUS/GATED_DELTA_NETfor HRXat any token count, but the gated-delta-net matchers only took
token_count <= 512. The claim decides placement, so the scheduler placed a nodethat no matcher could execute, and the whole graph failed:
SSM_CONVabove 512 tokens had no HRX path either: its rollback/generic Loomkernels declare
n_t <= 512, so it went to the CPU — 97 graph splits perubatch.
The log line naming the cause was invisible without
-v, becausellama-bench's null log callback discarded every line, including errors.That is fixed here too.
A second, independent face of the same defect appeared at
-ub 4096: the 27Bqkv projection went to the CPU (the prefill matmul matchers stop at 2048 tokens),
and the claimed
SSM_CONVfailed the graph. A claim cannot see its consumers, soa claim must also require the producers its matcher looks at to stay on this
backend.
Changes
ggml/src/ggml-hrx/ubatch-token-limits.h(new): shared token-count bounds,so the claim and the matchers cannot disagree again.
kSsmConvRollbackMaxTokens = 512,kSetRowsKernelMaxTokens = 2048,kUbatchMaxTokens = 65536.dispatch-ssm-conv-chunked.{h,cpp}(new): a conv prefill above 512 tokensruns as a chain of at most 512-token dispatches per sequence, each passing its
final 3-row conv history to the next through a ping-pong transient; the last
chunk writes the real cache.
dispatch-row-chunks.{h,cpp}(new): a KV-cache write cannot leave HRX (thecache lives there), so
SET_ROWSabove its 2048-token kernel range runs asseveral dispatches.
fused-context-claim.h: the GDN claim is bounded bykUbatchMaxTokens; theSSM_CONVclaim keys on the delta-net conv tensors' names (conv_input,conv_output_raw) so other conv layouts (Mamba's conv bias before SILU) keep thestandalone test and fall back to the CPU as before; and a second overload
fused_context_claim(op, supported)also requires the producers the matcherlooks at to stay on this backend.
llama-bench.cpp: the null log callback keepsGGML_LOG_LEVEL_ERRORand itscontinuation lines without
-v, so a failed decode says why.No kernel change.
Verification (Strix Halo, 2026-10-12)
5.7532 ± 0.16114on all three7.1431 ± 0.27993on both-ub 4096, Qwen3.8-27Bub 4096remains unverified by a run — the verification batch was aborted. ThisPR touches numerics, so it should carry the
hw-gatelabel before merge.