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 Loom dequant: IQ4_NL nibble remap uses XOR-12 instead of kvalues_iq4nl (garbage mul_mat_id on Loom-only path) #559
The Loom-corpus shared f16 dequant for IQ4_NL mis-applies the XOR-12 nibble remap, producing garbage for IQ4_NL mul_mat_id (routed MoE experts) on the HRX Loom path. This is why Qwen3.8-Flash-Next (qwen4exp) routed experts had to be forced to CPU on a Loom-only build (see the CPU-route fallback in the qwen4exp-on-HRX work).
Where
Loom corpus motif: ggml/src/ggml-hrx/.../motifs/dequant.loom (the shared f16 dequant used by the Loom WMMA mul_mat_id).
Observed on IQ4_NL ffn_down_exps (ne0=640) of the Flash-Next UD-IQ4_XS / UD-IQ3_XXS GGUFs.
Detail
The nibble-to-value remap for IQ4_NL should use the real ggml kvalues_iq4nl codebook. The Loom dequant applies an XOR-12 on the nibble index instead, which does not reproduce the codebook ordering, so decoded weights are wrong. The gpu-kernels HIP add-on path (addons/hip-hrx, hrx_prefill_mmid_iq4_nl / moe_decode_mmid_iq4_nl) does this correctly (uses kvalues_iq4nl), so IQ4_NL experts are correct when llama.cpp is built with GGML_HRX_HIP_ADDON_DIR; the bug is specific to the Loom-only path.
Impact / workaround
With the HIP add-on built (the engine's normal build), IQ4_NL experts run correctly on HRX via HIP — no action needed for shipping.
On a Loom-only build, IQ4_NL mul_mat_id must be routed to CPU to avoid garbage (current qwen4exp fallback).
Fix
Correct the IQ4_NL nibble remap in the Loom dequant motif to match kvalues_iq4nl, then verify the Loom mul_mat_id matches the CPU double-precision reference (NMSE < 1e-10) on the Flash-Next IQ4_NL ffn_down (ne0=640).
Filed for the record per the HRX kernel-routing review; the HIP add-on carries IQ4_NL meanwhile.
Verified on the Loom-only path today (no HIP add-on in the build), because the premise does not reproduce — the dequant is already correct and a PR follows with the docs update rather than a code change.
test-backend-ops -b HRX0 # engine's pinned fork source, -DGGML_HRX=ON, no GGML_HRX_HIP_ADDON_DIR
MUL_MAT iq4_nl n=1..9 k=256 : OK MUL_MAT iq4_xs same : OK
GET_ROWS iq4_nl be1=1 : OK MUL_MAT_ID iq4_nl/iq4_xs : not supported (declined to CPU)
0 FAIL, 2/2 backends passed
motifs/dequant.loom builds the real kvalues_iq4nl table (-127 … 113) and reads it with vector.table.lookup; there is no XOR-12 on the IQ4_NL path in the corpus at all. Fork #41 is what fixed the two copies, and the engine's pinned source carries it.
So what the Loom path does run is numerically correct, and what it does not run (MUL_MAT_ID for those types on a Loom-only build) is declined to the CPU rather than decoded wrongly. The shipped engine build carries the HIP add-on, whose routed-expert kernels handle IQ4_NL on HRX. The remaining not supported cases are shape coverage — k=32, GET_ROWS on a view, and the batched gather be1=7 that #390 already covers (where q8_0 fails identically, so the quant is not the variable).
Closed as already fixed, now verified and documented. The XOR-12 remap the report describes was removed by fork #41 (motifs/dequant.loom reads the real kvalues_iq4nl table through vector.table.lookup; no XOR-12 remains on the IQ4_NL path anywhere in the corpus), and the engine's pinned source carries it.
Verifying run (2026-10-25, strixhalo, HRX0) on a Loom-only build — -DGGML_HRX=ON with no HIP add-on, so every case goes through the Loom corpus:
test-backend-ops -b HRX0
MUL_MAT iq4_nl n=1..9 k=256 : OK MUL_MAT iq4_xs the same : OK
GET_ROWS iq4_nl be1=1 : OK MUL_MAT_ID iq4_nl/iq4_xs : not supported (declined to CPU)
0 FAIL, 2/2 backends passed
What runs is numerically correct; what does not run is declined, not garbage — MUL_MAT_ID for those types on a Loom-only build takes the CPU, and the shipped engine build carries the HIP add-on whose routed-expert kernels handle IQ4_NL on HRX. The remaining not supported cases are shape coverage (k=32, GET_ROWS view v=1, batched gather be1=7 — the #390 gap, where q8_0 fails identically).
Docs updated in #567 (merged, 99040cea): the docs/hrx.md bullet moved from "Not yet" to done with these numbers.
Activity
bong-water-water-bong commentedon Oct 25, 2026
Verified on the Loom-only path today (no HIP add-on in the build), because the premise does not reproduce — the dequant is already correct and a PR follows with the docs update rather than a code change.
motifs/dequant.loombuilds the realkvalues_iq4nltable (-127 … 113) and reads it withvector.table.lookup; there is no XOR-12 on the IQ4_NL path in the corpus at all. Fork #41 is what fixed the two copies, and the engine's pinned source carries it.So what the Loom path does run is numerically correct, and what it does not run (
MUL_MAT_IDfor those types on a Loom-only build) is declined to the CPU rather than decoded wrongly. The shipped engine build carries the HIP add-on, whose routed-expert kernels handle IQ4_NL on HRX. The remainingnot supportedcases are shape coverage —k=32,GET_ROWSon a view, and the batched gatherbe1=7that #390 already covers (whereq8_0fails identically, so the quant is not the variable).bong-water-water-bong commentedon Oct 25, 2026
Closed as already fixed, now verified and documented. The XOR-12 remap the report describes was removed by fork #41 (
motifs/dequant.loomreads the realkvalues_iq4nltable throughvector.table.lookup; no XOR-12 remains on the IQ4_NL path anywhere in the corpus), and the engine's pinned source carries it.Verifying run (2026-10-25, strixhalo, HRX0) on a Loom-only build —
-DGGML_HRX=ONwith no HIP add-on, so every case goes through the Loom corpus:What runs is numerically correct; what does not run is declined, not garbage —
MUL_MAT_IDfor those types on a Loom-only build takes the CPU, and the shipped engine build carries the HIP add-on whose routed-expert kernels handle IQ4_NL on HRX. The remainingnot supportedcases are shape coverage (k=32,GET_ROWSviewv=1, batched gatherbe1=7— the #390 gap, whereq8_0fails identically).Docs updated in #567 (merged,
99040cea): thedocs/hrx.mdbullet moved from "Not yet" to done with these numbers.