Repository navigation
Commit 47dd4db
committed
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.1 parent c9b611d commit 47dd4db
2 files changed
Lines changed: 35 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4217 | 4217 | | |
4218 | 4218 | | |
4219 | 4219 | | |
4220 | | - | |
| 4220 | + | |
4221 | 4221 | | |
4222 | 4222 | | |
4223 | 4223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4811 | 4811 | | |
4812 | 4812 | | |
4813 | 4813 | | |
| 4814 | + | |
| 4815 | + | |
| 4816 | + | |
| 4817 | + | |
| 4818 | + | |
| 4819 | + | |
| 4820 | + | |
| 4821 | + | |
| 4822 | + | |
| 4823 | + | |
| 4824 | + | |
| 4825 | + | |
| 4826 | + | |
| 4827 | + | |
| 4828 | + | |
| 4829 | + | |
| 4830 | + | |
| 4831 | + | |
| 4832 | + | |
| 4833 | + | |
| 4834 | + | |
| 4835 | + | |
| 4836 | + | |
| 4837 | + | |
| 4838 | + | |
| 4839 | + | |
| 4840 | + | |
| 4841 | + | |
| 4842 | + | |
| 4843 | + | |
| 4844 | + | |
| 4845 | + | |
| 4846 | + | |
| 4847 | + | |
4814 | 4848 | | |
4815 | 4849 | | |
4816 | 4850 | | |
| |||
0 commit comments