Repository navigation
inkling2 cuda: split Mini's loop gate into a down half and an up half (decode 5.6 to 7.2 tok/s, same bits) - #4697
Conversation
3e0e9bc to
f790014
Compare
|
Independent sm_120 check on
The correctness side matches your GB10 numbers: every gate-1..4 cell passes, including the QKV/down/up shapes and the planted controls. The 22 |
|
Thanks for the sm_120 run, @joshuaswarren. The How your live values compare with nvcc 13.0 on sm_120:
The base launches' 13.0 rows are on To clear the run on 13.4, the registry needs a 13.4 receipt set. Could you post the full |
aefb063 to
c41911e
Compare
|
Sorry for the noise: this was closed automatically when #4387 landed on main and its branch was removed. It is reopened and now targets
|
ed5da93 to
dea5ed2
Compare
|
Thanks @jschmied. The split preserves the reduction tree, BF16 rounding and output steps in source, and the contract compares its bytes with the original gate. Scratch ownership and stream ordering also look sound. The five target records are filled for compiler 13.0; later compiler receipts remain separate. This looks ready for a serving comparison against current main on the pinned Mini checkpoint: matching token IDs and logits, plus decode and prompt timings. Please keep the existing speed figures labelled with the revisions they were measured on, and refresh the old base and commit wording in the description.
|
|
Results on our side, @jschmied: we compared this head (
No cell was slower. Thank you for this one; it goes into our landing queue now.
|
…block and an up half a column a thread tf_ink2_loop_gate ran one block a gate row: one block read the 590 KB down matrix and the 590 KB forget/gain pair for each of the 96 gates a token. tf_ink2_loop_gate_down runs a block a row and rank pair, each with the one-block kernel's norms, 256-thread chains and reduction tree, and writes the BF16 zeta to a [rows][64] scratch; tf_ink2_loop_gate_up runs a thread a column with the same ascending rank chains, tanh and four rounding steps. tf_ink2_loop_gate stays in the image, unserved, as the contract's baseline: the halves are gated bit-equal to it.
…20 too nvcc 13.0 -cubin -O3 --resource-usage per SM, as the image builds them: tf_ink2_loop_gate_down 22/24/24/32 registers, tf_ink2_loop_gate_up 38/70/46/46, static shared bytes and launch bounds as on sm_121, no stack or spills. The two launches admit sm_80 onward, so the registry check now has their numbers on every pinned SM.
dea5ed2 to
60f2cce
Compare
|
Thank you @jschmied. 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. |
Update for review 7098920791: head
ed5da93076Point 2, the kernel records. The two new launches admit sm_80 onward, and now carry compiled usage for every pinned SM.
-cubin -O3 --resource-usageper SM, the image's flags. There are no stack frames or spills; static shared bytes and launch bounds are as on sm_121.tf_ink2_loop_gate_downregstf_ink2_loop_gate_upregscheckCudaoverall_cuda): thetest-kernel-contractregistry test finds 40 on this head, the base's 40. Before this commit it was 48.Checks on
ed5da93076(on05a5ed3ffd, GB10):pr_check: 0 errors, lean 167 vs 167. fmt and diff-check: clean.inkling2: 53/53, 37 of 37 controls red, 0 limit problems.loop_math.cuis unchanged by this commit (only the records file changed); all its functions are identical to05a5ed3ffd's on sm_80/86/89/120/121.inkling2-serving: PASS.05a5ed3ffd. Best of 2: 7.216 vs 7.215 tok/s. Paired median 0.9998, 1 of 2 pairs slower, so mixed.#4718 now stacks on this head, because the two conflicted in
contract_inkling2_loop_math_extra.zig.What this changes
Mini's loop gate (
tf_ink2_loop_gate, 96 calls a token) ran one block per gate row. At decode that is one block on one SM for each gate. That block reads the 590 KB down matrix and the 590 KB forget/gain pair, so the gates took 41.2 ms of the 181.8 ms a token on #4640's head (nsys, c=1, 60 decode forwards).This PR splits the gate into two kernels:
tf_ink2_loop_gate_down: one block per row and rank pair (grid rows × 32). Each block runs the same code path as the one-block kernel for its two ranks: the same norms, the same 256-thread chains and the same two-level reduction tree. It writes the BF16 zeta to a[rows][64]scratch (Scratch.zeta,loop_engine.zig).tf_ink2_loop_gate_up: one thread per output column (64 per block). It runs the same ascending rank chains for forget and gain, the sametanhfand the same four FP32 rounding steps.Every value is computed by the same operations in the same order, so the outputs are bit-equal. The gates go from 41.2 ms to 1.65 ms a token (down 1.23, up 0.42).
tf_ink2_loop_gatestays in the image, unchanged and not served. It is the contract's baseline: the split is registered as its replacement, so gate 3 requires its bytes.321432e4b2), baselead/inkling2-mini. One commit,05a5ed3ffd. If Inkling 2 Mini on CUDA: #4387's engine loads the checkpoint, answers correctly (64/64 teacher-forced), serves --parallel streams, and resumes prompt-cache states exactly #4640 merges, I'll retarget this PR.inkling2_loop_mathis Mini's own image. No shared code, no Metal file and no other family is touched; the one file undersrc/core/contract/is the Inkling records table (two rows added).kernels/cuda/inkling2/loop_math.cu,families/inkling2/loop_math_cuda.zig(gate=gateDown+gateUp),loop_engine.zig(zeta scratch), the loop-math contract andinkling2_experts_records.zig.Checks on this head (
05a5ed3ffd)GB10 (sm_121, CUDA 13.0), Zig 0.17.0,
thinkingmachines/Inkling-2-Mini@ed40e7da.zig build test-inkling2-host test-inkling2-cuda-host compile-cuda-tests check-native-cuda-host: 24/24 steps, 86/90 tests passed (4 skipped).zig fmt --check build.zig zig: clean.git diff --check: clean.tools/pr_check.py --base 321432e4b2: 0 errors, lean 167 vs 167, 0 new.tf-cuda-test kernel-contract inkling2):SUMMARY 53 kernels: 53 pass gates 1-4, 0 fail, 0 known findings; 37 controls: 37 red as planted, 0 missed; 0 limit problems.tf_ink2_loop_gate_down + _upis bit-equal totf_ink2_loop_gateat all three served shapes (1×2304, 16×2304, 2048×128).contract_inkling2_loop_math.zig,GateFault):half_ranks: the down half launched for 16 of its 32 rank pairs.wrong_gain: the up half given the forget weights again in place of gain. This one existed before and now runs through the up kernel.gate_down31 registers, 264 shared bytes;gate_up46 registers, 256 shared bytes (sm_121, recorded).tanhtolerance missed by 1.7e-4 at one element of the 2048×128 shape. The old kernel's bytes are the same on those inputs, so it would miss there too. A standalone comparison of old and new kernels on 2048×128, 1×2304, 16×2304 and 200×2304 found 0 differing outputs of 760k. Bit-equality to the kernel being replaced is the stronger gate.loop_math.cucompiled at base and head for sm_80/86/89/120/121 and compared function by function. All 5 existing functions are identical on every SM (includingtf_ink2_loop_gate); 2 functions are added.tf-cuda-test inkling2-serving(your test): all 6 cases PASS. They include host-reference token equality, fresh == resumed, cross-prompt resume, four slots greedy and seeded == solo with a fifth refused before anything is queued, and copy drafting rollback.tensorfold-native serve --parallel 4 --context 8192, page cache dropped, default copy drafting and prompt cache on; hashes cover reasoning and content, and an empty reply fails):9b35cbd7c284 6cab4f209b56 b776a20d70d3 b00493ac337c). Again == solo 4/4, four at once == solo 4/4.5b886d0faf27 454f0d516c07 0784bd565d6f e4b491588221). Again 4/4, c=4 4/4.dad96525689aboth times, as on Inkling 2 Mini on CUDA: #4387's engine loads the checkpoint, answers correctly (64/64 teacher-forced), serves --parallel streams, and resumes prompt-cache states exactly #4640.fdb1da1ad592, as on Inkling 2 Mini on CUDA: #4387's engine loads the checkpoint, answers correctly (64/64 teacher-forced), serves --parallel streams, and resumes prompt-cache states exactly #4640.Speed (A-B-B-A against #4640's head, this head's binary)
Served,
tensorfold-native serve --parallel 4 --context 8192, default copy drafting and prompt cache on, page cache dropped before each server start. Each arm is a fresh server. Order A B B A, two rounds. A = #4640's head (321432e4b2), B = this head.usage.0x400, the box's boot-time clock cap). No round was dropped.The reply hashes were equal in every arm, solo and c=4. nsys on the same kernels (c=1, 60 decode forwards): 181.8 → 141.0 ms a token, and the gates 41.2 → 1.65 ms (down 1.23, up 0.42).
019c09e6(built from321432e4b2), Ba8088b93(built from05a5ed3ffd, the commit itself). The gates above ran on the same B build.lead/inkling2-mini, whose Mini engine main does not have.Proposed CHANGELOG line