Repository navigation
ggml-hrx: 256-expert MoE routing layout, and claim fused-only nodes (Qwen3.6-35B-A3B on HRX0) - #1
Merged
bong-water-water-bong merged 2 commits intoSep 25, 2026
Conversation
…xperts Qwen3.6-35B-A3B (256 experts) faulted on HRX0 on every prompt batch of two or more tokens (HSA_STATUS_ERROR_MEMORY_FAULT, "failed to decode prompt batch"). Single-token decode worked. The MoE router fusion (llm.moe_router.top8_f32) builds the expert partition table with the Qwen descriptor layout for every expert count: 7-bit expert mask, shifts 7 and 13, 128 lanes. For 256 experts the builder masked expert ids to 7 bits and gave experts 128 and up no partitions. The table goes to the common mul_mat_id kernels, which decode the common layout (9-bit expert, shifts 9 and 15, hard-coded in ggml_moe_unpack_expert_partition_descriptor). They read (row_count - 1) bits as a partition ordinal, so an expert with two or more tokens pointed past its expert-table row. The serial trace put the fault in ggml.mul_mat_id_swiglu (gate/up) of layer 27 at p=2. The router now picks the layout by expert count: the Qwen layout up to 128 experts (the qwen3_moe routed kernels, which only match 128 experts, keep their input), the common layout above. The choice lives in the new header dispatch-moe-routing-layout.h; dispatch-moe-router.cpp only calls it. The same tables fed single-token decode, which ran but skipped experts 128 and up: teacher-forced KLD against Vulkan0 with -ub 1 was 15.3 (PPL 1.8e7). With this change it is 0.0026, and tg128 goes from 40.7 to 34.5 tok/s, because decode now computes every selected expert. Qwen3.6-35B-A3B Q8_0 on HRX0 (router claimed, see the next commit): p=2, 8, 32, 512 and 2048 run; KLD against Vulkan0 0.0046 over 1024 tokens (ctx 512). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…raphs 61a5308 made device_supports_op claim a node only when can_execute_standalone_op_as_graph accepts it. Nodes that HRX runs only inside a fused pattern have no standalone dispatch, so they went to the CPU: - the MoE router chain SOFT_MAX, ARGSORT, GET_ROWS, SUM_ROWS, CLAMP; - L2_NORM, SOFTPLUS and GATED_DELTA_NET of the DeltaNet layers; - the per-head RMS_NORM and ROPE of the Qwen3.5/3.6 attention fusions. That split every MoE and DeltaNet layer. Qwen3.6-35B-A3B pp512 fell to 67 tok/s, and Qwen3-30B-A3B prompt decode failed ("value alias target 43 is not transient"). fused-context-claim.h keeps the per-op claim for these nodes when they have the producers of their fused pattern (router logits from MUL_MAT, ARGSORT fed by SOFT_MAX, and so on) and a 3-D shape, head-sized rows for RMS_NORM and ROPE. Nodes in test-backend-ops graphs do not have these producers or shapes, so the standalone test still applies to them. ggml-hrx.cpp gets a one-line hook. HRX0, fa on, llama-bench -r 3 (before -> after this commit): - Qwen3.6-35B-A3B Q8_0: pp512 141 -> 909, pp2048 156 -> 1028, tg128 14.1 -> 35.3; the whole graph is one HRX0 split. KLD against Vulkan0 (ctx 512, 1024 tokens) 2.63 -> 0.0046. Before, ctx 2048 with -b 2048 faulted. - Qwen3-Coder-30B-A3B Q4_K_M: pp512 1114 -> 2040, tg128 failed -> 89.4. - Qwen3-0.6B Q4_K_M: pp512 21938 -> 21789, tg128 322.5 -> 323.8 (unchanged). test-backend-ops -b HRX0: 790/790 passed. The first try, a claim for any node fed by another op, failed 17 ADD_RMS_NORM, RMS_NORM_MUL_ADD and RMS_NORM_MUL_ROPE cases (4-D shapes, 8192-wide rows), hence the shape limits. Co-Authored-By: Claude Opus 5.5 <[email protected]>
bong-water-water-bong
merged commit Sep 25, 2026
c075cc1
into
1bit/hrx-vulkan-patched
2 of 24 checks passed
bong-water-water-bong
added a commit
to 1bit-MONSTER/engine
that referenced
this pull request
Sep 25, 2026
…en3.6-35B-A3B) (#84) 1bit-MONSTER/llama.cpp#1 on 1bit/hrx-vulkan-patched (merge c075cc1, same tree as the tested 9a7aad6): 96049a2 writes the MoE router's partition table in the layout the mul_mat_id kernels decode once there are more than 128 experts (before: batches >= 2 faulted, decode was wrong, KLD 15.3 vs Vulkan), and 9a7aad6 claims the fused-only nodes (router chain, gated delta net, ...) instead of sending them to the CPU. Qwen3.6-35B-A3B Q8_0 on HRX0: pp512 141 -> 909, tg128 14.1 -> 35.3, KLD vs Vulkan 0.0046; Qwen3-Coder-30B-A3B decodes again (89.4 tok/s); Qwen3-0.6B unchanged; test-backend-ops -b HRX0 790/790. docs/hrx.md: the fix and the remaining known issues. Co-authored-by: bong-water-water-bong <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
bong-water-water-bong
pushed a commit
that referenced
this pull request
Nov 8, 2026
…se release() nulls slot.task (engine ggml-org#1489) A CLIP encode failure killed llama-server with SIGSEGV three milliseconds after it had already produced the error. Reproduced with a backtrace, and the frame names the site: Thread 1 received signal SIGSEGV #0 server_context_impl::pre_decode()::{lambda(server_slot&)#5}::operator()(server_slot&) #1 server_context_impl::iterate(std::vector<server_slot>&, std::function<void(server_slot&)>) #2 server_context_impl::pre_decode() #3 server_context_impl::update_slots() The failing path is the multimodal chunk loop in pre_decode(): process_mtmd_chunk() returns non-zero, the slot's error is sent, slot.release() runs - which does both "task_prev = std::move(task)" and "task.reset()", leaving slot.task null - and then "continue" re-enters that loop, whose first statement reads slot.task->n_tokens(). Null dereference, every time. Return instead: the slot has been released and must not be batched in this pass. Upstream master's equivalent handler does exactly that, with the comment "the slot is done, skip it entirely". No other site in this file releases a slot and then continues. Not verified by a rebuild in this lane: the tree here has no configured HRX build, and the only configured one on this box is a shared build tree whose rebuild is precisely the ggml-org#1403 incident (it swaps libraries under running services). The pre-fix crash is recorded with the full backtrace in engine ggml-org#1489; the post-fix acceptance is the issue's own - an HTTP error and a live process - which CI's build can run.
bong-water-water-bong
added a commit
that referenced
this pull request
Nov 8, 2026
…se release() nulls slot.task (engine ggml-org#1489) (#246) Same one-line fix as #245, cherry-picked onto 1bit/hrx-vulkan-patched -- the branch the engine actually pins. The bug site is identical on this branch (tools/server/server-context.cpp:3667-3670), so until this lands the pinned tree still dies on a failed CLIP encode. A CLIP encode failure kills llama-server with SIGSEGV three milliseconds after it has already produced the error. Reproduced with a backtrace, and the frame names the site: Thread 1 received signal SIGSEGV #0 server_context_impl::pre_decode()::{lambda(server_slot&)#5}::operator()(server_slot&) #1 server_context_impl::iterate(std::vector<server_slot>&, std::function<void(server_slot&)>) #2 server_context_impl::pre_decode() #3 server_context_impl::update_slots() The failing path is the multimodal chunk loop in pre_decode(): process_mtmd_chunk() returns non-zero, the slot's error is sent, slot.release() runs - which does both "task_prev = std::move(task)" and "task.reset()", leaving slot.task null - and then "continue" re-enters that loop, whose first statement reads slot.task->n_tokens(). Null dereference, every time. Return instead: the slot has been released, nothing is left to advance (the failed chunk was never added to the prompt or the cache), and it must not be batched in this pass. Upstream check, since the reviewer of #245 could not reach it from the fork tree: at upstream origin/master the equivalent handler does slot.release(); return; // the slot is done, skip it entirely (verified by fetching origin/master into a fork checkout and reading tools/server/server-context.cpp there; the honest caveat is that upstream has since refactored the chunk helper into free functions, so the surrounding code differs while the failure handling does not). No other site in this file releases a slot and then continues (checked on this branch). Not verified by a rebuild in this lane: this tree has no configured HRX build, and the box's only configured one is a shared build tree whose rebuild is precisely the ggml-org#1403 incident. The pre-fix crash is recorded with the full backtrace in engine ggml-org#1489; the post-fix acceptance is the issue's own - an HTTP error and a live process. Co-authored-by: bong-water-water-bong <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes for Qwen3.6-35B-A3B on HRX0. They fast-forward onto the pinned
79788e90. Our code is in two new files with the Apache notice; the AMD files only get small hooks.1. MoE router partition table (96049a2)
dispatch-moe-router.cpphard-coded the 128-expert routing descriptor (mask 127, shifts 7/13). The commonmul_mat_idkernels that read the table decode 511/9/15. With 256 experts:HSA_STATUS_ERROR_MEMORY_FAULT);Fix: the router picks the layout by expert count, in
dispatch_registration/common/dispatch-moe-routing-layout.h. Up to 128 experts nothing changes.2. Claim fused-only nodes in model graphs (9a7aad6)
Our commit 61a5308 only claims nodes that can run standalone, so these fell back to the CPU:
The effect: the 35B split per layer (KLD 2.63 against Vulkan), and the 30B-A3B could not decode.
fused-context-claim.hclaims these nodes when their fused pattern's producers are present and their shapes fit.Results (Strix Halo, fa on, -r 3)
Qwen3.6-35B-A3B Q8_0:
Qwen3-Coder-30B-A3B Q4_K_M:
test-backend-ops -b HRX0: 790/790.Still open (these predate this PR):
-fa off, and n_seq > 1.After merging, the engine pin (
third_party/llama.cpp, now 79788e9) can move to the new head.🤖 Generated with Claude Code