transformers
083a0adc - Fix assisted decoding crash when the model returns no attentions (#51244)

Commit
4 hours ago
Fix assisted decoding crash when the model returns no attentions (#51244) * Fix assisted decoding crash when the model returns no attentions Assisted decoding (`assistant_model=...` or `prompt_lookup_num_tokens=...`) with `output_attentions=True` raised `IndexError: tuple index out of range` for any attention implementation that does not return attentions, including `sdpa`, the default for most models. The guard already intended to cover this case -- its comment reads "some (V)LLMs have hard requirement on SDPA and thus never return attn" -- but it only handled an `attentions` tuple populated with `None`s. `sdpa` returns an empty tuple instead, so indexing it raised before the `is not None` check could run. Every other decoding strategy only warns and returns empty attentions. The existing assisted-decoding tests force `_attn_implementation = "eager"` so that attentions are available, which is why the no-attentions path was never exercised. * remove test --------- Co-authored-by: Cyril Vallez <cyril.vallez@gmail.com>
Author
Parents
Loading