Reduce default-flash RAM by reusing BF16 projection scratch - #1030
Open
Mikyx-1 wants to merge 1 commit into
Open
Reduce default-flash RAM by reusing BF16 projection scratch#1030Mikyx-1 wants to merge 1 commit into
Mikyx-1 wants to merge 1 commit into
Conversation
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.
Default flash attention retains a full sequence-major projection history
after transposing it into the K/V buffers consumed by attention.
This change reuses BF16 projection scratch and reduces peak process RAM
while preserving the projection rounding and attention computation.
Fixes #1029
Implementation
Measured RAM effect
Peak RSS includes weights, KV caches, and inference working buffers.
These percentages describe the whole process, not model-weight compression.
For 270M, the projection allocation falls from 578.00 to 4.25 MiB.
Combined projection plus K/V allocations fall from 1,154.00 to 580.25 MiB.
Dormant virtual allocations are not counted as physical RAM savings.
Measured speed effect
Observed decode changes: +1.2% for 270M, -1.4% for 1B, +1.2% for 4B.
Prefill is essentially unchanged. The small measured speedups are tentative:
16-token decode intervals and few repeats do not establish statistical significance.
Measurement setup
ffc1abc; measured fixcaa2e13; Linux / Intel i5-12400F.--map 1in both versions.Validation and scope
scratch growth, retained sequence capacity, cache copying, and T5 storage.