Repository navigation
inkling2 metal: routed experts and combine one thread an output, each dot the serial chain - #4894
Merged
Merged
Conversation
ashhart
force-pushed
the
lead/inkling2-metal-expert-grid
branch
from
November 24, 2026 13:47
25d0de4 to
2bd11a5
Compare
This was referenced Nov 24, 2026
… dot the serial chain Each expert product ran one 32-thread group a route pair, its lanes looping over the pair's outputs: 36 outputs a lane for GU (n 1152), 72 for down (n 2304), and eight groups a decode step. Combine ran one group a token. The four products and the combine now launch threadgroups along the outputs by route pairs (or tokens), one thread an output. Each thread runs the same ink2_dot_nv / ink2_dot_mx as before: one FP32 chain from column 0 up, every product rounded before its add (fp contract off), then the same BF16 rounding and activation. Combine keeps its ascending-expert loop. Only which thread computes an output changes, so every output is bit-identical to the serial reference. Threads past the row return before any read. Launches stay 32 threads, so the existing records hold; the quantize kernels are unchanged. The grid of outputs by route pairs and launchGrid follow #4448's 2f386ca; its lane-strided partial sums and simd_sum, which change the FP32 sum order, are not taken. Tests: test-inkling2-controls-host checks the source keeps both dots serial with no simd_sum and launches every product and the combine one output a thread (fails before: five lane loops), and that the grid covers every output exactly once, with no thread past the row reading. The block count rounds up as n / 32 plus one for a remainder, so the largest u32 widths (4294967265 through 4294967295) take 134217728 blocks instead of overflowing n + 31; a test asserts those widths and fails on the n + 31 form. Co-authored-by: Seth For Privacy <40500387+sethforprivacy@users.noreply.github.com>
… kernels The contract's expert cells ran products of at most 12 outputs a pair and combines of at most 12 a token, so only the first output block of the new grid ever ran, and they compared with a float64 bound, not with main's bytes. Each of the five operations the grid changed (NVFP4 and MXFP8 GU and down, and the combine) now has a cell that replaces main's kernel: main's experts.metal at 5e39051, frozen under baselines/, on main's own launch (one 32-thread group a route pair, a token for the combine, each lane looping over its outputs). On the same inputs, every output byte of the new grid must equal main's. The shapes are several output blocks with tails (n 65, 64, 63 and the 1, 31, 32, 33 edges), Mini's own widths (GU k 2304 n 1152, down k 1152 n 2304, combine n 2304) and 64 rows (128 route pairs). The float64 reference now holds dots of 2304 terms. Two planted grid faults go into all five kernels, each a control at the shapes gate: every output block past the first returning before it writes, and the pair (token) index halved so two pairs write one row.
…utput, each dot the serial chain
ashhart
force-pushed
the
lead/inkling2-metal-expert-grid
branch
from
November 24, 2026 20:45
2bd11a5 to
3d8f271
Compare
Owner
Author
|
Thank you @sethforprivacy. This is merged into main with your commits under your own name, so you're credited as a TensorFold contributor. |
17 tasks
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.
Inkling 2 Mini Metal: the routed experts and the combine run one thread per output, and the contract checks the new grid byte for byte against main's kernels.
Before: each expert product ran one 32-thread group per route pair, its lanes looping over the pair's outputs (36 outputs a lane for gate-up at n 1152, 72 for down at n 2304). The combine ran one group per token.
After:
ink2_dot_nv/ink2_dot_mxas before. That is one FP32 chain from column 0 up, with every product rounded before its add (fp contract off), followed by the same BF16 rounding and activation. The combine keeps its ascending-expert loop.Credit: the outputs-by-route-pairs grid follows @sethforprivacy's 2f386ca in #4448 (Co-authored-by in the commit). Its lane-strided partial sums and
simd_sumchange the FP32 summation order, so they are not taken.Base: two commits on main 9fa8863. Between 5e39051, where the device cells below ran, and 9fa8863, main changed no Inkling or Metal file.
Contract: the second commit adds a byte-for-byte check against main.
zig/tests/contract/baselines/, run on main's own launch (one group per route pair, a token for the combine).simd_sum, that the grid covers every output exactly once with no thread past the row reading, and that block counts can't overflow at the largest u32 widths.Checked on device (thinkingmachines/Inkling-2-Mini at ed40e7da62):
tf-kernel-contractbuilt for apple_m1 in ReleaseSafe:--only 'metal inkling2 experts': 12 kernels pass gates 1-4, and 17 controls go red as planted, 0 missed, 0 limit problems.--only inkling2: 46 kernels pass, 51 controls go red, 0 limit problems.--only 'metal inkling2 experts': 12 kernels pass gates 1-4, and 17 controls go red, 0 missed, 0 limit problems.--only inkling2: 46 kernels pass, 51 controls go red, 0 limit problems.and every resumed reply equals its fresh run.
cell is slower.
Not checked: