Skip to content

inkling2 cuda: Mini decode experts a warp 8 columns, gate and up in one launch (stacked on #4728, decode +3.8 %, same bits) - #4729

Merged
ashhart merged 4 commits into
ashhart:mainfrom
jschmied:ink2-mini-speed-experts-nt
Nov 24, 2026
Merged

ashhart merged 4 commits into
ashhart:mainfrom
jschmied:ink2-mini-speed-experts-nt

Conversation

@jschmied

@jschmied jschmied commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Update: head b54506ca73, the bounded scale loads at no cost

The round-1 head e8de695145 was slower than 39fd949338 in a three-round A-B-B-A: c=1 0.9990 (6 of 6 pairs slower), c=4 0.9991 (5 of 6), TTFT 1.0004 (6 of 6). Its bounded scale loads chose between a word and bytes for each word.

b54506ca73 makes one test a tile instead. When the row's scales are word-aligned with no partial word, which is every tile at Mini's shapes, it takes the whole-word loop it took before the bound. Otherwise the byte path loads the rest.

  • Registers: 111 on sm_121, unchanged.
  • SASS against 39fd949338: _plan, _act and _combine are identical on sm_80/86/89/120/121; _up and _prompt_up differ.

Checks on b54506ca73:

cell paired median B/A pairs where B is slower
c=1 decode 1.0003 1 of 6
c=4 aggregate 1.0002 2 of 6
prompt TTFT 1.0001 3 of 6

No cell is consistently slower, so the "don't land yet" below is withdrawn.


Update for review 7098920791: head e8de695145, stacked on #4728 fb55ed477e

Checks on e8de695145 (GB10):

  • Host: the Inkling steps are green. The registry test finds the base's 40. pr_check: 0 errors, lean 167 vs 167.
  • Kernel contract inkling2: 55/55 pass gates 1-4, 36 of 36 controls red, 0 limit problems. The K = 32 cases pass shapes, nonfinite and repeat. Memcheck on kernel-contract "K = 32": 0 errors.
  • SASS against the previous head 39fd949338: _plan, _act and _combine are identical on all 5 SMs; _up and _prompt_up differ, which is the scale-load change. Registers on sm_121 are unchanged (111 and 198), as recorded.
  • Served: hashes identical to 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's (greedy, seeded, again, c=4, long, turn 2). inkling2-serving: PASS. The binary (5e79fa1d) is byte-identical to the one the gates ran on.
  • Speed: one A-B-B-A against 39fd949338:
    • c=1: 10.195 vs 10.184 tok/s, paired median 0.9994, 2 of 2 slower;
    • c=4: 10.099 vs 10.090, paired median 0.9994, 2 of 2 slower;
    • TTFT: 0.9998, 1 of 2 slower.
  • That is a paired loss of 0.06 %, so don't land this head yet. A three-round A-B-B-A is running and I'll post it here.

What this changes

Stacked on #4728 (the expert tile staging, 3cd12eb55e), which is stacked on #4640 (321432e4b2); base lead/inkling2-mini. The diff against #4728 is one commit, 39fd949338. If either merges, I'll retarget this PR.

After #4728, decode's tf_ink2moe_up still ran one warp per 32 output columns over the whole K. A layer's three projections had 288 to 576 warps, about 6 an SM. nsys and ncu (on the contract's synthetic shapes) showed the issue slots 70 % idle. The gate and up halves of w13 were also two launches of 1.5 waves each.

This PR changes two things at decode:

  • 8 columns a warp. A decode warp now owns one n8 tile (kDecodeTiles, 8 output columns) and stages 8 weight rows a tile. That gives four times the warps.
  • Gate and up in one launch. The decode launch walks w13's rows in order (row_step 1). It stores even rows to the gate buffer and odd rows to the up buffer, so each layer makes 2 expert launches instead of 3.

Each output's mma sequence over K, its weights and its BF16 rounding are unchanged, so the outputs are bit-equal. Prompt chunks keep 32 columns a warp and two launches; tf_ink2moe_prompt_up's SASS is identical to #4728's.

nsys (c=1, 60 decode forwards): experts 14.3 → 10.5 ms a token (11.3 ms with the column split alone); expert launches 144 → 96 a token.

  • Inkling-only: modelopt.cu is Mini's expert image, modelopt.zig is its launcher, and the records file is the Inkling contract's (the sm_121 row of tf_ink2moe_up). No shared code and no Metal file are touched.

Checks on this head (39fd949338)

GB10 (sm_121, CUDA 13.0), Zig 0.17.0, thinkingmachines/Inkling-2-Mini@ed40e7da.

Speed (A-B-B-A against #4728'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 = #4728's head (3cd12eb55e), B = this head.

  • Cells: cold TTFT of a 7,262-token prompt (1 token out); c=1 decode = 4 topics × 128 greedy tokens, (tokens − 1) / (wall − 1-token wall); c=4 aggregate = the 4 topics at once, total tokens / wall. Tokens are counted from usage.
  • SM clock was logged at 1 Hz: median 2288 MHz in both arms, with the same constant clock-event mask (0x400, the box's boot-time clock cap). No round was dropped.
cell A (#4728), best of 4 B (this PR), best of 4 paired median B/A pairs where B is slower
c=1 decode 9.86 tok/s 10.24 tok/s 1.038 0 of 4
c=4 aggregate 9.77 tok/s 10.15 tok/s 1.038 0 of 4
prompt TTFT (7,262 tokens) 27.06 s 27.04 s 0.999 1 of 4
  • The reply hashes were equal in every arm, solo and c=4.
  • The prompt cell is flat, as it should be: prompt chunks run tf_ink2moe_prompt_up, whose SASS is unchanged. The one slower pair is 27.091 → 27.098 s (+0.03 %); the four A runs spread over 0.07 s.
  • Binaries: A 516459f0 (built from 3cd12eb55e), B e43fdeb1. B was built from 17c3175e76; this head 39fd949338 differs from that commit only in the records file's unmeasured-SM rows, and a rebuild from 39fd949338 gave the same tensorfold-native md5. The gates above ran on B.
  • Why not against main: this PR targets lead/inkling2-mini, whose Mini engine main does not have.

Proposed CHANGELOG line

  • Inkling 2 Mini on CUDA: decode experts run a warp per 8 output columns and the gate and up halves in one launch, 14.3 ms to 10.5 ms a token, with the same bits.

@jschmied

Copy link
Copy Markdown
Contributor Author

The three-round A-B-B-A on the round-1 head e8de695145 confirmed a small loss against 39fd949338: c=1 0.9990 (6 of 6 pairs slower), c=4 0.9991 (5 of 6), TTFT 1.0004 (6 of 6). The cause was the bounded scale loads from #4728.

New head b54506ca73 fixes it. The scale loads make one test a tile: word-aligned tiles with no partial word, every tile at Mini's shapes, take the old whole-word loop, and the byte path serves only the rest.

Checks on b54506ca73:

No cell is consistently slower, so the "don't land yet" is withdrawn. Details are at the top of the body.

@joshuaswarren

Copy link
Copy Markdown
Contributor

sm_120 contract run on RTX 5060 Ti (independent of GB10), head b54506c.

tf-cuda-test kernel-contract inkling2:

No gate failures on sm_120; limit diffs are record-staleness on this arch, same as the rest of the stack.

@ashhart
ashhart force-pushed the lead/inkling2-mini branch 3 times, most recently from aefb063 to c41911e Compare November 24, 2026 09:43
@ashhart
ashhart deleted the branch ashhart:lead/inkling2-mini November 24, 2026 09:43
@ashhart ashhart closed this Nov 24, 2026
@ashhart ashhart reopened this Nov 24, 2026
@ashhart
ashhart changed the base branch from lead/inkling2-mini to main November 24, 2026 09:46
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Sorry for the noise: this was closed automatically when #4387 landed on main and its branch was removed. It is reopened and now targets main. We will rebase it onto main for you; nothing is needed from you.

  • Synthena

ashhart added a commit to jschmied/TensorFold that referenced this pull request Nov 24, 2026
ashhart#4729 rewrites tf_ink2moe_up again (a warp eight output columns, gate and
up in one launch) and records its compiled usage at sm_121 only, leaving
zeros at sm_80, sm_86, sm_89 and sm_120 for the kernel registry test.

The values are nvcc 13.0's, from kernel-contract-limits over fatbins built
for all five SMs from this tree; the sm_121 entry equals the one the PR
recorded. No kernel changes.
@ashhart
ashhart force-pushed the ink2-mini-speed-experts-nt branch from b54506c to aba9fb8 Compare November 24, 2026 12:16
ashhart added a commit to jschmied/TensorFold that referenced this pull request Nov 24, 2026
ashhart#4729 rewrites tf_ink2moe_up again (a warp eight output columns, gate and
up in one launch) and records its compiled usage at sm_121 only, leaving
zeros at sm_80, sm_86, sm_89 and sm_120 for the kernel registry test.

The values are nvcc 13.0's, from kernel-contract-limits over fatbins built
for all five SMs from this tree; the sm_121 entry equals the one the PR
recorded. No kernel changes.
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you, @jschmied. We rebased this onto main and ran a serving A/B on a GB10 with Inkling 2 Mini: main against this branch, which also carries #4728; builds alternated base, new, new, base.

We'll land #4728 first, then this one, then #4786.

  • Synthena

ashhart added a commit to jschmied/TensorFold that referenced this pull request Nov 24, 2026
ashhart#4729 rewrites tf_ink2moe_up again (a warp eight output columns, gate and
up in one launch) and records its compiled usage at sm_121 only, leaving
zeros at sm_80, sm_86, sm_89 and sm_120 for the kernel registry test.

The values are nvcc 13.0's, from kernel-contract-limits over fatbins built
for all five SMs from this tree; the sm_121 entry equals the one the PR
recorded. No kernel changes.
@ashhart
ashhart force-pushed the ink2-mini-speed-experts-nt branch from aba9fb8 to 4052417 Compare November 24, 2026 18:09
jschmied and others added 3 commits November 24, 2026 21:48
…up in one launch

At decode tf_ink2moe_up ran a warp per 32 output columns over the whole K, so a layer's projections had
288 to 576 warps, about 6 an SM, and each warp's long serial stream left 70 % of the issue slots idle; the
gate and up halves of w13 were two launches of 1.5 waves each. Decode warps now own one n8 tile (8 columns,
kDecodeTiles), and one launch walks w13's rows in order, storing even rows to the gate and odd rows to the up
buffer. Each output's mma sequence over K and its rounding are unchanged, so the bits are unchanged; prompt
chunks keep 32 columns a warp and two launches.
… a tile

The bounded scale loads chose word or bytes per word. A tile whose row scales are word-aligned with no
partial word, every tile at Mini's shapes, now takes the whole-word loop it took before the bound, after
one test; the byte path serves only the rest.
ashhart#4729 rewrites tf_ink2moe_up again (a warp eight output columns, gate and
up in one launch) and records its compiled usage at sm_121 only, leaving
zeros at sm_80, sm_86, sm_89 and sm_120 for the kernel registry test.

The values are nvcc 13.0's, from kernel-contract-limits over fatbins built
for all five SMs from this tree; the sm_121 entry equals the one the PR
recorded. No kernel changes.
@ashhart
ashhart force-pushed the ink2-mini-speed-experts-nt branch from 4052417 to 5555e46 Compare November 24, 2026 21:48
@ashhart
ashhart merged commit df64c54 into ashhart:main Nov 24, 2026
1 check failed
ashhart added a commit that referenced this pull request Nov 24, 2026
#4729 rewrites tf_ink2moe_up again (a warp eight output columns, gate and
up in one launch) and records its compiled usage at sm_121 only, leaving
zeros at sm_80, sm_86, sm_89 and sm_120 for the kernel registry test.

The values are nvcc 13.0's, from kernel-contract-limits over fatbins built
for all five SMs from this tree; the sm_121 entry equals the one the PR
recorded. No kernel changes.
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

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.

ashhart added a commit that referenced this pull request Nov 24, 2026
ashhart added a commit that referenced this pull request Nov 24, 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.

3 participants