Repository navigation
inkling2 metal: split-K GQA decode, multi-row NAX verify attention, and 8 KiB bfloat4 dense_units - #4761
inkling2 metal: split-K GQA decode, multi-row NAX verify attention, and 8 KiB bfloat4 dense_units#4761cwschroeder wants to merge 19 commits into
Conversation
|
Thanks @cwschroeder for the split-K decode and multi-row NAX verify work. We found one edge case in the two new verify kernels, Could you keep masked V out of each row's sum, without clearing V the other row needs, and add a contract case comparing finite and NaN future V against scalar attention? The older prompt loop on the base branch has the same pattern. That one is ours to fix, so you can leave it.
|
aefb063 to
c41911e
Compare
|
Sorry for the noise: this was closed automatically when #4387 landed on main and its base branch was removed. It is reopened and now targets
|
a57ef2e to
2c7549c
Compare
…in the fewest 1,024-key folds a slot
…up to 32 rows is one launch
…uffers, independent launches side by side
… a row's sums never depend on its chunk
…t attention, and use mv_mma for prompt dense projections
Replace the scalar stride-2304 tf_inkling2_logits kernel with a 256-thread (8-simdgroup) batched implementation where each simdgroup computes one vocab row across up to 8 token rows, sharing coalesced bfloat4 unembed loads and preserving width-invariant FP32 reduction and BF16 softcap rounding. Update glue dispatch, contract limits record, host check, and 8x8 tile/interval contract tests.
… and batch conv staging and commits
…size prompt part_o by capacity, and widen glue/loop scratch to 512
…eams and raise batch_rows to 64
…, 8 KiB active-expert NAX, and blocked stage_conv
…nd 8 KiB bfloat4 dense_units
2c7549c to
6d5ac6e
Compare
|
Thank you for rebasing this onto main, @cwschroeder. We went through the new head commit by commit. It still carries the earlier Inkling Metal stack underneath your work, including commits that change the order FP32 dot products are summed in (the lane-strided sum and the simdgroup router, loop-gate and grouped-expert dots). TensorFold keeps every output bit equal to the serial reference, by default and behind a switch, so those commits cannot land, and the PR is held until the stack is rebuilt without them. Where your own commits reshape a reduction, the same applies; where they only reorder work, scheduling or launches, they can be reviewed once they sit on a base without those changes. An exact version of the faster router and gate dots, one thread per output in the original summation order, is something we are looking at on our side. Nothing is needed from you right now; we will follow up here.
|
What this changes
Stacked on #4747 (
ca63d0505, overlead/inkling2-mini3e0e9bcb8). Touches only 8 files across Inkling 2 Mini Metal attention anddense_units(no DSpark or host lane changes):tf_ink2_attn_split, 256 threads, 4,160 B TG) & sliding GQA decode (tf_ink2_attn_gqa, 32 threads) inattention.metal/attention.zig/inkling2_attention_metal_records.zig:exp2online softmax path whenscore <= peak.tf_ink2_attn_verify_slide_nax, 32 threads, 0 B TG;tf_ink2_attn_verify_global_nax, 256 threads, 9,216 B TG) inprompt_attention.metal/attention.zig/inkling2_attention_metal_records.zig:(row, head)query pairs per NAX tile directly viabfloat4loads (16x KV reuse) for single-stream multi-row verification (rows >= 2,last_pos >= 256), with 8-simdgroup split-K across global chunks.metal_inkling2_attention.zigandmetal_inkling2_attention_controls.zig.part[2048]+bfloat4fragment loads indense_units.metal(inkling2_dense_units_metal_records.zigupdated to.tg_memory = 8192):ink2_part_put_half/ink2_part_sum_half(from inkling2 metal: pre-sorted combine, simdgroup group, split-pow2 MXFP8, 8 KiB active-expert NAX, and blocked stage_conv #4747'sunits.metal) and vectorizes BF16 fragment loads.Checks on this head (
6d4ea7da4)zig fmt --check build.zig zig: PASS (Zig0.17.0)tools/zig/lean_check.pyvsca63d0505: 167 vs 167, 0 newtools/pr_check.py --base origin/lead/inkling2-mini: 0 errors (1 advisory warning for--pr NUMBER)zig build test-inkling2-controls-host test-inkling2-metal-host test-metal-launch-map-host: PASS (1230 registered launches, 2 controls, 0 missing)zig build -Dfixed-cpu test-kernel-contract: 279/280 PASS (1 pre-existinglead/inkling2-miniCUDA SM failure ininkling2_modelopt/inkling2_loop_math, 0 Metal issues)tf-kernel-contracton Apple M5 Max,applegpu_g17,tensor units true):--only "inkling2 attention": 10/10 kernels pass Gates 1–4, 8/8 controls red as planted, 0 limit problems--only "inkling2 prompt": 4/4 kernels pass Gates 1–4 (incl.tf_ink2_attn_verify_slide_naxworst 0.060 of bound andtf_ink2_attn_verify_global_naxworst 0.046 of bound), 4/4 controls red as planted, 0 limit problems--only "inkling2 dense_units": 6/6 kernels pass Gates 1–4, 6/6 controls red as planted, 0 limit problems (8,192 B TG exact on all 6)atc overlap --json: incomplete (pullFilesUnavailable,timeLimit); diff againstlead/inkling2-minishows only the base inkling2 metal: GQA 3:1 sliding KV sharing, multi-stream slots, and batch_rows=64 #4596/inkling2 metal: pre-sorted combine, simdgroup group, split-pow2 MXFP8, 8 KiB active-expert NAX, and blocked stage_conv #4747 stack plus these 8 files, with zero overlap against open Inkling 2 Mini PRs outside this stack.Receipt
0.17.0,thinkingmachines/Inkling-2-Mini@ed40e7da625f594fc9c4990f5f66be24873c22d7(unmodified BF16+NVFP4+MXFP8).sha=b5017c21c071, 4Ksha=2469b1cbb494).fwd_1single-token decode: total57.95 -> 45.51 ms(-21.5%), 48-layer attention14.58 -> 5.66 ms(-61.2%), 8 global layers~12.0 -> 2.74 ms(~4.4x faster).fwd_verifymulti-row verify: total35.24 -> 33.32 ms(-5.4%), 40 sliding layers1.591 -> 1.029 ms, 8 global layers0.722 -> 0.433 ms(54.1 us/layer), total 48-layer verify attention1.462 ms(~10.7x faster than scalar).dense_units:dense6_units_16-20.7%,dense_units_16-29.7%.