Skip to content

inkling2 metal: exact FP8 LUT/UE8M0 decode and parallel wide grouping - #4683

Open
gilby wants to merge 40 commits into
ashhart:mainfrom
gilby:inkling2-lead-moe-group-active-bm64
Open

gilby wants to merge 40 commits into
ashhart:mainfrom
gilby:inkling2-lead-moe-group-active-bm64

Conversation

@gilby

@gilby gilby commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Rebases the 0-ULP FP8 E4M3 LUT/shiftless UE8M0 decode and parallel 8-simdgroup wide grouping (tf_ink2_group_wide) onto #4618 while keeping #4618's exact BM=16, BN=32 ink2_units kernel untouched.

What this changes

Replaces scalar/per-element FP8 E4M3 and UE8M0 weight decoding in MXFP8 expert and unit paths with a 256-entry ink2_e4m3_lut and shiftless ink2_e4m3_bits/ink2_mx_edge_bf/ink2_mx_bf helpers (verified exhaustively across all 65,536 (e4m3, ue8m0) pairs on both host and GPU), and adds the 256-thread / 8 KiB shared-memory parallel tf_ink2_group_wide kernel for rows * topk > 256 while preserving #4618's exact BM=16, BN=32 ink2_units reduction order and tf_ink2_logits_units.

Checks on this head

  • Head commit: df4cf37616b035a4b0c77216b74b31651e204095
  • Lean checker, python3 tools/zig/lean_check.py: 7495 files, 167 problems (0 new vs base ad3d31f9ff); tools/pr_check.py --pr 4683 --base ad3d31f9ff: 0 error(s), 1 warning(s) (changelog reminder).
  • Tests run:
    • Host CPU checks (-Dcpu=apple_m1): zig fmt --check build.zig zig exit 0; git diff --check ad3d31f9ff..HEAD exit 0; test-inkling2-controls-host 15/15 pass; test-inkling2-host 44 pass, 4 skip; test-inkling2-metal-host (CPU) 76 pass, 5 skip (including exhaustive 256-entry LUT & 65,536 (w, scale) host parity); test-metal-launch-map-host 8/8 pass (1211 registered launches, 2 controls, 0 missing); test-inkling2-metal-capabilities 1/1 pass; inkling2_experts_metal_records.zig 7/7 pass.
    • Real-checkpoint test-inkling2-metal-host (TF_INKLING2_METAL_DIR set to Inkling-2-Mini-ed40e7da, ReleaseFast -Dcpu=apple_m1): 80 passed; 3 skipped; 0 failed across Apple M5 Ultra, Apple M5 Pro, and Apple M3 Ultra (3 skips are DSpark-gated tests when TF_INKLING2_DSPARK_DIR is unset).
  • CI: Local host, M5 Max contract (48/48 + 48 red), and full M5 Ultra, M5 Pro, and M3 Ultra contract/real-ckpt/serving/cache runs all passed.
  • Not run, and why: Non-Apple backends; all 4 Apple Silicon hardware tiers (M5 Max, M5 Ultra, M5 Pro, M3 Ultra) ran on real hardware.

Receipt

  • Base against branch (Apple M5 Ultra / M5 Pro / M3 Ultra, Inkling-2-Mini-ed40e7da, plain --no-drafts vs #4618 ad3d31f9ff):
    • Apple M5 Ultra (bench_concurrent.py --levels 1,4,16 --temperatures 0,1.0 --tokens 128 --reps 2 --alone):
      • chat T=0.0: c=1 57.6 vs 57.6, c=4 199.2 (st=209.1) vs 196.8 (st=203.1), c=16 460.1 (st=553.7) vs 452.7 (st=552.8) tok/s (sha=32ddb869bec4 exact match, alone_unequal=0)
      • code T=0.0: c=1 58.8 vs 53.6 (+9.7%), c=4 207.2 (st=215.9, +4.1%) vs 199.1, c=16 501.2 (st=575.4, +2.0%) vs 491.2 tok/s (sha=4490e6bbcfbd exact match, alone_unequal=0)
      • chat T=1.0: c=1 35.5 vs 34.7, c=4 60.1 (st=60.5) vs 59.4, c=16 72.4 (st=73.3) vs 71.9; code T=1.0: c=1 35.1 vs 34.4, c=4 58.7 (st=59.8) vs 57.8, c=16 69.8 (st=71.4) vs 69.4 (exact sha set match)
      • bench_cache.py --tokens 64 --repeats 2 --streams 4 --require-cold (pt=8704): qualified=True, cold ttft_s=8.2865s (rep_min=8.2509s) vs 8.7536s ref (-5.3%), dec=47.4 (rep_max=51.0) vs 48.5 tok/s (sha=95e612cfdcaf exact match)
    • Apple M5 Pro 20-core (bench_concurrent.py --levels 1,4 --temperatures 0,1.0 --tokens 128 --reps 2 --alone):
      • code T=0.0: c=1 33.1 vs 31.8 (+4.1%), c=4 117.4 (st=124.4, +6.1%) vs 110.7 (sha=4490e6bbcfbd exact match, alone_unequal=0)
      • chat T=0.0: c=1 32.9 vs 31.5 (+4.4%), c=4 107.9 (st=120.0, +5.2%) vs 102.6 (sha=32ddb869bec4 exact match, alone_unequal=0)
      • code T=1.0: c=1 24.0 vs 22.5, c=4 40.6 (st=41.7) vs 39.1; chat T=1.0: c=1 24.2 vs 23.1, c=4 42.0 (st=43.5) vs 40.2 (exact sha set match)
      • bench_cache.py --tokens 32 --repeats 2 --streams 2 --require-cold (pt=2571): qualified=True, cold ttft_s=12.6444s (rep_min=12.5966s) vs 12.6426s ref, dec=29.9 (rep_max=30.1) vs 29.6 tok/s (sha=1fbe89b22692 exact match)
    • Apple M3 Ultra (Metal 3, bench_concurrent.py --levels 1,4 --temperatures 0,1.0 --tokens 128 --reps 2 --alone):
      • chat T=0.0: c=1 45.7 vs 45.3, c=4 107.3 (st=115.5, +6.3% agg) vs 100.9 (sha=34819971792d exact match, alone_unequal=0)
      • code T=0.0: c=1 46.1 vs 45.4, c=4 112.2 (st=118.0, +5.2% agg) vs 106.7 (sha=4490e6bbcfbd exact match, alone_unequal=0)
      • chat T=1.0: c=1 28.3 vs 28.4, c=4 43.5 (st=44.5) vs 43.5; code T=1.0: c=1 27.9 vs 28.3, c=4 43.2 (st=44.0) vs 43.9 (exact sha set match)
      • bench_cache.py --tokens 32 --repeats 2 --streams 2 --require-cold (pt=2571): qualified=True, cold ttft_s=8.2639s (rep_min=8.2460s) vs 8.7351s ref (-5.4%), dec=37.7 (rep_max=37.7) vs 37.6 tok/s (sha=1fbe89b22692 exact match)
  • Boxes it reaches: Apple Silicon Metal (M5 Max, M5 Ultra, M5 Pro, and M3 Ultra all verified).
  • New switch? None (tf_ink2_group_wide selected automatically for rows * topk > 256).
  • Environment: Commit df4cf37616 on ad3d31f9ff, Zig 0.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), checkpoint Inkling-2-Mini-ed40e7da.
  • Paths and platforms the change reaches: Inkling 2 Mini MXFP8 weight decode (experts.metal, experts_units.metal) and expert grouping (tf_ink2_group, tf_ink2_group_wide) across all 4 Apple Silicon hardware tiers.
  • Exactness: alone_unequal=0; 100% T=0.0, T=1.0, and cache token_sha parity against #4618 across M5 Ultra, M5 Pro, and M3 Ultra, plus GPU 65,536-pair MXFP8 check and tf_ink2_group vs tf_ink2_group_wide bit-identity check.
  • Licence of any new weights or drafter: n/a.
Kernel contract, only when a GPU kernel is new or changed
  • Kernels registered with the contract, and replacements:
    • Updated tf_ink2_group (32 threads, 0 B TG) and added tf_ink2_group_wide (256 threads, 8192 B TG, parallel wide grouping).
    • Updated MXFP8 decode helpers across experts.metal and ink2_mx_quad in experts_units.metal (keeping ink2_units BM=16, BN=32 and tf_ink2_logits_units unchanged).
  • Planted controls and status: Existing expert and unit controls (.mx_gu_scale/.mx_down_scale adapted for shiftless ink2_mx_quad) plus new .group_pair_order and .group_wide_pair_order controls all fail red as planted on M5 Max, M5 Ultra, M5 Pro, and M3 Ultra.
  • Backend SUMMARY lines and exit status:
    • M5 Max (applegpu_g17): SUMMARY 48 kernels: 48 pass gates 1-4, 0 fail, 0 known findings; 48 controls: 48 red as planted, 0 missed; 0 limit problems; gates 7073 ms, limits 13 ms (exit 0).
    • M5 Ultra (applegpu_g17): SUMMARY 48 kernels: 48 pass gates 1-4, 0 fail, 0 known findings; 48 controls: 48 red as planted, 0 missed; 0 limit problems; gates 5731 ms, limits 388 ms (exit 0).
    • M5 Pro (applegpu_g17): SUMMARY 48 kernels: 48 pass gates 1-4, 0 fail, 0 known findings; 48 controls: 48 red as planted, 0 missed; 0 limit problems; gates 5680 ms, limits 7 ms (exit 0).
    • M3 Ultra (applegpu_g15): SUMMARY 43 kernels: 43 pass gates 1-4, 0 fail, 0 known findings; 43 controls: 43 red as planted, 0 missed; 0 limit problems; gates 6036 ms, limits 356 ms (exit 0).
  • Chips not yet run: None (all 4 Apple Silicon hardware tiers completed).

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.
  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.
  • No precision traded for speed. If the bits change, the description says which sums change and why.
  • Decode and prompt processing are no slower than main at one stream and the widest admitted; with --drafter, no slower than without it, greedy and sampled.

ashhart and others added 30 commits November 21, 2026 16:05
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.
@gilby
gilby force-pushed the inkling2-lead-moe-group-active-bm64 branch from a9df5b8 to df4cf37 Compare November 23, 2026 06:03
@gilby gilby changed the title Inkling 2 Mini on Metal: 32x32 MoE tensor-unit tiles, parallel wide pair grouping, and exact FP8 LUT / shiftless UE8M0 decode inkling2 metal: exact FP8 LUT/UE8M0 decode and parallel wide grouping Nov 23, 2026
@ashhart
ashhart force-pushed the lead/inkling2-mini branch 3 times, most recently from aefb063 to c41911e Compare November 24, 2026 09:43
@ashhart
ashhart deleted the branch ashhart:lead/inkling2-mini November 24, 2026 09:43
@ashhart ashhart closed this Nov 24, 2026
@ashhart ashhart reopened this Nov 24, 2026
@ashhart
ashhart changed the base branch from lead/inkling2-mini to main November 24, 2026 09:48
@ashhart

ashhart commented Nov 24, 2026

Copy link
Copy Markdown
Owner

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 main. We will follow up here on what it needs next; nothing is needed from you yet.

  • Synthena

This branch has not been deployed

No deployments
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.

3 participants