Skip to content

[Refactor] Simplify BOS/EOS token handling#34435

Open
DarkLight1337 wants to merge 10 commits intovllm-project:mainfrom
DarkLight1337:sim-bos-eos
Open

[Refactor] Simplify BOS/EOS token handling#34435
DarkLight1337 wants to merge 10 commits intovllm-project:mainfrom
DarkLight1337:sim-bos-eos

Conversation

@DarkLight1337
Copy link
Member

@DarkLight1337 DarkLight1337 commented Feb 12, 2026

Purpose

  • Move Request.eos_token_id -> SamplingParams.eos_token_id, which is only populated if SamplingParams.ignore_eos is False.
  • Move get_bos_token_id and get_eos_token_id from InputPreprocessor to Renderer.
  • Remove unnecessary failbacks for accessing tokenizer.eos_token_id as it's a required field now.

Test Plan

Test Result


Essential Elements of an Effective PR Description Checklist
  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.
  • (Optional) Release notes update. If your change is user facing, please update the release notes draft in the Google Doc.

Signed-off-by: DarkLight1337 <[email protected]>
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the handling of BOS/EOS tokens by moving eos_token_id from Request to SamplingParams and centralizing the logic to get BOS/EOS token IDs into the Renderer. The changes are consistently applied throughout the codebase, including extensive updates to tests. This refactoring simplifies the code and removes unnecessary fallbacks, assuming tokenizer.eos_token_id is a required field. The implementation appears correct and improves code clarity. I have not found any issues with the changes.

Signed-off-by: DarkLight1337 <[email protected]>
Signed-off-by: DarkLight1337 <[email protected]>
Signed-off-by: DarkLight1337 <[email protected]>
Signed-off-by: DarkLight1337 <[email protected]>
@DarkLight1337
Copy link
Member Author

/gemini review

Signed-off-by: DarkLight1337 <[email protected]>
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a solid refactoring that simplifies token handling by moving eos_token_id from Request to SamplingParams and relocating BOS/EOS token retrieval methods to the Renderer. The changes are applied consistently across the codebase. However, I've identified a couple of issues related to the ignore_eos handling. The production scheduler logic in check_stop and the MockEngineCore in the test suite no longer respect the ignore_eos flag, which could lead to incorrect behavior and broken tests. I've provided suggestions to restore the previous, correct logic.

@DarkLight1337
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a well-executed refactoring that simplifies the handling of BOS/EOS tokens. Moving eos_token_id from Request to SamplingParams and centralizing token-related methods in the Renderer class are positive changes that improve code clarity and maintainability. The removal of unnecessary fallbacks for tokenizer.eos_token_id is also a good simplification. The changes have been applied consistently across the codebase, including extensive updates to the test suite, which demonstrates thoroughness. I have not found any issues of high or critical severity.

Signed-off-by: DarkLight1337 <[email protected]>
Signed-off-by: DarkLight1337 <[email protected]>
Signed-off-by: DarkLight1337 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kv-connector ready ONLY add when PR is ready to merge/full CI is needed structured-output v1

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants