Repository navigation
lfm metal: a keep that drops nothing skips its copy - #3078
Merged
Merged
Conversation
This was referenced Nov 21, 2026
LFM2-MoE and LFM3's Cache.keep return early when the path keeps every row of the last round. The recorded call already left that state: commit() restored the last row's conv state, run() copied its logits, and len is start + rows. A full path skips about 0.5 MB of copying a stream per shared round; a partial path still copies, through a private take(). New state tests check both paths against the copy, byte for byte.
ashhart
force-pushed
the
lead/lfm-d820
branch
from
November 21, 2026 07:13
de72634 to
950283f
Compare
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 round, LFM2-MoE and LFM3 on Metal copied each stream's conv state and logits back in
Cache.keepeven when the keep kept every row of the round. That copy is about 0.5 MB a stream a round on the CPU, inside the GPU's idle gap.commitandrunalready wrote the same conv row, logits and length, so a keep that drops nothing now returns early. A partial keep still restores, through a newtake().Checks on this head
zig fmt --check: clean.compile-metal-residency-hostandcheck-metal-prefill-rest-host: 14/14 steps. The two new state tests (a full-path keep leaves conv buffers, logits and length byte-identical with no copy; a partial keep still restores) compile here and run on a Mac with a GPU.test-lfm2,zig build testand the LFM3 exactness tool, which need a Metal device. We'll run them on an M5 Mac before landing.Receipt
Checklist