Repository navigation
Conversation
The prefix attention path already concatenates the prefix K/V with the new
K/V for the attention:
all_k = ConcatModule({1}).build(ctx, *attention_prefix_key, k);
but the layer state only handed back the *new* K/V, so a caller that needs the
prefix state again has to rebuild the same concatenation itself.
DecoderAttentionPolicy::prefix_state_returns_full_kv makes the prefix path
return the concatenation it already built. The flag is off by default: the
existing prefix-state callers (yue2/ar_runtime.cpp, audio8_tts/ar.cpp)
concatenate the returned K/V themselves and would otherwise duplicate the
prefix.
Co-Authored-By: Deepseek v4.1-Flash
The fused depth runtime rebuilt the prefix state by concatenating the prefix K/V with the new K/V, which the decoder's prefix path had already concatenated for its own attention. A rocprof trace of the shipped build showed 648 concat_cont dispatches per audio frame, half of them redundant. The runtime now uses the concatenation the decoder hands back (prefix_state_returns_full_kv) as the next prefix state. Measured on gfx1101, interleaved A/B of the two binaries, q8_0, guidance_scale = 1.0, two rounds each: RTF 0.4757 -> 0.4641 (-2.4 %) and 36.13 -> 35.23 ms per AR frame (-2.5 %), with bit-identical output. Co-Authored-By: Deepseek v4.1-Flash
Owner
|
@apt-install-coffee Thanks! PR 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.
Streaming decoders that carry a growing K/V prefix either concatenate the prefix with the new K/V for attention, or write the new K/V into a preallocated cache. In the shared decoder, DecoderLayerModule::build casts the (post-RoPE) prefix and concatenates it with the new tokens on every prefix path but returned only the new K/V, so a caller that wants the accumulated K/V as its next state had to rebuild the same node.
Change is opt-in with DecoderAttentionPolicy::prefix_state_returns_full_kv so only the callers that want the accumulated state need to change.
Only callers that reach this path with a non-null prefix could benefit: breeze_tts's fused depth loop, and higgs's prefill-with-cache-view call. Only breeze_tts has been changed here, since it is the only one tested.