-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
[Bugfix] fix when skip tokenizer init #21922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The pull request aims to fix a crash when skip_tokenizer_init=True. The changes correctly guard against a None tokenizer in two places, preventing crashes during input validation and processing. However, the fix is incomplete and will still lead to a crash during output processing because detokenization is attempted without a tokenizer. I've identified this critical issue and suggested a more comprehensive fix to make the skip_tokenizer_init feature robust.
vllm/v1/engine/processor.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change correctly handles the case where allowed_token_ids are provided with skip_tokenizer_init=True. However, the PR is incomplete and will still lead to a crash in other common scenarios.
When skip_tokenizer_init=True, OutputProcessor is initialized with tokenizer=None. This will cause a crash in process_outputs when it tries to create a Detokenizer, which will raise a ValueError: Tokenizer not initialized. This happens even if the user sets detokenize=False in SamplingParams, because the default SamplingParams has detokenize=True. The test case in the PR description will trigger this crash.
Additionally, if bad_words are provided, they are silently ignored as update_from_tokenizer is skipped, but no warning or error is raised to the user.
To properly fix this, we should validate these unsupported parameter combinations when skip_tokenizer_init=True and raise an error, similar to how structured output is handled. A good place for these checks would be in _validate_params or at the beginning of this method (_validate_sampling_params).
For example:
if self.tokenizer is None:
if params.detokenize:
raise ValueError(
"Detokenization is not supported when `skip_tokenizer_init=True`. "
"Please set `detokenize=False` in `SamplingParams`."
)
if params.bad_words:
raise ValueError(
"`bad_words` is not supported when `skip_tokenizer_init=True`."
)Without this, the bug is not fully fixed and the feature remains partially broken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will cause a crash in process_outputs when it tries to create a Detokenizer, which will raise a ValueError: Tokenizer not initialized.
I don't think this is correct, may be getting confused with v0.
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels. Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging. To run CI, PR reviewers can either: Add 🚀 |
njhill
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @lengrongfu! Do you think you could also add a unit test?
I thought we had test coverage for this already but perhaps it was only for the V0 case...
76b0cee to
ffe0fe3
Compare
I add a unit test, can test this case. |
|
Can you merge from main to fix the CI failures? |
Signed-off-by: rongfu.leng <[email protected]>
ffe0fe3 to
dc047a7
Compare
Signed-off-by: rongfu.leng <[email protected]>
Signed-off-by: rongfu.leng <[email protected]> Signed-off-by: Jinzhen Lin <[email protected]>
Signed-off-by: rongfu.leng <[email protected]> Signed-off-by: Noam Gat <[email protected]>
Signed-off-by: rongfu.leng <[email protected]> Signed-off-by: Paul Pak <[email protected]>
Signed-off-by: rongfu.leng <[email protected]> Signed-off-by: Diego-Castan <[email protected]>
Signed-off-by: rongfu.leng <[email protected]>
Signed-off-by: rongfu.leng <[email protected]>
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.Purpose
Fix when set
skip_tokenizer_initafter can't running vllm.Test success.
Resolves #21846.
Test Plan
Test Result
(Optional) Documentation Update