Repository navigation
perf: reuse lfm3_audio backbone head and prefill block graphs - #1136
Merged
Merged
Conversation
The text head and every prefill block graph were built and allocated on each call. The runtime now keeps the head graph, and a block's graph once the block repeats its row count at one cache capacity, so prompts of a repeated length save 0.3-0.5 ms per block; outputs do not change.
Owner
|
@ykhrustalev Thanks! All 3 PRs merged. |
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.
Problem
The
lfm3_audiobackbone built, planned and freed a new graph for the text head and for every prefill block (up to 256 rows) on each call. That host work costs 0.46-0.65 ms per block on an H100 and 0.26-0.32 ms on an M3 Ultra, even when the prompt length repeats.Solution
lfm3_audio.backbone.prefill.built_blocks, the block graphs each prefill builtTesting
lfm3_audio_backbone_teston CUDA, Metal and CPU: a secondlogits()call, and 15 prefills of 100, 300 and 512 rows across a capacity change, match fresh runtimes bit for bit, and the timing log shows the block graphs each prefill builds. Clean under ASan (CPU); breaking any of the keep, reuse or drop rules fails it.test_lfm3_audio_{parity,asr,tts,s2s}in F32 and Q8_0 on both hosts: stdout byte-identical to main's.LFM3_AUDIO_DUMP_DIR: the 3rd builds no block graph, and every dumped array, text and WAV is byte-identical to main's.lfm3_audio.backbone.prefill.ms, Q8_0, main → this PR. Medians over 16 requests per side, 8 per size when alternating, and 4 (H100) or 6 (M3 Ultra) for the 418 s file:build/bin/lfm3_audio_backbone_test --backend best build/bin/audiocpp_cli --family lfm3_audio --model LFM3-Audio-2B-GGUF/LFM3-Audio-2B-Q8_0.gguf \ --task asr --batch-audio-dir clips --log-file run.log # prefill.ms and prefill.built_blocks per requestRefs #1119