Repository navigation
Conversation
|
/atc depends 5024 |
|
/atc depends 4917 |
a0c1a56 to
ddaba92
Compare
|
Thank you @gilby. The batch offsets keep streams separate, and proposals still reach the unchanged target verifier. The posted equality checks are useful; the TTFT regression should remain visible too. The new contract suites have an allocation-failure ownership bug: after the probe enters the owner list, a failed kernel append frees it locally, then suite cleanup follows the retained pointer. Please make both appends transactional and add a focused failing-allocator case for that sequence, including the attention/walk/control variants. The snapshot combination will also need both sets of state hooks retained.
|
|
@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.
|
ddaba92 to
c0fd524
Compare
|
Updated #5029 (head
|
Batch up to 8 concurrent streams per pass across DFlash 2 Metal absorb and hold paths so N > 1 streams share BF16 and Q4 linear projections, multi-ring KV updates and attention, and parallel selector walks in one command buffer with bit-identical results to N = 1 serial runs. Make batch, attention, and walk contract-probe publishing transactional via publishProbe with FailingAllocator coverage. (Refs ashhart#4961)
c0fd524 to
d298c5f
Compare
|
Rebased #5029 onto rebased #5024 (
|
What this changes
Before: stacked on #4917 and #5024, DFlash 2 drafting (
absorbRowsandhold) processed one stream at a time, re-reading weights per stream and dispatching separate command buffers/kernels when multiple concurrent requests were active, and the batched contract suites appended probes to their owner list befores.kernels.append.After (stacked on #5024 and #4917):
zig/kernels/metal/inkling2/dflash2.metal&dflash2_kernels.zig: Batchestf_ink2_df2_conv,tf_ink2_df2_ctx_kv,tf_ink2_df2_block_qkv,tf_ink2_df2_attend,tf_ink2_df2_attend_merge, andtf_ink2_df2_walkacross up to 8 concurrent streams per pass (DF2_MAX_BATCH = 8) with isolated per-stream KV rings and candidate slices.zig/src/families/inkling2/metal/{dflash2,dflash2_prepared}.zig&zig/src/native/inkling2.zig: Batches DFlash 2absorbandholdrounds soN > 1streams share BF16 and Q4 linear projections and selector walks in one command buffer with bit-identical results toN = 1serial runs (+23.1 MiBfixed batch scratch whenbatch=4).Tests & kernel contracts: Adds
dflash2_batch_test.zig,metal_inkling2_dflash2_{attn,batch,batch_controls,walk}.zig, and updatesmetal_inkling2_dflash2*.zig,metal_inkling2_main.zig, andhost_test.zig; makes probe ownership transfer transactional viapublishProbeacross batch, attention (plain/streams and control cases), and walk (normal and control) suites withstd.testing.FailingAllocatorcoverage inmetal_inkling2_dflash2_batch_controls.zig.Issue: Refs Inkling 2 Mini Metal V4: exact-serial scaling, GPU sampling, DFlash 2 acceleration, and kernel fusions #4961
Stacked on: inkling2 metal: opt-in --drafter-bits 4 quantization for DFlash 2 #5024 (
db54905fa2, V4-1) and inkling2 metal: native DFlash 2 drafter support (DFlash2DraftModel) #4917 (9a4a1619c2);git merge-tree --write-tree origin/main HEADclean (65b0cd3a5d) againstorigin/main(f3c0fa8c65).Checks on this head
d298c5f89e(16changed files,2245 insertions(+), 209 deletions(-))python3 tools/pr_check.py --base db54905fa2 --pr 5029(python3 tools/zig/lean_check.py):lean 164 vs 164, 0 new,0 error(s)(16changed files, max touched file584lines<= 600);zig fmt --check build.zig zigandgit diff --check db54905fa2..HEADexit0.-Dcpu=apple_m1 -Doptimize=ReleaseFast):zig build -Dcpu=apple_m1 -Doptimize=ReleaseFast: exit0.zig build compile-inkling2-native-host: exit0;zig build compile-inkling2-native-host -Dtarget=x86_64-windows: exit0;zig build compile-native-cuda-windows: exit0.zig build test-inkling2-host -Dcpu=apple_m1 -Doptimize=ReleaseFast:45 passed; 4 skipped; 0 failed(exit0).zig build test-inkling2-controls-host:30tests passed (0failed);zig build test-kernel-contract: exit0;zig build tf-kernel-contract -Doptimize=ReleaseFast: exit0.zig build test-inkling2-metal-host -Dcpu=apple_m1 -Doptimize=ReleaseFasttest binary:144 passed; 6 skipped; 0 failed(includes batched DFlash 2 host/GPU tests indflash2_batch_test.zig; JPEG and checkpoint env tests skipped)../zig-out/bin/tf-kernel-contract):d298c5f89e,--only "metal inkling2 dflash2"):SUMMARY 17 kernels: 17 pass gates 1-4, 0 fail, 0 known findings; 21 controls: 21 red as planted, 0 missed; 0 limit problems; gates 7480 ms, limits 563 ms(exit0).--only "metal inkling2"):SUMMARY 78 kernels: 78 pass gates 1-4, 0 fail, 0 known findings; 86 controls: 86 red as planted, 0 missed; 0 limit problems; gates 26189 ms, limits 764 ms(exit0).kc_v4_2_mod, prior commit; kernels unchanged):SUMMARY 54 kernels: 54 pass gates 1-4, 0 fail, 0 known findings; 63 controls: 63 red as planted, 0 missed; 0 limit problems; gates 15855 ms, limits 74 ms(exit0).db54905fa2) and inkling2 metal: native DFlash 2 drafter support (DFlash2DraftModel) #4917 (9a4a1619c2) cleanly againstorigin/main(f3c0fa8c65); CI checks triggered on force-push.Receipt
tools/bench_concurrent.py --tokens 128 --reps 2,{TARGET} --drafter {DFLASH2} --drafter-bits 4 --parallel 4 --context 8192,0cross-legtoken_sha256mismatches across all cells on both machines; 16/16 cells win decode throughput, with 1 TTFT regression on Apple M5 Ultracode T=1.0 c=1+7.14%):bits=4, fixed_mib=416.8vs batchedfixed_mib=439.9, batch=4, pool363.2 GiB):code T=0.0 c=1:32.00 -> 32.25(+0.78%, TTFT0.218 -> 0.213s,-2.06%)code T=0.0 c=4:44.60 -> 47.50(+6.50%, TTFT0.528 -> 0.504s,-4.45%)chat T=0.0 c=1:28.90 -> 30.30(+4.84%, TTFT0.504 -> 0.504s,-0.10%)chat T=0.0 c=4:44.65 -> 47.50(+6.38%, TTFT1.796 -> 1.764s,-1.81%)code T=1.0 c=1:22.20 -> 22.95(+3.38%, TTFT0.217 -> 0.232s,+7.14%regression)code T=1.0 c=4:38.55 -> 40.95(+6.23%, TTFT0.512 -> 0.506s,-1.27%)chat T=1.0 c=1:21.20 -> 22.50(+6.13%, TTFT0.506 -> 0.500s,-0.99%)chat T=1.0 c=4:34.05 -> 36.10(+6.02%, TTFT1.802 -> 1.769s,-1.83%)bits=4, fixed_mib=416.8vs batchedfixed_mib=439.9, batch=4, pool27.2 GiB):code T=0.0 c=1:16.70 -> 17.70(+5.99%, TTFT0.552 -> 0.530s,-3.89%)code T=0.0 c=4:18.80 -> 19.15(+1.86%, TTFT1.296 -> 1.276s,-1.58%)chat T=0.0 c=1:15.40 -> 16.10(+4.55%, TTFT1.307 -> 1.288s,-1.42%)chat T=0.0 c=4:19.10 -> 19.60(+2.62%, TTFT5.029 -> 4.973s,-1.10%)code T=1.0 c=1:12.75 -> 13.50(+5.88%, TTFT0.537 -> 0.530s,-1.40%)code T=1.0 c=4:16.30 -> 16.70(+2.45%, TTFT1.332 -> 1.289s,-3.19%)chat T=1.0 c=1:12.90 -> 13.55(+5.04%, TTFT1.336 -> 1.312s,-1.83%)chat T=1.0 c=4:14.10 -> 14.15(+0.35%, TTFT5.288 -> 5.245s,-0.81%)dflash2.metal,dflash2_kernels.zig,dflash2.zig,dflash2_prepared.zig,dflash2_batch_test.zig,host_test.zig,native/inkling2.zig,metal_inkling2_controls_host.zig,metal_inkling2_main.zig,metal_inkling2_dflash2*.zig.DF2_MAX_BATCH = 8per batch).d298c5f89estacked on inkling2 metal: opt-in --drafter-bits 4 quantization for DFlash 2 #5024 (db54905fa2) and inkling2 metal: native DFlash 2 drafter support (DFlash2DraftModel) #4917 (9a4a1619c2), Zig0.17.0-Dcpu=apple_m1 -Doptimize=ReleaseFast, Apple M5 Max (applegpu_g17), Apple M5 Ultra 512 GiB, Apple M5 Pro 64 GiB; checkpoint Inkling-2-Mini and DFlash 2 drafter (incoai/Inkling-2-Mini-DFlash2).0cross-legtoken_sha256mismatches across all cells (T=0.0,1.0,c=1,4) on both Apple M5 Ultra and Apple M5 Pro; multi-stream kernels maintain bit-identical arithmetic and isolated KV/candidate state vsN = 1serial execution.8/8cells on Apple M5 Ultra (up to+6.50%,c=4+6.02%..+6.50%) and8/8cells on Apple M5 Pro (up to+5.99%,c=4+0.35%..+2.62%).15/16cells (up to-4.45%on Apple M5 Ultra and-3.89%on Apple M5 Pro), with 1 regression on Apple M5 Ultracode T=1.0 c=1(0.217 -> 0.232s,+7.14%).Kernel contract, only when a GPU kernel is new or changed
tf_ink2_df2_conv,tf_ink2_df2_ctx_kv,tf_ink2_df2_block_qkv,tf_ink2_df2_attend,tf_ink2_df2_attend_merge, andtf_ink2_df2_walkacrossDF2_MAX_BATCH = 8streams indflash2.metal/dflash2_kernels.zig, replacing single-stream-only dispatch.21/21DFlash 2 controls (d298c5f89e,--only "metal inkling2 dflash2") and86/86full Inkling 2 controls (prior commit on same kernels) on Apple M5 Max, plus63/63controls on Apple M5 Pro (kc_v4_2_mod), fail red as planted (0missed), including per-stream isolation mutations inmetal_inkling2_dflash2_batch_controls.zig.SUMMARYline and exit status:d298c5f89e,--only "metal inkling2 dflash2"):SUMMARY 17 kernels: 17 pass gates 1-4, 0 fail, 0 known findings; 21 controls: 21 red as planted, 0 missed; 0 limit problems; gates 7480 ms, limits 563 ms(exit0).kc_v4_2_mod, prior commit; kernels unchanged):SUMMARY 54 kernels: 54 pass gates 1-4, 0 fail, 0 known findings; 63 controls: 63 red as planted, 0 missed; 0 limit problems; gates 15855 ms, limits 74 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.