Skip to content

perf(cuda): a fused blend, warp sums, a kernel for short wide matrices, a shared value sum - #33

Merged
Defilan merged 5 commits into
mainfrom
agent/i2-fuse-blend
Nov 25, 2026
Merged

Defilan merged 5 commits into
mainfrom
agent/i2-fuse-blend

Conversation

@defilan-agent

@defilan-agent defilan-agent Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

What

Faster kernels for one token at a time on the GB10. Inkling 2 Mini, same prompt, same text: 24.5 to 28.1 tokens per second (40.8 to 35.5 ms a token). A sweep of eight positions: 82.2 to 74.7 ms.

  • Ops::mix_many: a blend for several queries followed by the normalization that always follows it. The default is the two steps one after another, so the CPU model is unchanged bit for bit.
  • On the device, one kernel normalizes the candidates, blends them for up to four queries and applies the following normalization. About 270 fewer launches per token. More than 16 candidates fall back to the steps one by one.
  • Sums inside the blend are taken within each warp first, instead of by one thread.
  • A kernel for matrices of few, long rows (at most 256 rows of at least 1,024 columns: the gates, the router, the per-token taps). The general kernel made each thread walk hundreds of columns one load after another.
  • Attention's weighted sum of values is shared by 16 threads per output element instead of one. This one grows with the context.
  • The old blend kernel is no longer used and is removed.

How it was checked

  • Mac: format, lint, and the test suite with the real model.
  • GB10: format, lint, and the whole workspace's tests with the real model. The real model still matches the reference on 96 of 96 recorded cases.
  • Each new kernel against the CPU function on shapes at and around its limits, including 17 candidates for the fallback.
  • Planted bugs 140 to 152, each caught by a test.

Review

Two rounds.

First round, changes requested on two points, both declined after checking:

  • "A local layer now uses one set of norm weights for its three inputs." The loader gives a local layer one tensor in all three places, so nothing changed. The code now says so and asserts it in debug builds.
  • "The model-level change has no test." Four planted bugs change exactly that code and are caught by the tiny model's recordings.

Taken from the first round: the unused kernel removed; a test for the fallback path; refusal cases.

Second round (after the three kernel changes): approve with nits, all taken. The thread-sharing constant is checked at compile time, and a test now asserts what its comment says.

@Defilan
Defilan merged commit 3ffc0ba into main Nov 25, 2026
2 checks passed
@Defilan
Defilan deleted the agent/i2-fuse-blend branch November 25, 2026 17:40
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.

1 participant