Repository navigation
feat: exl3 support - #201
Conversation
|
Vulkan support for these ops is in #204: a dot kernel, a coopmat GEMM for prefill and a device-routed EXL3_MUL_MAT_ID, with EXL3_GET_ROWS left on the CPU as here. It sits on top of this branch. On Strix Halo, Qwen3.5-9B EXL3 4.00bpw goes from 102 / 1.3 t/s (prefill / decode, linears on the CPU) to 1191 / 39.9, at KLD 1e-6 against the CPU path. While comparing, we also ran this PR's HIP path on gfx1151 (ROCm 10.1, b5fe405, LFM2.5-8B-A1B EXL3 2.10bpw). Two things that may help the MoE prefill: 1. One f16 product for the experts looks free. At ub512 every expert has fewer than 512 rows, so EXL3_MUL_MAT_ID runs hi + lo everywhere. KLD against the EXL3 CPU path (wiki, 4 chunks of 4096):
llama-bench pp2048: ub512 4448 -> 5430 t/s (+22%, ahead of Q4_K_M's 5160 there), ub2048 5428 -> 5659 (+4%). 2. The input rotations are most of the remaining ub2048 gap. rocprofv3, pp2048 ub2048, kernel time over the run with one product: EXL3 1041 ms vs Q4_K_M 934. The MoE GEMMs are about even (532 vs 525) and the dense ones too (183 vs 199); |
halo-box#201 by Piotr Wilkin, taken locally for STASH-021 (EXL3 vs IQ3_XXS / Q2_0), 2026-11-04. Assisted-by: Claude Code
…egisters) Wave32 kernels for the EXL3 linear of halo-box#201 (GGML_EXL3, see ggml/exl3/README.md). exl3_rotate computes H(x*suh) in f32 as the CPU op does and zeroes the arrival counters. exl3_mul_mat_vec decodes each lane's 8 weights of a tile to the exact fp16 codebook values (3inst, mcg, mul1; K = 1..8 and 1.5, 2.5, 3.5, all as specialization constants), accumulates in f32 for 1, 2, 4 or 8 rows per pass (more rows in groups of 8), and the last workgroup of a 128-column segment applies H and svh/128. Scratch in prealloc_split_k. Qwen3.5-9B EXL3 4.00bpw, gfx1151: decode 40.5 t/s (EXL3 linears on the CPU: 1.31 t/s), wiki PPL 7.9652 (CPU 7.9651). Assisted-by: Claude Opus 5.5 (cherry picked from commit de6da4e)
|
Converter memory: write the stacked EXL3 experts one expert at a time
Here is one commit on top of your head 7361167: With this commit we converted Flash-Next at 1.66, 2.05 and 3.05 bpw. All three load and run with #204's Vulkan Not verified:
Written by Claude Code (an AI agent), run on rcfa's Strix Point machine; rcfa owns it. |
dzannotti
left a comment
There was a problem hiding this comment.
Verdict
Changes requested. The EXL3 path gives correct output on ROCm for the model we tested, and it does not change normal GGUF models. But the PR breaks an existing test on current master, has an out-of-bounds write that a model file can trigger, and has no description or numbers to review it against.
Direction
Accept after work. EXL3 on Strix Halo is useful, and new ops on plain I16/F16 tensors (no new ggml type) is the right shape for a fork that tracks upstream. At about 8.9k lines in one PR, it is hard to review and to carry through upstream merges. Please consider moving the -m DIR importer (common/exl3-dir.cpp) and the qwen4exp n-gram (PLE) work to follow-up PRs, so that this one is the decoder, the ops, the HIP kernels and qwen35/lfm2moe support.
Asks
- Blocking.
src/llama-model-loader.cpp:798: shaped tensors in the metadata now mean "the complete tensor set".tests/test-draft-vocab.cppon master passes a shapedoutput.weightas a type override tollama_model_init_from_user, and it now fails withtensor 'token_embd.weight' not found(it fails on every run on ROCm and Vulkan, with the flag off and on; master passes 3/3). Keep the old meaning for the existing API, and select the complete-set mode with an explicit signal (for example a metadata key that only the importer sets). - Blocking.
ggml/exl3/exl3.c:274:ggml_exl3_decode_ngram_rowalways decodes 160 values, but the loader (src/llama-model-loader.cpp:~1604) and the caller (src/models/qwen4exp.cpp:2494) size the row, the bias and the output byple_head_dim, which comes from the file. A qwen4exp EXL3 file withembedding_length_per_layer< 160 reads and writes past the buffers. Rejectple_head_dim != GGML_EXL3_ROW_DIMat load, or pass the width to the decoder. - Blocking. Fill in the description: the supported architectures and codebooks, the backends with a GPU path (HIP on RDNA3/RDNA4 only; CUDA and Vulkan run the EXL3 ops on the CPU), the models you tested, and the numbers behind the GSM8K claim (model, bpw, score per backend, the reference). Add PPL/KLD against the CPU path and
llama-benchorllama-completionspeed for at least one model per architecture, asCONTRIBUTING.mdasks. - Should fix.
ggml/src/ggml-cuda/exl3.cu:961:exl3_gemm_kernel<7, {0,1,2}, false, 4, 2>spills (3 spill saves, 16 scratch bytes per lane on gfx1151, ROCm 10.1). Remove the spill, or show that the K=7 GEMM is not slower because of it. - Should fix. The
test-backend-opsEXL3 cases use k and n up to 384, so the 8- and 16-warp split-K dot, the GEMM tails and more than 512 rows have no correctness case. Add production shapes (for example 4096 x 12288 and back, and an LFM2 MoE expert shape). Also make the one-or-two f16 product choice (exl3_gemm_products,exl3.cu:1512) a fixed EXL3 rule. Today it follows the MMB dispatch heuristic, so an unrelated MMB tuning change can change EXL3 precision.
Nits: qwen4exp.cpp:~290 sets direct_io = true after it reads LLAMA_PLE_DIRECT, so the override is lost; exl3_mmid_route (exl3.cu:~1634) has no expert id bound check (the CPU path asserts); write_exl3_experts (conversion/exl3.py:184) holds all experts in memory (see the converter commit offered in the comments); merge commit 46524f920 has no Assisted-by: line.
Correctness
FAIL on both backends, because of ask 1. Everything else that ran passed. Normal GGUF models are unchanged: final f32 logits and prompt token IDs are byte-identical to master on all four corpora (Qwen3.8-27B Q4_K_XL, ROCm and Vulkan, flag off and on), 256-token greedy decode is identical, and the full test-backend-ops suites have no new failure. The EXL3 ops pass on ROCm with HIP_LAUNCH_BLOCKING unset and =1, and the -Werror HIP build is clean. The VGPR spill gate fails (ask 4). On Qwen3.5-9B EXL3 2.00bpw, ROCm against the CPU path gives mean KLD 0.000000 and the same top token 99.97%. Vulkan with the flag on runs the EXL3 ops on the CPU, at KLD 0.000004. We could not test lfm2moe or qwen4exp EXL3 models, the converter or row-ring embeddings (see Not tested).
Performance
No change for normal models, flag off or on (base vs head, 2 alternated rounds of -r 5, all within one stddev):
| Backend | Case | master t/s | head t/s (flag off) | head t/s (flag on) |
|---|---|---|---|---|
| ROCm | 27B Q4_K_XL pp2048 | 416.6 | 416.2 (-0.1%) | 416.4 (-0.0%) |
| ROCm | 1.5B Q4_K_M pp2048 d64000 | 1113.2 | 1112.0 (-0.1%) | 1112.3 (-0.1%) |
| Vulkan | 27B Q4_K_XL pp2048 | 474.8 | 475.0 (+0.0%) | 474.3 (-0.1%) |
| Vulkan | 1.5B Q4_K_M pp2048 d64000 | 907.9 | 894.9 (-1.4%, +-15) | 888.2 (-2.2%, +-19) |
EXL3 itself (Qwen3.5-9B 2.00bpw, ROCm): 1510 t/s prompt (12.4k tokens), 45.6 t/s decode. With Vulkan the decode is 1.3 t/s, because the EXL3 linears run on the CPU.
Verification
Strix Halo (gfx1151), ROCm and Vulkan. We tested the PR merged into current master 8acea9aa4 (the PR is 172 commits behind) against master, with identical build flags, plus a third head build with -DGGML_EXL3=ON.
Not tested
lfm2moe and qwen4exp EXL3 models, the converter (convert_hf_to_gguf.py, not runnable in our environment), row-ring token embeddings, RDNA4, CUDA, and the GSM8K claim.
Thank you for the work on this.
Review made with AI on behalf of the strix-llama.cpp maintainers.
Full verification (for reproduction and agents)
Environment
Strix Halo (gfx1151, Radeon 8060S), Ubuntu 26.04.1, kernel 7.0.0. ROCm 10.1 (hipconfig 7.16.26385), AMD clang 24.0.0git d6f6cb69, Mesa RADV (STRIX_HALO, KHR_coopmat), cmake 4.2.3, gcc 15.2.0.
Compared
- master tip:
8acea9aa4cd7196ac5160f3967c551b3c83dc71c - PR head:
73611675bcde4e33ac38506812dfdbfd00281abc - PR merged into master (local, not pushed):
6c5e71b62e1dd13e8f28d14d5347605bc41f8961, clean merge - merge base:
da731374077f2ad9bdffd4848f782b5694b9bb68, 172 commits behind master - three builds per backend: base (master), head (merged,
GGML_EXL3off, the default), head-exl3 (merged,-DGGML_EXL3=ON)
Build
HIP="-DGGML_HIP=ON -DGGML_VULKAN=OFF -DGPU_TARGETS=gfx1151 -DCMAKE_HIP_COMPILER=$(hipconfig -l)/clang -DCMAKE_PREFIX_PATH=$(hipconfig -R) -DCMAKE_BUILD_TYPE=Release -G Ninja"
VK="-DGGML_VULKAN=ON -DGGML_HIP=OFF -DCMAKE_BUILD_TYPE=Release -G Ninja"
cmake -S <tree> -B <tree>/build-hip $HIP # base, head
cmake -S <head> -B <head>/build-hip-exl3 $HIP -DGGML_EXL3=ON # head-exl3
cmake -S <tree> -B <tree>/build-vk $VK # base, head; head-exl3 adds -DGGML_EXL3=ON
cmake --build <dir> -j
# -Werror: $HIP -DGGML_EXL3=ON "-DCMAKE_HIP_FLAGS=-Werror -Wno-tautological-compare", target ggml-hip: builds clean
# spill gate: $HIP [-DGGML_EXL3=ON] -DGGML_HIP_EXPORT_METRICS=On, target ggml-hip, base and head-exl3
python3 scripts/hip/gcn-cdna-vgpr-check.py <dir> --baseline scripts/hip/gfx1151-vgpr-baseline.json --compiler-version "<clang --version | head -1>"
Models
| Model | Source | sha256 |
|---|---|---|
Qwen3.5-9B EXL3 2.00bpw (mcg codebook), loaded with -m <dir> |
turboderp/Qwen3.5-9B-exl3, branch 2.00bpw, commit 0508aa8eeca823529f4a871bdb2bf3f50a86b18e |
model.safetensors 381dce8844603a25174ffc0b397d45e3ee63bd225a8b7469ba5143629dbc2adf (matches the Hub LFS oid) |
| Qwen3.8-27B-UD-Q4_K_XL.gguf (qwen35 arch, normal GGUF) | local copy | 3f227079003add2511437e5b1e94812e363385225bf6a9b47b0054a72bc8b01e |
| qwen2.5-1.5b-instruct-q4_k_m.gguf | Qwen/Qwen2.5-1.5B-Instruct-GGUF |
6a1a2eb6...407e |
Corpora at master, sha256 (first 16 hex): code dec1127ae75ffa56, numeric d9f08d9470e53ef6, prose c90398f2e2885f20, structured c21947b360bea62d.
Commands
# ops (ROCm with HIP_LAUNCH_BLOCKING unset and =1)
test-backend-ops test -b ROCm0 -o EXL3_MUL_MAT | EXL3_MUL_MAT_ID | EXL3_GET_ROWS
test-exl3 --backend ROCm0
test-backend-ops test -b <ROCm0|Vulkan0> -j 4
ctest --test-dir <build> --output-on-failure -L main -E 'test-opt|test-llama-archs'
test-llama-archs -b <ROCm0|Vulkan0>
test-vk-exact
# parity on the normal qwen35 model, all four corpora
llama-debug -m <27B> -f tests/corpus/correctness-<t>.txt -c 16384 -b 16384 -ub 512 -ngl 99 -fa on -ctk f16 -ctv f16 --save-logits --logits-output-dir <out>
cmp <base>/llamacpp-*.bin <head>/llamacpp-*.bin # logits and tokens
llama-completion -m <27B> -f correctness-prose.txt -n 256 --temp 0 --seed 1 -no-cnv --ignore-eos -ngl 99 -fa on -c 16384 # base twice, head, head-exl3
# EXL3 model: pure CPU reference, then the GPU against it
llama-perplexity -m <exl3 dir> -f correctness-prose.txt -c 2048 -b 2048 -ub 512 --chunks 3 -ngl 0 -dev none --no-op-offload --kl-divergence-base <ref>.kld
llama-perplexity -m <exl3 dir> -c 2048 -b 2048 -ub 512 --chunks 3 -ngl 99 -fa on --kl-divergence-base <ref>.kld --kl-divergence
# also: -ngl 0 with op offload as reference; ROCm at -ub 512, -ub 2048, HIP_LAUNCH_BLOCKING=1, -ngl 20; Vulkan head-exl3 at -ngl 99
# backend noise floor: the same pair on qwen2.5-1.5b Q4_K_M
llama-completion -m <exl3 dir> -p "The capital of France is" -n 64 --temp 0 --seed 1 -no-cnv -ngl <99|0> -fa on -c 4096
llama-completion -m <exl3 dir> -f correctness-prose.txt -n 128 --temp 0 --seed 1 -no-cnv --ignore-eos -ngl 99 -fa on -c 16384 -b 2048 -ub 512 # speed, 3 runs
# performance, base / head / head-exl3 alternated, 2 rounds
llama-bench -m <1.5B> -p 2048 -d 0,12000,32000,64000 -b 2048 -ub 512 -n 0 -r 5 -ngl 99 -fa on -ctk f16 -ctv f16 --load-mode none -o jsonl
llama-bench -m <1.5B> -p 0 -n 128 -r 5 -ngl 99 -fa on -o jsonl
llama-bench -m <27B> -p 2048 -d 0 -b 2048 -ub 512 -n 128 -r 5 -ngl 99 -fa on -ctk f16 -ctv f16 --load-mode none -o jsonl
Results
ROCm:
| Check | base | head (off) | head (EXL3 on) |
|---|---|---|---|
| test-backend-ops, HLB unset | 40386/40386 | 40386/40386 | 40413/40413 |
| test-backend-ops, HLB=1 | 40386/40386 | 40386/40386 | not run |
| EXL3_MUL_MAT / _ID / GET_ROWS, HLB unset and =1 | n/a | not supported (flag off) | 16/16, 7/7, 4/4 |
| test-exl3 --backend ROCm0 | n/a | n/a | OK |
| ctest -L main | 64/65 (tokenizers-ggml-vocabs) | 63/65 (+ test-draft-vocab) | 65/67 (+ test-draft-vocab) |
| test-draft-vocab alone, 3 runs | 3/3 pass | 0/3 | n/a |
| test-llama-archs | 136/136 | 136/136 | 136/136 |
| llama-debug logits + tokens, 4 corpora | reference | byte-identical | byte-identical |
| greedy decode 256 tokens | A/A identical | identical | identical |
Vulkan:
| Check | base | head (off) | head (EXL3 on) |
|---|---|---|---|
| test-backend-ops | 43840/43840 | 43840/43840 | 43840/43840 (EXL3 ops not supported, run on CPU) |
| ctest -L main | fails tokenizers-ggml-vocabs, test-llama-context | + test-draft-vocab | + test-draft-vocab |
| test-llama-archs | 137/137 | 136/137 in the suite run (mpt causal-toggle nan), then 3/3 mpt alone and 137/137 in 2 more full runs: flaky, mpt is not touched by the PR | 137/137 |
| test-vk-exact | 11 failing checks (hc-up-mix) | same 11 | same 11 |
| llama-debug logits + tokens, 4 corpora | reference | byte-identical | byte-identical |
| greedy decode 256 tokens | A/A identical | identical | identical |
EXL3 model (Qwen3.5-9B 2.00bpw), prose corpus, 3 chunks of 2048:
| Run | PPL | mean KLD | same top p |
|---|---|---|---|
| CPU, no op offload (reference) | 8.5443 +- 0.3471 | - | - |
| ROCm -ngl 99, -ub 512 vs reference | 8.5414 | 0.000008 | 99.902 +- 0.056 % |
| same, HIP_LAUNCH_BLOCKING=1 | 8.5414 | 0.000008 | 99.902 % |
| CPU with op offload (second reference) | 8.5412 | - | - |
| ROCm -ub 512 / -ub 2048 / HLB=1 vs that | 8.5414 | 0.000000 | 99.967 % |
| ROCm -ngl 20 vs that | 8.5413 | 0.000000 | 99.935 % |
| Vulkan head-exl3 -ngl 99 vs that | 8.5442 | 0.000004 | 99.870 % |
| Floor: qwen2.5-1.5B Q4_K_M, ROCm vs pure CPU | - | 0.008530 | 94.428 % |
Code corpus PPL on ROCm: 2.7182 +- 0.0982. Greedy output with -ngl 99 and -ngl 0 is the same text.
Correctness
| Check | Method | Result |
|---|---|---|
| test-backend-ops, changed ops | -o EXL3_*, ROCm, HLB unset and =1 |
PASS (Vulkan: no kernel in this PR) |
| test-backend-ops, full suite | ROCm and Vulkan, base vs head vs head-exl3 | PASS, no new failure |
| ctest -L main | base vs head | FAIL: test-draft-vocab fails on head only, both backends, 3/3 |
| test-llama-archs | base vs head | ROCm PASS; Vulkan one flaky mpt case on head (passes 5 reruns), not attributed to the PR |
| test-vk-exact | base vs head | same failures as master, not caused by the PR |
| f32 logit parity + prompt token IDs, 4 corpora | llama-debug + cmp, 27B | PASS, byte-identical, both backends, flag off and on |
| KLD/PPL short and long, normal model | follows from byte-identical f32 logits | PASS (identical) |
| multi-step greedy decode with A/A | llama-completion, 256 tokens | PASS |
| EXL3 GPU vs CPU | llama-perplexity KLD, 9B EXL3 | PASS, KLD 8e-6 (floor 8.5e-3) |
| ROCm HLB unset vs =1 | ops and EXL3 KLD | PASS, no difference |
| -Werror HIP build | head-exl3 | PASS |
| VGPR spill gate | base vs head-exl3 | FAIL: 3 new spills (exl3_gemm_kernel<7,{0,1,2},false,4,2>, 3 saves, 16 B/lane). Coverage warnings are the same on master |
| test-save-load-state | not built on current master | n/a |
| lfm2moe / qwen4exp EXL3, converter, row-ring embeddings | needs a converted GGUF; the converter needs torch, which we could not use | not run |
Performance
ROCm (t/s, mean of 2 rounds, each -r 5, with each round's stddev):
| Case | base | head (off) | head (EXL3 on) |
|---|---|---|---|
| 1.5B pp2048 d0 | 5618.6 (5660.1+-115.3, 5577.1+-152.5) | 5565.0 (5543.2+-104.0, 5586.8+-144.5) -0.95% | 5583.5 (5587.1+-164.3, 5579.9+-159.2) -0.63% |
| 1.5B pp2048 d12000 | 3230.3 (+-66.5, +-59.7) | 3222.3 -0.25% | 3224.6 -0.18% |
| 1.5B pp2048 d32000 | 1904.4 (+-37.8, +-38.7) | 1905.0 +0.03% | 1904.7 +0.01% |
| 1.5B pp2048 d64000 | 1113.2 (+-18.0, +-19.5) | 1112.0 -0.11% | 1112.3 -0.07% |
| 1.5B tg128 | 155.5 (+-0.8, +-0.9) | 155.3 -0.11% | 155.5 -0.05% |
| 27B pp2048 | 416.6 (+-1.4, +-1.6) | 416.2 -0.09% | 416.4 -0.04% |
| 27B tg128 | 12.1 | 12.1 | 12.1 |
Vulkan:
| Case | base | head (off) | head (EXL3 on) |
|---|---|---|---|
| 1.5B pp2048 d0 | 5382.5 (5405.8+-176.3, 5359.2+-103.1) | 5394.9 +0.23% | 5357.5 -0.47% |
| 1.5B pp2048 d12000 | 2880.2 (+-45.3, +-38.0) | 2891.0 +0.38% | 2892.6 +0.43% |
| 1.5B pp2048 d32000 | 1583.4 (+-36.6, +-43.3) | 1604.9 +1.36% | 1567.5 -1.00% |
| 1.5B pp2048 d64000 | 907.9 (900.3+-12.9, 915.5+-16.8) | 894.9 (906.9+-17.3, 882.8+-11.8) -1.43% | 888.2 (882.7+-22.6, 893.7+-15.2) -2.16% |
| 1.5B tg128 | 190.7 (+-1.4, +-1.1) | 190.6 -0.05% | 190.4 -0.11% |
| 27B pp2048 | 474.8 (+-1.3, +-0.4) | 475.0 +0.04% | 474.3 -0.11% |
| 27B tg128 | 12.7 | 12.7 | 12.7 |
All deltas are inside the summed stddev. EXL3 Qwen3.5-9B 2.00bpw on ROCm, 3 runs: prompt 1510.3 / 1510.1 / 1510.4 t/s (12386 tokens), decode 45.55 / 45.56 / 45.56 t/s. Vulkan head-exl3 (EXL3 ops on the CPU): decode 1.26 t/s.
Findings in full
src/llama-model-loader.cpp:798(withinclude/llama.h:544): the new "shaped metadata = complete tensor set" mode changesllama_model_init_from_userfor every caller. Master'stests/test-draft-vocab.cpp(added after this PR's merge base) builds a virtual llama model with a shapedoutput.weightand now fails at load:check_tensor_dims: tensor 'token_embd.weight' not found.ggml/exl3/exl3.c:274:ggml_exl3_decode_ngram_rowdecodesGGML_EXL3_ROW_DIM(160) positions. The loader check atsrc/llama-model-loader.cpp:~1604useswidth = ple_head_dim, andsrc/models/qwen4exp.cpp:2480-2494strides the output and the head bias byple_head_dim.ple_head_dimcomes fromembedding_length_per_layerand is only checked to be non-zero. With a value below 160 the decoder reads past the row and the bias and writes pastembd_buf.src/models/qwen4exp.cpp:260:ple_exl3_kis computed before the EXL3 checks run, and the checks only run whenexl3.versionis present.ggml/src/ggml-cuda/exl3.cu:~1634, ~1664:exl3_mmid_routeindexes shared counters by expert id without a bound check. The CPU path asserts (exl3-ops.cpp:331).ggml/src/ggml-cuda/exl3.cu:1512, 1672: the one-or-two product choice asks the MMB dispatcher with stand-in F32 tensors, so EXL3 precision follows MMB tuning.exl3.cu: GEMM prefill is RDNA3 only; RDNA4 is accepted bysupports_opand takes the dot path for prefill. CUDA builds compileexl3.cuempty (GGML_USE_EXL3is only defined for HIP), so NVIDIA runs the EXL3 ops on the CPU. Vulkan does the same until a Vulkan implementation lands.- test-backend-ops EXL3 shapes stop at k, n = 384, so
exl3_warps()always picks 4 warps in the tests. - No CI job builds with
-DGGML_EXL3=ON, so test-exl3, test-exl3-dir and the EXL3 backend-ops cases never run in CI. common/exl3-dir.cppis a second qwen35 HF-to-GGUF converter in C++ (hparams, BPE tokenizer setup, V-head reorder, MTP names). Only a manual mode of test-exl3-dir compares it with the Python converter.- About 125 lines of EXL3 checks sit inside
create_tensor(src/llama-model-loader.cpp:1543-1669), an often-edited upstream function. One helper with a short hook would merge more easily. src/models/qwen4exp.cpp:~290:direct_io = trueoverridesLLAMA_PLE_DIRECT, against the commit message.conversion/exl3.py:184-193:write_exl3_expertskeeps all stacked experts in memory until the write.ggml/include/ggml-rpc.h: only the RPC patch version changes, so an older server accepts a graph with the new op ids.- Overlap: the PR conflicts with open #253 (
src/llama-model.cpp) and #255 (src/models/qwen4exp.cpp).
Claims
- "Implements native exl3 support": partly reproduced. Qwen3.5-9B EXL3 (qwen35, mcg) loads from its directory and runs on ROCm, CPU and Vulkan (CPU fallback) with GPU-vs-CPU KLD 8e-6. lfm2moe, qwen4exp, mul1/3inst model files and the converter were not tested.
- "GSM8K within margin of error": not tested; the PR gives no model, scores or setup.
Not tested
lfm2moe and qwen4exp EXL3 models and the converter (they need a converted GGUF, and the converter needs torch, which we could not use), row-ring token embeddings, n-gram (PLE) tables and O_DIRECT reads, RDNA4, CUDA, the GSM8K claim, the long-context (-c 16384) KLD on the EXL3 model, and test-backend-ops HLB=1 on the EXL3-on build (the EXL3 ops ran with HLB=1).
Fork-local, off by default. Decodes exllamav3 EXL3 linears (3inst/mcg/mul1 codebooks, K 1..8 and 1.5/2.5/3.5) to the rotated fp16 weight and to f32 W with the Hadamards and scales folded in. No new ggml type. test-exl3 checks the codebooks and every rate x codebook case against hashes made with exllamav3's independent tests/testlib/trellis.py; --gguf decodes a GGUF container. Assisted-by: Claude Opus 5.5
When quantization_config.quant_method is exl3, every .trellis/.suh/.svh is copied as <name>.exl3_trellis (I16) / .exl3_suh / .exl3_svh (F16) and the codebook markers are checked and replaced by exl3.* keys. The qwen35/qwen3next V head reorder is applied on whole 128-blocks (exact, H is block diagonal). Other tensors keep their stored type. The size label counts the k x n weights of a trellis. Assisted-by: Claude Opus 5.5
y = x W for an EXL3 linear without materializing W: the activations go through the 128-point Hadamards and the scales, the trellis is decoded tile by tile to exact codebook values, and the products accumulate in f32. The op exists in every build; only GGML_EXL3=ON builds compute it on the CPU, other builds report it as unsupported. test-exl3 checks it against ggml_mul_mat on the f32 W of ggml_exl3_dequantize (NMSE <= 1e-10) for every rate x codebook case and, with --op-gguf, on the shapes of a container at 1 to 513 rows. test-backend-ops gets EXL3_MUL_MAT cases. The RPC patch version is bumped for the new op count. Assisted-by: Claude Opus 5.5
Each EXL3 linear becomes "<base>.weight" F32 from ggml_exl3_dequantize, the exl3.* keys are dropped, and every other key and tensor is copied unchanged. Any build can load the result, which serves as the reference for model-level comparisons of the EXL3 op. The tensors are streamed, and the file is read back to check its layout. Assisted-by: Claude Opus 5.5
The exl3.* keys set hparams.exl3_codebook. create_tensor then takes "<name>.exl3_trellis/_suh/_svh" for a requested "<name>.weight" and returns the trellis as the weight. This runs before the caller sees a missing tensor, so the optional qwen35 head is not replaced by the tied embedding. The buffer type is probed with the EXL3 op. build_lora_mm makes ggml_exl3_mul_mat for these weights, and a check on the reserved graph refuses any other op that reads a trellis. The arch whitelist is qwen35. EXL3 weights are refused with prism.hadamard, with LoRA adapters, with the MTP draft vocabulary and for models built without a file. A build whose backends do not support the op says so at load time. The qwen35 graph is unchanged: the converter already reordered the V-head blocks of the linear-attention linears. Assisted-by: Claude Opus 5.5
The float32 torch.exp of x86 torch wheels is MKL vmsExp, which is not correctly rounded. In the Qwen3.5-4B EXL3 checkpoint exp(-0.90234375) lies 0.002 ulp from a float32 midpoint: MKL rounds it down, libm and the float64 result round it up. A C++ importer cannot reproduce MKL, so for EXL3 checkpoints ssm_a is now computed in float64 and rounded once. The container changes in one element (blk.20.ssm_a[15], 1 ulp). Other conversions are unchanged. Assisted-by: Claude Opus 5.5
llama_model_init_from_user builds a virtual model: every tensor the model code asks for is made, with the type of a tensor of the same name in the metadata if there is one. If the tensors in the metadata have shapes, they are now indexed like the tensors of a model file: shapes are checked, an optional tensor that is not there stays missing (so the tied output fallback works), an EXL3 linear is found by its trellis, and done_getting_tensors checks that every tensor is used. The data still come from set_tensor_data. Tensors without a shape keep the virtual model (test-llama-archs). Model files are not affected. Assisted-by: Claude Opus 5.5
The loader counted the int16 words of an EXL3 trellis and its scale vectors as parameters, so the Qwen3.5-4B EXL3 container reported 1.77 B. A trellis now counts as the k x n weights of its linear and the scale vectors count as none, as the converter does for general.size_label. The container now reports 4.84 B (its lm_head is stored apart from the embedding). Assisted-by: Claude Opus 5.5
With GGML_EXL3=ON, -m DIR of the tools built on common loads an exllamav3 directory as shipped. common/exl3-dir.cpp reads config.json, the header of every *.safetensors file and the tokenizer files, builds the GGUF metadata and tensor set that convert_hf_to_gguf.py writes for the directory (qwen35 only), and gives them to llama_model_init_from_user. The data are copied from the safetensors files while the model loads (no mmap). - tensors are found by reading every safetensors header, with or without an index, so a side file the index does not list is found; a tensor name in two files is refused; quantization_config.json (tensor_storage) is not read - tensor offsets are only read into buffers (they are 2 mod 4 in real files) - the vision tower and MTP tensors are not loaded, and no MTP layer count is taken from config.json - a stored lm_head is loaded also when tie_word_embeddings is set - the pre-tokenizer is named by the sha256 of the tokenizer.json normalizer and pre_tokenizer, and an unknown one is refused - model.vocab of tokenizer.json is parsed by a small scanner, because common_json parses an object with 250k keys in quadratic time For UnstableLlama/Qwen3.5-4B-exl3-4.00bpw the import is equal to the converter's container (all 829 tensors, their bytes and every key except the general.* provenance keys), and -m DIR gives logits that are byte-identical to the container's on the four correctness corpora. test-exl3-dir runs a synthetic directory, and its --compare mode compares an import with a container. Assisted-by: Claude Opus 5.5
The 15 EXL3_MUL_MAT rows of test-backend-ops support --output csv on a CPU build with GGML_EXL3=ON are appended to docs/ops/CPU.csv, and docs/ops.md is regenerated with scripts/create_ops_docs.py. The rest of the CSV is not regenerated: the current test-backend-ops writes about 37k rows against the 20k of the committed file, which would rewrite rows that have nothing to do with this op. The script reproduces the committed ops.md unchanged before the rows are added. Assisted-by: Claude Opus 5.5
Allow LazyChunkedTensor in the writer input and stored tensor annotations, reject a missing EXL3 codebook before add_string, and remove the unused LazyTorchTensor import. Assisted-by: Codex
write_exl3_experts stacked every projection's expert trellises eagerly and handed the arrays to the GGUF writer, which keeps them until the final write, so memory grew to the size of all expert tensors (Qwen3.8-Flash-Next 2.05bpw: OOM-killed at a 10 GiB limit after 16 of 48 layers). The trellis now goes to the writer as a LazyChunkedTensor of per-expert loaders, as the n-gram row tables already do; suh / svh stay stacked (small). Peak RSS for the 2.05bpw conversion: about 1.2 GiB. Assisted-by: Claude Code (cherry picked from commit 8b93194)
Keep the K7 non-routed W4 two-product tuple and arithmetic unchanged while shortening activation liveness. Add decode and 33-row K7 cases for all three codebooks. ROCm 10.1 gfx1151 final assembly clears all three spills: 256 to 244 VGPRs, 3 to 0 spill saves, 16 to 0 scratch bytes per lane. GPU numerical parity and performance remain unverified in this CPU-only pass. Assisted-by: Codex
Apply the environment override after selecting dense and EXL3 defaults. Update lazy-mode help and EXL3 documentation. Assisted-by: Codex
Describe the fixed one-product threshold for contiguous rows and routed rows per expert without tying EXL3 precision to the MMB dispatcher. Assisted-by: Codex
Enable EXL3 in both HIP quality builds and extend the clean gfx1151 metrics inventory with its 446 kernels. Preserve all existing TU counts and spill budgets. Assisted-by: Codex
Assisted-by: Codex
Assisted-by: Codex
…egisters) Wave32 kernels for the EXL3 linear of halo-box#201 (GGML_EXL3, see ggml/exl3/README.md). exl3_rotate computes H(x*suh) in f32 as the CPU op does and zeroes the arrival counters. exl3_mul_mat_vec decodes each lane's 8 weights of a tile to the exact fp16 codebook values (3inst, mcg, mul1; K = 1..8 and 1.5, 2.5, 3.5, all as specialization constants), accumulates in f32 for 1, 2, 4 or 8 rows per pass (more rows in groups of 8), and the last workgroup of a 128-column segment applies H and svh/128. Scratch in prealloc_split_k. Qwen3.5-9B EXL3 4.00bpw, gfx1151: decode 40.5 t/s (EXL3 linears on the CPU: 1.31 t/s), wiki PPL 7.9652 (CPU 7.9651). Assisted-by: Claude Opus 5.5
…egisters) Wave32 kernels for the EXL3 linear of halo-box#201 (GGML_EXL3, see ggml/exl3/README.md). exl3_rotate computes H(x*suh) in f32 as the CPU op does and zeroes the arrival counters. exl3_mul_mat_vec decodes each lane's 8 weights of a tile to the exact fp16 codebook values (3inst, mcg, mul1; K = 1..8 and 1.5, 2.5, 3.5, all as specialization constants), accumulates in f32 for 1, 2, 4 or 8 rows per pass (more rows in groups of 8), and the last workgroup of a 128-column segment applies H and svh/128. Scratch in prealloc_split_k. Qwen3.5-9B EXL3 4.00bpw, gfx1151: decode 40.5 t/s (EXL3 linears on the CPU: 1.31 t/s), wiki PPL 7.9652 (CPU 7.9651). Assisted-by: Claude Opus 5.5
…egisters) Wave32 kernels for the EXL3 linear of halo-box#201 (GGML_EXL3, see ggml/exl3/README.md). exl3_rotate computes H(x*suh) in f32 as the CPU op does and zeroes the arrival counters. exl3_mul_mat_vec decodes each lane's 8 weights of a tile to the exact fp16 codebook values (3inst, mcg, mul1; K = 1..8 and 1.5, 2.5, 3.5, all as specialization constants), accumulates in f32 for 1, 2, 4 or 8 rows per pass (more rows in groups of 8), and the last workgroup of a 128-column segment applies H and svh/128. Scratch in prealloc_split_k. Qwen3.5-9B EXL3 4.00bpw, gfx1151: decode 40.5 t/s (EXL3 linears on the CPU: 1.31 t/s), wiki PPL 7.9652 (CPU 7.9651). Assisted-by: Claude Opus 5.5
…egisters) Wave32 kernels for the EXL3 linear of halo-box#201 (GGML_EXL3, see ggml/exl3/README.md). exl3_rotate computes H(x*suh) in f32 as the CPU op does and zeroes the arrival counters. exl3_mul_mat_vec decodes each lane's 8 weights of a tile to the exact fp16 codebook values (3inst, mcg, mul1; K = 1..8 and 1.5, 2.5, 3.5, all as specialization constants), accumulates in f32 for 1, 2, 4 or 8 rows per pass (more rows in groups of 8), and the last workgroup of a 128-column segment applies H and svh/128. Scratch in prealloc_split_k. Qwen3.5-9B EXL3 4.00bpw, gfx1151: decode 40.5 t/s (EXL3 linears on the CPU: 1.31 t/s), wiki PPL 7.9652 (CPU 7.9651). Assisted-by: Claude Opus 5.5
…egisters) Wave32 kernels for the EXL3 linear of #201 (GGML_EXL3, see ggml/exl3/README.md). exl3_rotate computes H(x*suh) in f32 as the CPU op does and zeroes the arrival counters. exl3_mul_mat_vec decodes each lane's 8 weights of a tile to the exact fp16 codebook values (3inst, mcg, mul1; K = 1..8 and 1.5, 2.5, 3.5, all as specialization constants), accumulates in f32 for 1, 2, 4 or 8 rows per pass (more rows in groups of 8), and the last workgroup of a 128-column segment applies H and svh/128. Scratch in prealloc_split_k. Qwen3.5-9B EXL3 4.00bpw, gfx1151: decode 40.5 t/s (EXL3 linears on the CPU: 1.31 t/s), wiki PPL 7.9652 (CPU 7.9651). Assisted-by: Claude Opus 5.5
The GEMM path took one f16 product for every expert group from 512 tokens. #201 takes one product only for an expert with at least 512 routed rows and hi + lo for the others. The route now writes a second group table for those experts (one_rows = 512 from 512 tokens on the GEMM path, as exl3_mmid_route on HIP); the rotation always writes lo, the hi + lo GEMM runs over table 0 and the one-product GEMM over table 1. No GEMM work on an empty MUL_MAT_ID (n_pairs == 0). Tests: a per-case NMSE limit for EXL3_MUL_MAT_ID, 512 tokens at 128 experts (32 rows each) at 1e-10, and one expert with 600 rows (one product) at the default limit. Assisted-by: Claude Opus 5.5
…egisters) Wave32 kernels for the EXL3 linear of halo-box#201 (GGML_EXL3, see ggml/exl3/README.md). exl3_rotate computes H(x*suh) in f32 as the CPU op does and zeroes the arrival counters. exl3_mul_mat_vec decodes each lane's 8 weights of a tile to the exact fp16 codebook values (3inst, mcg, mul1; K = 1..8 and 1.5, 2.5, 3.5, all as specialization constants), accumulates in f32 for 1, 2, 4 or 8 rows per pass (more rows in groups of 8), and the last workgroup of a 128-column segment applies H and svh/128. Scratch in prealloc_split_k. Qwen3.5-9B EXL3 4.00bpw, gfx1151: decode 40.5 t/s (EXL3 linears on the CPU: 1.31 t/s), wiki PPL 7.9652 (CPU 7.9651). Assisted-by: Claude Opus 5.5
Overview
Implements native exl3 support
Measurements
Measured GSM8K results, they're within margin of error of each other (I think a difference of one out of the 1000+ questions).