Skip to content

cuda contract: NVFP4_NZ5's stress fill holds +5s, read as 5 by the float64 reference - #3543

Merged
ashhart merged 7 commits into
ashhart:mainfrom
Bizuayeu:pr/glm-nz5-stress-e7e24243d6
Nov 21, 2026
Merged

ashhart merged 7 commits into
ashhart:mainfrom
Bizuayeu:pr/glm-nz5-stress-e7e24243d6

Conversation

@Bizuayeu

@Bizuayeu Bizuayeu commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

#2894's review, point 1: plant put NVFP4_NZ5's +5s only into the random fill, so gate 4 (sums) and the non-finite gate never saw one on the nz5 kinds, and each +5 stood alone in its group at a power-of-two scale. Here gate 4's stress fill holds +5s among its 4s and 6s, the float64 reference reads 0b1000 as 5, and a second planted control shows that gate 4 now reads them.

tf-cuda-test kernel-contract NVFP4_NZ5, GB10 (sm_121) this head's code (693cee1496) the same without its call to nz5.stress
The five nz5 entries, gates 1 to 4 pass, 20 PASS lines pass, 20 PASS lines
nz5_control, E2M1's entry on the nz5 codes red at shapes, as planted red at shapes, as planted
nz5_sums_control, E2M1's entry on the stress fill's codes red at sums, as planted: 35.8x over its exact-sum bound at k 4096 CONTROL MISSED: sums did not go red
Exit status 0 1, FAIL kernel-contract: 0 gate failures, 1 controls missed, 0 limit problems

The right column is a tree built only for this table and never pushed.

What this changes

  • zig/tests/cuda/contract_nvfp4_nz5.zig, new: NVFP4_NZ5's codes in contract_nvfp4_fact.zig's fills, and the float64 weight its block 32 entries read.

    • stress: in K's first half, each group of 32 gets a pair of equal inputs, at an even offset from 2 to 30 so never input 0, which has no mirror. The mirror half gets the same pair. Each column then holds one of three in each group: the stress fill's own mirror; +5, +5 against -4, -6 in the mirror; or the halves swapped. NVFP4_NZ5 has no -5 to mirror a +5, but 5x + 5x - 4x - 6x = 0, so the sums stay exact in any order and the result is as small as before.
    • weight: nz's nibble, 0b1000 as 5, under its group of 32's e4m3 scale (bases and offsets). On the random and non-finite fills this is the value block 16's reading gave.
    • plant, moved from contract_nvfp4_fact.zig unchanged, so that file stays within 600 lines (581).
  • contract_nvfp4_fact.zig: the non-finite fill plants +5s as the random fill does, and the stress fill calls nz5.stress. The reference reads the nz5 kinds through nz5.weight. nz5_sums_control is a second planted control: E2M1's entry (tf_nvfp4_decode32_swiglu) on the stress fill's codes, each +5 read as -0, red at gate 4.

  • docs/kernel-contract.md: NVFP4_NZ5's sentence says what gate 4's stress fill holds and names the second control.

  • Issue: Refs glm cuda: NVFP4_NZ5 checkpoints, block 32's experts with E2M1's code 0b1000 read as +5 #2894, its review's point 1, which the review said could be a follow-up.

  • Stacked on: main (e7e24243d6), which has glm cuda: NVFP4_NZ5 checkpoints, block 32's experts with E2M1's code 0b1000 read as +5 #2894.

  • atc overlap --json: complete: false (timeLimit), with no pull request listed; its four worktreeOverlaps rows are other local working trees of this checkout, not pull requests. By the file lists of the 422 open pull requests, none touches either contract test file. docs/kernel-contract.md is shared with 74 of them, each adding its own paragraph; this changes NVFP4_NZ5's sentence alone. The branch merges without conflicts into main at 08f1de5941, 20 commits past its base, none of them in these three files.

Checks on this head

  • Head commit: a9b1134415. Over 693cee1496 it changes CHANGELOG.md alone, and every run here is of 693cee1496. Besides that line, three files: two of the CUDA contract's test files and docs/kernel-contract.md. No kernel, engine or served binary changes.
  • Lean checker, python3 tools/zig/lean_check.py, on the base and on this head: 337 problems on both, 0 new (lean_new.py). python3 tools/pr_check.py --base origin/main: on this branch and on it merged into main at 08f1de5941, 0 errors, 0 warnings with --pr, 4 changed files, lean 337 against 337 with 0 new.
  • Tests run, with the command and pass, fail and skip counts: on x86_64 (WSL), on 693cee1496: zig fmt --check build.zig zig; zig build compile-cuda-tests, 10 of 10 steps; zig build test-cuda-host, 6,807 of 6,841 with 34 skipped and 0 failed (408 of 408 steps); python3 tools/zig/cuda_common_check.py; and pytest as CI runs it (python -m pytest -q -rs from the root, with clang++ and Zig 0.17.0 on PATH), 516 passed, 86 skipped, 0 failed, 616 subtests. CI's pytest on main at this base gave 518 passed and 84 skipped: the two more skips here are tools/zig/test_nfkd_tables.py's two tests (this interpreter has Unicode 15.0.0). On one GB10 (sm_121): tf-cuda-test kernel-contract NVFP4_NZ5 on 693cee1496 and on the tree without the call (the table), and the whole contract, zig build kernel-contract, on main and on 693cee1496 (under Kernel contract below).
  • CI: green on a9b1134415: fmt, zig, zig-b, zig-windows, zig-macos-dev-tools, pytest, benchmark-clients on Ubuntu and Windows, and release-paths. host-nightly-linux and host-nightly-macos were skipped.
  • Not run, and why: Metal, HIP, XPU and anything served: the diff is two of the CUDA contract's test files and one sentence of docs/kernel-contract.md. zig build test, the full host suite: nothing under zig/src changes. Any CUDA chip but GB10.

Receipt

n/a: only the contract's fills, its float64 reference and one control change. No kernel changes, nor anything that builds or serves a model, so this cannot reach inference.

Kernel contract, only when a GPU kernel is new or changed

No kernel is new or changed. The table above and this section are the contract's own output on the changed fills.

  • Kernels registered with the contract, and the kernel each one replaces: as in glm cuda: NVFP4_NZ5 checkpoints, block 32's experts with E2M1's code 0b1000 read as +5 #2894, the five NVFP4_NZ5 entries (tf_nvfp4_nz5_*), each bit-equal to the block 16 instance it replaces on the same values.
  • A planted control for each new kernel, and each one fails as planted: no kernel is new. The control glm cuda: NVFP4_NZ5 checkpoints, block 32's experts with E2M1's code 0b1000 read as +5 #2894 planted (E2M1's tf_nvfp4_decode32_swiglu on NZ5's codes) still goes red at shapes, and the new nz5_sums_control goes red at sums. Without the call to nz5.stress the new control is CONTROL MISSED (the table's right column).
  • Each backend's SUMMARY line and exit status: CUDA on one GB10 each, nvcc 13.0, Zig 0.17.0, each tree built with an empty Zig global cache.
    • main (e7e24243d6): SUMMARY 657 kernels: 657 pass gates 1-4, 0 fail, 8 known findings; 420 controls: 420 red as planted, 0 missed; 186 limit problems; …
    • This head's code (693cee1496): SUMMARY 657 kernels: 657 pass gates 1-4, 0 fail, 8 known findings; 421 controls: 421 red as planted, 0 missed; 186 limit problems; …
    • Between the two runs' FAIL, KNOWN, CONTROL and limits lines, with timings masked, this head adds the new control's FAIL sums and CONTROL lines. The one other line that differs is the atomic-add control's first differing byte (4 on main, 0 here), which moves from run to run (docs/kernel-contract.md: "its order changes from run to run"). The 186 limit problems are the same lines on both: 183 launches with no compiled usage recorded at one SM and three FAIL limits live lines (fn_row_topk, tf_exl3_prompt_gu, tf_exl3_prompt_down), none of them in nvfp4_experts32. Both runs end in FAIL kernel-contract: 0 gate failures, 0 controls missed, 186 limit problems, exit status 1.
  • Chips I could not run: any CUDA chip but GB10 (sm_121).

Checklist

  • The title and description match the head commit, including the receipt and the stack. (a9b1134415, two commits on main at e7e24243d6: 693cee1496, which every run here is of, and CHANGELOG.md's line.)
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (The new check is nz5_sums_control: red at sums on this head, and CONTROL MISSED on the same tree without its call to nz5.stress, the table's right column. It runs inside tf-cuda-test kernel-contract, on a GPU; no host test is new.)
  • 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 in the diff or its commits. No AI attribution lines. (The diff and the commit's message, searched.)

Bizuayeu added a commit to Bizuayeu/TensorFold that referenced this pull request Nov 16, 2026
@ashhart

ashhart commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Thanks @Bizuayeu, this is exactly the follow up point 1 asked for. The stress fill holding fives among its fours and sixes with the sums still exact in any order, the reference reading 0b1000 as 5, and above all the second planted control that goes red only with your change, shown from both trees, is the way to prove a gate reads what it claims. CI green, the file stays under the line, and the docs sentence names the new control.

No asks. We will run the contract entry once on a GB10 to see the two controls red as planted, and then this queues.

  • Synthena

@ashhart

ashhart commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Thanks @Bizuayeu. The stress fill holding fives among its fours and sixes, the reference reading the nz5 code as five, and the second planted control that goes red only with the stress call are exactly what the review point asked for. Showing CONTROL MISSED on the same tree without that call is the strongest part of the evidence. CI is green at this head, and nothing served changes.

No asks remain. We will run the contract entry on our side before this lands.

  • Synthena

ashhart pushed a commit to Bizuayeu/TensorFold that referenced this pull request Nov 19, 2026
@ashhart
ashhart force-pushed the pr/glm-nz5-stress-e7e24243d6 branch from a9b1134 to 8b368ef Compare November 19, 2026 05:24
@ashhart

ashhart commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Thanks @Bizuayeu. To get this moving, we rebased it onto current main ourselves, keeping every one of your commits as it was (author and message) and fitting it to the code main has gained since; no behaviour changes. It is in the landing queue now, and if anything else is needed from you we will say so here.

  • Synthena

@AIFlowML

Copy link
Copy Markdown
Contributor

I ran the filtered contract independently on an RTX 5090 Laptop GPU (SM 120), using Zig 0.17.0 and CUDA 13.1.115. The trial merge of 8b368ef19 into main 210e3b0c5 was clean.

zig build compile-cuda-tests -Dnvcc=/usr/local/cuda/bin/nvcc \
  -Dsm=120 -Doptimize=ReleaseFast -j6 --summary all
tf-cuda-test kernel-contract NVFP4_NZ5

The build passed all 175 steps. All five kernels passed gates 1–4, and both controls went red at their intended gates: the original at shapes and the new stress control at sums, 35.8× over the exact-sum bound at K=4096. The filtered run exited 0 with no missed controls or limit problems. This adds SM 120 device coverage to the author's SM 121 receipt.

Igor Lessio - AIFLOW LABS

@ashhart

ashhart commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Thanks @Bizuayeu. Nothing has changed in the code since our last review: the rebased head 8b368ef19 keeps your commits as they were, applies cleanly to today's main, and docs/kernel-contract.md is at 600 lines.

The independent SM 120 run posted here, at this head, shows both controls red at their intended gates, the new one at sums (35.8x over its bound at K 4096). That adds a second chip to your SM 121 receipt.

There are no asks for you. It lands after CI is green at 8b368ef19 and the SM 121 contract entry has run at this head.

  • Synthena

@Bizuayeu

Copy link
Copy Markdown
Contributor Author

This adds SM 120 device coverage to the author's SM 121 receipt.

#3543 (comment)

Thanks for running it on SM 120, and for checking both controls go red at their gates.

ashhart and others added 7 commits November 21, 2026 06:21
…oat64 reference

plant put NVFP4_NZ5's +5s only into the random fill, so gate 4 (sums)
and the non-finite gate never saw one on the nz5 kinds, and each +5
stood alone in its group at a power-of-two scale. The stress fill now
holds +5s among its 4s and 6s. NVFP4_NZ5 has no -5 to mirror one, so
they come two on equal inputs, mirrored by a -4 and a -6: the sums stay
exact in any order and the result as small as before. The float64
reference reads nz's codes, 0b1000 as 5, under block 32's scales, which
on the random and non-finite fills is the value block 16's reading gave.

The non-finite fill plants +5s as the random fill does, and E2M1's
entry on the stress fill's codes is a second planted control, red at
gate 4. The fills and the weight live in contract_nvfp4_nz5.zig, plant
moved there unchanged, so contract_nvfp4_fact.zig stays within 600
lines.
@ashhart
ashhart force-pushed the pr/glm-nz5-stress-e7e24243d6 branch from 8b368ef to 5b7bb38 Compare November 21, 2026 06:21
@ashhart
ashhart merged commit 44a3529 into ashhart:main Nov 21, 2026
2 of 11 checks passed
ashhart added a commit that referenced this pull request Nov 21, 2026
@ashhart

ashhart commented Nov 21, 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-nz5-stress-e7e24243d6 branch November 21, 2026 08:07
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.

3 participants