Repository navigation
qwen4exp: Qwen3.8-Flash-Next on HRX (clean rebase; IMROPE->NEOX + CPU-route experts) - #142
Merged
bong-water-water-bong merged 3 commits intoOct 25, 2026
Merged
Conversation
…d_norm) HRX rms_norm requires a materialized (non-view) input. qwen4exp feeds strided ggml_view slices into normalization: the gated-delta-net L2-norm of q_conv/k_conv (build_gdn_l2_norm) and the per-head q/k norms via build_norm. Insert ggml_cont for non-contiguous / view-op inputs. No-op for the contiguous residual-stream tensors other arches (e.g. qwen35 27B) pass, so their HRX path is unchanged. Clears the "unsupported HRX node: RMS_NORM<-VIEW" abort on Qwen3.8-Flash-Next. Remaining HRX blockers (IMRoPE mode 40, MoE mul_mat_id input_size=640) are separate kernel work. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…IQ4_NL/IQ2_S/640-wide experts to CPU)
Make the full Qwen3.8-Flash-Next (arch qwen4exp) forward pass complete on the
HRX backend so llama-perplexity runs and a KLD can be measured.
Two blockers fixed, logic in a new owned header (qwen4exp-hrx-support.h), with
only minimal one-line hooks into the AMD matcher/backend files:
1) ROPE matcher rejected qwen4exp's GGML_ROPE_TYPE_IMROPE (mode 40) + 4-section
positions. For text decode llama.cpp sets p_t==p_h==p_w==token pos, p_e==0; for
this model's sections [11,11,10,0] (sect_dims 32 = n_dims/2) ggml_mrope_cache_init
never selects p_e, so the interleaved rotation collapses to a plain NEOX rotation
on the shared position -- which the existing rope_f32 kernel computes bit-exactly.
The matcher now accepts a collapsible IMROPE, admits the 4*token_count positions
layout, and hands the kernel NEOX mode. No kernel change (proven bit-exact).
2) MUL_MAT_ID routed-expert GEMM could not run on HRX: UD-IQ4_XS gate/up experts are
IQ4_NL (shared f16 dequant mis-applies the XOR-12 nibble remap -> garbage),
UD-IQ3_XXS experts are IQ2_S (no HRX MUL_MAT_ID path), and the Q8_0 down-proj has a
640-wide contraction that violates the kernel's 256-multiple input_size constraint
("value 640 violates constraint 'mul'"). device_supports_op now keeps every such
MUL_MAT_ID (bad weight type, or input_size % 256 != 0) on CPU, so the forward pass
completes correctly instead of failing JIT link with no fallback.
Measured (strixhalo, performance mode, power_mode=performance, HRX0, 12 chunks, -c 512
-b 512 -ngl 99 -fa on, wikitext-2 test; MoE experts on CPU):
* "Paris" generation on HRX0: coherent ("...directly state Paris as the answer").
* Correctness vs CPU (UD-IQ4_XS): HRX0 PPL 1.7997 +/- 0.0507 vs CPU PPL 1.8202 +/-
0.0527 (~1.1%, within error bars; benign f16-WMMA rounding, not a bug).
* KLD UD-IQ3_XXS vs UD-IQ4_XS reference (both HRX0): mean 0.3118 +/- 0.0138,
median 0.0179, 99% 3.950, 99.9% 6.076, max 9.243, Same-top-p 87.42%,
PPL(Q)/PPL(base) 1.0927, PPL(Q)-PPL(base) 0.1665.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
… (CPU only for IQ2_S)
Refine ggml::hrx::mul_mat_id_weight_type_requires_cpu / mul_mat_id_requires_cpu in
qwen4exp-hrx-support.h so the device_supports_op guard defers to the gpu-kernels HIP
add-on (addons/hip-hrx) when it is compiled in (GGML_HRX_HIP_ADDON):
* add-on built -> route to CPU ONLY IQ2_S (no add-on mmid path); IQ4_NL / IQ3_S /
Q5_1 / Q8_0 (and the K-quant / MXFP4 / NVFP4 / Q2_0 formats) run
on HRX via the add-on's decode + prefill mmid, which carry the real
GGUF code books. The 640-wide (K%256!=0) restriction also lifts:
the add-on mmid handles input_size % 32.
* add-on absent -> unchanged (the Loom WMMA mmid mis-applies the IQ4_NL XOR-12 remap
and rejects K%256!=0), so IQ4_NL + IQ2_S + K%256!=0 stay on CPU.
Rope IMROPE->NEOX and the rms_norm view-materialization fix are untouched.
NOT YET VERIFIED ON DEVICE: building this tree with the add-on is blocked by a stale
hrx-system pin (see report) -- the base d65a7e5 corpus needs the Loom 'multiple_of'
predicate (hrx-system >= Oct-18), but HRX_SOURCE_DIR resolves to the Sept-23 51b1739ae
whose loom-link/runtime lacks it. The guard change itself is a compile-time no-op unless
GGML_HRX_HIP_ADDON is defined.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Author
Verified on device — defer-to-HIP guard green ✅Built this branch (incl.
The guard now correctly defers to the HIP add-on (CPU only for IQ2_S). This PR should pin as "Flash-Next experts on HRX via HIP." Merge timing into |
bong-water-water-bong
marked this pull request as ready for review
October 25, 2026 04:43
bong-water-water-bong
added a commit
that referenced
this pull request
Oct 25, 2026
…ts the kernels (#144) The #142 guard sends IQ2_S MUL_MAT_ID to HRX when the embedded hrx_prefill_gemm code object exports the IQ2_S kernels (names looked up in the code object), every batch incl. one token (GGML_HRX_HIP_IQ2S_MIN_TOKENS, default 1): a CPU decode reading experts the loader had moved into HRX memory collapsed to 0.64 tok/s. Flash-Next UD-IQ3_XXS on HRX0 with gpu-kernels #38: PPL 1.9514, pp512 297, tg128 25.2. Co-Authored-By: Claude Fable 5.1 <[email protected]>
bong-water-water-bong
added a commit
that referenced
this pull request
Oct 25, 2026
…e-token decode back on the fused GDN kernel) (#152) #142 (a25b4b8) made build_norm wrap every view / reshape input in a CONT for all arches. On qwen35 (Qwen3.5 / 3.8, Ternary-Bonsai) the CONT before RMS_NORM(VIEW(gated-delta-net output)) broke the HRX add-on's fused one-token GDN match (hip.q36.gdn_decode): decode fell back to the Loom llm_gated_delta_net_f32_wmma_head128 path plus 112 copies, 1432 -> 1608 dispatches per token. The CONT now applies to LLM_ARCH_QWEN4EXP only, the arch it was added for. HRX dispatch profile, Ternary-Bonsai-2-27B PQ2_0, one-token decode, 31 steps, medians (fork 6ded110 + gpu-kernels 2b626798a -> this): 1608 -> 1432 dispatches, step period 50.20 -> 48.05 ms (GDN 1.24 ms Loom -> 0.51 ms q36_gdn_decode_f32; state get_rows 2.18 -> 1.06 ms; copy_f32 0.51 ms -> gone). llama-bench tg128 -r 3, three interleaved rounds (performance mode): PQ2_0 20.17 / 20.36 / 20.46 -> 20.94 / 21.31 / 21.31 tok/s; Qwen3.8-27B UD-Q4_K_XL 11.70 / 11.79 / 11.78 -> 12.13 / 11.89 / 12.11. KLD vs the Bonsai F16 CPU logits (8 x 512): -ub 1 0.000000 (same top 100%, as before); -ub 8 0.000074. No kernel changed (gpu-kernels 2b626798a in both builds). Co-authored-by: bong-water-water-bong <[email protected]> Co-authored-by: Claude Opus 5.5 <[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.
Supersedes the draft #141 with a clean, rebased version on the current
1bit/hrx-vulkan-patchedtip (d65a7e5).What this does
Brings Qwen3.8-Flash-Next (
qwen4exp) onto the HRX (gfx1151) backend — first full forward pass +llama-perplexity+ coherent decode on-dev HRX0. Three commits:materialize view inputs to HRX rms_norm—build_gdn_l2_normandbuild_normfed a non-contiguousVIEWinto HRXrms_norm; added aggml_contguard + the matching dispatch-rmsnorm acceptance. Clears theunsupported HRX node 48: RMS_NORM<-VIEW[128,16,T]->SCALEabort. No-op for 27B/other arches.decode Flash-Next on HRX (IMROPE->NEOX rope, route problem experts to CPU)IMROPE(mode 40) with a 4-section position tensor collapses to NEOX for this model (sections=[11,11,10,0], text decode) — matcher accepts the collapsible case and reuses the existingrope_f32kernel. Bit-exact by construction, no new kernel.mul_mat_idfallback for the Loom-only path.defer routed-expert MUL_MAT_ID to the HIP add-on when built (CPU only for IQ2_S)— gated onGGML_HRX_HIP_ADDON: with the add-on built (the engine's normal build), route to CPU only IQ2_S; IQ4_NL/IQ3_S/Q5_1/Q8_0 (and the 640-wide ffn_down) run on HRX via the add-on's prefill+decode mmid. Without the add-on, unchanged Loom-only CPU-routing.New logic in our own Apache-headed
ggml/src/ggml-hrx/qwen4exp-hrx-support.h; AMD files get minimal hooks.Correctness and KLD (strixhalo HRX0, 12 chunks wikitext-2; Loom-only build, experts on CPU)
GGUF expert layout (all 3 shards)
fn-iq2s-mmidGEAK follow-up. (The IQ4_NL XOR-12 Loom-path dequant bug is tracked at HRX Loom dequant: IQ4_NL nibble remap uses XOR-12 instead of kvalues_iq4nl (garbage mul_mat_id on Loom-only path) engine#559.)Merge gating (per RC coordination)
82804197bcbe+ gpu-kernels4b8b9d0d6) is being verified now to confirm the defer-to-HIP guard runs UD-IQ4_XS experts fully on HRX.1bit/hrx-vulkan-patchedonly after that add-on build shows the defer-to-HIP behaviour green (expert placement from the dispatch log + prefill/decode tok/s). Until then it stays a draft.🤖 Generated with Claude Code