Repository navigation
Conversation
ad4b96c to
277865b
Compare
|
I checked the stack on main I tested a narrower restack in scratch. I merged #4415 into main first, then used Once #4415 lands, replaying the ANE delta onto that parent looks like a clean route. The scratch check covered host policy and the stack shape. Live ANE and device gates would still need receipts on the resulting head. Igor Lessio - AIFLOW LABS |
The net change of ashhart#3859 at c07419f over its merge base 6858510, carried as one commit because four of the branch's merge commits hold changes of their own.
Main 881e224 added the prompt-tail slices retained by the rebase. Move the unchanged round fingerprint into its own module so the combined runner remains below 600 lines.
…dd_ane_bf16 contract
277865b to
9be67b2
Compare
|
Thanks @gilby for the careful Neural Engine work and for keeping it off by default. We can't take the ANE slices, because TensorFold takes no lossy weight formats and no mode that can change output tokens, even opt-in. With This does not affect your GPU work. The SenseNova-Loop BF16, AWQ, MLX-affine and native MTP changes stay in #4415, and review can continue there.
|
|
Thanks @gilby for keeping the Neural Engine share off by default. That default and the chip gates are confirmed, but the precision objection remains: INT8 mode creates new row scales and codes, while the FP16 path and fallback add weight and FFN rounding. Neither target mode can land as is, even opt-in. The qualification flag is logged rather than enforced. There is also a cleanup issue in the new contract collector: if the kernel-list append fails after the owning append, the probe is freed but its pointer remains owned. Please make that transfer transactional. The separate GPU work can continue through its own review.
|
|
@gilby, about the probe-registration cleanup our review asked for: the same two-append pattern was on main in 85 places, and #5058 (now merged) fixes it there with one helper, errdefer p.deinit(); // with errdefer s.a.destroy(p) after create, as the suite's teardown frees it
try ct.register(s.a, &s.probes, &s.kernels, p, p.kernel());Using it for this PR's new suites closes that item.
|
What this changes
Adds strictly opt-in Neural Engine + GPU hybrid prefill FFN slices (
TF_ANE_COLUMNS,default_columns = 0everywhere) and strictly opt-inTF_ANE_INT8=1W8A8 MILconstexpr_blockwise_shift_scalecompilation (falsedefault everywhere viaane_policy.int8andane_policy.int8For, including looped checkpoints) for SenseNova-Loop AWQg128(ane_awq.zig) and MLX-affineg64(ane_affine.zig, 4-bit register unpacking restricted top.bits == 4). Opt-in ANE (TF_ANE_COLUMNS=0,TF_ANE_INT8=falsedefaults everywhere) targets SenseNova-Loop on Apple M3-M5 (AWQ g128andMLX-affine g64viarequestedOnGeneration(columns, generation)>= 15) plus denseqwen27checkpoints on Apple M5 tensor-unit Macs (requestedOnChip(columns, tensorUnits())). Registersq27 ane awq q27_add_ane_bf16and its planted controls with the Metal kernel contract (zig/src/core/contract/q27_ane_records.zigandzig/tests/contract/metal_q27_ane.zig). Default inference behavior with unsetTF_ANE_COLUMNS/TF_ANE_INT8is unchanged.552de160c4), addingad4b96c0817206e461b2860042f5ffad4c9e4cda(21changed files).atc overlap --json: Timed out after 10s (TIMEOUT 10s);21changed files are scoped toqwen27ANE builders/policy/residency,zig/src/metal/ane.zig,platform/environment*.zig,core/contract/*,tests/contract/*,docs/environment.md, andCHANGELOG.md.Checks on this head
ad4b96c0817206e461b2860042f5ffad4c9e4cdapython3 tools/zig/lean_check.py, on the base and on this head:552de160c4(7388files,167problems) ->ad4b96c081(7392files,167problems),0 new(tools/zig/lean_new.pyandtools/pr_check.py --base 552de160c4:0 error(s), 1 warning(s)).zig fmt --checkandgit diff --check 552de160c4..HEAD: passed.zig build -j6 dev-tools native tf-kernel-contract -Dcpu=apple_m1: exited0.test-golden324/337+69/69,test-metal-launch-map-host1164 registered launches, 2 controls, 0 missing,test-kernel-contract,test-qwen27,test-qwen27-ane-policy-host,test-environment-host): exited0.test-metal-residency-owners-host(includingresidency_qwen27_tests.zigandresidency_qwen27_share_tests.zig):76/78passed (only the2pre-existing base1b394565ccGLMe.dflashcrashes).macOS 26.6.2,applegpu_g15,tensor_units=false):tf-kernel-contract --only "q27 ane"(exit0):SUMMARY 2 kernels: 2 pass gates 1-4, 0 fail, 0 known findings; 2 controls: 2 red as planted, 0 missed; 0 limit problems; gates 18 ms, limits 12 ms.tf-kernel-contract --only q27(exit0):SUMMARY 26 kernels: 26 pass gates 1-4, 0 fail, 0 known findings; 2 controls: 2 red as planted, 0 missed; 0 limit problems; gates 21786 ms, limits 5449 ms.applegpu_g17,tensor_units=true):tf-kernel-contract --only "q27 ane"(exit0):SUMMARY 2 kernels: 2 pass gates 1-4, 0 fail, 0 known findings; 2 controls: 2 red as planted, 0 missed; 0 limit problems; gates 17 ms, limits 421 ms.tf-kernel-contract --only q27(exit0):SUMMARY 26 kernels: 26 pass gates 1-4, 0 fail, 0 known findings; 2 controls: 2 red as planted, 0 missed; 0 limit problems; gates 19131 ms, limits 5018 ms.tf-kernel-contract --only sensenova(exit0):SUMMARY 24 kernels: 24 pass gates 1-4, 0 fail, 0 known findings; 45 controls: 45 red as planted, 0 missed; 0 limit problems; gates 21568 ms, limits 2160 ms.tf-kernel-contractstops at pre-existingUnrecordedRotaryCompiler(rotary probes) and--no-gatesstops at pre-existing base1b394565ccglmUnknownLaunch, unrelated to this PR (test-metal-launch-map-host1164launches,0missing).Apple M3 Ultra(macOS 26.6.2),Apple M5 Pro(64 GiB,macOS 27.2.1), andApple M5 Ultra(512 GiB): see Receipt below.ad4b96c081.rotary probes/ baseglmuncappedtf-kernel-contractitems noted above; non-Apple backends untouched.Receipt
macOS 26.6.2,applegpu_g15,tensor_units=false),SenseNova-Loop-9B-AWQ-g128(#4415vsthis PRdefault-off vsthis PRopt-inTF_ANE_COLUMNS=4096 TF_ANE_INT8=1):requested_columns=0 loaded_columns=0 program_weight_bytes=0 loaded=false exact_output_qualified=false.info: qwen27: ANE AWQ share built layers=32 columns=4096 rem=8192 mode=int8,loaded_columns=4096 program_weight_bytes=3221225472 loaded=true exact_output_qualified=false.#4415 == this PR default-off:100%exacttoken_sha&output_sha256parity across20/20bench_openai.pyruns and all5/5bench_cache.py --require-coldrows (token_sha=eaa68149fc60, first TTFT3.418s -> 3.421s, repeat[3.380, 3.454]s -> [3.374, 3.377]s).this PRopt-in ANE INT8 (TF_ANE_COLUMNS=4096 TF_ANE_INT8=1) vsthis PRdefault-off (bench_concurrent.py --levels 1,4 --temperatures 0 --tokens 128 --reps 2 --alone --serial): exacttoken_shaparity (code=339b36c97870,chat=e8723704c2fc),alone2/2(c=1) &8/8(c=4)0unequal/failed,serial1/1,plain_drafted=0;chat c=4TTFT median1.050s -> 0.920s(-12.4%), makespan4.711s -> 4.590s, agg decode130.1 -> 131.4 tok/s;code c=4TTFT median0.352s -> 0.334s, agg160.0 -> 162.3 tok/s.Qwen3.8-27B-MLX-4bit(#4415vsthis PRdefault-off vsthis PRTF_ANE_COLUMNS=4096 TF_ANE_INT8=1):requestedOnChip(4096, tensorUnits()=false)->loaded=false) with100%exacttoken_sha&output_sha256parity across20/20bench_openai.pyruns,5/5bench_cache.py --require-coldrows (token_sha=2bef4621bf99, TTFT6.198s / 6.189s), andbench_concurrent.py(code=f5c9409cfe40c=4 175.5/175.6 tok/s,chat=b69b0269917fc=4 147.8/147.7 tok/s,0unequal/failed).64 GiB,macOS 27.2.1),SenseNova-Loop-9B-MLX-Q4-hq(#4415vsthis PRdefault-off vsthis PRopt-inTF_ANE_COLUMNS=6144 TF_ANE_INT8=1):TF_ANE_COLUMNS&TF_ANE_INT8unset):requested_columns=0 loaded_columns=0 program_weight_bytes=0 loaded=false exact_output_qualified=false(verified on bothSenseNova-Loop-9B-MLX-Q4-hqandQwen3.8-27B-MLX-4bit).#4415 == this PR default-offonSenseNova-Loop-9B-MLX-Q4-hq:100%exacttoken_sha&output_sha256match across all20/20bench_openai.pyruns and all5/5bench_cache.py --require-coldrows (token_sha=eaa68149fc60, cold TTFT4.774svs4.846s, rep4.609s / 4.648svs4.717s / 4.677s), zero regression.TF_ANE_COLUMNS=6144 TF_ANE_INT8=1):info: qwen27: ANE affine share built layers=32 columns=6144 rem=6144 mode=int8,loaded_columns=6144 program_weight_bytes=4831838208 loaded=true exact_output_qualified=false.this PRopt-in ANE INT8 vs default-off (bench_concurrent.py --levels 1,4 --temperatures 0 --tokens 128 --reps 2 --alone --serial): exacttoken_shamatch (code=b5eabd2f8348,chat=ce0afb1a0d65),0failed/unequal (alone2/2&8/8,serial1/1):code c=1 43.4/c=4 agg 133.2 tok/s,chat c=1 32.2/c=4 agg 104.9 tok/s.64 GiB),Qwen3.8-27B-MLX-4bit:bench_cachequalified=True(sha=6a2395ffd378,5.193s),bench_openai17.44 tok/s,bench_concurrentc=4 agg 62.3 / 62.6 tok/s(0unequal).TF_ANE_COLUMNS=4096for 27B on a64 GiBMac (25.9 GiBkept wired leaving1564 MiBunder the 70% cap) cleanly refuses loading via the admission guard (prompts run on the GPU alone,loaded=false).512 GiB),Qwen3.8-27B-MLX-4bit(TF_ANE_COLUMNS&TF_ANE_INT8unset vs opt-inTF_ANE_COLUMNS=4096 TF_ANE_INT8=1):requested_columns=0 loaded_columns=0 loaded=false exact_output_qualified=false([tensorfold] profile: stable; registered overrides: none);bench_cache.py --require-cold(2,571prompt tokens,qualified=True,sha=6a2395ffd378, rep TTFT1.356s / 1.362s, decode47.2 / 45.1 tok/s),bench_openai.py(fib T=0 46.21 tok/ssha=a10c9b848ed9,chat T=0 47.19 tok/ssha=a06fab348fbe).TF_ANE_COLUMNS=4096 TF_ANE_INT8=1on non-looped 27B dispatches the existing FP16 ANE path (loaded=true,program_weight_bytes=8053063680,bench_concurrent c=4 agg 162.0 / 162.7 tok/s,alone2/2&8/80unequal); M5 Ultra tensor units outrun ANE on the2,571-token prompt (2.04svs1.36sGPU), confirming why strict opt-in (TF_ANE_COLUMNS=0,TF_ANE_INT8=false) avoids regressing M5 Ultra while delivering M5 Pro (1.19x-1.30x) and M3 Ultra (-14.1%/-17.1%)SenseNova-Loopopt-in INT8 speedups.AWQ g128andMLX-affine g64viarequestedOnGeneration(columns, generation)>= 15) plus denseqwen27checkpoints on Apple M5 tensor-unit Macs (requestedOnChip(columns, tensorUnits())), strictly opt-in (TF_ANE_COLUMNS=0,TF_ANE_INT8=falsedefaults everywhere).TF_ANE_INT8: flag (0or1,false/"0"/ unset by default everywhere including looped checkpoints;1or"true"enables W8A8 INT8 ANE weight slices whenTF_ANE_COLUMNS > 0).TF_ANE_COLUMNSkeepsdefault_columns = 0everywhere.ad4b96c0817206e461b2860042f5ffad4c9e4cda, Zig0.17.0, Apple M3 Ultra (macOS 26.6.2,applegpu_g15,tensor_units=false), Apple M5 Pro (64 GiB,macOS 27.2.1), Apple M5 Ultra (512 GiB), and Apple M5 Max (applegpu_g17,tensor_units=truekernel contract),SenseNova-Loop-9B-AWQ-g128,SenseNova-Loop-9B-MLX-Q4-hq, &Qwen3.8-27B-MLX-4bit.qwen27opt-in ANE prefill path, ANE policy/residency accounting,metal/ane.zigMIL/INT8 compilation, andq27_add_ane_bf16contract (macOS build/host checks, M3 Ultra GPUtf-kernel-contract& serving, M5 Max GPUtf-kernel-contract, M5 Pro serving & admission-guard, and M5 Ultra 27B default-off/opt-in verification completed; non-Apple backends untouched).tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false:SenseNova-Loop-9B-AWQ-g128:#4415 == this PR default-off100%exact across20/20bench_openai.pyruns &5/5bench_cache.py --require-coldrows (token_sha=eaa68149fc60);this PRopt-in ANE INT8 (TF_ANE_COLUMNS=4096 TF_ANE_INT8=1) matchestoken_sha=eaa68149fc60onbench_cache.py, greedybench_openai.py(fib=2f1d93533424,chat=6545de7bd9dc), and greedybench_concurrent.py(code=339b36c97870,chat=e8723704c2fc,0unequal/failed;T=1.01/5fib and3/5chat seeds differ as expected underexact_output_qualified=false).Qwen3.8-27B-MLX-4bit:100%exacttoken_sha&output_sha256parity across20/20bench_openai.py,5/5bench_cache.py --require-cold(2bef4621bf99), andbench_concurrent.py(0unequal/failed).SenseNova-Loop-9B-MLX-Q4-hq:#4415 == this PR default-off100%exact across20/20bench_openai.pyand5/5bench_cache.py(token_sha=eaa68149fc60);this PRopt-in ANE INT8 (TF_ANE_COLUMNS=6144 TF_ANE_INT8=1) matchestoken_sha=eaa68149fc60across all5/5bench_cache.pyrows, greedybench_openai.py(fib=21e104d752ff,chat=6d8124a912ce), and greedybench_concurrent.py(code=b5eabd2f8348,chat=ce0afb1a0d65,0unequal/failed;T=1.0fib 4/5andchat 3/5match GPU underexact_output_qualified=false).Qwen3.8-27B-MLX-4bit:bench_cache(sha=6a2395ffd378),bench_concurrent(0unequal).Qwen3.8-27B-MLX-4bit: default-offbench_cache(sha=6a2395ffd378),bench_openai(fib=a10c9b848ed9,chat=a06fab348fbe); opt-inTF_ANE_COLUMNS=4096bench_concurrentalone2/2&8/8(0unequal).tools/bench_openai.py:SenseNova-Loop-9B-AWQ-g128,this PRdefault-off -> opt-inTF_ANE_COLUMNS=4096 TF_ANE_INT8=1):T=0.0:fibTTFT0.1500s -> 0.1397s(prefill93.33 -> 100.20 tok/s, exacttoken_sha=2f1d93533424);chatTTFT0.3280s -> 0.2907s(-11.4%, exacttoken_sha=6545de7bd9dc).T=1.0:chatTTFT0.3294s -> 0.2811s(-14.7%).bench_concurrent.py(T=0,c=4):chatagg decode130.1 -> 131.4 tok/s,codeagg decode160.0 -> 162.3 tok/s.SenseNova-Loop-9B-MLX-Q4-hq,this PRdefault-off -> opt-inTF_ANE_COLUMNS=6144 TF_ANE_INT8=1):T=0.0:fib38.09 -> 40.01 tok/s(sha=21e104d752ff),chat31.54 -> 32.68 tok/s(sha=6d8124a912ce).Qwen3.8-27B-MLX-4bit, default-off):fib T=0 46.21 tok/s(sha=a10c9b848ed9),chat T=0 47.19 tok/s(sha=a06fab348fbe);bench_cachedecode47.2 / 45.1 tok/s.ttft_sfromtools/bench_cache.py --require-coldon a long prompt, or "n/a" with the reason when the change cannot reach prompt processing:SenseNova-Loop-9B-AWQ-g128,2,571prompt tokens,qualified=true, exacttoken_sha=eaa68149fc60):#4415 -> this PR default-off: first TTFT3.418s -> 3.421s, repeat[3.380, 3.454]s -> [3.374, 3.377]s(parity).this PR default-off -> this PR opt-in(TF_ANE_COLUMNS=4096 TF_ANE_INT8=1): cold first TTFT3.421s -> 2.938s(-14.1%), repeat TTFTs[3.374, 3.377]s -> [2.806, 2.793]s(-17.1%), concurrent makespan8.389s -> 7.179s(-14.4%),end_to_end_tps15.259 -> 17.831(+16.9%).Qwen3.8-27B-MLX-4bit): cold TTFT6.198s / 6.189s(token_sha=2bef4621bf99, unchanged).SenseNova-Loop-9B-MLX-Q4-hq,2,571prompt tokens,qualified=True, exacttoken_sha=eaa68149fc60across all5rows):#4415 -> this PR default-off: cold TTFT4.846s -> 4.774s, repeat[4.717, 4.677]s -> [4.609, 4.648]s.this PR default-off -> this PR opt-in(TF_ANE_COLUMNS=6144 TF_ANE_INT8=1): cold first TTFT4.774s -> 4.026s(1.19xfaster), repeat TTFTs4.609s -> 3.567s(1.29xfaster) and4.648s -> 3.569s(1.30xfaster), concurrentstreams=2makespan10.819s -> 8.462s(1.28xfaster,11.83 -> 15.13e2e tok/s).Qwen3.8-27B-MLX-4bitdefault-off): cold TTFT5.193s(token_sha=6a2395ffd378).Qwen3.8-27B-MLX-4bit,2,571prompt tokens,qualified=True): default-off rep TTFT1.356s / 1.362s(sha=6a2395ffd378) vs opt-inTF_ANE_COLUMNS=40962.04s.sensenova/SenseNova-Loop-9Bweights; no new drafter).Kernel contract, only when a GPU kernel is new or changed
q27 ane awq q27_add_ane_bf16(zig/src/core/contract/q27_ane_records.zig, probesmetal q27 ane awq add ane onlyandmetal q27 ane awq add gpu+aneinzig/tests/contract/metal_q27_ane.zig, both passnonfinite,repeat, andshapeson Apple M3 Ultra and Apple M5 Max); new residual-add kernel for ANE FP16 plane output + optional BF16 GPU remainder.control: q27 ane awq add nonfinite(Q27_ANE_CTL=1,red at nonfinite, as planted) andcontrol: q27 ane awq add row shift(Q27_ANE_CTL=2,red at shapes, as planted).SUMMARYline and exit status:test-metal-launch-map-host):1164 registered launches, 2 controls, 0 missing, exited0.applegpu_g15,tf-kernel-contract --only "q27 ane", exit0):SUMMARY 2 kernels: 2 pass gates 1-4, 0 fail, 0 known findings; 2 controls: 2 red as planted, 0 missed; 0 limit problems; gates 18 ms, limits 12 ms(Gate 5:PASS limits here q27 ane awq q27_add_ane_bf16: 256 threads launched, the pipeline takes 1024; 0 threadgroup bytes and 0 set (declared at most 0, the GPU's most 32768)).applegpu_g15,tf-kernel-contract --only q27, exit0):SUMMARY 26 kernels: 26 pass gates 1-4, 0 fail, 0 known findings; 2 controls: 2 red as planted, 0 missed; 0 limit problems; gates 21786 ms, limits 5449 ms.applegpu_g17,tensor_units=true,tf-kernel-contract --only "q27 ane", exit0):SUMMARY 2 kernels: 2 pass gates 1-4, 0 fail, 0 known findings; 2 controls: 2 red as planted, 0 missed; 0 limit problems; gates 17 ms, limits 421 ms(q27_add_ane_bf16Gate 5256threads,0tg_memory,0limit problems).applegpu_g17,tf-kernel-contract --only q27, exit0):SUMMARY 26 kernels: 26 pass gates 1-4, 0 fail, 0 known findings; 2 controls: 2 red as planted, 0 missed; 0 limit problems; gates 19131 ms, limits 5018 ms.applegpu_g17,tf-kernel-contract --only sensenova, exit0):SUMMARY 24 kernels: 24 pass gates 1-4, 0 fail, 0 known findings; 45 controls: 45 red as planted, 0 missed; 0 limit problems; gates 21568 ms, limits 2160 ms.applegpu_g15) and Apple M5 Max (applegpu_g17) both ran and passed.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