Repository navigation
inkling2 metal: pre-sorted combine, simdgroup group, split-pow2 MXFP8, 8 KiB active-expert NAX, and blocked stage_conv - #4747
Conversation
|
Thanks @cwschroeder for the new Mini Metal kernels and multi-stream attention paths. While reviewing, I found that snapshot save and restore in the shared base under this branch copies each KV region flat, although the live cache is stored per head, so a partly filled sliding ring can resume incorrectly. That code is not from your changes, and we are fixing it separately in #4542. Nothing is needed from you on this point, and we will rebase your branch onto the fix.
|
3e0e9bc to
f790014
Compare
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
|
63b736a to
b345a64
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
b345a64 to
1a50f48
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.
|
Bit-exact Metal kernel optimizations for Inkling 2 Mini on Apple Silicon (verified on Apple M5 Max, 40-core GPU,
applegpu_g17,tensor units true), audited for zero overlap against#4593,#4594,#4596,#4465, and#4699.#4596(bd8842833,lead/inkling2-minibase), 1 commit:ca63d0505What this changes
tf_ink2_combine(zig/kernels/metal/inkling2/experts.metal): Pre-sorta.topk <= 32route slots once per threadgroup inthreadgroupmemory instead of repeating the52.13 -> 2.73 ms, -85.0% verify1.51 -> 0.23 ms).tf_ink2_group(zig/kernels/metal/inkling2/experts.metal): 1 simdgroup (32 lanes) per expert with coalescedidsloads andsimd_prefix_exclusive_sum(-81.2% prefill12.00 -> 2.25 ms).ink2_nv_quad&ink2_mx_quad(zig/kernels/metal/inkling2/experts_units.metal): Useink2_e4m3_bitsand exact split-power-of-two IEEE754 multiplies in place ofldexp(bit-identical across all 65,536 byte pairs; -28.0% MXFP8 Down / -12.6% MXFP8 GU).part[2048]+ active-expert NAX dispatch (units.metal,experts_units.metal,experts.zig,forward.zig):ink2_units_storeinto two 8-row halves reusingpart[2048](8 KiB instead of 16 KiB, doubling threadgroup occupancy across all widths).tf_ink2_*_units_1(1 KiB scratch, dispatches only the 8 active route slots directly forrows == 1, skippingtf_ink2_groupcompletely; -21.8%fwd_1NVFP4 experts6.71 -> 5.25 ms).tf_ink2_group_compact(single 128-thread TG) +tf_ink2_*_units_active(dispatches onlymin(rows * topk, 128)compacted experts for2 <= rows <= 8; -16.5%fwd_verifyNVFP4 Down / -8.2% GU).tf_ink2_stage_conv(runtime.metal,runtime_plan.zig,forward.zig): 16-row block parallelism with a zero-division fast path forrows <= 16(-86.8% prefill15.97 -> 2.11 ms, zero decode regression).tf_ink2_attn_scalar&tf_ink2_attn_slots(attention.metal): Register-hoistqvbefore the KV loop and vectorizeVloads withbfloat4.Verification (Apple M5 Max, 40-core GPU, 128 GiB, Zig
0.17.0,-Doptimize=ReleaseFast -Dcpu=apple_m1)zig fmt --check build.zig zig: PASSpython3 tools/zig/lean_check.py: 0 new findings (all modified files <= 600 lines)test-inkling2-host,test-inkling2-metal-host,test-inkling2-controls-host,test-metal-launch-map-host: ALL PASS./zig-out/bin/tf-kernel-contract --only inkling2: 63/63 PASS gates 1-4, 0 fail, 62/62 controls red as planted, 0 limit problemsthinkingmachines/Inkling-2-Mini@ed40e7da625f594fc9c4990f5f66be24873c22d7(unmodified BF16 + NVFP4 + MXFP8): 100% bit-exact output parity (sha=b5017c21c071).