You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pull request strengthens input validation for Whisper model token IDs and improves test coverage for these checks. The main focus is on ensuring that special token IDs (such as EOS and timestamp tokens) are within valid vocabulary bounds, preventing out-of-range errors during generation. Additionally, new unit tests are added to verify these validations.
Validation Improvements:
Added explicit checks in BeamSearchParameters::ValidateWhisperTimestampTokenId and TimestampLogitsProcessor::Process to ensure that eos_token_id, end_of_text_token_id, and timestamp token IDs are within the valid vocabulary range, throwing informative errors if not. [1][2]
Test Enhancements:
Introduced new unit tests in beam_search_test.cc to verify that invalid token IDs are correctly rejected and valid boundary values are accepted, including tests for out-of-range EOS and timestamp token IDs.
Added a TestSequences helper class and MakeTimestampProcessor factory function to facilitate testing of the logits processor.
Included necessary headers for new tests and processor usage. [1][2]
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Beam-search tests cannot compile because non-const span references bind to temporaries, and four timestamp-validation tests leave eos_token_id uninitialized, making validation unreliable.
This PR strengthens vocabulary-bound checks in ONNX Runtime’s Whisper generation code to reject invalid EOS and timestamp token IDs before unsafe score access.
Changes:
Adds EOS validation to Whisper beam-search parameters.
Checks end-of-text and sequence timestamp IDs during logits processing.
Adds tests for invalid IDs, valid boundary values, and unchanged scores on rejection.
The reason will be displayed to describe this comment to others. Learn more.
No blocking issues found in a bounded static review of the diff, Whisper parameter validation, timestamp logits processing, and added tests. The added EOS and sequence-token bounds checks precede the corresponding score writes; the tests include out-of-range values and a valid vocabulary boundary.
Validation scope: static inspection only; I did not build or run the tests or sanitizers.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
EOS validation tests omit negative IDs in both test paths and the accepted zero boundary in the parameter test, leaving lower-bound regressions undetected.
Both new EOS guards reject negative IDs, but the parameter and processor tests only exercise upper-bound failures, so removing either >= 0 check would go unnoticed. Add -1 to both invalid-EOS loops (including line 163) and cover 0 as an accepted lower boundary in the parameter test.
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
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.
This pull request strengthens input validation for Whisper model token IDs and improves test coverage for these checks. The main focus is on ensuring that special token IDs (such as EOS and timestamp tokens) are within valid vocabulary bounds, preventing out-of-range errors during generation. Additionally, new unit tests are added to verify these validations.
Validation Improvements:
BeamSearchParameters::ValidateWhisperTimestampTokenIdandTimestampLogitsProcessor::Processto ensure thateos_token_id,end_of_text_token_id, and timestamp token IDs are within the valid vocabulary range, throwing informative errors if not. [1] [2]Test Enhancements:
beam_search_test.ccto verify that invalid token IDs are correctly rejected and valid boundary values are accepted, including tests for out-of-range EOS and timestamp token IDs.TestSequenceshelper class andMakeTimestampProcessorfactory function to facilitate testing of the logits processor.