Repository navigation
Conversation
|
On M5 Max I tested TF_INKLING2_METAL_DIR=/path/to/target TF_INKLING2_DSPARK_DIR=/path/to/drafter \
TF_INKLING2_DRAFT_HEAD_Q4=1 zig build test-inkling2-metal-host -Dfixed-cpu -j2 --summary allI filtered the Metal test artifact to This is a parity and activation check on M5 Max. I did not measure throughput or run older Apple GPUs. #5020 by itself also trial-merges cleanly after #4981 at Igor Lessio - AIFLOW LABS |
|
The current-main integration of Adding zig build test-inkling2-metal-host tf-kernel-contract -Dfixed-cpu -j2 --summary all
./zig-out/bin/tf-kernel-contract --only 'metal inkling2 dspark'This retest covers current-main integration and launch bounds. The checkpoint parity and activation receipt above is from the earlier base. Igor Lessio - AIFLOW LABS |
|
Thank you, @gilby. The Q4 copy stays on the draft side, and target verification keeps the original weights. Two fixes remain before landing. The new shader entry needs its declared 256-thread reservation to satisfy current main's assertion. Also, if the kernel-list append fails after the probe is stored, cleanup frees it while the owner list still holds it; make that ownership transfer safe on allocation failure. The earlier parity and activation results are recorded.
|
e19d1f7 to
688c39c
Compare
|
I trial-merged zig build test-inkling2-host test-inkling2-metal-host test-inkling2-launch-map-host \
compile-inkling2-native-host tf-kernel-contract -Dfixed-cpu -j2 --summary all
./zig-out/bin/tf-kernel-contract --only 'metal inkling2'The allocation rollback finding still reproduces on The loader correction also fixes the standalone main failure reported on #4699. If Q4 needs another revision, that correction can land on its own. Checkpoint timing was outside this run. Igor Lessio - AIFLOW LABS |
|
Thank you @gilby. The Q4 shader now has its declared thread reservation, and the loader correction is present. The copy remains draft-only, with the original target weights used for verification. The registration cleanup issue remains: if the kernel-list append fails after the owner append, local cleanup frees a probe still held by the suite. Please make the transfer atomic and cover that allocation failure. The earlier parity and activation results remain credited.
|
688c39c to
2b22da8
Compare
|
Rebased onto
|
|
@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.
|
|
Updated
Verification on
|
2b22da8 to
5803648
Compare
|
Thanks @gilby, this is close. The earlier asks are all closed, and with the switch off, nothing changes. The target always verifies against the BF16 unembed, so only draft proposals are affected. We found two overflow cases in the opt-in Q4 head:
Once both pass, we'll run the Mac device cells (default-off and opt-in, M3 and M5) ourselves.
|
|
Updated
Verification (Apple M5 Max 48 GiB)
|
|
Thank you for fixing both full-span BF16 overflow cases. The latest head merges cleanly with current main. The host now computes the quantization ratio in binary64, and the shader uses an explicit fused multiply-add. The new tests pin the 0/11/15 codes and the finite maximum case. The earlier thread reservation and shared probe-registration asks also remain closed. We found no new static correctness, ownership, fallback, or provenance blocker. The remaining step is the promised M3 and M5 device coverage. Both default-off and opt-in runs need the DSpark kernel contract and checkpoint activation checks. Serving must compare current main with this head across greedy and sampled code/chat at one and four streams, with exact target tokens, positive accepted drafts when enabled, rollback and warm-cache replay. The off case should also confirm that pipeline loading and serving remain unchanged. Thank you for the careful overflow reproductions and focused fixes.
|
Compute (v - b) / s in FP64 during host Q4 group quantization and evaluate s * q + b via fma(s, float(q), b) in tf_ink2_dspark_logits_q4 so full-span finite BF16 groups (b = -255 * 2^120, s = 34 * 2^120) do not overflow intermediate FP32 arithmetic.
Add a host unit test for BF16 {0xff7f, 0x7f7f, 0x7f00} and a Metal contract case exercising q = 15, 11, and 0 under the full-span metadata.
86fd596 to
3cdf72f
Compare
What this changes
Before: on
main, Inkling 2 Mini Metal's DSpark drafter reads the target's full BF16 unembedding weights (~893 MiB forlm_headacross ~202k vocab rows xhidden=2304) on every draft pass viatf_ink2_dspark_logits/tf_ink2_dspark_base, leaving smaller-bandwidth GPUs memory-traffic-bound during speculative drafting while target verification remains BF16.After: adds an opt-in draft-only 4-bit/group-64 affine copy (
TF_INKLING2_DRAFT_HEAD_Q4=1, default0/off) inzig/src/families/inkling2/metal/draft_head_q4.zigand kerneltf_ink2_dspark_logits_q4inzig/kernels/metal/inkling2/dspark.metal(with[[max_total_threads_per_threadgroup(256)]]). When enabled and spare GPU memory accommodates the ~247 MiB copy (layout(n, k)aligned to 256-byte words/scales/biases) viad.weights.enableDraftHeadQ4(leavingdspark.Drafter.initintact anddspark.zigat597lines), load-time quantization builds the Q4 copy without touching the BF16 target weights, and DSpark dispatchesdspark_kernels.baseOrQ4(logitsQ4withsoftcap=falseon DSpark base,softcap=trueoptional) while target verification continues on unmodified BF16 weights. Rebased cleanly ontoorigin/main(a992d0da99, resolving#5041):dspark_kernels.Kind.requiredThreads()anddspark_kernels_test.expectedWidth()retain#5041's width guards and live pipeline test with.logits_q4 => 256. Also adds transactional probe registrationcontrols.registerProbeinzig/tests/contract/metal_inkling2_dspark_controls.zig(reserving capacity in bothprobesandkernelsbefore appending viaappendAssumeCapacity, used bymetal_inkling2_draft_head_q4.zig:Suite.addandmetal_inkling2_dspark.zig:Suite.add) plus astd.testing.FailingAllocatorunit test verifying zero dangling probe / double-free / leak onOutOfMemory, registersTF_INKLING2_DRAFT_HEAD_Q4inzig/src/platform/environment.zig+docs/environment.md, and addsmetal_inkling2_draft_head_q4.zigkernel contract gates and controls.main(a992d0da99, including merged#5041;git merge-treecleanb3343afa8a3dd3e4f5da9926d4f5951447aaa497againstorigin/maina992d0da99)origin/main(a992d0da99),19changed files.Checks on this head
2b22da8c44python3 tools/pr_check.py --base origin/main --pr 5020(python3 tools/zig/lean_check.py):lean 164 vs 164, 0 new,0error(s) (19changed files, max touched.zigfile600lines inzig/src/platform/environment_test.zig;dspark.zigstays597lines,metal_inkling2_dspark.zigis596lines,dspark.metalis594lines);zig fmt --check build.zig zigandgit diff --check origin/main..HEADpass with exit0.2b22da8c44, with the command and pass, fail and skip counts:zig build -Dcpu=apple_m1 -Doptimize=ReleaseFast(exit0),zig build compile-native-cuda-windows(exit0),zig build compile-inkling2-native-host(exit0), andzig build compile-inkling2-native-host -Dtarget=x86_64-windows(exit0).zig build test-inkling2-host -Dcpu=apple_m1 -Doptimize=ReleaseFast --summary all:46 passed; 4 skipped; 0 failed(5/5steps; skipped: optional local checkpoint/tokenizer env tests).zig build test-inkling2-metal-host -Dcpu=apple_m1 -Doptimize=ReleaseFast --summary all(--seed=0x31108503):117 passed; 6 skipped; 0 failed(5/5steps, including the live DSpark pipeline threadgroup-width test).zig build test-inkling2-controls-host --summary all:25/25tests passed (5/5steps, including theFailingAllocatorregisterProberollback test);zig build test-environment-host test-inkling2-controls-host test-metal-launch-map-host --summary all:11/11steps succeeded,8/8launch map tests passed (1313launches,2controls,0missing),0failed.zig build test-kernel-contract --summary all:45/45steps succeeded;255/255tests passed.zig build tf-kernel-contract -Doptimize=ReleaseFast(exit0) and./zig-out/bin/tf-kernel-contract --only "metal inkling2"on Apple M5 Max (applegpu_g17,--seed 0x6b63):SUMMARY 62 kernels: 62 pass gates 1-4, 0 fail, 0 known findings; 68 controls: 68 red as planted, 0 missed; 0 limit problems; gates 12471 ms, limits 224 ms(exit0).2b22da8c44; CI checks pending after push.688c39cc53(unchanged kernel/runtime paths) cover default-off (TF_INKLING2_DRAFT_HEAD_Q4unset on Apple M5 Pro) and opt-inTF_INKLING2_DRAFT_HEAD_Q4=1self-drafted DSpark decode acrossc=1,4andT=0.0,1.0.Receipt
688c39cc53(tools/bench_concurrent.py --tokens 128 --reps 2,--drafter {TARGET} --parallel 4 --context 8192,0cross-legtoken_sha256mismatches across all cells on both machines):mainvs branch,19.09 -> 19.33 GiBweights /27170 -> 26923 MiBspare =+247 MiBopt-in):TF_INKLING2_DRAFT_HEAD_Q4unset,T=0.0):0.0%delta across all4/4cells (code c=1:13.80 -> 13.80,c=4:10.30 -> 10.30,chat c=1:11.55 -> 11.55,c=4:7.20 -> 7.20 tok/s).TF_INKLING2_DRAFT_HEAD_Q4=1,8/8cells win):c=1:code T=0.0:13.80 -> 15.10 tok/s(+9.42%, TTFT0.560s -> 0.552s,-1.34%);chat T=0.0:11.60 -> 13.90 tok/s(+19.83%, TTFT1.337s -> 1.280s,-4.26%);code T=1.0:10.80 -> 13.50 tok/s(+25.00%, TTFT0.560s -> 0.536s,-4.29%);chat T=1.0:11.05 -> 13.40 tok/s(+21.27%, TTFT1.373s -> 1.296s,-5.54%).c=4:code T=0.0:10.30 -> 11.00 tok/s(+6.80%, TTFT1.345s -> 1.280s,-4.83%);chat T=0.0:7.15 -> 8.00 tok/s(+11.89%, TTFT5.139s -> 4.928s,-4.12%);code T=1.0:8.45 -> 9.10 tok/s(+7.69%, TTFT1.360s -> 1.285s,-5.48%);chat T=1.0:7.10 -> 7.60 tok/s(+7.04%, TTFT5.285s -> 5.070s,-4.08%).mainvs branch,TF_INKLING2_DRAFT_HEAD_Q4=1,19.09 -> 19.33 GiBweights /371234 -> 370987 MiBspare =+247 MiBopt-in,7/8cells win):c=1:code T=0.0:26.00 -> 25.30 tok/s(-2.69%, TTFT0.224s -> 0.216s,-3.35%);chat T=0.0:21.10 -> 23.10 tok/s(+9.48%, TTFT+5.04%);code T=1.0:19.40 -> 21.50 tok/s(+10.82%, TTFT+6.53%);chat T=1.0:20.50 -> 22.30 tok/s(+8.78%, TTFT+4.70%).c=4:code T=0.0:28.10 -> 29.00 tok/s(+3.20%, TTFT-2.15%);chat T=0.0:19.45 -> 21.00 tok/s(+7.97%, TTFT-2.84%);code T=1.0:22.95 -> 24.30 tok/s(+5.88%, TTFT-7.93%);chat T=1.0:19.80 -> 20.70 tok/s(+4.55%, TTFT-2.87%).draft_head_q4.zig,dspark.zig,dspark_kernels.zig,dspark_kernels_test.zig,dspark_weights.zig,dspark.metal,dspark_sources.zig,host_test.zig,inkling2_dspark_metal_records.zig,native/inkling2.zig,platform/environment.zig,platform/environment_test.zig,tensorfold.zig,docs/environment.md,metal_inkling2_draft_head_q4.zig,metal_inkling2_dspark.zig,metal_inkling2_dspark_controls.zig,metal_inkling2_main.zig,metal_mapping_test.zig.TF_INKLING2_DRAFT_HEAD_Q4(0or1, default0/off), documented indocs/environment.mdand registered inzig/src/platform/environment.zig.2b22da8c44stacked onorigin/main(a992d0da99), Zig0.17.0-Dcpu=apple_m1 -Doptimize=ReleaseFast, Apple M5 Max (applegpu_g17); served A-B-B-A numbers from688c39cc53on Apple M5 Pro 64 GiB and Apple M5 Ultra 512 GiB; checkpoint Inkling-2-Mini.0cross-legtoken_sha256mismatches across all--serialA-B-B-A legs on both Apple M5 Pro (default-off+TF_INKLING2_DRAFT_HEAD_Q4=1) and Apple M5 Ultra (TF_INKLING2_DRAFT_HEAD_Q4=1), proving identical target token output because target verification keeps unmodified BF16lm_head.TF_INKLING2_DRAFT_HEAD_Q4unset,0.0%delta; withTF_INKLING2_DRAFT_HEAD_Q4=1,8/8wins (+6.80%..+25.00%) on Apple M5 Pro and7/8wins (+3.20%..+10.82%,code T=0 c=1 -2.69%) on Apple M5 Ultra.-1.34%..-5.54%TTFT across all8/8cells on Apple M5 Pro;-2.15%..-7.93%TTFT onc=4(+4.70%..+6.53%onc=10.5s/0.2sprompts) on Apple M5 Ultra.Kernel contract, only when a GPU kernel is new or changed
tf_ink2_dspark_logits_q4(256threads) inzig/kernels/metal/inkling2/dspark.metalandinkling2_dspark_metal_records.zigas the opt-in draft-head counterpart totf_ink2_dspark_logits/tf_ink2_dspark_basewhenTF_INKLING2_DRAFT_HEAD_Q4=1.68/68controls on Apple M5 Max (2b22da8c44) and56/56controls on Apple M5 Pro (pre-rebase92d78f5924) fail red as planted (0missed), includingTF_INKLING2_DRAFT_HEAD_Q4/logits_q4contracts and controls inmetal_inkling2_draft_head_q4.zigandmetal_inkling2_dspark_controls.zig.SUMMARYline and exit status:2b22da8c44):SUMMARY 62 kernels: 62 pass gates 1-4, 0 fail, 0 known findings; 68 controls: 68 red as planted, 0 missed; 0 limit problems; gates 12471 ms, limits 224 ms(exit0).92d78f5924):SUMMARY 49 kernels: 49 pass gates 1-4, 0 fail, 0 known findings; 56 controls: 56 red as planted, 0 missed; 0 limit problems; gates 9085 ms, limits 7 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.