Skip to content

Fix Whisper genai_config context_length using wrong config attribute#28600

Merged
kunal-vaishnavi merged 1 commit into
mainfrom
fix/whisper-context-length
May 21, 2026
Merged

Fix Whisper genai_config context_length using wrong config attribute#28600
kunal-vaishnavi merged 1 commit into
mainfrom
fix/whisper-context-length

Conversation

@jiafatom
Copy link
Copy Markdown
Contributor

Description

WhisperConfig does not have a max_length attribute. Accessing config.max_length falls back to the PretrainedConfig default (20) in some transformers versions, causing a runtime error:

RuntimeError: max_length (448) cannot be greater than model context_length (20)

Fix

Use config.max_target_positions (always 448 for all Whisper variants) instead of config.max_length for both context_length and search.max_length in the generated genai_config.json.

Testing

Verified that max_target_positions is correctly set to 448 for whisper-tiny, whisper-medium, and whisper-large-v3-turbo.

WhisperConfig does not have a max_length attribute. Accessing
config.max_length falls back to the PretrainedConfig default (20)
in some transformers versions, causing a runtime error:
  'max_length (448) cannot be greater than model context_length (20)'

Use config.max_target_positions (always 448 for Whisper) instead,
which is the correct decoder sequence length for all Whisper variants.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jiafatom jiafatom force-pushed the fix/whisper-context-length branch from c0af89c to 10fadda Compare May 20, 2026 18:55
@jiafatom jiafatom requested a review from kunal-vaishnavi May 20, 2026 18:55
@kunal-vaishnavi kunal-vaishnavi enabled auto-merge (squash) May 21, 2026 08:42
@kunal-vaishnavi kunal-vaishnavi merged commit 86aae8c into main May 21, 2026
107 of 113 checks passed
@kunal-vaishnavi kunal-vaishnavi deleted the fix/whisper-context-length branch May 21, 2026 09:51
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