mirror of
https://github.com/mw00/project-maya.git
synced 2026-12-03 21:08:26 +07:00
[PR #265] [MERGED] EXL3: exllamav3 1.6's half-integer bitrates (K 1.5 / 2.5 / 3.5) - every decoder bit for bit exllamav3's #434
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
mw00/project-maya#434
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/mw00/project-maya/pull/265
Author: @sociolog
Created: 10/18/2026
Status: ✅ Merged
Merged: 10/20/2026
Merged by: @mw00
Base:
main← Head:exl3-half-k📝 Commits (1)
986ca21EXL3: exllamav3 1.6's half-integer bitrates (K 1.5 / 2.5 / 3.5) - every decoder bit for bit exllamav3's📊 Changes
24 files changed (+1108 additions, -676 deletions)
View changed files
➕
data/exl3-exllamav3/exl3_k2_3_cb2.bin(+0 -0)➕
data/exl3-exllamav3/exl3_k2_5_cb2.bin(+0 -0)➕
data/exl3-exllamav3/exl3_k2_7_cb2.bin(+0 -0)📝
include/strata/core/glm_model.hpp(+2 -2)📝
include/strata/kernels/cpu/exl3_cpu.hpp(+8 -5)📝
include/strata/kernels/cpu/exl3_ref.hpp(+8 -4)📝
include/strata/kernels/exl3.hpp(+18 -7)📝
src/core/glm_fast_path.cu(+6 -6)📝
src/core/glm_model.cu(+62 -21)📝
src/core/glm_prefill.cu(+2 -2)📝
src/ds4/ds4_gguf.cu(+5 -4)📝
src/ds4/ds4_gguf.cuh(+7 -5)📝
src/ds4/ds4_model.cu(+36 -28)📝
src/kernels/cpu/exl3_cpu.cpp(+337 -180)📝
src/kernels/cpu/exl3_cpu_bench.cpp(+32 -19)📝
src/kernels/cpu/exl3_ref.cpp(+10 -6)📝
src/kernels/cuda/exl3.cu(+182 -131)📝
src/kernels/cuda/exl3_legacy.cu(+88 -75)📝
tests/ds4_cpu_bench.cpp(+1 -1)📝
tests/ds4_gguf_test.cu(+4 -4)...and 4 more files
📄 Description
What
exllamav3 1.6 writes half-integer bitrates K = KA + 0.5 - 24 / 40 / 56 int16 words a 16x16 tile, the mul1 codebook
only - where a self-calibrated quant's budget for a layer falls between two integer widths (e.g. a community SC 4.05 of
Qwen3.8-Flash-Next has K 3.5 gate / up in 8 of its MoE layers). Their trellis steps alternate KA bits (even step) and
KA + 1 (odd step), so step p's 16-bit window ends at
which is (p + 1) K for an integer K as well. Today
tools/exl3_pack.pyrefuses such a model ("half-integer bitrate ...not supported yet") and the engine and its kernels take K 1..8. This makes every path take K 1.5 / 2.5 / 3.5.
exl3::Mat::k2,ExpertLayout::k2[3],cpu::Exl3Part::k2, the pack'smatrices and layers,
trellis_bytes->trellis_bytes_k2,exl3_inner->exl3_inner_k2(renamed, so no callerpasses a K where a k2 is meant).
k2_supported(k2, cb): K 1..8 with any codebook, 1.5 / 2.5 / 3.5 with mul1.bitrate, refused by name) and writes such a K as
3.5inexl3.txt. Integer packs are written byte for byte asbefore. The engine reads
KorK.5(by hand, so no locale's decimal point matters), checks every matrix and layerpart against
k2_supportedat load (and that a layer's gate and up have one K, as the blob's layout needs), andsizes each part from k2 (16 k2 bytes a tile), every layer its own. An engine from before this change refuses a
3.5line ("exl3.txt: bad mat line" / "bad layer line") instead of misreading it.
exl3.cu):frag8takes K2; an odd K2 decodes throughfrag8_half- exllamav3'sdq8_half: alane's 8 steps start even, so their windows end at S(p + 7) = (p / 2 + 4) K2 and then KA + 1, KA, KA + 1, ... bits
earlier; four windows span 18 + 3 KA <= 27 bits, one funnel shift of two words for each group of four. One change for
the decode GEMV, the routed experts, the verify window, the prompt path's tensor-core set kernels and its decoded W'.
dispatchinstantiates K 1..8 x 3 codebooks and the half K with mul1 (three more instances of each kernel), andrefuses anything else before a launch.
exl3_legacy.cu(GPUs before sm_80):state_attakes S(p).int16 a tile), its experts checked against
k2_supportedat load. The ggml types its GGUF matrices and experts kept inMat::KandExpertLayout::Kget a field of their own (Mat::gg_type,ExpertLayout::gg_type[3]). Checked on anRTX 4000 (sm_75):
ds4_gguf_testALL OK (every streamed expert bit for bit its VRAM copy),exl3_testandexl3_exllamav3pass.exl3_cpu.cpp): the scalar and AVX-512 kernels are table-driven - their tables take S(p). The AVX2integer path rests on an invariant a half K breaks: a half row's 8 windows lie in one residue class of the words with
one shift, but at K 3.5 the columns are 3.5 words apart. Its half-K path (
Avx2TileHalf) uses what holds instead,as
dq8_halfdoes: a lane's 4 windows of one column span <= 27 bits, so per tile the k2 "pair" registers[class rho | class rho + KA] (128-bit loads and 4x4 transposes, never past the tile), per group of rows one
vpermdfor each of the span's two words, per-lane shifts and an or - every gather is still one
vpermd, a row's states oneimmediate shift and a mask. The row kernels take a
Tile(Avx2TileInt: the class registers exactly as before). AnAVX-512 CPU runs a half K on the AVX2 kernels: the same bits, and the AVX-512 instances could not be run where this
was written (a Zen 3).
exl3_cpu_bench --Ktakes 3.5.tools/exl3_exllamav3_fixture.pypacks half-integer tiles with exllamav3'spack_trellis_frac(MASK 0xAAAA, the onepattern exllamav3 instantiates);
data/exl3-exllamav3gets K 1.5 / 2.5 / 3.5.Same bits
RTX 3060 (sm_86), Ryzen 9 5900X (AVX2):
exl3_test --exllamav3,tools/test_exl3_exllamav3.py): its tiles at K 1.5 /2.5 / 3.5 - states and W' 0 of 4,096 differ in the CPU reference, the CPU tiers' exact model and
exl3_pack'sdecoder, the device's W' 0 of 16,384 in both layouts, the AVX2 tier bit for bit that model.
Vemloir's sc-exl3 4.05 of Qwen3.8-Flash-Next (the same EXL3 1.6 format) - experts at K 3.5 (layers 1, 4, 7, 9), 5, 3
and 4 and a K 7
out_proj, 10 matrices, against exllamav3's reconstruct (exl3_test --expect): W' 0 differences inevery one (CPU reference, device both layouts), the AVX2 tier bit for bit its model.
exl3_test, now with K 1.5 / 2.5 / 3.5 everywhere, and SC-style experts - gate / up3.5 with down 5, 1.5 with 3, 2.5 with 4 - in the routed-expert, verify-window and set kernels): 217 ok on the
tensor-core kernels and 217 with
MAYA_GLM_EXL3_DECODE=legacy; a half K with 3inst / mcg is refused. Its 142integer cases run first, in the order they always ran: the same numbers as before to the last digit.
sc_3.10bpw(Maya's scorer, 1,135 held-out tokens, a two-GPU split,the CPU lane off) against v1.1.15: KL 0.000000 (max 0.0000), the same top token 100 %, nll 1.29114 both;
with the CPU lane on (its plan fixed, the cards loaded one after the other) KL 0.000000, nll 1.28070 both, the same
80,824 experts on the CPU and the same tiers; its 12 matrices against exllamav3 as before (84 / 84). The build's
ctest (56 of 58 -
ple_parityneeds a Qwen3.8 model file andexpert_multi_testan AVX-512 CPU), the tools tests(274) and
tools/check_hip_compat.pypass.sc_3.10bpwwith layer 10's routed gate and up (576 matrices, K 3) decoded by exllamav3'sreconstructand encodedagain at K 3.5 by its own quantizer (
quantize_tileswith mul1,pack_trellis_frac; its unpacker reads back thechosen states in all 576), everything else as stored.
tools/exl3_pack.pypacks it (layer 10 2 3.5 3.5 3 ...,3,682,304-byte gate / up parts beside layer 11's 3,158,016); three of the new matrices against exllamav3
(
exl3_test --expect): W' 0 of 8,388,608 differ in each, CPU reference and device both layouts. Maya's scorer(1,135 held-out tokens) against the unchanged
sc_3.10bpw: KL 0.0135 with the CPU lane off (the same top token97.1 %, nll 1.2857 against 1.2911) and 0.0128 with it on (96.6 %, 80,914 experts on the lane) - the device's and the
lane's half-K paths agree. The KL is the re-encoding of the layer (W'' is 9.3 % RMS from W'), not the half-integer
path: the same pipeline gives back the stored weights exactly at their own K 3 (0.0000 RMS), and at an integer K 4
(6.6 % RMS) costs KL 0.0117 (96.2 %) - the same size. v1.1.15 refuses the pack at load:
exl3.txt: bad layer line: layer 10 2 3.5 3.5 3 ....Not done
frag8branch; not built here.Credit: the half-integer layout and
dq8_half's grouping are exllamav3's (MIT, turboderp).🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.