← Back to Pull requests

fix(rollout): stop on every EOS id in the model's generation config #9161

Closed
unknown closed this pull request without merging on Nov 24, 2026 11:34 UTC
View on GitHub
unknown unknown commented on Nov 24, 2026 07:33 UTC
Author

Fixes #9157.

Summary

HybridEngineRollout ended responses only on the tokenizer's eos_token_id, so a model whose generation_config lists more EOS ids (Qwen3, Llama 3.1) kept decoding past them to max_new_tokens. Every path now stops on the tokenizer's id and every id in generation_config.eos_token_id.

Changes

  • _eos_token_ids() returns the tokenizer's EOS id, then the generation config's ids, without duplicates or negative ids (generate() ignores a list that holds one).

  • The set replaces the tokenizer's id in _generation_kwargs (generate() and the ZeRO-3 stopping criterion), _pad_after_eos on the static path, _is_eos in both continuous loops, and every EOS check of _generate_graph. A single id is still passed to generate() as a scalar.

  • Docs: which ids end a response.
  • Behavior change: setting only tokenizer.eos_token_id to an id that never occurs no longer disables EOS when the generation config lists one; set generation_config.eos_token_id = None as well. The v1 test models now do.

    Tests

  • CPU: test_eos_token_ids_merge_tokenizer_and_generation_config (an id, a list, overlap, no config, a negative tokenizer id); test_continuous_rows_end_on_a_generation_config_eos_id; test_non_zero3_generation_stops_on_every_eos_id, replacing test_non_zero3_generation_uses_native_eos, checks that generate() gets the list and that a row ends at its first id of either kind.

  • GPU: test_every_path_stops_on_a_generation_config_eos_id on static, static graph, continuous and continuous graph, against generate() with the same generation config. All four cases fail on master.
  • Validation

    Hardware and software: 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.

    | Command | Result |
    |---|---|
    | pytest tests/unit/v1/test_hybrid_engine_rollout_v1.py (2 GPUs) | 50 passed, 1 skipped (opt-in pretrained test) |
    | pytest tests/unit/runtime/rollout | 195 passed, 3 skipped (two 4-GPU classes, one model download) |

    Reproduction on Qwen3-0.6B, fp32 greedy, with an extra EOS id the model generates midway: master generates the full 32 tokens on every path; this PR stops each row where generate() does (3, 32, 4, 14 tokens) on all four paths.

    Performance: one torch.isin over a few ids per step in place of an equality check; not measured separately.

    Compatibility matrix: single GPU and AutoTP 2 with ZeRO 0, fp32, on the paths above; ZeRO-3 is covered by the CPU tests of the stopping criterion, not on GPU.

    AI assistance

    This PR was written with AI assistance (Claude Code). The submitter reviewed every changed line and ran the tests above.

    Diff: 336 lines (+252 / -84) across 4 files Reviewer: delock Review duration: 241m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.65) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.65 · 336 lines diff across 4 files
    0.65
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.348
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.065
    Real PR Conversation Timeline
    1 comments
    "Review active on #9161"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 65.4% (HIGH) · Higher = larger blast radius
    65.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.8% · Safe to merge
    25.8%