Skip to content

feat: support Whisper token timestamps with beam search - #1816

Open
justsml wants to merge 24 commits into
huggingface:mainfrom
justsml:t3/whisper-timestamped-attentions
Open

justsml wants to merge 24 commits into
huggingface:mainfrom
justsml:t3/whisper-timestamped-attentions

Conversation

@justsml

@justsml justsml commented Oct 22, 2026 •

Copy link
Copy Markdown

Adds beam-aware attention ancestry and Whisper token timestamps. Depends on #1539; this draft targets main until the beam-search foundation merges.

Each returned hypothesis selects the attention rows that predicted its tokens, including the final prompt query and the row that predicts EOS. Short-form generation supports batches and multiple returned sequences. Public attentions retain raw per-step beam rows, with beam_indices and sequence_lengths describing the selected hypotheses. Internal attention and encoder/cache allocations are released on success and failure while caller-owned tensors are preserved.

Long-form seek requires one input and one returned sequence. Retaining attention history increases memory use with model size, beam count, and generated length.

This follows #1809's token-to-attention mapping and normalization order, with an independent reference implementation and its real-audio expected timestamps used for regression checks. Required seek bounds and resource cleanup overlap #1742 and #1755; those shared sections need reconciliation when the prerequisite fixes merge, rather than treating them as separate fixes supplied by this PR.

Validation:

  • Full workspace suite: 2,321 passed, 47 skipped, 33 suites passed.
  • Both packages and TypeScript declarations build; docs generation and changed-file checks pass.
  • Focused tests cover changing beam ancestry, early EOS, token-limit endings, cached/uncached decoding, multiple heads, prompt normalization, and comparison with the independent Fix Whisper word timestamps being one token late #1809 reference.

The revised alignment is CPU-validated. Earlier NVIDIA/Apple GPU runs used the previous alignment convention and are not claimed as numerical validation of this revision. AMD testing and fresh GPU alignment checks remain outstanding, so this PR remains a draft.

Changes specific to this follow-up.

Related PRs:

Related issues:

justsml and others added 24 commits April 27, 2026 19:00
…gface#1809

Preserve original prompt rows during normalization, align EOS and token-limit outputs through their predicting queries, and trim seek segments without retaining a discarded next query. Compare selected beam histories against the independent PR huggingface#1809 algorithm and update its real ASR goldens. Remove standalone benchmark scripts from the published patch while preserving local copies.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant