Repository navigation
Conversation
tiles() takes BK 64 in place of 32 for every shape. tl.dot runs the same mma.m16n8k16 chain over K in k16 order either way, so every output bit is unchanged (a sweep of the 27B's 13 projection shapes found no differing bit); the loads are wider and the loop half as long. Measured on a DGX Spark (GB10), turboderp/Qwen3.8-27B-exl3 4.00bpw through tensorfold serve, cold prompts: 8K 981 -> 1,034 tok/s (+5.4%), 32K 954 -> 1,005, 64K 885 -> 923, 126K 773 -> 804 (+4.0%). Greedy replies are hash-identical to before at 1K-64K. Tests: tests/cuda/test_exl3_prefill.py checks that K steps of 32 and 64 give the same bits on four codebook/width/shape cases at 300 rows.
…milies that opt in A family that passes Workspace(fold=True) (the 27B's EXL3 loader does) runs its bf16 prompt matmuls on W'' = diag(suh) H W_q H / 128: unpack_fold2 decodes the trellis and applies both 128-point Hadamards and suh in one kernel, rounding once to bf16, and _gemm_fold (a fixed-tile bf16 Triton GEMM, fp32 accumulation, K in order) multiplies the raw bf16 rows by it, then svh and the bias. No rot_in pass and no Hadamard epilogue run. Tiles depend on (K, N) alone (FOLD_TILES, swept on a GB10 for the 27B's shapes), so a row's bits never depend on its chunk and resumed prompts still equal fresh ones. Other families (Flash Next's EXL3 projections) keep the W_q path unchanged. unpack_fold is the straightforward kernel (fp32 shared tile, fwht128 along rows then columns); unpack_fold2 gives the same bits faster: the N side runs in registers on the decoded fragments, the K side through shared memory in two 64-column halves with XOR swizzles, two blocks an SM. On the 27B's 409 groups it is bit-identical in bf16 and fp16 and decodes the whole model in 315 ms against 552 (207 GB/s read+write, GB10's DRAM floor). Measured on a DGX Spark (GB10), 27B 4.00bpw, layers 2+3 at 4,096 rows: the GEMM on a decoded W'' takes 66.7 ms against 95.0 for the W_q path (BK 64), where MLX 4-bit's prompt matmul takes 71.6. The decode itself is paid once a call here; the next commit holds a layer's W'' for a whole prompt. Accuracy: bf16 weights round more coarsely than fp16 (2.28e-3 mean relative error per matmul against float64, 1.44e-3 before), which does not show end to end: KL(BF16 || EXL3) over 49,152 held-out tokens 0.01838 against 0.01841 before, top-1 96.77% against 96.74%. Switches: TENSORFOLD_EXL3_FOLD=0 (every family on the W_q path), TENSORFOLD_EXL3_FOLD_BF16=0 (fp16 W'' and fp16 rows), TENSORFOLD_EXL3_FOLD2=0 (unpack_fold). docs/recipes/exl3.md describes both paths. Tests: tests/cuda/test_exl3_prefill.py: unpack_fold2 == unpack_fold on seven codebook/width cases in bf16 and fp16; W'' and the folded matmul against float64 references; rows on the folded path bit-identical alone, in windows of 1-300 rows and at an offset, on four shapes; a plain Workspace keeps the W_q path's bits, and TENSORFOLD_EXL3_FOLD=0 restores them.
…(same bits) On one GPU, an EXL3 pack's prompt of two or more chunks (dense layers, no image) now runs every chunk through layer l before layer l + 1. The folded prompt path decodes each projection's W'' once a prompt instead of once a chunk and holds it only while its layer runs (cuda/exl3/prefill.py scope_begin / release / end), so a 64K prompt decodes the weights once, not 16 times, without keeping the whole model's W'' (47.7 GiB in bf16 for the 27B). prefill_rows' forward becomes _Rows, set up once and run a layer at a time, so prefill_rows (one forward over several streams' rows, upstream's batched fill) and the layer-major prefill share one per-layer body; each chunk is one _Rows of one item and makes the same calls on the same rows as chunk by chunk, so every state, kept state, last row and drafter tap has the same bits. A kept point at a chunk start moves that chunk's bound one row on (any bounds give the same bits). TP, image prompts, MoE layers and non-EXL3 packs stay chunk by chunk. Measured on a DGX Spark (GB10), 27B 4.00bpw through tensorfold serve (--parallel 4 --context 131072, DFlash2), cold prompt tok/s at 1K / 8K / 32K / 64K / 126K, with the previous commit and without the next one's tail merge: 682 / 1,309 / 1,323 / 1,199 / 1,004, against MLX 4-bit on the same engine in the same session 1,219 / 1,430 / 1,310 / 1,170 / 979 (0.6.0's EXL3 path, an earlier session: - / 1,003 / 950 / 890 / 773). Host memory available while serving: 65.4 GiB against 71.9 for MLX 4-bit. Short prompts are behind: one chunk still pays a whole-model decode (0.21 s at GB10's DRAM rate); the next commits address that. TENSORFOLD_PREFILL_LAYER_MAJOR=0 runs chunk by chunk. Tests: tests/cuda/test_qwen27_exl3_prefill.py on a synthetic GDN + attention EXL3 model: layer-major == chunk by chunk (last row, every layer's conv, recurrent and KV state, the kept state) from a fresh and a resumed start, kept points inside a chunk, at chunk starts and at the end; with 64 layers a recording drafter gets the same taps, skips and snapshots; no W'' is held after the prompt; prefill_batch pieces equal each prompt alone.
…e same call (same bits) The server filled a one-message prompt in two calls: to its last stop (the assistant start, usually 3-5 rows before the end) and then the tail. On an EXL3 pack each call decodes every weight, so the tail paid a whole-model decode for a few rows. When the step ends at the last stop and fewer than MIN_GAP rows are left, _step and _steps now prefill to the end with keep_at at the stop (a cut chunk), and the stop's cache entry is the state kept there. Any chunk bounds give the same bits, so the final state, the kept state, the drafter's snapshot and the first token equal the two-call ones; every pack takes the same rule. Measured on a DGX Spark (GB10), 27B EXL3 4.00bpw through tensorfold serve (--parallel 4 --context 131072, DFlash2), cold prompt tok/s at 1K / 8K / 32K / 64K / 126K, same session: 682 / 1,309 / 1,323 / 1,199 / 1,004 without this, 896 / 1,424 / 1,350 / 1,212 / 1,011 with it (MLX 4-bit 1,219 / 1,430 / 1,310 / 1,170 / 979). Greedy replies equal at 1K-64K and tools/bench_concurrent.py found 0 unequal replies (alone and serial) in both builds. TENSORFOLD_PREFILL_TAIL_MERGE=0 fills in two calls. Tests: tests/cuda/test_qwen27_multi.py: a 3-row tail with MIN_GAP 4 fills in one call (two with the switch off), keeps the shared prefix, and both later prompts resume from it to their serial tokens.
…per 16 or 32 rows (same bits) linear_kernel runs 16 rows a pass and reads and decodes every trellis word again each pass; a big layer's words (the 27B's gate: 44 MB) exceed L2, so a 128-row call costs eight DRAM sweeps. linear_mpg_kernel<P> gives each CTA one 16 P-row group of one column block (P = 1 for 17-48 rows, 2 for 49-128), decodes each k step's tiles once for its P passes, and puts the CTAs of a block side by side in the grid so they read its words from L2 together. The warps keep linear_kernel's K ranges, mma chain from zero, warp-order reduction and split fold, so every output bit equals linear_kernel's at any row count; fp16 operands are unchanged. Measured on a DGX Spark (GB10), 27B 4.00bpw, layers 2+3 under CUDA graphs with L2-busting copies, EXL3 time over MLX 4-bit's: 32 rows 1.50x -> 0.96x, 64 rows 2.44x -> 1.20x, 128 rows 3.04x -> 1.48x; 1-16 rows unchanged (0.92-0.96x). Through tensorfold serve (--parallel 8 --context 32768, DFlash2, tools/bench_concurrent.py --reps 3), aggregate tok/s: code greedy 4 users 122.6 -> 157.1 (+28%), 8 users 129.4 -> 177.9 (+37.5%); chat greedy 8 users 108.0 -> 139.2 (+28.9%); single-user cells within noise. 0 unequal replies (alone and serial) and greedy replies hash-identical before and after. TENSORFOLD_EXL3_MIDM=0 keeps linear_kernel at every row count. The new mode argument of ext.linear names the kernel family so the next commit can add one. Tests: tests/cuda/test_exl3_linear.py: at 1..128 rows the mid-M kernels give linear_kernel's bits on the 27B's projections with the loader's splits and four other shapes, mul1 and 3inst; a row alone equals it inside 128.
…bit mul1 layers (same bits) linear_wc.cuh follows the tiling of MLX's 4-bit qmm: a CTA holds one 128-column block, one K split and 32 or 64 rows; warp w owns column tile w for every row and decodes each of its trellis tiles once a CTA straight into mma B fragments; the words and the fp16 rows stream through a 4-stage cp.async ring (A by ldmatrix from XOR-swizzled rows), with branch-free stages since the stage size divides the K range. Layers split over K with 32+ column blocks (the 27B's in_proj_qkv / in_proj_z at SK 5, out_proj / o_proj at SK 16) run every split in one CTA and add the split sums in registers, so no Z buffer goes through L2. Per row the arithmetic is linear_kernel's: the same K ranges, the same mma chain from zero, range sums in range order and split sums in split order, so every output bit is the same at any row count. Rows: 17-32 one 32-row group, 33-40 the mid-M kernels (4-bit, unsplit), 41-64 one 64-row group, 65-96 three 32-row groups, 97-128 two 64-row groups. Other codebooks and widths keep the mid-M kernels. Measured on a DGX Spark (GB10), 27B 4.00bpw, one verify round (multi_tree_forward with DFlash2 taps and full logits), ms with the mid-M kernels -> with linear_wc (MLX 4-bit): 32 rows 84.6 -> 75.1 (80.0), 64 rows 115.3 -> 86.8 (93.1), 128 rows 213.0 -> 144.7 (139.6). At 128 rows out_proj took 470 us a call against 204 for MLX 4-bit, mostly the 42 MB of split partials through L2; that is gone. Through tensorfold serve (--parallel 8 --context 32768, DFlash2), steady tok/s with 8 streams decoding, code greedy / code sampled / chat greedy / chat sampled: 279 / 283 / 187 / 178 -> 351 / 357 / 236 / 222 (MLX 4-bit 278 / 331 / 214 / 212). 0 unequal replies in tools/bench_concurrent.py, greedy replies equal before and after at 1K-64K, and KL to BF16 unchanged (same logits hash). TENSORFOLD_EXL3_WC=0 leaves these rows to the mid-M kernels. Tests: tests/cuda/test_exl3_linear.py's mode test runs linear_wc too (MODES 0, 6, 7), including a 6-bit split layer of 32 column blocks.
…de the GEMM (same bits) A short prompt (or a short follow-up) on the folded path paid a whole W'' decode and write per call, about 0.27 s for the 27B before its first token. fdirect_kernel takes 4-bit calls of up to TENSORFOLD_EXL3_FDIRECT_ROWS (48) rows when no W'' is held: each program owns one 128-column block and walks K in 128-row blocks in order, rebuilding each W'' block exactly as unpack_fold2 does (same decode, butterflies, scale and rounding) into shared memory, and feeds it straight into one mma.m16n8k16 bf16 chain over K in k16 order from zero, the chain tl.dot runs in _gemm_fold. The output equals unpack_fold2 + _gemm_fold bit for bit, so the choice by row count keeps rows independent of their call. Above 128 rows a call runs in 128-row slices. Measured on a DGX Spark (GB10), 27B 4.00bpw, layers 2+3: 1 row 6.4 ms (decode + GEMM 16.2, MLX 4-bit 2.7), 16 rows 7.8, 32 rows 9.4, 48 rows 12.1; from 64 rows (18.5) the decode + GEMM wins. A whole prefill of 1 token 504 -> 212 ms, 17 tokens 257 ms, 48 tokens 371 ms. Through tensorfold serve, a cold 41-token prompt's first token comes in 0.36 s against 0.53 s, and 8 users' slowest first token in tools/bench_concurrent.py in 0.30 s against 0.58 s. 0 unequal replies, greedy replies unchanged. Limits: each program walks K in order (the bit-exact chain), so narrow, long-K projections under-fill the GPU; one program an SM. TENSORFOLD_EXL3_FDIRECT_ROWS=0 turns it off. fdirect only runs with bf16 W'' (TENSORFOLD_EXL3_FOLD_BF16=1, the default), whose bits it reproduces. Tests: tests/cuda/test_exl3_prefill.py: fdirect == unpack_fold2 + _gemm_fold at 1-200 rows on five shapes (mul1, 3inst, mcg; with and without bias); the folded row-invariance test now crosses the 48/49-row switch.
At some shapes fdirect does not reproduce fold2 + _gemm_fold bit for bit (16 rows of a 4-bit 5120x6144 layer, and layers with a bias), so a short call could round differently from the same rows in a longer call. Off by default every prompt row keeps one arithmetic at any row count; TENSORFOLD_EXL3_FDIRECT_ROWS=48 turns it back on. The bias cases of its test are marked xfail until fdirect matches the GEMM epilogue.
|
A receipt for commits 5 and 6 ( Environment.
Exactness.
Decode speed. Aggregate tok/s, median, alternated on, off, off, on:
Prompt speed. Not measured. These kernels take verify windows of 17-128 rows; our prompt passes are 256 rows or more and take the prompt GEMM. Tests. As above, on GB10: 12 + 24 passed, 0 failed. Our host dispatch test (row ranges, modes, shared-memory and counter bounds per pack shape): 70 passed. What we did not run.
Measured on our DGX Spark with AI assistance (Claude Code). |
|
A one-stream receipt on 0.6.5 from one DGX Spark (GB10), with turboderp's 4.00bpw and 5.00bpw packs. Setup. 0.6.5 ( Tests.
A question on commit 3: Not run: |
…ual stream (same bits) A prompt of several chunks runs layer by layer (cuda prefill, LAYER_MAJOR), so one _Rows per chunk is built up front and every row's x and pending (bf16, hidden wide) live until the prompt ends: 4 * hidden bytes a row, 2.4 GiB at 126K tokens for the 27B. The startup estimate counted one chunk's scratch only, so it printed the same figure with layer-major on and off. admission(layer_major=True) adds 4 * hidden bytes a cache slot, the engine passes LAYER_MAJOR, for one stream and for --parallel alike. Nothing else changes: no kernel, no rounding, no row sees different bits; with TENSORFOLD_PREFILL_LAYER_MAJOR=0 the estimate is as before. Measured on a DGX Spark (GB10), 27B EXL3 4.00bpw, a cold 126K-token prompt, --context 131072: peak torch allocation above its starting level 11.97 GiB layer-major against 9.14 GiB chunk by chunk at --parallel 1 (+2.83), 4.23 against 1.34 at --parallel 4 (+2.89). Estimate printed 29.13 / 30.34 GiB either way before; 31.64 / 32.84 GiB with layer-major, 29.13 / 30.34 without. Replies equal: drafted == "draft": false in 12 of 12 pairs (3 prompts of 20K tokens, 4 configs) and layer-major == chunk by chunk by token_sha. Tests: tests/test_exl3_engines.py::test_admission_counts_a_layer_major_prompts_residual_stream_by_slots fails before (admission() has no layer_major) and passes after.
|
@Arminova, thank you for the receipt, and for asking about commit 3. Short answer: no, the startup estimate does not count it. With layer-major on, Measured on one DGX Spark (GB10), 27B EXL3 4.00bpw, one cold 126K-token prompt,
The estimate printed 29.13 GiB at What we are changing: the admission adds 4 x hidden bytes a cache slot when layer-major is on, for one stream and for
On the 5.00 code reply that differs from stock: the PR text lists commit 2 (W'' held in bf16) among the commits that change the prompt path's rounding, and your KL row shows no cost. We have not run your 5.00 prompts, so we can't say that is the cause. Not run: only the 4.00bpw pack, on one Spark. Resumed equals fresh on real packs and concurrent equals solo were not rerun here; the existing tests cover them. Nothing was rebased onto 0.6.5. |
|
Thank you, @BHCC2025. This is a careful series. The mid-M kernels decode each tile once per 16 or 32 rows, linear_wc covers 4- and 6-bit mul1 layers, layer-major prefill holds one layer's decoded weights, and the tail merge saves a prefill call, each behind its own switch with its own tests. The Python engine is frozen (#286), so this won't merge. The Zig engine has no EXL3 reader or 27B family yet, and Zig CUDA runs only Nemotron. When the 27B's EXL3 packs serve on Zig CUDA, the bit-identical commits come across first, with your credit. The folded weights rounded to bf16 hold fewer bits than the fp16 path they replace, so that part would come across as an opt-in mode, off by default, with the replies it changes documented. |
…ows, projection groups, PDL (same bits) The Python engine's EXL3 speed series (ashhart#260) on the native Dense module. Weight.sk/wk let a family fix a shape's plan (K splits, warps); the mid-M kernels and linear_wc give the linear's bits at 17-128 rows; matmulGroup runs up to three layers of one K over the same rows in one rotation and one linear launch; the rotations and decode-row linears launch with programmatic dependent launch (TF_EXL3_PDL=0: plain), and counters are zeroed once. tf-cuda-test exl3-plans, exl3-midm and exl3-shapes check and time them.
…ows, projection groups, PDL (same bits) The Python engine's EXL3 speed series (ashhart#260) on the native Dense module. Weight.sk/wk let a family fix a shape's plan (K splits, warps); the mid-M kernels and linear_wc give the linear's bits at 17-128 rows; matmulGroup runs up to three layers of one K over the same rows in one rotation and one linear launch; the rotations and decode-row linears launch with programmatic dependent launch (TF_EXL3_PDL=0: plain), and counters are zeroed once. tf-cuda-test exl3-plans, exl3-midm and exl3-shapes check and time them.
…ows, projection groups, PDL (same bits) The Python engine's EXL3 speed series (ashhart#260) on the native Dense module. Weight.sk/wk let a family fix a shape's plan (K splits, warps); the mid-M kernels and linear_wc give the linear's bits at 17-128 rows; matmulGroup runs up to three layers of one K over the same rows in one rotation and one linear launch; the rotations and decode-row linears launch with programmatic dependent launch (TF_EXL3_PDL=0: plain), and counters are zeroed once. tf-cuda-test exl3-plans, exl3-midm and exl3-shapes check and time them.
…ows, projection groups, PDL (same bits) The Python engine's EXL3 speed series (ashhart#260) on the native Dense module. Weight.sk/wk let a family fix a shape's plan (K splits, warps); the mid-M kernels and linear_wc give the linear's bits at 17-128 rows; matmulGroup runs up to three layers of one K over the same rows in one rotation and one linear launch; the rotations and decode-row linears launch with programmatic dependent launch (TF_EXL3_PDL=0: plain), and counters are zeroed once. tf-cuda-test exl3-plans, exl3-midm and exl3-shapes check and time them.
…ows, projection groups, PDL (same bits) The Python engine's EXL3 speed series (#260) on the native Dense module. Weight.sk/wk let a family fix a shape's plan (K splits, warps); the mid-M kernels and linear_wc give the linear's bits at 17-128 rows; matmulGroup runs up to three layers of one K over the same rows in one rotation and one linear launch; the rotations and decode-row linears launch with programmatic dependent launch (TF_EXL3_PDL=0: plain), and counters are zeroed once. tf-cuda-test exl3-plans, exl3-midm and exl3-shapes check and time them.
Summary
On a DGX Spark the 27B's EXL3 packs decode well for one user but were slow at prompts and with several users.
Prompts ran at about two thirds of the MLX 4-bit checkpoint's speed: every prompt chunk decoded every weight again,
rotated its input in a separate pass and ran a Hadamard epilogue. With several users, DFlash2 verify windows of
32-128 rows went through
linear_kernel, which decodes every trellis tile again for each 16 rows. A short promptalso paid a whole-model decode.
This series fixes both without changing what the model computes beyond rounding. Every commit is
row-invariant, so drafted == serial, concurrent == solo and resumed == fresh hold as before. Four of the seven
commits leave every output bit unchanged. The other three change the prompt path's rounding: W'' is held in bf16,
and the raw bf16 rows go into the GEMM. KL to BF16 is unchanged within noise (0.01806 against 0.01841 on 49K
held-out tokens, on 0.6.2; MLX 4-bit is at 0.0568).
The commits stand alone, so you can take any subset. Each one builds, has its own tests and an env switch that
turns it off. The only dependency between them is that 2 → 3 → 7 build on each other (3 and 7 need the folded path
of 2). 1, 4, 5 and 6 are independent of the rest, and 6 needs 5's dispatch argument.
Commits
Speeds are on one DGX Spark (GB10). The model is turboderp/Qwen3.8-27B-exl3 at 4.00bpw with z-lab's DFlash2. The
numbers for each commit come from the session where it was measured, mostly on 0.6.0 before the port. The results
table below is one session on 0.6.2.
perf(exl3 cuda): the prompt GEMM steps K by 64perf(exl3 cuda): prompts on W'' with both rotations folded in, for families that opt inunpack_fold2decodes the whole model's W'' in 315 ms, at GB10's DRAM rateperf(27b cuda): an EXL3 prompt of several chunks runs layer by layerperf(27b cuda): a short tail after the last message start fills in the same callperf(exl3 cuda): verify windows of 17-128 rows decode each tile once per 16 or 32 rowsperf(exl3 cuda): linear_wc for 17-128-row verify windows of 4- and 6-bit mul1 layersperf(exl3 cuda): 4-bit prompt calls of up to 48 rows rebuild W'' inside the GEMMfix(exl3 cuda): fdirect off by default (TENSORFOLD_EXL3_FDIRECT_ROWS=0)What each one changes:
tiles()steps K by 64.tl.dotruns the same k16 chain, so the bits are unchanged.unpack_fold2decodes the trellis and applies both 128-point Hadamards andsuhinone kernel, rounding once to bf16.
_gemm_fold(fixed tiles by (K, N), fp32 accumulation, K in order) multipliesthe raw bf16 rows by that. There is no
rot_inand no epilogue.unpack_foldis the plain reference kernel;unpack_fold2reproduces its bits. Only a family that passesWorkspace(fold=True)takes this path, which hereis the 27B's EXL3 loader. Flash Next's EXL3 projections keep the W_q path, since we haven't measured them.
prefill_rows' forward becomes_Rows, which runs one layer at a time. Your batchedfill and the layer-major prefill share one per-layer body. A multi-chunk EXL3 prompt on one GPU runs every chunk
through layer l before layer l + 1, and a scope in
cuda/exl3/prefill.pyholds each W'' only while its layerruns. TP, images, MoE layers and non-EXL3 packs stay chunk by chunk.
MIN_GAProws left,_stepand_stepsprefill to the end with
keep_atat the stop. The stop's cache entry comes from the kept state. Any chunk boundsgive the same bits, and every pack takes this rule.
linear_mpg_kernel<P>gives each CTA 16 P rows of one column block. CTAs of a block sit sideby side in the grid, so they read its words from L2 together. It keeps
linear_kernel's K ranges, chain andfixed-order sums.
ext.lineargains amodeargument for the kernel family.mul1layers, this follows the tiling of MLX's qmm. Each warp decodes its tileonce per CTA into mma fragments, through a 4-stage
cp.asyncring. Split layers with 32+ column blocks add theirsplit sums in registers in split order, with no Z buffer. Other codebooks and widths keep 5.
unpack_fold2does and feed itstraight into one bf16 mma chain over K in k16 order, which is the chain
tl.dotruns. The output isunpack_fold2+_gemm_foldbit for bit on most shapes, but not all: on 16 rows of a 4-bit 5120x6144 layer,and on layers with a bias, it rounds differently from the GEMM. So commit 8 turns it off by default, and
every prompt row keeps one arithmetic at any row count.
TENSORFOLD_EXL3_FDIRECT_ROWS=48turns it back on.Its test marks the bias cases xfail until fdirect matches the GEMM's epilogue. We're happy to drop commit 7
instead if you'd rather not carry it until then.
Not included:
b16.prompt/prompt_pair).but it moves the server's cache entry to the last message start, so it is a follow-up if you want it.
Results: one session on 0.6.2
These runs had fdirect (commit 7) on. With commit 8's default (off), a lone short prompt's first token
goes back to about 0.5 s, as on stock; the cold-prompt and 8-user figures are not affected by it.
Same Spark, same session: stock 0.6.2 with the MLX 4-bit checkpoint (Vontra/Qwen3.8-27B-MLX-4bit), stock 0.6.2
with the EXL3 4.00bpw pack, and this branch with the same pack. DFlash2 on.
Cold prompts (
--parallel 4 --context 131072), tok/s:Your
tools/bench_concurrent.py --levels 1,2,4,8 --alone --serial --reps 3(--parallel 8 --context 32768),aggregate tok/s at 1 / 2 / 4 / 8 users:
0 unequal replies (alone and serial) in every cell for all three. Against stock EXL3 the branch is 2.0x at 8 users
on code and +69% on chat. Against MLX 4-bit it is level or ahead from 2 users up; one user on chat is behind
(45 vs 51 greedy), and a lone short prompt's first token takes 0.23 s against 0.11. A second Spark, same settings,
gave the branch 365 / 229 at 8 users (code / chat greedy) and 1,370 / 1,300 / 981 tok/s cold at 8K / 32K / 126K.
For reference, the same kernels on 0.6.0 (one session, same box) gave the following. Cold prompts ran +0.7% /
+3.9% / +4.2% / +3.8% against MLX 4-bit at 8K / 32K / 64K / 126K. With
--parallel 8the aggregate ran +2..+36%in every multi-user cell. The one-user sampled-chat cell was -11%, which is seed variance: over 16 seeds it is
45.9 against 46.7 tok/s. A lone short prompt's first token took 0.23 s against MLX 4-bit's 0.11 s.
Exactness
Drafted == serial:
test_checkpoint_drafted_equals_serialon the real pack (greedy and two seeds) passes on the branch tip and at every commit.Concurrent == solo:
tools/bench_concurrent.py --alone --serialgave 0 unequal replies in every cell, for every commit's build, for the full branch's kernels on 0.6.0, and in the 0.6.2 session above.Resumed == fresh: every prompt row's bits depend only on its tokens, at any chunking, step or batch. The tests
in each commit check this on the kernels (rows alone, in windows, at offsets, across the fdirect and mid-M
switches) and on the prompt path. For the prompt path that covers layer-major against chunk by chunk, kept states,
drafter taps, and
prefill_batchpieces against each prompt alone. Yourtest_prompts_ignore_chunking_and_resume_as_freshand the prompt-end-cache tests pass as before. Greedy replies to the 1K-64K prompts are equal across the
bit-identical commits.
Quality: KL(BF16 || EXL3) over 49,152 held-out tokens (96 windows of 512; prose, code and chat), on
TensorFold's own prompt path:
The branch's KL to stock 0.6.2's own EXL3 output is 0.00091 (top-1 agreement 99.49%), about 1/20 of the
quantization's own drift, in both directions around BF16. Stock EXL3 gives the same logits on 0.6.0 and 0.6.2.
Memory
The layer-major path holds one layer's W'' (about 0.75 GiB in bf16 for the 27B) instead of the whole model's (47.7
GiB). Host memory available while serving, from the minimum over the run:
--parallel 4 --context 131072, after the long prompts--parallel 8 --context 32768, during the benchOne gap we left for you to decide. Admission (
exl3_workspace) still counts one decoded matrix. During alayer-major prompt the scope holds a whole layer's W'' (about 0.45 GiB more on the 27B), and a long prompt's
activations stay alive across chunks. We can add both to the estimate if you prefer.
Method
pytorch:26.07-py3-based container, torch 2.13,CUDA 13.3.
Vontra/Qwen3.8-27B-MLX-4bit on the same engine.
tensorfold servewith--parallel 4 --context 131072for prompts and--parallel 8 --context 32768for concurrency. Cold prompts were 8K-126K tokens of public text, a fresh server per build, andservers ran one at a time on an otherwise idle GPU.
tools/bench_concurrent.py --levels 1,2,4,8 --alone --serial --reps 3(seed 1234). Thesampled cells were also run at seeds 2234 and 3234.
PLANSsplits. Exactnessused
torch.equal.Env switches
All are read at import, and each restores the previous behaviour of its commit:
TENSORFOLD_EXL3_FOLDTENSORFOLD_EXL3_FOLD_BF16TENSORFOLD_EXL3_FOLD2unpack_fold, the plain kernel (same bits)TENSORFOLD_PREFILL_LAYER_MAJORTENSORFOLD_PREFILL_TAIL_MERGETENSORFOLD_EXL3_MIDMlinear_kernelat every row count (commits 5 and 6)TENSORFOLD_EXL3_WCTENSORFOLD_EXL3_FDIRECT_ROWSWe're glad to drop any of these switches, rename them, or fold them into your own settings.
Checks
tests/cuda/test_exl3_prefill.py: BK 32 == BK 64; fold2 == fold; float64 references; folded rows alone, inwindows and at offsets; opt-in; fdirect == fold2 + GEMM (bias cases xfail; fdirect is off by default).
tests/cuda/test_qwen27_exl3_prefill.py: layer-major == chunk by chunk, with a drafter, no W'' held after aprompt, and
prefill_batch== each prompt alone.tests/cuda/test_exl3_linear.py: every kernel mode giveslinear_kernel's bits at 1..128 rows.tests/cuda/test_qwen27_multi.py: tail merge.test_exl3_linear.py,test_exl3_checkpoint.py,test_exl3_experts.py,test_qwen27_exl3.py,test_glm_exl3.py,test_qwen4_exp_exl3.pyplus the new files):163 passed / 60 skipped. Stock 0.6.2 gives 147 / 60 (the 16 more are this branch's new tests). The skips need
exllamav3installed.maintest by test (3,118 passed; the same 133 failuresand 13 errors on
mainin that container, which has no MLX).ruff checkon the touched files: no new findings againstmain.Happy to rework any of it, split it into separate PRs, or port the folded path to Flash Next's EXL3 projections
if you want that measured too.