Repository navigation
cuda ernie5_5: MultiMax on the head's fp32 logits, under the kernel contract - #5202
Merged
Merged
Conversation
Bizuayeu
force-pushed
the
pr/ernie55-multimax
branch
from
November 26, 2026 10:48
958f98c to
c65c282
Compare
Merged
8 tasks done
Bizuayeu
force-pushed
the
pr/ernie55-multimax
branch
2 times, most recently
from
November 26, 2026 15:14
65eca9a to
648f48e
Compare
Bizuayeu
marked this pull request as ready for review
November 26, 2026 18:56
1 task done
…ontract ERNIE 5.5 rewrites its head's fp32 logits in place as x + t0 relu(r0 - x) + t1 relu(x - r1) + t2 relu(r2 - x)^2 + t3 relu(x - r3)^2, with the four ranges and weights stored bf16. The vendor's Triton kernel turns fp fusion off, so tf_ernie55_multimax (ernie5_5/head.cu, a new ernie5_5_head image) rounds each subtract, square, multiply and add once in its order (__fsub_rn, __fmul_rn, __fadd_rn), and relu keeps NaN and makes -0 a +0 as torch.relu does. ernie5_5/multimax.zig replays those fp32 steps on the host and gives float64's value; the contract asks each output to be the replay's value at a decode row and a 16-row verify window over the 201,216-logit vocabulary and over a TP=2 rank's half, and gate 4 runs whole logits with whole ranges and power-of-two weights, where every step is exact. Two planted controls, each term's multiply and add fused into an fma and the last term's square dropped, go red. Nothing launches it yet. gradient-serving.tsv re-pins zig/src/cuda/kernels.zig.
ashhart
force-pushed
the
pr/ernie55-multimax
branch
from
November 27, 2026 01:31
648f48e to
7add436
Compare
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
to jschmied/TensorFold
that referenced
this pull request
Nov 27, 2026
ashhart
added a commit
that referenced
this pull request
Nov 27, 2026
ashhart
added a commit
that referenced
this pull request
Nov 27, 2026
ashhart
added a commit
that referenced
this pull request
Nov 27, 2026
8 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
A new
ernie5_5_headimage with ERNIE 5.5's MultiMax,tf_ernie55_multimax, which rewrites the head's fp32 logits in place as x + t0 relu(r0 - x) + t1 relu(x - r1) + t2 relu(r2 - x)^2 + t3 relu(x - r3)^2, with the four ranges and weights stored bf16 in the checkpoint (model.lm_head.multimax_ranges,multimax_ts). The vendor's Triton kernel turns fp fusion off (enable_fp_fusion=False), so each subtract, square, multiply and add rounds once, in its order (__fsub_rn,__fmul_rn,__fadd_rn), and relu keeps NaN and makes -0 a +0, astorch.reludoes. Nothing launches it yet, so served output is unchanged.zig/src/families/ernie5_5/multimax.zigreplays those fp32 steps on the host (apply) and gives float64's value and magnitude (reference).multimax_test.zigpins the rules: an input where an fma would round differently, NaN and -0, the non-finite classes, and the bf16 widening.The contract (
zig/tests/cuda/contract_ernie5_5_head.zig,tf-cuda-test ernie5_5-head, also inkernel-contract) asks each output to be the replay's value, at a decode row and a 16-row verify window over the 201,216-logit vocabulary and over a TP=2 rank's half. Float64's bound covers eight roundings. Gate 4 runs whole logits with whole ranges and power-of-two weights, where every step is exact (sumsf16 0, bf16 0: five terms a logit is no sum long enough to tell fp32 from half). There are two planted controls: each term's multiply and add fused into an fma, and the last term's square dropped.The records (
zig/src/core/contract/ernie5_5_records.zig), the image incuda_kernels.zigandkernels.zig, andgradient-serving.tsv's re-pin ofzig/src/cuda/kernels.zig.Issue: Refs ERNIE-5.5-Flash-Preview on two DGX Sparks: a native CUDA family #4926. The gate is the one set there for each ERNIE kernel (ERNIE-5.5-Flash-Preview on two DGX Sparks: a native CUDA family #4926 (comment): "Each kernel also comes one to a PR, registered with the kernel contract, with its rounding points and sum order written down, an FP64 bound for that order and planted controls.").
Stacked on: main (
eff4e5b754); one commit: 19 files, 423 insertions, 2 deletions.atc overlap --json: atc 0.9.4 withATC_READ_ONLY=1and--base c21d201714, run in this tree on 2026-11-26 at 14:39 UTC:complete: false(otherPullRequestsLimit,pullFilesUnavailable,pullRequestsLimit,timeLimit), 40 pull requests in its working tree's rows, 5conflicts, 5cleanand 30unknown.conflict_delta(each open pull request merged bygit merge-treewith main and with this head, conflicting files and hunks compared): over the 256 open pull requests on 2026-11-26, this commit with its two registration lines where they first stood added a conflict to 9, 7 of them at the image's line inzig/build/cuda_kernels.zig. That line now followshy4_ihc_fused, and theimage()line inzig/tests/cuda/contract_limits.zigfollowszonos3's: there a 3-way merge of the file against every open pull request that touches it adds no conflict. Rerun after the move for those 9 only (not a new pass over every open pull request), it adds one to 3, CUDA: native TFQ3 (3/4/5-bit 2D-FWHT) runtime + drafters for Qwen3.8-27B, GLM-5.3-Flash, and Flash Next #4986 and cuda: sparse gather attention over listed cache rows (Kolibri 1.1, slice 1 of #4846) #5166 (both since landed) and Inkling-2-Mini: Serve on two GB10s with images and 1M context window #5059, each ongradient-serving.tsv's one pin line forzig/src/cuda/kernels.zig, which each of them re-pins too (Inkling-2-Mini: Serve on two GB10s with images and 1M context window #5059's head had moved between the two runs).Checks on this head
648f48ec3bcuda ernie5_5: MultiMax on the head's fp32 logits, under the kernel contract. It was rebased onto mainc21d201714after cuda: sparse gather attention over listed cache rows (Kolibri 1.1, slice 1 of #4846) #5166 landed and again ontoeff4e5b754after CUDA: native TFQ3 (3/4/5-bit 2D-FWHT) runtime + drafters for Qwen3.8-27B, GLM-5.3-Flash, and Flash Next #4986 landed; each time the one conflict wasgradient-serving.tsv's pin line forzig/src/cuda/kernels.zig, re-pinned with both notes. The GB10 and WSL runs below are on65eca9a14d, the head before the second rebase, and the code has not changed since; on this head,zig build compile-cuda-tests12 of 12 steps,test-gradient-serving1 of 1 andpr_check0 errors (Windows).tools/pr_check.py --base eff4e5b754 --pr 5202): 123 problems on main and 123 on this head, 0 new; 0 errors. The 123 are inherited from main.zig build compile-cuda-tests fatbins kernel-contract-fatbins -Dnvcc=... -Dsm=80,86,89,120,121: 0 errors. On the GPU,tf-cuda-test kernel-contract-limits zig-out/fatbingives the fivetf_ernie55_multimaxlinesPASS ... 12 registers, 0 static shared bytes, bound 256 (record current)(its other lines are main's: see the receipt);tf-cuda-test ernie5_5-headpasses gates 1-4 with both controls red as planted, andkernel-contract ernie5_5the same (below);zig build test-kernel-contract343 of 343 passed;test-ernie5_5-host16 of 18, 2 skipped;test-gradient-serving1 of 1;head.cu's PTX, 33 compiles at each of compute_80 and compute_86 with address randomization on and off, one form at each.zig fmt --checkandzig ast-checkon the 15 changed Zig files;zig build test-ernie5_5-host16 of 18 passed, 2 skipped (the skips are main's).c21d201714:git diff --checkclean;zig build compile-cuda-tests12 of 12 steps;test-gradient-serving1 of 1;test-ernie5_5-host16 of 18, 2 skipped;tools/zig/check_cuda_sources.pyonhead.cuwith clang++ 6 of 6;host_tests_testOK; CI's pytest from the root (-q -rs) 856 passed, 116 skipped, 827 subtests passed on both trees, the same skips as main's.648f48ec3b: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-installerand bothbenchmark-clientsjobs passed;host-nightly-linuxandhost-nightly-macoswere skipped. The annotations are GitHub's Node.js 20 deprecation warnings and a macOS runner queue notice.Receipt
tf_ernie55_multimax, so no served token or byte can change; the new image is the only fatbin added. On the GB10, main's tree (c21d201714) and this one built the same way (empty global cache, five SMs): the fatbins that differ areglm_glueandglm_index, which differ between any two builds (andmoecan, whose router tiles' PTX follows address randomization, CUDA build: nvcc 13.0.88 gives the router-tiles entries different PTX between identical compiles, about one in ten #5123; it did not this time);ernie5_5_headis the image this commit adds.kernel-contract-limitsgives both trees the same 186 stale records and the same RED and FAIL lines, apart from this tree's fivetf_ernie55_multimaxlines.65eca9a14don mainc21d201714(this head is the same change oneff4e5b754); Zig 0.17.0, nvcc 13.0.88; one GB10 (sm_121); no checkpoint (synthetic logits).tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false: n/a (no served path).tools/bench_openai.py: n/a (no served path).Kernel contract, only when a GPU kernel is new or changed
tf_ernie55_multimax(new; replaces none), records for sm_80, 86, 89, 120 and 121 inzig/src/core/contract/ernie5_5_records.zig.tf_ctl_ernie55_multimax_fma(each term's multiply and add fused) andtf_ctl_ernie55_multimax_drop_square(the last term's square dropped), both red atshapes("output leaves its signed pointwise interval").SUMMARYline and exit status:SUMMARY ernie5_5 head: 1 kernels, 1 pass gates 1-4, 0 fail, 0 known findings; 2 controls: 2 red as planted, 0 missed, exit 0;kernel-contract ernie5_5:(filtered) SUMMARY 1 kernels: 1 pass gates 1-4, 0 fail, 0 known findings; 2 controls: 2 red as planted, 0 missed; 0 limit problems, exit 0. CUDA only (no HIP, Metal or XPU image).Checklist
-Dnvccthe CUDA steps are not built, as for every image)."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).