-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
[V1][Core] using cached vocab_size for Structured Outputs #14630
base: main
Are you sure you want to change the base?
Conversation
👋 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 🚀 |
self.vllm_config = vllm_config | ||
|
||
tokenizer = tokenizer_group.get_lora_tokenizer(None) | ||
self.vocab_size = len(tokenizer.get_vocab()) |
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.
Could use len(tokenizer)
, which is cached: https://github.com/vllm-project/vllm/blob/main/vllm/transformers_utils/tokenizer.py#L101
Or it might be better to use tokenizer.max_token_id
. I have seen cases where the vocab size is actually larger than the number of tokens in the tokenizer since some were removed.
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.
Will need @Ubospica confirmation here.
Will add tests once #14625 is merged |
8fa2aa6
to
a53c058
Compare
This pull request has merge conflicts that must be resolved before it can be |
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
689278a
to
8872481
Compare
Previously, we obtained vocab_size for xgrammar from hf_text_config directly.
However, in the recent version of xgrammar, the detected vocab_size now include special_tokens, in which raises the issue found in #14534
By calculating the vocab size, it ensures supporting custom tokenizers with the like of Olmo, etc.