Repository navigation
Conversation
This was referenced Nov 14, 2026
Closed
ashhart
force-pushed
the
lead/dsv41-decode-waves
branch
from
November 14, 2026 18:52
0067cf7 to
4978466
Compare
This was referenced Nov 14, 2026
Owner
Author
|
Rebased onto main 2ba55ec as part of the decode stack. It now sits on @gilby's #2973 and #2983 (#3292 needs #2983's expert rows) and lands after them in order: #2973, #2983, #3287, #3288, #3292, #3296, #3376. Measured on an M5 Ultra on the release checkpoint, the whole decode stack (#2973, #2983, #3287, #3288, #3292, #3296, #3376) against main 2ba55ec: 48 of 48 replies equal (greedy, sampled and "draft": false; 16 prompts, 512 tokens). Greedy 73.1 -> 91.8 tok/s, sampled 60.1 -> 74.8, "draft": false 46.4 -> 51.3. test-dsv41-metal passes and the lean check finds nothing new.
|
This was referenced Nov 14, 2026
Closed
ashhart
force-pushed
the
lead/dsv41-decode-waves
branch
2 times, most recently
from
November 18, 2026 13:44
ec33c97 to
2446f2f
Compare
…f its rows, bit-equal to one row a launch The decode gate/up and down for an expert's slot of 2-16 rows ran Kimi's four-row passes: two rows paid for four rows of arithmetic, five rows for two passes of four, each rereading the weights. The new tf_dsv41_xp_upc_rows and tf_dsv41_xp_down_rows decode each 32-group of an expert's MXFP4 weights once per pass and apply it to every row in it (passes of 2, 4, 6 or 8 rows for gate/up, 2 or 4 for down, rows past the slot repeating its last row unwritten), reading the activations straight from device memory. Each row's chain is the one-row kernel's: 32 products in k order from zero, then its group's scale, then the same tree and epilogue, so a row's bits are the same alone or with any other rows and routing. Slots of one row keep tf_dsv41_xp_upc_one/down_one unchanged. Contract: registrations with every row on the same six experts (gate/up coded and down, gates 1-4 against the oracle), one planted control a kernel (rows reading their pass's first row, red at shapes), gate-5 records for both launches, and a probe holding a launch's act, out and combine output bit-equal to each row launched alone at 1-16 rows on the same, disjoint and random experts, with NaN and Inf planted, plus its own control. Device test: the same equality at 2-16 rows.
…olumn a simdgroup for big K The one-launch FP8 row kernel now issues every weight and scale load before its chains, and an output's tile roots meet in one simdgroup's butterfly (lane k holds tile k's root, zero past the tiles), the same zero-padded pair tree that one thread used to walk over 32 roots. A new block kind d takes one column a simdgroup over 32-group tiles. kindOf picks d for K in whole 1024s with 2048 or more columns in the batch at 1 and 3-5 rows, and b otherwise; c is no longer picked. The contract's row invariance covers every kind. Bits unchanged: release layers 2 and 21 give main's output and KV hashes at 1 and 4 rows, 20 of 20 concurrent launches equal, and the float64 real-layer checks pass. M5 Ultra, release layer 2, the 8 FP8 launches timed alone: 1 row 247 -> 215 us, 4 rows 325 -> 281 us, 5 rows 360 -> 316 us. x40 round: 1 row 25.1 -> 24.6 ms, 4 rows 41.9 -> 40.0 ms, 5 rows 47.5 -> 45.7 ms.
…pt between picks The greedy argmax takes the first maximum in vector steps and keeps the scalar scan for a row holding a NaN, so it picks the same id; a sampled pick reuses its float64 logits and its ids instead of allocating both every row.
…ord of codes at a time tf_dsv41_route_gate_plan runs the router's matvec, the route and the experts' plan as one launch: groups of 32 columns compute the gate logits (mv.metal's lane chains and butterfly, rows in up to four slices), and the last group to finish (its count in the scratch's sync word, zero between launches) reads the logits as atomics, ranks every row's picks in the route's order (each simdgroup's top-k, then their union's) and plans them. It runs beside the shared expert's w1/w3, so the MoE takes four waves after the norm instead of six: gate+route+plan beside the shared up and act_quant; gate/up beside the SwiGLU and the hc mixes; down beside the shared w2; the join. The one-row gate/up and down decode each word of E2M1 codes by shifts (no integer multiplies) and stage x a 32-value group on a stride of 40; every chain keeps its order. Every output and KV byte is unchanged: layers 2, 21 and 5 at 1 and 4 rows hash as main. The new launch is in the contract twice (matvec and route suites, controls under TF_GCTL and TF_CTL).
ashhart
force-pushed
the
lead/dsv41-decode-waves
branch
from
November 18, 2026 19:49
2446f2f to
74f0299
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DeepSeek-V4.1's decode MoE on Metal ran six barrier-separated waves after its norm, and the router's matvec, the route and the expert plan were three small dependent launches. This puts those three in one launch and moves it beside work it doesn't depend on, so the MoE takes four waves. Every output and KV byte is unchanged.
tf_dsv41_route_gate_plan.mv.metal's lane chains and butterfly, rows in up to four slices.upc[0]anddown[0]decode each 32-bit word of E2M1 codes with shifts instead of integer multiplies, and stage x a 32-value group on a stride of 40. Every chain keeps its order.Measured on an M5 Ultra (512 GB), release layers,
time-dsv41-metal-real, fastest of 41, base and branch alternated twice:Bits: outputs and KV state hash as main on layers 2, 21 and 5 at 1 and 4 rows, with 20 of 20 concurrent launches equal. The float64 real-layer checks pass on 2, 21 and 5.
Kernel contract,
--only dsv41: 91 kernels pass gates 1-4, 194 controls red, 0 limit problems. The new launch registers in the matvec suite (exact bytes at 384 experts, 1-16 rows, four controls underTF_GCTL) and in the route suite on given logits.zig build test-dsv41-metal -Dcpu=apple_m1andtest-dsv41-metal-servepass on an M5 Max. Lean: 0 new.With dsv41 metal: decode experts decode an expert's weights once for all of its rows (stacked on #1720, #2973) #2983: this conflicts textually in
experts.metal(arounddown_one), the experts records anddocs/kernel-contract.md. A version rebased on dsv41 metal: decode experts decode an expert's weights once for all of its rows (stacked on #1720, #2973) #2983's head exists and hashes the same on layers 2, 21 and 5; I'll push whichever is needed once one of the two lands.Tried and dropped: matvec with eight chains a thread, hoisted loads in combpost/prenorm/postnorm, a separate route+plan kernel (level), gate and up split across simdgroups (60-105% slower).
Synthena (Ash's Agent)