Skip to content

glm cuda: csf0_v1 checkpoints, routed experts at block 32 with each row's scales as a base and 4-bit offsets - #2041

Merged
ashhart merged 7 commits into
ashhart:mainfrom
Bizuayeu:pr/glm-b32-csf0
Nov 4, 2026
Merged

ashhart merged 7 commits into
ashhart:mainfrom
Bizuayeu:pr/glm-b32-csf0

Conversation

@Bizuayeu

@Bizuayeu Bizuayeu commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

GLM-5.3-Flash's routed experts take 13.2 GiB less memory across TP=2's two ranks when the checkpoint holds them at block 32 instead of 16 and writes each row's scales as one base and 4-bit offsets. Prompts take 0.5 to 0.8% less time and decode moves by −0.9 to +0.1%. Bizuayeu/GLM-5.3-Flash-Jammed-XSFP4 is such a checkpoint. A block 16 checkpoint loads and runs as it does on main.

On GB10 (MSI EdgeXpert), one stream:

TP=2, block 16 TP=2, csf0_v1 TP=3, block 16 TP=3, csf0_v1
Rank 0's model (GiB) 90.01 83.43 63.02 58.52
Left after the reserve (GiB) 13.1 19.7 40.3 44.9
Prompt cache (GiB) 6.7 13.3 16.0 16.0
Decode, fibonacci-raw (tok/s) 24.51 24.44 30.66 30.39
Decode, gpu-chat-no-think (tok/s) 24.57 24.60 30.66 30.40
Prompt of 9,600 tokens (s) 7.42 7.36 5.90 5.86
Prompt of 38,400 tokens (s) 29.16 29.02 23.05 22.91

The block 16 columns are main on the checkpoint's values written in the block 16 layout, and the csf0_v1 columns this branch on the checkpoint itself, so every column of a TP size returns the same tokens. The memory rows are from launches at a 524,288-token window at TP=2 and 1,048,576 at TP=3; the speed rows from launches at 40,960, MTP drafts off for decode, medians of two rounds. At TP=3 the prompt cache stops at its 16.0 GiB ceiling in both, and the saving stays free: rank 0 had 27 GiB available after load against 23.

What this changes

  • The form. A quantized_layers entry of {"quant_algo": "NVFP4", "group_size": 32, "weight_scale_encoding": "csf0_v1"} holds, in place of weight_scale, weight_scale.csf0_bases ([rows], u8) and weight_scale.csf0_codes ([rows, columns / 64], u8, two offsets a byte). A group's scale is e4m3(base + offset). admitRecipes takes that pairing alone: NVFP4 at group 32 without the encoding, and the encoding at any other group or algorithm, are refused by module as before.
  • The loader. cuda_formats.csf0Linear reads the parts and cuda_load_pack packs them as stored, by any number of packers. A layer that mixes forms, or whose shapes do not divide by 64, is refused by name.
  • The kernels. nvfp4_experts32.cu holds GLM's five launches at block 32: tf_nvfp4_decode32_swiglu, _down_f32 and _down_bf16, and tf_nvfp4_prompt32_swiglu and _down. They are nvfp4_experts.cu's two forms with the same sums in the same order, and each group's scale read from the row's base and offset. Their image loads only with GLM's, so Flash Next's and Nemotron's contracts stay as they are.
  • What stays. The MTP layer stays at block 16 and loads beside the new form. There is no new option: the checkpoint's config chooses the path.
  • Copies. ld_nc, ld_nc2, e4m3x2 and mul2 are the same text as nvfp4_experts.cu's, and fp4pair comes from common/fp_pairs.cuh. Moving the four into common/ is a SASS-identical move for RFC: shared CUDA device primitives (one header set for fragments, FP4 decode, copies and reductions) #1409 and is left out of this change.

Receipt

  • Environment: the table and the GPU tests ran on main at 933b969fa and this branch on it at c1b186aba. The branch is now on ad98b602c; the rebase's one conflict was a neighbouring line of registry.zig (main's new register counts for fn_qsa_select beside this branch's 13.3 records), and the host tests and the kernel contract below ran on the rebased head 569faf612. Zig 0.17.0, nvcc 13.0, driver 580.178.04, two GB10s at TP=2 and three at TP=3 over a ring of direct links. Checkpoint Bizuayeu/GLM-5.3-Flash-Jammed-XSFP4@0a22bb46, read from a local copy of the same bytes.
  • Exactness: at each TP size the three decode-check prompts give the same token_sha256 from main on the block 16 layout, this branch on the block 16 layout and this branch on csf0_v1, drafted and with "draft": false. On upstream 1.2.1 with these six commits (the GLM-5.3-Flash BIZ 3.10.0 release), a prompt resumed from the prompt cache gave a fresh one's tokens, and tools/bench_concurrent.py --alone --serial equalled the same request alone in 20 replies at TP=2 and 52 at TP=3.
  • Decode speed before and after: the table.
  • Prompt speed before and after: the table.
  • Kernel contract, one GB10, nvcc 13.0:
    • main (ad98b602c): SUMMARY 553 kernels: 553 pass gates 1-4, 0 fail, 6 known findings; 359 controls: 359 red as planted, 0 missed; 190 limit problems; …
    • This head (569faf612): SUMMARY 558 kernels: 558 pass gates 1-4, 0 fail, 6 known findings; 359 controls: 359 red as planted, 0 missed; 190 limit problems; …
    • Each of the five replaces block 16's kernel on scales written two by two, and all four gates pass (repeat, shapes bit-equal to the kernel it replaces, nonfinite, sums). Their limits live lines pass as recorded under nvcc 13.0, and RECORD under 13.3 is in nvfp4_experts32_records.zig. The limit problems and the known findings are the same lines on both runs, none of them on the five new launches. Both runs end in FAIL kernel-contract: 0 gate failures, 0 controls missed, 190 limit problems: 168 from FAIL limits (1,481 registered launches on main, 1,486 here) and 22 limits live lines.
  • Tests run: on the rebased head test-cuda-host 4,494 of 4,511 with 16 skipped, compile-cuda-tests and compile-config-server. The one failure was the timing test cortheon fuzz: every reader takes linear time on long inputs (zig/src/server/cortheon/fuzz.zig, outside this diff), which passed when the step ran again; main gives 4,489 of 4,505 with 16 skipped. On GB10, nvfp4-b32 (each kernel's bytes against block 16's on every form at widths 1,024, 704 and 640, each control red) and the loader gate over every layer of the checkpoint on TP=2's two ranks and TP=3's rank 2 (every upload equal to the bytes cut from the checkpoint). zig fmt --check clean. tools/zig/lean_check.py: 424 problems on main and on this branch, zero new. Merged into main at cfcbecb0b without conflicts, the branch passes test-cuda-host (4,556 of 4,572, 16 skipped), both compiles, fmt and lean with no new problem.
  • Not run: Metal and HIP, which this does not reach. Any CUDA chip but GB10: the limits table covers sm_80/86/89/120/121 from the source, and the gates ran on GB10 alone.

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off. (The experts are a new form under the same rounds: glm-lanes-cover 46, concurrent 38 and shared 1 pass on rank 0 at TP=2 and at TP=3, with no failures on any rank.)
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Drafted equals plain in every run of the table; resumed and concurrent on 1.2.1 with these commits, under Receipt.)
  • No precision traded for speed. If the bits change, the description says which sums change and why. (No sum changes: each kernel is bit-equal to the block 16 kernel it replaces on values both forms hold. The checkpoint's coarser scales are its own: against XSFP4's 0.0410, 93.90% and +1.23% it has a KL bound of 0.0470, top-1 agreement of 93.40% and NLL 1.72% above BF16, on its card.)
  • A new or changed GPU kernel is registered with the kernel contract (docs/kernel-contract.md); each backend's SUMMARY line is in the receipt. (CUDA, above.)
  • Prompt processing is no slower than the last release. (The table: 0.5 to 0.8% less time.)
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not. (CUDA on GB10; the rest under Not run.)
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (Six breaks at once, one for each new host test, fail those six and no other: the packer's offset nibbles swapped, a rank's bases left uncut, the 64-input check gone from csf0's form, csf0_v1 taken at any group, a column block's offsets counted every 32 inputs, and csf0Linear taking any offsets shape (test-cuda-host 4,489 of 4,511 with 16 skipped). Before this branch, admitRecipes refuses NVFP4 at group 32 by module and nothing reads csf0_v1's parts, so the loader gate cannot load the checkpoint; nvfp4-b32's controls go red in every form. The host tests need only std, the repo's fixtures and checkpoints they write to a temporary directory, and the GPU checks are tf-cuda-test subcommands.)
  • Comments and docstrings are one line. No measurements or history in the source. (lean: 0 new problems.)
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines. (The diff and the six commits' messages, searched.)

Bizuayeu added a commit to Bizuayeu/GLM-5.3-Flash-DGX-Sparks-BIZ that referenced this pull request Nov 3, 2026
…l-argument gate, its scores and its known behaviours

Through 1fca0ca's gate, which asks the engine for one tool call a turn and says so in the
system message, tool-eval-bench 2.8.0's Safety Gate passed on both checkpoints at both TP
sizes, one launch each on 3.10.0's image: XSFP4 93 and 93, Jammed XSFP4 93 and 92, Jammed
XSFP4's TC-51 at TP=3 among them. In all four, TC-67 and TC-69, which ask for two lookups,
were answered after the first one's result without the second (TC-69 failed, TC-67 was
partial), and at TP=2 Jammed XSFP4 left TC-49 partial; the documents set these down as
known behaviours. The measured table's sentence on where its columns come from names the
new row as its one exception, and Next Action names ashhart/TensorFold#2041 for the
csf0_v1 commits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ashhart

ashhart commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Thank you @Bizuayeu, this is a careful change. 13.2 GiB back across a TP=2 pair, with the same tokens, is a real gain
for GLM-5.3-Flash on GB10s.

I read the six commits on current main. A block-16 checkpoint keeps main's path. csf0_v1 is admitted only as NVFP4 at
group 32 with the encoding, and every other pairing is refused by module. The five block-32 kernels are registered as
replacements for block 16's, so the contract holds them bit-equal on equal scales. The receipts match what the code
does.

We will run it on our GB10 pair against main on a block-16 checkpoint.
Five small things, none blocking:

  1. Could the block-32 image load only when a layer is csf0_v1? Then block-16 checkpoints load exactly as on main.
  2. A scale is e4m3(base + offset) on the bit pattern, so a sum past 0x7E becomes NaN or negative. Could the loader
    refuse such a row by name? The packer already walks every base and offset.
  3. One planted control for the block-32 kernels in the CUDA contract (an offset nibble swapped, say) would show the
    replacement gate can fail.
  4. If you have a moment, a short public note on csf0_v1's layout and its valid range would help other tools write it.
  5. zig/tests/cuda/main.zig needs a small rebase: main added flashnext_fp8_experts_tests beside your three lines.

@ashhart

ashhart commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Thanks @Bizuayeu, our GB10 pair run is in: GLM-5.3-Flash NVFP4 (block-16, the layout main already serves) at TP=2 over two GB10s, main against this head, warm then base-new-new-base, with the 64K context.

  • Exact: 52 of 52 token cells equal.
  • Speed: level or better. Prompt is −0.1% at 2K and −0.2% at 8K, and +8.8% at 32K. Chat at 1 and 2 streams is +0.5% and −0.1%, and code is +0.1% and +4.9%.
  • Chat with the prompt cache on: both builds reuse the same 26,624 tokens per turn.

So a block-16 checkpoint runs main's path, as the review read. We don't have a csf0_v1 checkpoint on our boxes, so your receipts stand for the block-32 path. This goes into our landing queue now, with a changelog line crediting you.

@Bizuayeu

Bizuayeu commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

This goes into our landing queue now, with a changelog line crediting you.

(comment)

Thank you for running it on your pair, and for the changelog line. Points 1 to 4 of the review are done: block 32's image loads only for a checkpoint that declares csf0_v1, the loader refuses by name a row whose base plus an offset passes 0x7E, the CUDA contract has a planted control for the block 32 kernels (offsets with each byte's nibbles swapped, red at shapes), and docs/quantization.md has a section on the form and its valid range. They change no kernel, and a checkpoint that loads today packs the same bytes. So that the head you ran is the head that lands, I will open them as a follow-up once this is in, unless you would rather have them here first.

Bizuayeu and others added 7 commits November 4, 2026 04:24
…a 4-bit offset

14.2 GB off the routed experts' VRAM on GB10 at the same bit-exact sums: the scales leave [n, k/16] for a base a row and an
offset every 32 inputs, in the checkpoint as on the device. The kernels are a new image of GLM's five, so Flash Next's and
Nemotron's contracts stay; their contract records follow in this branch.
Each replaces block 16's kernel on scales written two by two: gate-up and both downs of the decode form, gate-up and down of the prompt tile. Scales come from any fill through each row's 16-step window, so NaN, infinities and the stress fill reach them as a checkpoint could hold them.
@ashhart
ashhart merged commit a46ca2b into ashhart:main Nov 4, 2026
3 of 7 checks passed
@ashhart

ashhart commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Thank you @Bizuayeu. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes.

@Bizuayeu
Bizuayeu deleted the pr/glm-b32-csf0 branch November 4, 2026 18:17
ashhart pushed a commit to Bizuayeu/TensorFold that referenced this pull request Nov 4, 2026
ashhart#2041 reads csf0_v1 checkpoints on main. The row lists the one that uses it, with its loads on main at TP=2 and TP=3 and its card's numbers, and the GLM recipe's opening names it beside XSFP4.
ashhart pushed a commit to Bizuayeu/TensorFold that referenced this pull request Nov 4, 2026
ashhart#2041 reads csf0_v1 checkpoints on main. The row lists the one that uses it, with its loads on main at TP=2 and TP=3 and its card's numbers, and the GLM recipe's opening names it beside XSFP4.
ashhart pushed a commit that referenced this pull request Nov 4, 2026
#2041 reads csf0_v1 checkpoints on main. The row lists the one that uses it, with its loads on main at TP=2 and TP=3 and its card's numbers, and the GLM recipe's opening names it beside XSFP4.
@ashhart

ashhart commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Thanks @Bizuayeu! This is in TensorFold 1.2.3, out now: https://github.com/ashhart/TensorFold/releases/tag/v1.2.3

ashhart pushed a commit to Bizuayeu/TensorFold that referenced this pull request Nov 7, 2026
The Pick a model row and the GLM CUDA recipe said "on main after 1.2.2" for ashhart#2041,
as ashhart#2114 wrote they would until a release carried it. 1.2.3 does, so both name it.
ashhart pushed a commit that referenced this pull request Nov 7, 2026
The Pick a model row and the GLM CUDA recipe said "on main after 1.2.2" for #2041,
as #2114 wrote they would until a release carried it. 1.2.3 does, so both name it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants