Repository navigation
lfm3 metal: a shared round's qk in one dispatch for every stream - #3079
Merged
Merged
Conversation
This was referenced Nov 21, 2026
lfm3_qk_segments runs lfm3_qk's body for each row of a shared round, reading the row's stream, cache length, capacity, keys and values from the attention table that lfm3_attn_segments already uses. A shared round now dispatches qk once per attention layer instead of once per stream. lfm3_qk keeps its bindings and arithmetic through the shared inline row function, so every row computes the same bytes at the same address. The contract registers the kernel and a planted control (every row reads stream 0's entry), with a probe whose replaced path is lfm3_qk stream by stream; the qk reference takes each row's position. An engine test compares queries, keys and values byte for byte against the per-stream dispatches.
ashhart
force-pushed
the
lead/lfm-d821
branch
from
November 21, 2026 06:14
05fa37c to
5959cf4
Compare
ashhart
added a commit
that referenced
this pull request
Nov 21, 2026
ashhart
added a commit
that referenced
this pull request
Nov 21, 2026
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.
What this changes
In a shared LFM3 round on Metal,
lfm3_qkran once per stream per attention layer. A new kernel,lfm3_qk_segments, finds each row's stream from the round's attention-segment table and runs every stream's rows in one dispatch, so a round saves 11 × (streams − 1) dispatches.lfm3_qk's body moved into a shared inline row function that both kernels call, so the arithmetic per row is the same.lfm3_qkrun stream by stream.Checks on this head
zig fmt --check: clean.test-kernel-contract,test-lfm3-hostandcompile-metal-residency-host: 51/51 steps, 267/267 tests. The contract entry and the engine test compile.--only "shared qk": bit-equal, control red), the limits run and the LFM3 exactness tool. We'll run them on an M5 Mac before landing.Receipt
Checklist