Repository navigation
Conversation
This was referenced Nov 21, 2026
plotarmordev
added a commit
to plotarmordev/TensorFold
that referenced
this pull request
Nov 22, 2026
…nterleaves gate and up rows; E8M0 byte 0 checked on the GPU
plotarmordev
added a commit
to plotarmordev/TensorFold
that referenced
this pull request
Nov 22, 2026
1 task done
…SwiGLU in core Core grouped experts gain Format.mxfp8 (e4m3 codes times one E8M0 scale per row per 32 inputs, folded exactly into the bf16 mma operand, fp32 sums) and Layer.caps, Inkling's soft-capped SwiGLU epilogue (experts.cuh epilogue 4) on the NVFP4 decode and prompt kernels and on the new MXFP8 ones. NVFP4's per-expert factor is amax / denominator, each rounded to bf16 (experts_mx.nvfp4Factor, open question F1). Evidence: stored-experts contract 9 kernels pass gates 1-4, 7 short-K controls red; checkpoint layers 0 and 20 decode bit for bit on every weight of 128 experts, outputs within the fp32 bound; SASS of all 465 pre-existing (unit, sm, function) triples equal main on sm_80/86/89/120/121.
… checked on the GPU experts_mx.splitGateUp takes stored row 2j to gate j and 2j + 1 to up j before packGateUp (the kernels are unchanged); a host test plants a code in stored row 1 and requires it in the up part. The checkpoint reference reads row 2j + m. stored-experts ckpt adds E8M0 bytes 0 to 240 through tf_mxfp8_down_f32 against the host decode (byte 0 = 2^-127).
jschmied
force-pushed
the
inkling2-mini-c3
branch
from
November 22, 2026 21:41
eed574b to
b2cea56
Compare
Contributor
Author
|
Closing as superseded. Mini on CUDA now goes through #4387's engine: #4640 for correctness, and #4697, #4718, #4728 and #4729 for speed. Those four take it from 5.6 to 28.2 tok/s stacked, bit-equal to #4640, and a PR sharing one forward across streams follows. This stack would be a second Mini engine beside it (see #4387, comment 7092191800). The branch stays on my fork, so it can be reopened if a piece of it is wanted. The likeliest candidate is #4365's core NVFP4/MXFP8 expert entries, if Mini or another family moves onto core experts. |
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.
Proposal for review, draft. Slice C3 of the Inkling 2 Mini plan (#4274), claimed in #4274 (comment) and not yet confirmed. I'm opening it as a draft so the approach can be reviewed early; it stays a draft until the claim is confirmed. If @akol1 takes C3 instead, this can serve as a reference or be closed.
What this changes
Inkling 2 Mini's routed experts as stored, on core grouped experts (
src/cuda/experts.zig), not as a family kernel: NVFP4 and MXFP8 weights decoded in registers, bf16 activations, FP32 sums (decision 2 as corrected in #4274 (comment)).Reused unchanged:
grouped.zigrouting and plan, the NVFP4 packing and decode/prompt sums (Mini's per-expert factor goes into the existing per-expert fp32 scale slot), FP8 experts' code-word lane order.Core extended:
experts.cuh: epilogue 4, soft-capped SwiGLU:sigmoid(g) · gc·tanh(g/gc) · uc·tanh(u/uc), both caps.nvfp4_experts.cu:tf_nvfp4_softcap,tf_nvfp4_prompt_softcap.fp8_experts.cu: MXFP8tf_mxfp8_{softcap,down_f32,down_bf16,prompt_softcap,prompt_down}; the E8M0 scale is folded exactly into the bf16 operand, byte 0 = 2^-127.experts.zig:Format.mxfp8,Layer.caps; newexperts_mx.zig(MXFP8 experts,splitGateUp,nvfp4Factor, refusals);core/expert_decode.zig, a host decoder.Checkpoint layout:
w13interleaves gate and up rows (stored row 2j is gate j, 2j+1 is up j), split once at load bysplitGateUp; nibbles are low first. Both agree with Metal: experimental Inkling 2 Mini text, vision and bundled DSpark #4337's Metal decode.Issue: Refs docs: a plan for Inkling 2 Mini on CUDA and Metal in claimable slices #4274, Inkling 2 Small on four DGX Sparks: a native CUDA family #3476.
Overlap: merges cleanly with Inkling-2-Small: Add grouped-expert and vision kernels #4127 and Metal: experimental Inkling 2 Mini text, vision and bundled DSpark #4337. Inkling-2-Small: Add DSpark drafter kernels #4128 (head
e7d4e44529, stacked on an older base) conflicts with main itself in the shared lists; this branch adds no conflicts beyond those.atc overlap: incomplete (ATC's limits).Open for the maintainer
nvfp4Factorcomputesfp32(bf16(amax) / bf16(2688)), as Metal: experimental Inkling 2 Mini text, vision and bundled DSpark #4337 does. It is the one place to change once decision 2 settles rounding.tf_ink2_gateupform). Metal: experimental Inkling 2 Mini text, vision and bundled DSpark #4337 rounds gate and up to bf16 first. Which one is the contract for Mini?Checks on this head
Head
b2cea56fe6, rebased onto main14951bc65don the user's request (waseed574b91fon main362107c4c9); GB10 (sm_121).What the rebase changed. Main's #4493 (paired NVFP4 prompt experts) touched the same files:
nvfp4_experts.cu:prompt_tilesandprompt_bodykeep main'sX_b,out_b,splitand take this PR'slimit2after them (default 0); the pair branch's epilogues pass it too (EPI 2 and 3 ignore it). The file reached 600 lines, so the two soft-capped entries moved unchanged tonvfp4_experts_softcap.cuh, included at the end of the same unit (same fatbin, same symbols; pinned ingradient-serving.tsv).cuda/experts.zigandcuda/root.zig: main'sexperts_prompt_layoutandpair_expertsimports kept beside this PR'sexperts_mx. Main dropped the threepromptSmemasserts from the test this PR moves toexperts_host_test.zig; the moved copy drops them too.gradient-serving.tsv: the rows this PR touches take the rebased files' sha256, main's note plus this PR's.tools/zig/lean_check.py's multi-line rule).Because code under the PR moved, every device check was rerun on this head (
tf-cuda-testmd53a853326):ed40e7da, layer 0 (NVFP4) and layer 20 (MXFP8): everyw13andw2weight of all 128 experts read back on the GPU equals the host decode; outputs at 4 tokens (decode) and 64 (prompt) within the FP32 bound, worst error over bound 0.95 (gate-up) and 0.99 (down), the same as oneed574b91f. The NVFP4 peak code × scale is 2,688 in every expert. 13 of 13 checks pass.14951bc65d): all 475 pre-existing (unit, SM, function) triples in the 13 units that includeexperts.cuh, main's new paired prompt entries among them, have SASS identical to main on sm_80, 86, 89, 120 and 121; 35 new.tf_mxfp8_down_f32match the host decode on the GPU.FormatNotLoaded,EpilogueNotBuilt,OptionNotBuilt,BadSoftcap,UnexpectedShape.test-cuda-hostandtest-gradient-servingpass on the GB10. On x86:check-native-cuda-host,compile-cuda-tests,test-host,test,test-golden,test-kernel-contract,test-server-security,test-pull-security,fuzz-cortheon,check-release-pathspass, exceptrequest_admission_http_test"every way an n-choices request ends returns its places". That test fails on main14951bc65don the same x86 box and passed on a rerun of this head, so it is main's flaky test, not this PR.tools/pr_check.py: 0 errors, lean 165 vs 165, 0 new.zig fmt --check: clean.Speed
Main has no CUDA Inkling, so these rows have no main baseline; they are absolute numbers for the new entries. What main already serves is covered by the SASS check above: all 475 pre-existing functions in the 13 units that include
experts.cuhare identical to main14951bc65d, so no existing family's expert path can be slower. The new entries' SASS on this head is also identical toeed574b91f's (sm_121, all 32 functions ofnvfp4_expertsandfp8_expertsthat head had).One layer, gate-up plus down, real weights, median of 5 × 200, GB10 (273 GB/s), one run on this head
b2cea56fe6:On
eed574b91fthe same rows were 170 / 575 µs, 2.69 ms, 302 µs, 1.05 ms, 5.12 ms. With identical SASS, the 1-3 % on the two small NVFP4 rows is run-to-run spread, not code.Receipt
n/a: no served path reaches these kernels until C4.
Proposed CHANGELOG line