Repository navigation
Conversation
Derive per-visit cache access and exact arithmetic for the 48 visits so CUDA admission and kernels have a reference before serving is enabled.
Decode stored NVFP4 and MXFP8 expert weights to BF16 and launch them beside the grouped expert/vision kernels, with exact tensor baselines and planted faults.
Launch cross-pass messages, rank-64 gates, residual steps and split QKV with FP32 reductions, BF16 rounding controls and per-launch resource records.
Run all 48 visits with per-visit cache state, prompt snapshots and exact rollback. Refuse TP, vision and DSpark loading until those engines exist.
… rows where prep wrote them
…in the fewest 1,024-key folds a slot
…up to 32 rows is one launch
…y for up to 16 rows
50bcdea to
c741dcd
Compare
…2D bank_and_reset, and 32-row logits_all cap - conv_dynamic: dispatch 32 threads with bfloat4 sequential dot and simd_shuffle (0 B TG) - router: fuse route_scores and router into one 256-thread launch with 512 B TG and ascending tie-broken IDs - loop_messages: hoist per-row bank RMS into tf_inkling2_loop_rms and cache bank values per entry (80 B TG) - bankAndReset: replace per-row copyBf16 loops and prelude restore with 2D bfloat4 launch tf_ink2_bank_and_reset - state/forward: cap logits_all scratch allocation at batch_rows (32) and guard options.all rows <= batch_rows Refs ashhart#4652
c741dcd to
d42b52c
Compare
3e0e9bc to
f790014
Compare
|
Note on interaction with
|
…r at rows > 32 Refs ashhart#4652
|
Updated in
|
|
Thanks @gilby. The 256-thread
The branch conflicts with main now. We'll handle that rebase, so no need to do it.
|
|
Fixed in
Verified on |
aefb063 to
c41911e
Compare
|
Sorry for the noise: this was closed automatically when #4387 landed on main and its branch was removed. It is reopened and now targets
|
|
Thanks for your patience, @gilby. Since #4387 landed, this PR's own commits sit on top of an earlier Inkling Metal stack that has not landed on main, and that stack includes a change to the FP32 summation order we have kept out for exactness. Your commits do not apply to main's kernels without it, so we are holding this PR until that stack is decided, rather than carrying unreviewed work along with it. We will follow up here; nothing is needed from you now.
|
Rebases the 0-ULP prefill and scratch pieces onto #4618 (row-gated fused router, bfloat4 conv_dynamic, loop RMS hoist, 2D bank_and_reset, and 32-row logits_all cap) with zero standalone decode regression.
What this changes
Keeps 16-TG parallel
tf_inkling2_route_scores+ 32-thread zero-barriertf_inkling2_route_selectfor decode/verify (rows <= 32) while switchingrows > 32to the single 256-thread fusedtf_inkling2_routerkernel (512B TG, sharedink_select_top8), restores256-threadbfloat4vectorizedtf_inkling2_conv_dynamic(128B TG), hoists looped-attention bank RMS intotf_inkling2_loop_rms+ cached bank lanes intf_inkling2_loop_messages, vectorizesbankAndResetvia 2Dtf_ink2_bank_and_reset, records all loop (rms,messages,gates,zeta,blend) and glue (route_scores,route_select, plus the 9 main glue kernels) Metal launches ininkling2_loop_metal_records.zig/inkling2_glue_metal_records.zig+loop_plan.zig/glue_plan.zig/loop_test.zig/glue_test.zig, and capslogits_allatbatch_rows(32 rows, saving ~179 MiB scratch) while leavingprompt_attention.metalandprompt_rows = 256untouched.lead/inkling2-mini(ad3d31f9ff#4618), 3 commits:d42b52c884,3248767ddc,9d54e30c29atc overlap --json:overlapagainstorigin/lead/inkling2-minicovering#4592, #4593, #4594, #4596, #4683, #4685, #4699completed (workingTreeoverlaps those independent sibling Inkling 2 Metal PRs across sharedmetal/contract/testareas; all resolved independently onto#4618).Checks on this head
9d54e30c29(recordstf_inkling2_loop_rms,tf_inkling2_loop_zeta,tf_inkling2_loop_blend,tf_inkling2_route_scores, andtf_inkling2_route_selectin contract launch records and plan inventories)python3 tools/zig/lean_check.py:167 problems(0new vs basead3d31f9ff);tools/pr_check.py --pr 4594 --base ad3d31f9ff:0 error(s), 1 warning(s)(changelog reminder).9d54e30c29:zig fmt --checkexit0;git diff --checkexit0;test-inkling2-controls-host15/15pass;test-inkling2-host44 pass, 4 skip;test-inkling2-metal-host(CPU)76 pass, 5 skip(verifies all 5 loop and 11 glueLaunchrecords 1-to-1 againstkernel voidcounts and symbol/thread/tg_memory specs);test-metal-launch-map-host8/8pass (1215registered launches,2controls,0missing);compile-inkling2-native-host(macOS/Linux/Windows) pass;test-inkling2-metal-hostcompiles cleanly (0errors) forx86_64-linuxandx86_64-windows.9d54e30c29:./zig-out/bin/tf-kernel-contract --only "metal inkling2":47/47 pass gates 1-4, 47/47 controls red, 0 limit problems(gates 6323 ms, limits 12 ms)../zig-out/bin/tf-kernel-contract --no-gates --offline <dir> --only "metal inkling2 loop"and--only "metal inkling2 glue": all 5 loop launches (rms=256,messages=256,gates=256,zeta=256,blend=32) and all 11 glue launches (includingroute_scores=256,route_select=32) pass M1/M2 offline reservation compilation (0 limit problems).test-inkling2-metal-host(TF_INKLING2_METAL_DIRset toInkling-2-Mini-ed40e7da, ReleaseFast-Dcpu=apple_m1):80 passed; 3 skipped; 0 failedon Apple M5 Ultra on3248767ddc(and M5 Pro / M3 Ultra on parentd42b52c884; 3 skips are DSpark-gated tests whenTF_INKLING2_DSPARK_DIRis unset).47/47 + 47 red) + offline M1/M2 limits (0 limit problems) passed on9d54e30c29, and full M5 Ultra contract/real-ckpt/serving/cache runs passed on3248767ddc(only[[max_total_threads_per_threadgroup(32)]]attribute ontf_inkling2_loop_blendand host/contract launch inventory tests changed in9d54e30c29; M5 Pro and M3 Ultra baseline runs were captured atd42b52c884).Receipt
Inkling-2-Mini-ed40e7da, plain--no-draftsvs#4618ad3d31f9ff, measured at3248767ddcon M5 Ultra andd42b52c884on M5 Pro/M3 Ultra):3248767ddc,bench_concurrent.py --levels 1,4,16 --temperatures 0,1.0 --tokens 128 --reps 2 --alone):code T=0.0:c=157.3vs53.6(+6.9%),c=4198.0(st=207.7) vs199.1,c=16492.9(st=568.7) vs491.2tok/s (sha=4490e6bbcfbdexact match,alone_unequal=0)chat T=0.0:c=157.7vs57.6,c=4197.7(st=206.2) vs196.8,c=16445.6(st=544.5) vs452.7tok/s (sha=32ddb869bec4exact match,alone_unequal=0)code T=1.0:c=134.9vs34.4,c=458.3(st=59.4) vs57.8,c=1670.1(st=71.6) vs69.4;chat T=1.0:c=134.9vs34.7,c=459.7(st=60.2) vs59.4,c=1672.7(st=73.8) vs71.9(exact sha set match)bench_cache.py --tokens 64 --repeats 2 --streams 4 --require-cold(pt=8704):qualified=True, coldttft_s=8.7662s(rep_min=8.6760s) vs8.7536sref,dec=48.4(rep_max=48.4) vs48.5tok/s (sha=95e612cfdcafexact match)d42b52c884prior to3248767ddc,bench_concurrent.py --levels 1,4 --temperatures 0,1.0 --tokens 128 --reps 2 --alone):code T=0.0:c=131.2vs31.8,c=4110.6(st=117.9) vs110.7(st=118.0,sha=4490e6bbcfbdexact match,alone_unequal=0)chat T=0.0:c=130.5vs31.5,c=4101.8(st=113.9) vs102.6(st=114.6,sha=32ddb869bec4exact match,alone_unequal=0)code T=1.0:c=122.7vs22.5,c=438.4(st=39.4) vs39.1;chat T=1.0:c=122.9vs23.1,c=440.0(st=41.4) vs40.2(exact sha set match)bench_cache.py --tokens 32 --repeats 2 --streams 2 --require-cold(pt=2571):qualified=True, coldttft_s=12.4280s(rep_min=12.5297s) vs12.6426sref,dec=29.3(rep_max=28.6) vs29.6(sha=1fbe89b22692exact match)Metal 3, measured at parentd42b52c884prior to3248767ddc,bench_concurrent.py --levels 1,4 --temperatures 0,1.0 --tokens 128 --reps 2 --alone):code T=0.0:c=143.4vs45.4,c=4104.2(st=109.2) vs106.7(sha=4490e6bbcfbdexact match,alone_unequal=0)chat T=0.0:c=143.4vs45.3,c=499.8(st=106.4) vs100.9(sha=34819971792dexact match,alone_unequal=0)code T=1.0:c=127.1vs28.3,c=442.3(st=43.2) vs43.9;chat T=1.0:c=127.4vs28.4,c=442.1(st=43.0) vs43.5(exact sha set match)bench_cache.py --tokens 32 --repeats 2 --streams 2 --require-cold(pt=2571):qualified=True, coldttft_s=8.5404s(rep_min=8.5223s) vs8.7351sref (-0.195s),dec=36.1(rep_max=35.1) vs37.6(sha=1fbe89b22692exact match)router_fused_min_rows = 33selects 16-TGroute_scores+ 32-threadroute_selectforrows <= 32and fused 256-threadrouterforrows > 32;prompt_rows = 256andbatch_rows = 32unchanged).d42b52c884,3248767ddc, and9d54e30c29onad3d31f9ff, Zig0.17.0-Dcpu=apple_m1 -Doptimize=ReleaseFast, Apple M5 Max (applegpu_g17), Apple M5 Ultra (applegpu_g17), Apple M5 Pro (applegpu_g17), Apple M3 Ultra (applegpu_g15), checkpointInkling-2-Mini-ed40e7da.router,conv_dynamic,loop_messages,bank_and_reset,logits_allscratch sizing) across all 4 Apple Silicon hardware tiers.alone_unequal=0across allT=0.0andT=1.0cells; 100%T=0.0,T=1.0, and cachetoken_shaparity against#4618across M5 Ultra, M5 Pro, and M3 Ultra.Kernel contract, only when a GPU kernel is new or changed
tf_inkling2_router(rows <= 32runs256-threadtf_inkling2_route_scores+32-thread zero-barriertf_inkling2_route_selectwith512B TG;rows > 32runs fused256-threadtf_inkling2_routerwith512B TG; contract tested atrows = 1, 5, 64).tf_inkling2_conv_dynamic(256threads,128B TG,bfloat4Stage-1 dot).tf_inkling2_loop_messages(256threads,80B TG, replaces144B TG) paired withtf_inkling2_loop_rms(256threads,64B TG), plus fullLaunchlimit records forloop_gates(256threads,80B TG),loop_zeta(256threads,0B TG), andloop_blend(32threads,0B TG).tf_ink2_bank_and_reset(256threads,0B TG, replaces per-rowcopyBf16loop + prelude restore).tf_inkling2_conv_dynamic,tf_inkling2_router,tf_inkling2_loop_messages, and newtf_ink2_bank_and_resetcontrols all fail red as planted on M5 Max, M5 Ultra, M5 Pro, and M3 Ultra.SUMMARYlines and exit status:applegpu_g17,9d54e30c29):SUMMARY 47 kernels: 47 pass gates 1-4, 0 fail, 0 known findings; 47 controls: 47 red as planted, 0 missed; 0 limit problems; gates 6323 ms, limits 12 ms(exit0).applegpu_g17,3248767ddc):SUMMARY 47 kernels: 47 pass gates 1-4, 0 fail, 0 known findings; 47 controls: 47 red as planted, 0 missed; 0 limit problems; gates 5727 ms, limits 383 ms(exit0).applegpu_g17):SUMMARY 47 kernels: 47 pass gates 1-4, 0 fail, 0 known findings; 47 controls: 47 red as planted, 0 missed; 0 limit problems; gates 5654 ms, limits 381 ms(exit0).applegpu_g15):SUMMARY 42 kernels: 42 pass gates 1-4, 0 fail, 0 known findings; 42 controls: 42 red as planted, 0 missed; 0 limit problems; gates 6058 ms, limits 9 ms(exit0).Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.--drafter, no slower than without it, greedy and sampled.