Repository navigation
fix(frontend): preserve per-item lengths in Whisper batches - #3918
Open
8079-debug wants to merge 1 commit into
Open
8079-debug wants to merge 1 commit into
8079-debug wants to merge 1 commit into
Conversation
Use each utterance's input length instead of the first item's so mixed-length batches report correct feature lengths. Cover batch ordering, padding, layout, and list/tensor length inputs with real frontend regressions.
This branch has not been deployed
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
WhisperFrontend.forward()passinginput_lengths[0]for every utterance instead ofinput_lengths[i].Type of change
Reproduction
For input lengths
[1601, 4321]and a hop length of 160, the expected feature lengths are[10, 27]. The existing code reports[10, 10]because it reuses the first utterance's length. Reversing the batch similarly reports[27, 27]instead of[27, 10].Validation
Tests were executed locally on Windows x64 / Python 3.13.3 using CPU tensors, with
torch==2.14.1+cu126,numpy==2.2.6,openai-whisper==20250625, andpytest==9.2.0.Red/green regression evidence
The same new test file was run against both versions:
e227484d98ca90aa829a0ae180731c9ee2e87e77, copied into an isolated temporary tree: 16 failed, 16 passed. All failures were the per-item length assertions for unequal-length batches; equal-length and single-item controls passed.The tests also check output shape, finite feature values, and agreement between each batch item and its standalone frontend result.
python -m compileall -q funasr examples testspython -m black --check tests/test_whisper_frontend_batch_lengths.pygit diff --checkUser impact
Mixed-length Whisper frontend batches return each utterance's own feature length rather than repeating the first item's length. The Mel feature computation and existing padding/trimming behavior are unchanged.
Notes for reviewers
The test loads the frontend directly and stubs only the FunASR import root/registration, avoiding unrelated model imports. Torch and Whisper operations are real; no model weights or external inference services are used. The test requires
pytest,torch, andopenai-whisper; it skips if the optional runtime packages are absent.These are local frontend regression results, not end-to-end ASR accuracy measurements or GPU inference validation. No CI workflow was changed.