Repository navigation
DeepSeek-V4.1 on Metal: FP8 prompt projections 14-19% faster, bit-equal - #3322
Merged
Merged
Conversation
ashhart
added a commit
that referenced
this pull request
Nov 14, 2026
…tree's low levels in registers and skips the zero padding groups Every output keeps its four MMA steps from zero a group and the same zero-padded pair tree, so prompt rows stay bit-equal to main and to the decode rows. Release layer 2 stage hashes match main at 2048 and 4096 rows.
ashhart
force-pushed
the
lead/dsv41-fp8-mma-tiles
branch
from
November 15, 2026 12:43
89b0b87 to
4663697
Compare
ashhart
added a commit
that referenced
this pull request
Nov 15, 2026
1 task done
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 on Metal: the dense FP8 prompt projections (
tf_dsv41_fp8_mma: wq_a, wq_b, wkv, wo_a, wo_b, the shared expert, the indexer's wq_b, Engram's wkv) take 14 to 19% less time, with every output bit unchanged.Each output still sums four 8-wide simdgroup MMA steps from zero per 32-wide K group, then joins the roots in the same zero-padded pair tree. So prompt rows stay bit-equal to main and to the decode row kernels. What changed:
+0adds are replayed in closed form where the full tree has them, so-0and every other bit come out the same.fp8_rowsdoes). NaN codes and scales whose 256 multiple overflows take the old per-code path.Release layer 2 on an M5 Ultra, ms a stage (main is the mean of two runs bracketing the branch):
The kernel alone at 4096 rows: wq_b 16.34 -> 13.64 ms, wo_b 15.81 -> 13.57, w1 4.78 -> 3.84, wkv 1.13 -> 0.89. kv barely moves because most of it is the compressor's
g.mv.Exactness:
xe_up/xe_down, which also differ between main's own two runs (the gathered expert tiles' scratch). Theexperts,sharedandposthashes after them match.3 kernels: 3 pass gates 1-4, 0 fail; 4 controls: 4 red as planted, 0 missed; 0 limit problems. Chunk invariance has 0 differences, and every real shape is bit-equal tofp8_rows.zig build test-dsv41-metalpasses (1,135 checks, prompt vs decode rows included). Lean: 0 new.Tried and slower on the M5 Ultra:
This exact fp32 path peaks at 32.7 TFLOPS on that GPU (measured), and the kernel now runs at about 25.
Found along the way:
fp8_rows' fast decode path takes scale code 247, wherescale x 256overflows fp32, so a decode row would disagree with a prompt row at that one scale (2^120). Release checkpoints never use it (their largest scale byte is 127). This kernel sends codes above 246 down the per-code path so it stays equal to main; the decode kernel is untouched.