Repository navigation
Conversation
b134588 to
3575cc3
Compare
|
@ashhart #2634 now serves: |
33989ef to
71afe36
Compare
|
@jschmied, M3 Ultra cells on Exact. On every agent request, at T=0 and seeded T=1, the DSpine reply equals the DFlash2 reply and the reply with drafts off. Agent-shaped requests, one stream (decode tok/s):
That's a bigger agent gain than on the GB10. Chat and code (
One stream matches the GB10 picture. Two streams are where Metal differs: the server says "DSpine drafts for 1 stream", against DFlash2's "drafts for 2 streams". The patch drafts slot 0 alone (the Before this lands: could DSpine draft every admitted stream on Metal, as DFlash2 does and as #2633 does on CUDA? If one slot is a deliberate first step, please say so in the body and the CHANGELOG, and refuse or warn at |
|
@ashhart every admitted stream now drafts by default, as DFlash2 and CUDA do: Measured on our M3 Pro (36 GB, no tensor units), 27B MLX 4-bit,
Exact: 32 of 32 comparisons byte-identical. At T=0 (c=1 and c=2), DSpine with either setting and DFlash2 equal plain decode; at T=1 c=2, DSpine equals DFlash2 and the one-stream run. On this GPU a 2-stream pass costs about two 1-stream passes, so drafting both streams is 4-9 % slower than drafting one at c=2, and DFlash2 still leads there. Could you run the 2-stream cells (c=2, agent and chat, T=0 and T=1, Gates on Proposed CHANGELOG line (Unreleased): "- The 27B on Metal: DSpine drafts every admitted stream, as DFlash2 does; |
|
Thanks @jschmied, that's the change we asked for. Every admitted stream now drafts by default A few things before that:
On the 36 GB question: please keep the stock 8 GiB margin here. A Mac without the room should go on refusing DSpine by We'll write the CHANGELOG line when it lands. Main is closed for a release right now, so landing waits until it |
ac97590 to
0349d06
Compare
|
@ashhart thanks, all five done, and it is out of draft. The head is now
36 GB: the stock 8 GiB margin stays, with no new setting. The refusal now names the drafter (0349d06): "--parallel 1 needs 4.3 GiB for its streams and 512-row prompt scratch at a 4096-token context; 3.1 GiB remains beside the weights, the DSpine drafter (2.7 GiB) and an 8 GiB margin: Metal lets this Mac use 28.1 GiB; sudo sysctl iogpu.wired_limit_mb=29958 raises that limit enough for one stream at this context until reboot (or lower --context)". qwen27_served.zig is 595 lines. Gates on 0349d06: test-qwen27 46/46 steps, 191/191 tests; test-qwen27-startup-host 4/4; test-environment-host 13/13; test-environment-report-host 35/35; native 66/66; zig fmt clean; lean 386 vs 386 (0 new); Served exactness on the new code (test-only 4 GiB margin build, uncommitted, |
|
Thanks @jschmied. The rebase is clean on main with only this PR's commits. Two things are left:
We'll write the CHANGELOG line. After that we run the two-stream cells on our M3 and M5 Ultra Macs, and a GB10 check of the commit 11 CUDA loader on this head.
|
|
@ashhart both should be in place now; our update at 13:13 may have crossed with your read:
The GB10 side is also checked on this head: |
|
Thanks @jschmied, both are in. The description matches Nothing more is needed from you. Next we run the two-stream cells on our M3 Ultra and M5 Ultra Macs with
|
, ashhart#2464, ashhart#2375, ashhart#2634) and adds row 29, DSpine (ashhart#2633) Rebased onto main after ashhart#2760's row 28 (Scale index), which stays as on main. DSpine is row 29 with ashhart#2633's final GB10 ranges: agent 2-20 % faster, chat and code 10-19 % slower.
|
On exact head With those two files combined on the PR head, the same command passed 61 freshly run tests, and the unchanged 13-test artifact was reused. The shared suite gained the narrowing test. This verifies the shared-core resolution only. The registry and four remaining serving/drafter files need integration, and I did not run a DSpine checkpoint on this Mac. Igor Lessio - AIFLOW LABS |
…t reference of bridge, tables and tail The Metal port's first part, over core.dspine (shared with the CUDA drafter): - config: core.dspine.parse pinned to tencent/Qwen3.8-27B-DSpine-b16 (else NotStockDSpine), bind to the target - weights: the checkpoint's 71 names exactly, BF16 borrows; every version scalar must be 1 and out.weight zero - host: one bridge write, TG/TSV rows, top-k (ties to the lower id) and the greedy score table, rounding where Tencent's dspine_mlx rounds; the kernels' contract will compare against it - testdata/bridge-fixture.safetensors from dspine_mlx itself at small widths (bridge_fixture.py): the last write, TG, TSV, candidates and drafts match exactly, the early write within an ulp; the message-dropped control moves
…d the one-round gate against dspine_mlx - runtime: the checkpoint on the target's device, body linears affine-4 (or BF16 with --mode bf16), the bridge BF16 as dspine_mlx keeps it; gate/predecessor_gate/prev packed; TG built at load through the target head - forward: committed taps into 8,192-row K/V caches; the block (anchor + 15 masks) through plain layers with a block-causal, windowed mask, each closed by the bridge write; full-vocab head, top-16, senders, TSV rows, the exact-sender table; candidates sorted ascending and the chain walked by core.dspine.chain - kernels (qwen27/dspine.metal): add, bridge read/code/message/write, senders, table - kernels_test: on the dspine_mlx fixture the write is within 2 ulps, the table chains its drafts, and a zero write (message dropped) no longer matches - tf-qwen27-dspine-gate: the MLX reference's taps and anchor in (16 rounds, 4 prompts), drafts compared. BF16 linears: 15/16 chains identical, 233/240 positions; control (second pass off) 3/16, 90/240. Affine-4 body: 8/16, 165/240. Only an unwrapped context (below the 8,192 window) is drafted so far.
…e-4 bridge; 53 to 31 ms a proposal - The base term (raw * norm . head row) is no longer a second full-vocab head pass: tf_dspine_base dequantizes the 240 candidates' rows of the target lm_head (its MLX layout read once more from the target's files) and sums in f32, as dspine_mlx's RefinementTail does. The head runs once, over the 15 rows past the anchor. - --mode q4 (default) prepares the bridge's reads, writes, packed gates and the TSV pair affine-4 as well; q4_body keeps the bridge BF16 (as the reference); bf16 for the port check. - TF_DSPINE_PROFILE: each layer, the head and the tail in their own command buffers with their GPU times. M3 Pro, q4: 3.4 ms a layer (16-row blocks are compute-bound here), head 11.3 ms, tail 2.9 ms. - Gate against dspine_mlx: BF16 15/16 chains, 233/240 positions. Against a reference whose body linears carry this affine-4 exactly (same groups, scales, biases): q4_body 14/16, 222/240.
…y chains through them - dflash/generation: GenerationOf(D) takes a drafter with binds, tapIds, tapWidth, failed, idle, committed_end, absorb and propose; Generation stays GenerationOf(DFlash2's Model), which gains those methods. - dspine runtime: the same interface; absorb appends the accepted taps at once, propose returns its chain (at most `nodes` of the 15 greedy drafts) as a one-branch tree. - tf-qwen27-dspine-run: plain greedy, DFlash2 trees and DSpine chains on one stream (4,096 context), the same four prompts. M3 Pro, qwen38-27b-mlx-4bit, 256 tokens, 15 nodes, tokens a round: poem 2.75 / 1.83, primes 10.75 / 10.75, code 13.38 / 12.59, agent 4.92 / 3.88 (DFlash2 / DSpine q4); the bridge in BF16 (q4_body) moves DSpine little (agent 4.06). A round costs about the same for both (the 16-row verify dominates), so chains trail DFlash2's trees until DSpine drafts trees from its table.
… the table's scores read as logits A tree walker over the exact-sender table softmaxes each sender's row; the table holds raw * norm . head + rms * m . TG, and times 1 / rms of the written row it is that row's logits (the sender's own refined norm differs a little).
… and the context (--context) The CUDA runs' prompts.json (class, id, ids): every prompt of a class whose ids leave room for the reply in the context. M3 Pro, the five agent turns under 8,192: DSpine's chain 14.65 tok/s against DFlash2's tree 14.6.
…r the exact-sender table propose() hands grow() each row's 16 ids (ascending) and the table times each row's final-norm scale, so a sender's row softmaxes as logits; TF_DSPINE_CHAIN keeps the greedy chain. tf-qwen27-dspine-run: --no-plain.
…mented, its forms tested)
… DSpine behind one Generation q.drafter.Any picks the kind from the checkpoint's config (core.dspine.declared), admits it against the target, and gives Generation, the lane backend, keep, slots and residency one interface (ring, reset, recover, standAt). DSpine keeps DFlash2's taps ring: absorb writes the ring, each proposal catches the K/V caches up from it, so kept states save, restore and move slots as DFlash2's do; its caches wrap past the 8192 window. DSpine drafts slot 0 alone; other slots keep a taps ring only. A sampled stream's tree aims at its keyed draws. The head copy keeps the three head tensors, not the target's mapped shard: the drafter takes 3.0 GiB, not 6.5.
… in one pass Slots past 0 hold DSpine's K/V caches beside their taps ring (a lane Context), and draft_slots follows draftSlots() for DSpine too. One batched forward runs every drafting stream's block: linears, bridge and head over all rows, attention per stream over its own cache and mask, the top-k and table tail per stream. Below the 8192 window a served context sizes the ring, K/V and attention to the rows a stream can reach (exact: nothing wraps), 560 -> 280 MiB a slot at 4096. The gate checks a batch of two against each stream's own pass and takes --fit.
…le both loaders read core/dspine.zig holds every tensor's name, dtype and dims in the config's terms (globals, the code bridge, each layer's) with find, names and dims. Metal's weights.zig checks inventory, shapes and version scalars against it; CUDA's bridge loader expects its tensors through it. TG's device input row bf16(norm * W_write[last][:, k]) is core.dspine.tgInput, which Metal's runtime and CUDA's table both feed to the target head. The host reference keeps dspine_mlx's own rounding, bf16(head * norm) . W, which the fixture pins (the device form is off it by more than its 5-ulp bound).
…t reference, with planted controls metal_qwen27_dspine.zig runs tf_dspine_add, read (xn and rms), code, message, write, senders, base and table at the stock 27B drafter's shapes (rows of 1, 2 and 8 streams' 16-row blocks; a stream's 15 head rows) through gates 1-4 against float64 (senders by an exact copy check); three source edits must go red: message reading its own row's S, read's squares summed in half, table taking the first sender's message. Their launches are registered for gate 5 (M1/M2 compiled limits measured offline: 1024 each).
…_DRAFT_SLOTS names DSpine's count too
…e weights and its size
…r interface ashhart#2634 moves Context.ring's config into the context, so flint's absorb call drops the argument (X6 carried this; the X7 rebase lost it).
The MTP head's device check and load move to qwen27_mtp_flags.zig, unchanged. The Moss image, Moss decoder and DSpine contract suites register in the same order behind one create in metal_image_dspine_suites.zig.
Use explicit blocks for the DFlash2-only optional captures. This preserves the adaptive reset and makes the rebased source pass zig ast-check.
…as DFlash2's - Tree.scores hold path scores (`draft_tree.pathScores` after `grow`), which `local` reads by subtracting the parent's; a child's chance can no longer go above one in a shared round. - A DSpine request takes the stream's draw only through `drawFor`, DFlash2's rule (a lone sampled stream, drafting from where it stands); a shared round's tree keeps the drafter's own scores. - `Model.buffers` adds attention, top-k, the frame pool and the prepared and tiled weights through `appendDraft`; `residency.hold`/`drop` attach and detach DSpine's follow hook (`setDraft`).
61b6349 to
8d60eec
Compare
|
@ashhart the quiet rerun on our M3 Pro shows no loss. The chat c=2 drop I reported was noise from the Mac's load, so it's no reason to hold this from our side. Setup: the same as before.
Aggregate tok/s, clean sessions, mean (min–max):
At chat c=2, every clean B session is at or above every clean A session; they touch at 26.22. No cell is slower on the branch. What explains the earlier −0.6 %: I compared two separate builds of main, A and A'. Their binaries differ (3,060 bytes, same size), so Mac builds of one commit aren't byte-identical. That day the Mac was under load from antivirus, Java and a VM, and only 2 of 20 sessions had no warning. Tonight, with the gate, the difference is gone in both directions. Tokens:
DSpine on B, two sessions from the A-A' day (loaded Mac, so a floor, not a final number):
So the earlier 20.72 came from load, not a change. Tonight's run hit its 06:00 stop before its own DSpine pass. If you want quiet DSpine rows next to these, I'll add them tonight. All measured on |
This head: 61b6349 (ashhart's eeeaee5 plus one commit for review 7111733774)
Tree.scoresnow hold path scores (draft_tree.pathScoresaftergrow), which is whatlocalreads.drawFor: a lone sampled stream, drafting from where it stands).buffersadds attention, top-k, the frame pool and the prepared and tiled weights (sharedappendDraft), andhold/dropattach its follow hook (sharedsetDraft).test-lone-copy-host(path-score test; planted control: raw own log-chances read as paths give a chance above 1),test-metal-residency-owners-host(new DSpine owners test; planted controls: the oldbuffersleaves 9 allocations out, and with no hook a later frame buffer never joins), the qwen27/DSpine host set,zig fmt --check,git diff --checkandpr_check. The macOS targets compile for aarch64-macos.-Dcpu=apple_m1) on 61b6349,tensorfold-nativemd5aa5c55f70092d232cdee5da6b85d9904: the qwen27/DSpine build and tests 93/93 steps, 360/362 tests (2 skipped); DSpine contract 9 kernels pass, 3 controls red; served T=0 c=1/c=2 DSpine == plain and DFlash2 == plain 12/12, T=1 c=2 seed 7 DSpine == DFlash2 12/12;tf-qwen27-dspine-gatebatch of 2: 30/30 proposals equal to each stream's own pass. Speed rows below were measured on 82ae37f and not rerun.Previous head: 82ae37f, rebased onto main e6094de on the user's request
qwen27_served.zig'sLaneHost.init. Main's.penalties = trueis kept beside DSpine'sd.label(). As in AIFlowML's trial (qwen27 Metal: DSpine drafter for Qwen3.8-27B, opt-in #2634, 7072481473): main's MTP-head KV reserve sits beside DSpine'stapIds().len, the built-in MTP metadata stays, andTF_Q27_DRAFT_SLOTSdescribes both behaviours. Nothing in this PR uses.rotary_dim(metal: drop qwen27 prompt_glue/prompt_state and core tf_lane_rope, which nothing launches (#2251) #3065).qwen27_lanes,qwen27_draws,qwen27_resume,qwen27_slotsandqwen27_servedunder this PR, so the Metal device checks were rerun on this head.Rerun on 82ae37f:
native test-qwen27 test-qwen27-startup-host -Dcpu=apple_m1, 82/82 steps, 217/219 tests. The 2 skips are env-gated MTP tests.tensorfold-nativemd5 is 35cc1c84.--only "qwen27 dspine":SUMMARY 9 kernels: 9 pass gates 1-4, 0 fail, 0 known findings; 3 controls: 3 red as planted, 0 missed; 0 limit problems.zig build test: 965/970 steps. The 3 failing tests (DeepSeek-V4.1 vision config, persistence identity, native memcpy nm step) fail identically on main e6094de, so nothing is new against main.--parallel 2 --context 2048(concurrency 1 and 2), stock 8 GiB margin:tf-qwen27-dspine-gate: a batch of 2 == each stream's own pass 30/30. The one-round gate (6/16, 149/240) is unchanged.test-qwen35-dspine-hostand 15test-qwen27-*-hoststeps among them, plustest-environment-hostandtest-env-defaults-host. 69/69 steps, 890/892 tests (2 skipped).zig fmt --check,git diff --check,pr_check(0 errors, lean 165 vs 165, 0 new).native,test-qwen27,tf-kernel-contract) compile for aarch64-macos (no SDK, so no link) with 0 errors.native test-cuda-host -Dnvcc=/usr/local/cuda/bin/nvcc -Dsm=121, 618/618 steps, 6229/6268 tests (39 skipped).cuda_dspine_weights.zigreads the sharedcore.dspinetable, and main left it unchanged.Carried, not rerun: the kernel-contract full sweep (546 kernels) and every speed row below, all measured on the pre-rebase head before 0445547. The speed claim's code (DSpine runtime, kernels, tree walk) did not change in the rebase. No CHANGELOG commit. Proposed CHANGELOG line:
qwen27 Metal: DSpine drafter for Qwen3.8-27B behind --drafter, opt-in (#2634).Opt-in: nothing changes unless
--drafternames a DSpine folder. On main since #2633 landed; the CUDA DSpine,core.dspineand the shared tree walker it reuses are main's.What this changes
DSpine for Qwen3.8-27B on Metal, served, in its own
qwen27/dspine/(Metal's DFlash2 body is conv-wrapped with its own tap set, so it is not reusable as a body). Reused:shared_attention,draft_ops, the affine-4 prepare,bf16_topk, the target head kernels,core.dspine(config, table walk, the checkpoint's 71-tensor table and TG's head input) andlanes.draft_tree.qwen27/dspine/config+weights: the 27B checkpoint pinned (NotStockDSpineotherwise), its 71 tensors exactly, fromcore.dspine's table (the CUDA loader reads the same table).dspine_mlxrounds.lanes.draft_tree.grow.dflash/generationbecomesGenerationOf(D);qwen27/drafter.zigAny= DFlash2 | DSpine behind one Generation, so lanes/slots/keep/residency go through it.--drafter DIRpicks the kind fromconfig.json(core.dspine.declared); DFlash2 stays the default.draft_slots=draftSlots().TF_Q27_DRAFT_SLOTScaps it for DSpine as for DFlash2. Ring and K/V are sized tomin(8192, capacity + window)rows (exact below 8192: no context wraps), 280 MiB a stream at 4096.draft_treeCandidates (the same keyed-noise path as CUDA).tf_dspine_*kernels are in the Metal kernel contract (zig/tests/contract/metal_qwen27_dspine.zig): served shapes (bridge at 16/32/128 rows, hidden 5120, code 1024, rank 512; senders/base/table at a stream's 15 head rows, K 16) against a float64 host reference, senders bit-exact; three planted controls go red.Checks (M3 Pro 36 GB, no tensor units)
test-qwen27,test-qwen27-startup-host, the environment host tests, native build, fmt, lean (no new problems),pr_check(0 errors).tf-kernel-contractfromzig build,-Dcpu=apple_m1, with this Mac's--rotary-accuracysweep file):SUMMARY 546 kernels: 546 pass gates 1-4, 0 fail, 3 known findings; 576 controls: 576 red as planted, 0 missed; 0 limit problems. DSpine alone (--only "qwen27 dspine"):SUMMARY 9 kernels: 9 pass gates 1-4, 0 fail, 0 known findings; 3 controls: 3 red as planted, 0 missed; 0 limit problems.dspine_mlx(its taps and anchor), 4 prompts × 4 rounds: BF16 15/16 chains, 233/240 positions; affine-4 body against an affine-4 reference 14/16, 222/240; served mode (bridge linears affine-4 too) 6/16, 149/240; control (second pass off) 3/16.--parallel 2 --context 2048, multi.py agent 4×256 and chat 8×256: at T=0, c=1 and c=2, DSpine's and DFlash2's outputs equal plain decode (24/24 each); at T=1, c=2, DSpine's equal DFlash2's (12/12). A batch of 2 is bit-identical to each stream's own pass (30/30 proposals).cuda_dspine_weights.zigreadscore.dspine.tgInput, math unchanged):test-qwen35-dspine-host,test-cuda-hostand the CUDAnativebuild (sm_121) pass on the GB10 at this head.Speed (M3 Pro 36 GB,
qwen38-27b-mlx-4bit)One stream, drafter loop, T=0, up to 256 tokens, 15 nodes, the prompt set from #2592, decode tok/s:
A greedy chain instead of the tree was slower in every class (agent +0, chat −25, code −21 %), so the branch has no chain mode.
Served,
--parallel 2 --context 2048, aggregate tok/s (multi.py, agent 4×256, chat 8×256):TF_Q27_DRAFT_SLOTS=1Without tensor units every DSpine kernel is compute-bound in rows (one pass 37.8 ms for 1 stream, 68.4 ms for 2), so on the M3 Pro drafting both streams runs 4–9 % below drafting one at c=2;
TF_Q27_DRAFT_SLOTS=1gives the one-stream behaviour. The M3 Ultra cells (one stream +11..+62 % on agent) were on the earlier one-slot head; 2-stream Ultra cells on this head are the open number.36 GB Macs: with the stock 8 GiB margin no DSpine stream fits at context 4096 (4.3 GiB needed, 3.1 GiB left beside the weights and the drafter): the server refuses by name and says how far
iogpu.wired_limit_mbmust rise, or to lower--context. The served M3 Pro numbers above used a test-only 4 GiB margin build, not committed. Larger Macs are not affected.