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
{{ message }}
Repository navigation
Generation crashes with encoder_repetition_penalty when encoder_outputs are provided without input_ids #49695
Using distributed or parallel set-up in script?: No
Who can help?
No response
Reproduction
importtorchfromtransformersimportAutoModelForSeq2SeqLMmodel=AutoModelForSeq2SeqLM.from_pretrained(
"hf-internal-testing/tiny-random-t5"
)
model.eval()
encoder_input_ids=torch.tensor([[3, 4, 5]])
withtorch.no_grad():
encoder_outputs=model.get_encoder()(
input_ids=encoder_input_ids,
return_dict=True,
)
# Reported to crash when encoder token IDs are unavailable.model.generate(
encoder_outputs=encoder_outputs,
encoder_repetition_penalty=1.5,
max_new_tokens=5,
)
Reported exception:
RuntimeError: index -100 is out of bounds for dimension 1 with size 1103
A related test using encoder_no_repeat_ngram_size=2 reportedly completes without the expected warning, and the intended encoder-side constraint appears not to be applied.
Providing the original input_ids alongside encoder_outputs allowed both configurations to complete in the investigated tests.
Expected behavior
When precomputed encoder_outputs are provided without the original encoder token IDs, generation should not pass sentinel values such as -100 to encoder-side logits processors.
The generation process should handle unavailable encoder token IDs gracefully, following the existing warning-and-ignore behavior where appropriate, rather than crashing or silently applying an ineffective constraint.
Thanks for your interest in this issue! I've already investigated the problem, implemented a fix, and submitted [PR #49696](#49696), which is now linked to this issue. Just wanted to let you know so we're aware of the existing implementation and can avoid duplicate work. Thanks!
Activity
akhil9tiet commentedon Oct 17, 2026
I'd like to work on this — please assign it to me.
kunalsanga commentedon Oct 17, 2026
Thanks for your interest in this issue! I've already investigated the problem, implemented a fix, and submitted [PR #49696](#49696), which is now linked to this issue. Just wanted to let you know so we're aware of the existing implementation and can avoid duplicate work. Thanks!
akhil9tiet commentedon Oct 17, 2026
No problem — thanks for flagging it. Withdrawing my claim; PR #49696 has the fix covered. Happy to review it if helpful.