Repository navigation
inkling2 metal: native DFlash 2 drafter support (DFlash2DraftModel) - #4917
cwschroeder wants to merge 1 commit into
Conversation
|
I trial-merged zig build test-inkling2-host test-inkling2-metal-host compile-inkling2-native-host test-inkling2-launch-map-host -Dfixed-cpu -j2 --summary all
zig build tf-kernel-contract -Dfixed-cpu -j2 --summary all
./zig-out/bin/tf-kernel-contract --only 'metal inkling2 dflash2'The device run validates all 11 DFlash2 launch limits, then prints Igor Lessio - AIFLOW LABS |
|
Thanks, @cwschroeder. The live greedy comparison includes accepted drafts and is useful evidence. Please guard the previous token before the walk's codebook read. A non-finite score row produces invalid candidate IDs; the next slot uses that invalid address before the host checks it. The launch-limit records are present, but the filtered contract run reports zero numerical kernels and controls. Please wire numerical cases and planted controls, including this exceptional-value path. Keep every proposal checked by the unchanged target.
|
|
Thanks @ashhart and @AIFlowML for the reviews and trial merge. Rebased onto
Verification on Apple M5 Max (
|
75669dd to
f6cbbbb
Compare
|
I checked the revised head
Igor Lessio - AIFLOW LABS |
f6cbbbb to
867fcf6
Compare
|
Thanks @cwschroeder. The previous-token guard and bounded candidate reads are present. The numerical suite and exceptional-value controls are now wired, so those earlier asks are closed in source. One new setup issue remains: both collector helpers publish a probe before the fallible kernel-list append. If that append fails, local cleanup frees it while parent teardown still owns its pointer. Please make publication transactional and cover that failure for ordinary and control probes. Keep every proposal target-verified.
|
867fcf6 to
9a4a161
Compare
|
Fixed in
|
|
@cwschroeder, 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.
|
Summary
Adds native Metal speculative decoding support for
DFlash2DraftModel(such asincoai/Inkling-2-Mini-DFlash2) alongside the existingDSparkdrafter on--drafter DIR.When
--drafter DIRis passed,zig/src/native/inkling2.ziginspectsconfig.jsonand auto-selectsDFlash2(architecturescontainingDFlash2DraftModel) orDSpark, reportingkind = "DFlash2"inEngine.Info.What Changed
zig/src/families/inkling2/metal/dflash2_weights.zig): Strictconfig.jsonand 81-tensormodel.safetensorsloader validatingtarget_layer_ids = [5, 23, 41, 48],block_size = 8, 5 Qwen3 layers,sliding_window = 2048,valid_vocab = 200058,selector_top_k = 16,selector_softcap_mode = "after_correction", andfinal_logit_softcapping = 30.0.zig/kernels/metal/inkling2/dflash2.metal,dflash2_sources.zig,inkling2_sources.zig): 11 pure-BF16 kernels (tf_ink2_df2_*) covering target-hidden concat/projection/RMSNorm (fc), masked block embedding withembed_norm, Qwen3 blocks with 2-tap dynamic depthwise convolution (conv_proj), 2048-token sliding-window GQA 4:1 attention on a fixed 2176-slot KV ring, SwiGLU MLP, 1-pass radix top-16 candidate selection overvalid_vocabusing the shared targetlm_head, and exactafter_correctionsoftcapping plus greedy path selection.zig/src/families/inkling2/metal/dflash2.zig,dflash2_kernels.zig,backend.zig,zig/src/native/inkling2.zig): Fixed 44.5 MiB/stream KV ring perLane, async absorb pipelined with target verification, andwarm()timing ofwindow_costs(1..16 rows) solanesadaptive depth selection unlocks full 7-token draft blocks instead of falling back to depth 1-3.zig/src/core/contract/inkling2_dflash2_metal_records.zig,registry_joins.zig,contract.zig,zig/tests/contract/metal_limits.zig,zig/src/families/inkling2/metal/host_test.zig): Registers all 11tf_ink2_df2_*Metal launch records in Gate-5 contracts, shader limits verification, and host unit tests for weight config parsing, ABI sizes, and ring addressing.Local Validation
Run against
origin/main(00e0e9878) with Zig0.17.0:zig fmt --check build.zig zig— passpython3 tools/pr_check.py --base origin/main—0 errors,lean 165 vs 165, 0 newzig build test-kernel-contract— pass (1272 registered launches, 2 controls, 0 missing)zig build test-metal-launch-map-host— passzig build test-inkling2-controls-host— passzig build test-inkling2-launch-map-host— passzig build test-inkling2-host— passzig build test-inkling2-metal-host— passzig build compile-inkling2-native-host— passzig build native -Doptimize=ReleaseFast— passInkling-2-Mini+Inkling-2-Mini-DFlash2(temp=0.0, 128 tokens,"Write a Python AVL tree."):--no-drafts: 127 rounds, SHAd0993c9ef225--drafter <DFlash2>: 39 rounds (3.28tok/round,89/237accepted drafts,9.53 msdraft block), identical SHAd0993c9ef225(2.67xspeedup on unoptimizedmain)