Skip to content

[Whisper] Fix batch decode_with_timestamps in WhisperTokenizer.decode() - #47997

Merged
ydshieh merged 1 commit into
mainfrom
fix_whisper_integration_2
Aug 16, 2026
Merged

ydshieh merged 1 commit into
mainfrom
fix_whisper_integration_2

Conversation

@ydshieh

@ydshieh ydshieh commented Aug 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Continuation of #47995 ([Whisper] Fix integration test failures on A10G).

Fixes test_whisper_longform_single_batch, one of the 5 tests left in Group 5 of that PR as requiring changes outside the test file.


Why the test passed before PR #40936 (commit 05c0e1d390)

Before 05c0e1d390, the base class PreTrainedTokenizerBase.batch_decode iterated per-sequence, calling decode() once per sequence with a single 1D list of token ids. decode() in WhisperTokenizer therefore always received a 1D input, so both decode_with_timestamps=True and False worked correctly for both single and batch inputs.

Root cause

PR #40936 (commit 05c0e1d390, "rm slow tokenizers", Nov 27 2025) changed the base class batch_decode to pass the full 2D batch (list of token id lists) to decode() in one call instead of iterating per-sequence. decode() in WhisperTokenizer was partially updated to handle the 2D input:

  • ✅ The else branch (non-timestamp path) got isinstance(text, list) handling for _filter_timestamp_ids
  • ❌ The decode_with_timestamps=True branch was missed — it still calls _decode_with_timestamps(filtered_ids, ...) unconditionally

When batch_decode(decode_with_timestamps=True) is called with a batch, filtered_ids is now a list of lists. _decode_with_timestamps iterates over it and immediately hits token >= timestamp_begin where token is a list → TypeError: '>=' not supported between instances of 'list' and 'int'.

Bisect confirmed: parent commit 01c51596ec passes, 05c0e1d390 fails. First seen in CI on 2025-11-28 (the day after the commit landed).

Why only this one test is affected

decode_with_timestamps=True is used in exactly one integration test in the entire whisper test file — test_whisper_longform_single_batch (line 2348). All other tests use either:

  • output_offsets=True — the newer structured return format, a different code path entirely
  • Plain batch_decode(skip_special_tokens=True) — no timestamp decoding

The other 4 tests remaining in Group 5 of #47995 have completely unrelated root causes and are not addressed here.

Fix

Add the same isinstance batch check to the decode_with_timestamps branch that was already applied to the else branch: detect a 2D input and process each sequence individually.

if isinstance(filtered_ids, list) and filtered_ids and isinstance(filtered_ids[0], list):
    # batched input: process each sequence individually
    text = [
        self._decode_with_timestamps(seq, ...)
        for seq in filtered_ids
    ]
else:
    text = self._decode_with_timestamps(filtered_ids, ...)

Test

WhisperModelIntegrationTests::test_whisper_longform_single_batch — verified passing on runner (A10G, torch 2.13 / CUDA 13.0).

🤖 Generated with Claude Code

…er.decode()

PR #40936 (05c0e1d) made batch_decode delegate to decode() natively,
passing a 2D list of token ids. The decode_with_timestamps branch was not
updated to handle batched input, causing TypeError when >= compared a list
to an int. Add the same isinstance check already present in the else branch.

Fixes test_whisper_longform_single_batch (first failing in CI on 2025-11-28,
introduced by PR #40936 on 2025-11-27).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: whisper

@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@github-actions

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 31956662948:1
Result: success | Jobs: 16 | Tests: 181,622 | Failures: 0 | Duration: 17h 47m

@ydshieh

ydshieh commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator Author

Despite this touching a file outside the tests directory, the analysis shows the root cause and the fix is clearly necessary and correct. Merging directly.

@ydshieh
ydshieh merged commit 64b6595 into main Aug 16, 2026
113 checks passed
@ydshieh
ydshieh deleted the fix_whisper_integration_2 branch August 16, 2026 16:24
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.

2 participants