Add cross-attention accessor functions for AlignAtt streaming#3660
Open
danielbodart wants to merge 1 commit intoggml-org:masterfrom
Open
Add cross-attention accessor functions for AlignAtt streaming#3660danielbodart wants to merge 1 commit intoggml-org:masterfrom
danielbodart wants to merge 1 commit intoggml-org:masterfrom
Conversation
Add whisper_decode_with_state_and_aheads() which saves alignment head cross-attention data during decode, and whisper_state_get_aheads_cross_qks() to read the resulting tensor from state. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
whisper_decode_with_state_and_aheads()— same aswhisper_decode_with_statebut saves alignment head cross-attention data during decodewhisper_state_get_aheads_cross_qks()— reads the resulting cross-attention tensor from state, copying from GPU/backend to CPUThese enable external callers to implement AlignAtt-style streaming policies by accessing the cross-attention data that is currently only available internally via DTW timestamp computation.
Motivation
Building a streaming speech-to-text system that uses cross-attention analysis (AlignAtt) to decide when to stop decoding and emit partial results. The existing API only exposes DTW timestamps as a post-processing step via
whisper_full, but streaming requires access to the raw cross-attention data during manual decode loops.Details
whisper_decode_with_state_and_aheadscallswhisper_decode_internalwithsave_aheads=true, matching howwhisper_fullinternally enables attention head saving for DTWwhisper_state_get_aheads_cross_qksreturns a float pointer of shape[n_tokens × n_audio_ctx × n_heads], valid until the next call orwhisper_free_statedtw_token_timestamps=truein context params (same prerequisite as DTW timestamps)