[BUG] HybridEngineRollout stops only on the tokenizer's EOS id, not on those in the model's generation_config
Describe the bug
HybridEngineRollout ends a response only on the tokenizer's eos_token_id. _generation_kwargs passes it to Hugging Face generate() as eos_token_id, which replaces the list in the model's generation_config, and _is_eos (both continuous-batching loops), the static graph decode loops and _pad_after_eos compare against the same single id. Many models list more than one EOS id in generation_config:
| Model | Tokenizer eos_token_id |
generation_config.eos_token_id |
|---|---|---|
| Qwen3-0.6B, Qwen3-4B, Qwen3-4B-Instruct-2507 | 151645 (<|im_end|>) |
[151645, 151643] |
| Llama-3.1-8B-Instruct | 128009 (<|eot_id|>) |
[128001, 128008, 128009] |
A row that ends with one of the other ids, such as Llama 3.1's <|eom_id|> (128008) after a tool call, keeps decoding to max_new_tokens. The response then holds tokens past the point where the model ended its turn, and an RL trainer scores and trains on them.
To Reproduce
Qwen3-0.6B, fp32 greedy, 4 prompts, max_new_tokens=32, on master at ccdc60d5c (no rollout changes since, through 039bfc9f3). The model rarely emits its second EOS id on short prompts, so generation_config.eos_token_id gets one more id, a token the model generates midway (" The", 576). Hugging Face generate() stops on it; every rollout path generates the full budget:
| Response lengths | |
|---|---|
Hugging Face generate() |
3, 32, 4, 14 |
Rollout, static (generate() with the tokenizer's id) |
32, 32, 32, 32 |
| Rollout, static graph | 32, 32, 32, 32 |
| Rollout, continuous | 32, 32, 32, 32 |
| Rollout, continuous graph | 32, 32, 32, 32 |
Expected behavior
Every path stops on, trims at and checks for any id in the union of the tokenizer's EOS id and the model's generation_config.eos_token_id, as generate() does without an explicit eos_token_id.
Environment
2× NVIDIA A100-SXM4-40GB (driver 595.71.05), PyTorch 2.14.1+cu130, CUDA 13.0, Python 3.12.15, Transformers 5.19.0.