transformers
b6688043 - [Whisper] Fix speculative decoding: preserve cleared suppress tokens through super().generate() (#48108)

Commit
3 days ago
[Whisper] Fix speculative decoding: preserve cleared suppress tokens through super().generate() (#48108) * [Whisper] Fix speculative decoding regression from #42702: preserve cleared suppress tokens PR #42702 changed _prepare_generation_config to always merge self.generation_config values with defaults_only=True. This broke Whisper speculative decoding because: 1. Whisper's generate() override calls _prepare_generation_config, then processes suppress_tokens/begin_suppress_tokens in _retrieve_logit_processors() (creating the logits processors and clearing both fields to None on generation_config). For speculative decoding, begin_suppress_tokens is also explicitly cleared to allow the assistant model to emit EOS. 2. Whisper then calls super().generate(generation_config=generation_config, ...). 3. Inside super().generate(), _prepare_generation_config is called again. Since suppress_tokens and begin_suppress_tokens are now None (== global default), defaults_only=True restores them from the model's generation_config.json. 4. _get_logits_processor then creates a SuppressTokensAtBeginLogitsProcessor that suppresses EOS (token 50257) at position 0 in the assistant model, preventing it from stopping — causing hallucinated extra tokens ("Thank you."). Fix: pass suppress_tokens and begin_suppress_tokens explicitly to super().generate() so the final update(**kwargs) step (no defaults_only) pins them at None, preserving the state set by _retrieve_logit_processors(). Fixes test_speculative_decoding_non_distil regression introduced by #42702. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * [Whisper] Add PR reference comment to speculative decoding workaround Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
Author
Parents
Loading