Skip to content

ggml-hrx: fix MoE partition encoding and routing above 128 experts - #153

Merged
AaronStGeorge merged 1 commit into
hrx-graph-develop-v2from
users/astgeorg/fix-moe-routing-descriptors
Oct 21, 2026
Merged

AaronStGeorge merged 1 commit into
hrx-graph-develop-v2from
users/astgeorg/fix-moe-routing-descriptors

Conversation

@AaronStGeorge

Copy link
Copy Markdown
Collaborator

Overview

Fix HRX inference for Qwen3.5-35B-A3B-MTP-GGUF, which faults during multi-token prefill and produces decode perplexity around 19.8 million in the failing run.

The router packs expert partitions using the legacy 7-bit expert layout, while the generic expert matmul reads a 9-bit layout. This turns valid descriptors into out-of-bounds row offsets. The router also launches only 128 partition-builder threads for a model with 256 experts.

Use a shared 9/6/5-bit expert/partition/row-count layout across generic and specialized consumers, including the fused partition producer, and launch one partition-builder thread per supported expert. Update compiler fixtures and CPU references together.

Add end-to-end router-to-matmul regressions for 128, 256, and 512 experts with 1, 2, and 512 tokens, including high expert IDs, multirow partitions, and graph replay.

Validation

Single-model, perplexity-only upstream gfx1151 run: PASS, with the model's expected-failure exemption removed. Artifact metadata confirms this fix commit and HRX runtime 4341b71ab812e618b92b016176528363718e6667.

Regime HRX perplexity Vulkan perplexity
Prefill: context/batch/ubatch 512, 32 chunks 5.4237 5.4282
Decode: context/batch 512, ubatch 1, 2 chunks 6.0322 6.0373

Local gfx1100 validation:

  • All 9 new regression cases pass; the 256-expert one-token regression fails with the original backend.
  • All 7 existing specialized MoE/router checks and 3 focused dispatch/fused-partition checks pass.
  • JIT compile checks: 5/5 pass.
  • Full backend suite: 95/99 pass. The four failures reproduce on unmodified upstream: rope_set_rows_dispatch, generic_swiglu_k16_publication_edges, tiled_matmul_alternate_publish, and rmsnorm_binary_k16_output.
  • Full JIT suite including device materialization: 5/6 pass. The concat topology-range compile failure also reproduces on unmodified upstream.

The single-model automation manifest is on a separate validation branch and is not part of this PR.

Requirements

  • I have read and agree with the contributing guidelines. Contributor confirmation pending.
  • AI usage disclosure: YES. Codex assisted with root-cause investigation, implementation, regression coverage, validation, and this draft PR.

@AaronStGeorge
AaronStGeorge marked this pull request as ready for review October 21, 2026 16:06
@AaronStGeorge
AaronStGeorge merged commit 7fd4e51 into hrx-graph-develop-v2 Oct 21, 2026
1 of 14 checks passed
@AaronStGeorge
AaronStGeorge deleted the users/astgeorg/fix-moe-routing-descriptors branch October 21, 2026 19:28
AaronStGeorge added a commit that referenced this pull request Oct 28, 2026
## Overview

Fix two HRX failures encountered while running Qwen3.5-35B-A3B-MTP-GGUF with multi-token drafting:

- Give the dim-0 concat launch count an explicit range so Loom can compile the 2048+2048 hidden-state concat used by MTP. Add dynamic executable-reuse coverage for 1 and 128 rows.
- Compute recurrent snapshot decay ratios as `exp(log_decay_j - log_decay_i)` in both fused Gated DeltaNet snapshot publication paths. Dividing cumulative exponentials could produce `0/0` after underflow, corrupting saved states used for speculative rejection/rollback.

Add CPU-reference regressions for attention and every saved state with 2 through 5 verification tokens, ordinary and underflowing decay, fused dispatch, and repeated graph execution. The snapshot regression fails with NaNs for 3 through 5 tokens before the fix.

## Additional information

Prior validation on gfx1100 (RX 7900 XTX):
- Focused HRX ops: 5/5 pass, including all four snapshot cases and dynamic generic ops.
- Loom JIT suite passes, including the new concat workloads.
- Full-model drafting lengths 2, 3 and 4 pass repeated requests and a 477-token prefill. Default length 3 matches all three non-MTP baseline texts; traces cover full, partial and zero acceptance with recurrent rollback and no checkpoint fallback. Lengths 2/4 match counting and arithmetic; open-ended chat has minor wording differences.

Rebased onto `hrx-graph-develop-v2` at 7fd4e51 with an identical patch; whitespace checks pass. GPU tests have not been rerun after this rebase. gfx1151 validation remains outstanding.

Follows the MoE-routing fix in #153, already on the target branch. Lemonade automatic MTP enablement and ROCm/ggml-staging-automation#109 are separate changes; this PR contains only the backend kernels and their regressions.

## Requirements

- [ ] Contributor confirmation: I have read and agree with the [contributing guidelines](https://github.com/ggml-org/llama.cpp/blob/master/CONTRIBUTING.md).
- AI usage disclosure: YES. Codex assisted with investigation, implementation, regression tests, validation and preparation of this draft at the contributor's request.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant