Skip to content

cuda exl3: the grouped baseline control's word indices once a warp on sm_120 and sm_121 - #5262

Merged
ashhart merged 3 commits into
ashhart:mainfrom
Bizuayeu:pr/exl3-plain-once
Nov 28, 2026
Merged

ashhart merged 3 commits into
ashhart:mainfrom
Bizuayeu:pr/exl3-plain-once

Conversation

@Bizuayeu

@Bizuayeu Bizuayeu commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

On sm_120 and sm_121, the grouped EXL3 baseline controls (tf_ctl_exl3_grouped_old_0, _1 and _2 in contract_controls) work out each lane's word indices once, before the k loop, and read each tile's words through them. These controls are grouped_body with LOAD == PLAIN, main's loop, which gate 3 holds the load-ahead kernels (tf_exl3_grouped_*) to bit for bit. The served kernels read ahead from sm_120 on, so PLAIN is built at sm_120 and sm_121 only for these controls. Every other SM and load builds as before, and the served images are unchanged.

This is the fix I said I would look into separately on #5123 (#5123 (comment)). With nvcc 13.3.73 on a GB10, identical compiles of contract_controls_set.cu give the controls more than one PTX form at compute_120 and 121. The forms differ only in these three entries: where the k loop's invariant index work sits, before the loop or inside it, block by block. That covers the lane's word indices (word + i) % TW and the decode's per-lane addresses. The .text of tf_ctl_exl3_grouped_old_0 differs between the forms (141,568 against 141,696 bytes at sm_120). Turning address randomization off, as the SASS identity check does since #5170, does not remove this. Main then repeats one form in a given environment, but a longer source path gave the other form.

contract_controls_set.cu, nvcc 13.3.73, one GB10 main eff4e5b754 this head
compute_120, 40 compiles, randomization on 3 PTX forms (2, 23, 15) 1
compute_121, 40 compiles, randomization on 2 PTX forms (28, 12) 1
compute_120 under setarch -R, 4 environments × 8 (short and long source path, 1 KiB and 4 KiB of extra environment) 2 forms: the long path's differs 1 in all four
compute_121, the same 2 forms: the long path's differs 1 in all four
compute_120 and 121 with nvcc 13.0.88, 40 compiles each 1 each (another GB10, main 67ae36c4dc, whose EXL3 sources are these) 1 each

In the GB10 runs below, on this change's kernel sources on main eff4e5b754 and on main 91dbadce65, the same 40 compiles gave one PTX form at each of compute_120 and 121, and cuda_sass_compare.py on contract_controls finds only these three entries changed at sm_120 and sm_121 (754 of 760 functions equal).

How:

  • warp_tiles keeps at[LW], the lane's word indices in a tile (lane_start, then (word + l) % TW), computed before the loop when LOAD == PLAIN and __CUDA_ARCH__ >= 1200.
  • ldg_at reads tile + at[l] for each l. These are the same words in the same order as ldg_lane_words, into the same decode_lane and the same mma16816 calls.
  • I first tried the same change for every SM and load. It moved the served tf_exl3_grouped_* SASS at all five SMs with both releases (4 to 8 KB of .text), which would need speed receipts, so it is limited to the control.

Records: the three controls' sm_120 and sm_121 usage in exl3_grouped_records.zig (nvcc 13.0) is now 128, 127 and 126 registers, where it was 127, 128 and 128. In measurements/pending_133.zig (nvcc 13.3), old_0 is now 128, where it was 127. The three controls' static shared bytes are now 32,896 at all five SMs in both files, where they were 32,832. That was already stale on main: kernel-contract-limits gives 32,896 for them at every SM with both releases, and on a GB10 kernel-contract on the grouped EXL3 kernels fails main's three controls on their live limits (3 limit problems, the driver also gives 32,896). The kernels' shared memory itself is unchanged, with no stack and no spills.

Checks on this head

  • Head commit: f7962d76c7 Adapt grouped EXL3 lane precomputation to main, above 3bc2b4f218 (see the base line). The first GB10 run below is on e80490eb1b, the same lines on main 91dbadce65; the other receipts were taken on 24a5cdd60f on main eff4e5b754, which differs from 9822acad4a, the head before the rebase, only in the CHANGELOG line's pull request number. Three of them, the SASS comparisons, the PTX forms and the fatbins against main's, ran on the commit before 24a5cdd60f, which differs from it only in the two records files: the same zig/kernels, and 24a5cdd60f's build gave fatbins byte-equal to that commit's, every one with nvcc 13.0.88 and contract_controls with 13.3.73.
  • Lean checker (tools/pr_check.py --base eff4e5b754 --pr 5262, 24a5cdd60f against its main): 123 problems on both, 0 new; 0 errors. The 123 are inherited from main.
  • Tests run, with the command and pass, fail and skip counts (Zig 0.17.0):
    • GB10 (sm_121), on e80490eb1b with main 91dbadce65 beside it, each from an empty global cache at the five SMs with nvcc 13.0.88 and 13.3.73: kernel-contract-limits gives 178 problems against main's 191 with 13.0.88 (main's 15 more are the three controls' records at five SMs; this tree's 2 more are tf_nemo_router_tiles at sm_80 and sm_89, the router entries CUDA build: nvcc 13.0.88 gives the router-tiles entries different PTX between identical compiles, about one in ten #5123 is about, which this change does not reach), and 806 against 821 with 13.3.73 (the same 15). kernel-contract "exl3 grouped" exl3_grouped: (filtered) SUMMARY 5 kernels: 5 pass gates 1-4, 0 fail, 0 known findings; 2 controls: 2 red as planted, 0 missed; 0 limit problems, exit 0; main's the same with 3 limit problems, exit 1. Main's cuda_sass_compare.py with nvcc 13.0.88 on the reached images but contract_controls (dsv41_x3ld_epi, exl3_experts): SUMMARY PASS images=2 functions=440 scope=explicit; on contract_controls, 754 of 760 functions equal, the other six being the three controls at sm_120 and sm_121. The fatbins that differ from main's: contract_controls and nemotron_route (the router entries again) with 13.0.88; contract_controls, dsv41_lin2, qmm and qmm_group (images the change does not reach) with 13.3.73. 40 compiles of contract_controls_set.cu with 13.3.73: one PTX form at each of compute_120 and 121, where main's gave one at 120 and two at 121 (39 and 1).
    • GB10 (sm_121), on 24a5cdd60f (main eff4e5b754): with nvcc 13.0.88 from an empty global cache at sm_80, 86, 89, 120 and 121, zig build compile-cuda-tests fatbins kernel-contract-fatbins. kernel-contract-limits: the three controls' records current at all five SMs; 171 problems, each also among main's 186 (the 15 fewer are these records); with nvcc 13.3.73's fatbins, 791 against main's 806 the same way. kernel-contract "exl3 grouped" exl3_grouped (the grouped EXL3 kernels, gate 3's two planted faults and the controls' live limits): exit 0, with the SUMMARY below; main's runner on main's build gives the same gates and controls and 3 limit problems, exit 1. On the commit before (see the head line), main's cuda_sass_compare.py with nvcc 13.0.88 on the reached images but contract_controls (dsv41_x3ld_epi, exl3_experts): SUMMARY PASS images=2 functions=430 scope=explicit; on contract_controls alone, 754 of 760 functions equal, the other six being tf_ctl_exl3_grouped_old_0, _1 and _2 at sm_120 and sm_121. There, every nvcc 13.0.88 fatbin but contract_controls is byte-equal to main's. With nvcc 13.3.73, the two builds from this head's kernel sources gave the same contract_controls fatbin, while five images the change does not reach (dsv41_lin2, inkling2_ops, qmm, qmm_group, train) differed between them, as between main's build and this head's.
    • Windows, on 24a5cdd60f: zig fmt --check and zig ast-check on the 2 changed Zig files; zig build compile-cuda-tests 12 of 12 steps; test-gradient-serving 4 of 4 steps; test-kernel-contract 46 of 46 steps, 342 of 342 tests; pr_check 0 errors.
    • WSL 2 (x86-64), on 24a5cdd60f: git diff --check clean; zig build compile-cuda-tests 12 of 12 steps; test-gradient-serving 4 of 4 steps; test-kernel-contract 342 of 342 tests; tools/zig/check_cuda_sources.py with clang++ on exl3_experts.cu, contract_controls_set.cu, inkling2/experts.cu and exl3_block/x3ld_epi.cu: 24 of 24; and on this tree and on main, host_tests_test OK and CI's pytest from the root (-q -rs) 856 passed, 116 skipped, 827 subtests passed, with the same skips. cuda_sass_compare.py --plan-only lists the images the change reaches: contract_controls, dsv41_x3ld_epi and exl3_experts.
    • nvcc 13.0.88 and 13.3.73 with nvcc -cubin -Xptxas -v in WSL 2, at the five SMs, on this tree and on main: the three controls' registers above, and tf_ctl_exl3_grouped_skip and _stale unchanged.
  • CI on this head: fmt, pytest, zig-macos-dev-tools, release-paths (ubuntu-24.04) and both benchmark-clients jobs passed; zig failed at tools/zig/env_names.py on files this pull request does not touch (docs/environment-names.md: TF_INKLING2_DRAFT_HEAD_Q4 has no row; nine names in zig/src/server/confidential.zig); zig-b, zig-windows and comfyui-moss-installer were still running.
  • CI green on 9822acad4a: fmt, zig, zig-b, zig-windows, zig-macos-dev-tools, pytest (857 passed, 115 skipped, 827 subtests passed; the run in WSL 2 above has 856 and 116, and the CI log does not print skip reasons), release-paths (ubuntu-24.04), comfyui-moss-installer and both benchmark-clients jobs passed; host-nightly-linux and host-nightly-macos were skipped. The annotations are GitHub's Node.js 20 deprecation warnings and a macOS runner queue notice.
  • Not run, and why: the contract on GPUs other than the GB10 (sm_121). sm_120's control is checked by its records and SASS only. Any stability claim stays with these three controls, nvcc 13.0.88 and 13.3.73, and the environments above; this is not a toolchain-wide fix.

Receipt

  • Main against branch: no served code changes. Main's cuda_sass_compare.py finds the served images the change reaches equal to main's, function by function (440 functions on main 91dbadce65, 430 on eff4e5b754). On eff4e5b754 every nvcc 13.0.88 fatbin but contract_controls is byte-equal to main's; on 91dbadce65, nemotron_route differed too, the router entries CUDA build: nvcc 13.0.88 gives the router-tiles entries different PTX between identical compiles, about one in ten #5123 is about, which the change does not reach.
  • Boxes it reaches: none served. The contract's controls on sm_120 and sm_121.
  • New switch? None.
  • Environment, with the TensorFold commit, Zig and backend toolchain, machine and GPU, checkpoint and revision: e80490eb1b on main 91dbadce65 and 24a5cdd60f on main eff4e5b754; Zig 0.17.0, nvcc 13.0.88 (the build) and 13.3.73 (the forms and its records); one GB10 (sm_121); no checkpoint.
  • Paths and platforms the change reaches, which I ran and which I could not: the controls on sm_121 through gate 3. sm_120 by its records and SASS only.
  • Exactness, from tools/bench_concurrent.py --alone --serial or token_sha against "draft": false: n/a (no served path changes).
  • Main against this branch, same machine and checkpoint, posted before asking for a run on our machines (or why you can't): n/a (no served path changes).
  • Decode speed before and after, from tools/bench_openai.py: n/a (the served images are main's).
  • Prompt speed before and after: n/a (the served images are main's).
  • Licence of any new weights or drafter, or "n/a": n/a.
Kernel contract, only when a GPU kernel is new or changed
  • Kernels registered with the contract, and the kernel each one replaces: no kernel is added. The controls tf_ctl_exl3_grouped_old_0, _1 and _2 change their sm_120 and sm_121 code, and their records follow.
  • A planted control for each new kernel, and each one fails as planted: no new kernel. On this head, gate 3's two planted load-ahead faults (reads tile i + 2, decodes stale words on the last tile) are red as planted against tf_ctl_exl3_grouped_old_2.
  • Each backend's SUMMARY line and exit status: CUDA on one GB10 (sm_121), filtered to "exl3 grouped" exl3_grouped: on e80490eb1b, (filtered) SUMMARY 5 kernels: 5 pass gates 1-4, 0 fail, 0 known findings; 2 controls: 2 red as planted, 0 missed; 0 limit problems, exit 0 (3 kernels on 24a5cdd60f, the same otherwise). Main: the same with 3 limit problems, exit 1.
  • Chips I could not run: sm_120 GPUs (records and SASS only).

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency (no test is added: gate 3 holds the served kernels to these controls on the GPU, and the forms are counted above).
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off (no served image changes).
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo (no served path changes).
  • No precision traded for speed. If the bits change, the description says which sums change and why (no bits change: the same words in the same order into the same decode and MMA, and on the GB10 gate 3 finds the unchanged served kernels bit-equal to these controls at 19 shapes each, as on main).
  • Decode and prompt processing are no slower than main at one stream and the widest admitted; with --drafter, no slower than without it, greedy and sampled (the served images are main's).

Bizuayeu and others added 3 commits November 28, 2026 19:15
… sm_120 and sm_121

Gate 3 holds tf_exl3_grouped_* (a tile read ahead from sm_120 on) bit-equal to main's loop, which contract_controls
keeps as tf_ctl_exl3_grouped_old_*: grouped_body with LOAD == PLAIN. sm_120 and sm_121 build PLAIN only there, as
the served images read ahead. With nvcc 13.3 on a GB10, identical compiles of contract_controls_set.cu at
compute_120 and 121 gave three and two PTX forms, which differ only in those entries: where the k loop's invariant
index work (the lane's word indices (word + i) % TW, the decode's per-lane addresses) sits, before the loop or in it,
block by block; the .text of tf_ctl_exl3_grouped_old_0 differs between them.

There, warp_tiles now works out the lane's word indices once, before the loop, and reads each tile's words through
them (ldg_at): the same words, in the same order, into the same decode. Other SMs and the other loads build as
before, so every served image is unchanged. The records of the three controls at sm_120 and sm_121 follow: 13.0's
128, 127 and 126 registers, and 13.3's 128 for old_0. Their static shared bytes, already stale on main, become the
32896 that kernel-contract-limits and the driver give at every SM with both releases (32832 recorded), so the
controls' live limits pass.
@ashhart
ashhart merged commit aaf2c8f into ashhart:main Nov 28, 2026
2 of 12 checks passed
@ashhart

ashhart commented Nov 28, 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.

ashhart added a commit that referenced this pull request Nov 28, 2026
ashhart added a commit that referenced this pull request Nov 28, 2026
ashhart added a commit to jschmied/TensorFold that referenced this pull request Nov 28, 2026
ashhart added a commit that referenced this pull request Nov 28, 2026
ashhart added a commit that referenced this pull request Nov 28, 2026
ashhart added a commit that referenced this pull request Nov 28, 2026
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