Repository navigation
cuda: tf_situ_rows, SiTU in the core act_rows, sharing one body with the MXFP4 experts in common/act.cuh - #5817
Conversation
|
Thanks @Bizuayeu for doing this the way #4926 settled it, and for the full receipt. I read the head
I have no asks. It's ready for our device check on a DGX Spark (GB10, sm_121):
|
|
READY to land on this head. Reviewed at this head on a GB10 (sm_121): every existing function in all 176 fatbins (sm_80, 86, 89, 120 and 121) has the same SASS as main, and tf_situ_rows is the only addition. The kernel contract for tf_situ_rows and the MXFP4 SiTU ups passed with its controls red, the act-rows test kept every row count's bits equal, and the new records match their live launch limits. This head's CI passed.
|
…iTU body moved to common/act.cuh tf_situ_rows(gate, g_ld, up, u_ld, out, xs, n, beta, lin) turns bf16 gate and up rows into bf16 SiTU rows, beta tanh(g / beta) sigmoid(g) times lin tanh(u / lin), with the betas as arguments (ERNIE 5.5's 4 and 25, which Kimi K3 shares), 8 values a thread and the 64-value sums as tf_swiglu_rows has them. Its arithmetic is ashhart#5385's: the body moved from experts.cuh to common/act.cuh as tf_common::situ, and experts.cuh's situ rounds the sums to bf16 and calls it in the same statement order, so the MXFP4 experts image is byte-identical at all five SMs. act_rows' gated rows share glu_rows with an op (SiluMul for tf_swiglu_rows and tf_swiglu_rows_expf, Situ for the new entry), and its other 60 functions' SASS is unchanged. ActRows.situ launches it through glu, which now takes the betas or null. contract_act_situ.zig holds it to act_ref.situ within the contract's bound (20 fp32 steps, as the experts' up) at ERNIE's betas and at 2 and 8, on ERNIE 5.5's widths 2,048 (the shared expert) and 14,336 (layer 0's dense MLP), its sums bit-equal to the fp32 tree; three controls launch it with wrong arguments (the rows swapped, the up unclamped at linear beta 1e30, the betas swapped). Its records are nvcc 13.0's, in act_situ_records.zig.
29ccb77 to
ac68d70
Compare
|
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. |
What this changes
tf_situ_rows, a SiTU entry in core'sact_rows, as #4926's answer asked: bf16 gate and up rows and the two betas as arguments, bf16 rows of beta tanh(g / beta) sigmoid(g) times lin tanh(u / lin) out, with #5385's arithmetic. Served bits do not change: the MXFP4 experts image is byte-identical at all five SMs, andact_rowsgains only the new function, its 60 other functions' SASS unchanged. Nothing calls the entry yet; ERNIE 5.5's shared expert and layer 0's dense MLP will.situ's body moves fromexperts.cuhtocommon/act.cuhastf_common::situ;experts.cuh'ssiturounds the sums to bf16 and calls it in the same statement order, so the routed epilogue and the dense rows run one body.act_rows.cu's gated rows shareglu_rowswith an op:SiluMulfortf_swiglu_rowsandtf_swiglu_rows_expf,Situfor the new entry, 8 values a thread and the 64-value sums astf_swiglu_rowshas them.ActRows.situlaunches it throughglu, which now takes the betas or null.contract_act_situ.zigholds it toact_ref.situwithin the contract's bound (20 fp32 steps, as the experts' up) at ERNIE's betas 4 and 25 and at 2 and 8, on ERNIE 5.5's widths 2,048 (the shared expert) and 14,336 (layer 0's dense MLP), its sums bit-equal to the fp32 tree. Three planted controls launch it with wrong arguments: the rows swapped, the up unclamped (linear beta 1e30), the betas swapped. Its launch records (256 threads, and 128 at 16 rows or fewer) are nvcc 13.0's, inact_situ_records.zig;docs/kernel-contract.mdgains a paragraph.Searched first: no open pull request or issue adds a SiTU entry to
act_rowsor movesexperts.cuh'ssitu(open pull requests and issues searched for "situ", "act_rows", "swiglu_rows" and "experts.cuh" on 2026-12-01; the one hit for "SiTU" is my #5578, the synthetic weights).act_rows, the experts image's SASS unchanged at all five SMs and the existingact_rowsentries' as well, registered with the contract againstact_ref.situ's FP64 bound with planted controls).93a3172b5d.atc overlap --json: on this head against main93a3172b5d(11 changed files), 28 overlaps from the working tree, 1 conflicting (logit_bias: token biases and -100 bans on each row's draw for Qwen CUDA, Qwen3.5-2B Metal and Nemotron Parse HIP #3146, which already conflicts with main), 9 clean and 18 unknown (atc reports the result incomplete: pull files unavailable, time and pull request limits).conflict_deltaover 362 open pull requests on main93a3172b5d: this head adds a conflict to one, gemma4 cuda: opt-in dependent launches on the decode's non-GEMM kernels #4598, which already conflicts with main in 6 files and gainszig/src/cuda/act_rows.zig(203 already conflict with main).Checks on this head
29ccb771f8(one commit on main93a3172b5d). The GPU steps below ran on220b23c636, which has this head's kernels: this head differs from it in a test's set initialization, the gradient-serving fixture's hash ofexperts.cuh, and two comments.tools/pr_check.py --base 93a3172b5d): 88 problems on both, 0 new; import cycle edges 25 against 25, 0 new; cross-family edges 11 against 11 (1 allowed); 0 errors.220b23c636and main93a3172b5d, each checked out with an empty global cache and built alike,zig build compile-cuda-tests fatbins kernel-contract-fatbins -Dnvcc=... -Dsm=80,86,89,120,121with address randomization off: 0 errors on both. Of 212 fatbins, 207 are byte-identical,experts_mxfp4among them;act_rowsgainstf_situ_rowsat each SM with its 60 other functions' SASS unchanged (cuobjdump -sass); four (ernie5_5_hca,ernie5_5_index,glm_glue,glm_index) differ in bytes with no SASS function changed.tf-cuda-test kernel-contract-limits zig-out/fatbin: the tentf_situ_rowslinesPASS ... (record current)(35 registers at sm_80, sm_86 and sm_89, 34 at sm_120 and sm_121, 0 static shared bytes, bound 256); every other line is main's, where it reports 205record stalelaunches in other families, the same on both.kernel-contract situ SiTU: 6 kernels pass gates 1-4, 5 controls red as planted;kernel-contract "cuda act": 16 kernels pass gates 1-4. On this head, from a checkout path of 40 characters (shorter ones trip the load-prefetch test, which load prefetch: the allocation-failure test refuses resizes, so it passes at any checkout path length #5772 fixes) with empty global and local caches,zig build -Dfixed-cpu:test-gradient-serving1 of 1;test-kernel-contract49 of 49 steps, 383 of 383 tests;test-inc4-rows-host5 of 5;test-ernie5_5-contract-host27 of 27;test-cuda-host590 of 590 steps, 11,221 of 11,275 tests, 54 skipped.zig fmt --checkandzig ast-checkon the 6 changed Zig files andgit diff --check, clean;zig build -Dfixed-cpu compile-cuda-tests12 of 12 steps;test-kernel-contract49 of 49 steps, 383 of 383 tests (empty global and local caches);test-inc4-rows-host5 of 5.git diff --checkclean;compile-cuda-tests12 of 12;test-ernie5_5-host58 of 60, 2 skipped;test-kernel-contract49 of 49 steps, 383 of 383 tests;test-inc4-rows-host5 of 5;test-gradient-serving1 of 1;test-ernie5_5-contract-host27 of 27;test-cuda-host590 of 590 steps, 10,983 of 11,035 tests, 52 skipped (with an empty local cache; its first run, while this PC was also compiling, timed twohealth_testexchanges out at their 5-second poll);tools/zig/check_cuda_sources.pyonact_rows.cuandexperts_mxfp4.cuwith clang++ 12 of 12;host_tests_testOK; CI'spytest -q -rsfrom the root: 1,030 passed, 122 skipped on this head and on main, the same skips.fmt,zig,pytest,benchmark-clientsandcomfyui-moss-installerpass (runs 46615190832, No GPU, and 46615190946, Zig format); the rest are skipped.Receipt
act_rowsgains onlytf_situ_rowswith its other functions' SASS unchanged, and nothing calls the new entry yet.29ccb771f8(GPU steps on220b23c636, the same kernels) on main93a3172b5d; Zig 0.17.0, nvcc 13.0.88; a GB10 (sm_121), Windows and WSL 2 (x86-64); no checkpoint.tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: n/a (the served experts image is byte-identical; the new entry is not served).tools/bench_openai.py: n/a (no served path changes).Kernel contract, only when a GPU kernel is new or changed
tf_situ_rowsat ERNIE's betas 4 and 25 and at 2 and 8 (new; it replaces none, and the MXFP4 experts' SiTU ups keep their entries).SUMMARYline and exit status:SUMMARY 6 kernels: 6 pass gates 1-4, 0 fail, 0 known findings; 5 controls: 5 red as planted, 0 missed; 0 limit problems(kernel-contract situ SiTU: the new entry's two, the MXFP4 experts' two SiTU ups and MOSS-Image's two) andSUMMARY 16 kernels: 16 pass gates 1-4, 0 fail, 0 known findings; 0 controls(kernel-contract "cuda act"), each exit 0 (CUDA on the GB10).Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo (no served path changes).--drafter, no slower than without it, greedy and sampled (no served path changes).