-
-
Notifications
You must be signed in to change notification settings - Fork 11.6k
[V1] Entrypoints Test - Enable #14832
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
|
👋 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 🚀 |
| tokenizer = tokenizer_group.get_lora_tokenizer(None) | ||
| self.vocab_size = tokenizer.max_token_id + 1 | ||
| self.mask_size = max(tokenizer.max_token_id, | ||
| self.vllm_config.model_config.get_vocab_size()) |
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.
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.
but I'm definitely not confident in this ... I don't have a complete enough understanding of the factors involved here to know we're always getting the right value ...
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.
Do we need the +1?
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.
in the case that broke for me, get_vocab_size() returned the same as "max_token_id + 1".
There is another case, tested in CI, that needed the value "max_token_id" to work.
I'll probably run out of time today before I can get to the bottom of this properly...
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.
hmm, i think we should use len(tokenizer.get_vocab()) to calculate it eagerly
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.
I rebased on that and it’s still failing
| self._grammar_bitmask = xgr.allocate_token_bitmask( | ||
| self.vllm_config.scheduler_config.max_num_seqs, | ||
| self.vocab_size, | ||
| self.mask_size, |
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.
Is the bitmask applied to the logits?
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.
correct, applied here:
vllm/vllm/v1/worker/gpu_model_runner.py
Lines 869 to 914 in 270a5da
| def apply_grammar_bitmask( | |
| self, | |
| scheduler_output: "SchedulerOutput", | |
| logits: torch.Tensor, | |
| ): | |
| # Serialization of np.ndarray is much more efficient than a tensor, | |
| # so we receive it in that format. | |
| grammar_bitmask = scheduler_output.grammar_bitmask | |
| if grammar_bitmask is None: | |
| return | |
| # We receive the structured output bitmask from the scheduler, but the | |
| # indices of the requests in the batch may not match the indices of | |
| # the bitmask since the scheduler doesn't know how the gpu runner is | |
| # ordering the requests in the batch. We need to sort the bitmask to | |
| # match the order of the requests used here. | |
| struct_out_req_batch_indices: dict[str, int] = {} | |
| indices_match = True | |
| for req_id in self.input_batch.req_ids: | |
| mask_index = scheduler_output.structured_output_request_ids.get( | |
| req_id) | |
| if mask_index is None: | |
| # not a structured output request | |
| continue | |
| batch_index = self.input_batch.req_id_to_index[req_id] | |
| if batch_index != mask_index: | |
| indices_match = False | |
| struct_out_req_batch_indices[req_id] = batch_index | |
| if not indices_match: | |
| # Sort the bitmask to match the order of the requests | |
| sorted_bitmask = np.zeros_like(grammar_bitmask) | |
| for req_id, batch_index in struct_out_req_batch_indices.items(): | |
| orig_index = scheduler_output.structured_output_request_ids[ | |
| req_id] | |
| sorted_bitmask[batch_index] = grammar_bitmask[orig_index] | |
| grammar_bitmask = sorted_bitmask | |
| grammar_bitmask = torch.from_numpy(grammar_bitmask) | |
| # TODO: compatibility with spec decode | |
| xgr.apply_token_bitmask_inplace( | |
| logits, | |
| grammar_bitmask.to(self.device, non_blocking=True), | |
| indices=list(struct_out_req_batch_indices.values()), | |
| ) |
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.
It would make sense to me that this is the model vocab_size then, since then it matches the shape of the logits
|
This pull request has merge conflicts that must be resolved before it can be |
|
The tests passed in CI, though the change is very suspicious. It could use more analysis and a proper explanation of the right thing, but it's definitely better than it was ... I can try to dig into this for a proper explanation (and likely another change) to put this to bed for good next week |
Signed-off-by: [email protected] <[email protected]>
022159e to
ce6c82a
Compare
|
I rebased this on main. I THINK that all fixes necessary are in main and we're down to the one line that turns on the tests ... let's see what CI says |
|
Looks like @aarnphm ’s last fix for the xgrammar bitmask didn’t do the trick. |
|
replaced by #14903 |
SUMMARY: