-
-
Notifications
You must be signed in to change notification settings - Fork 7k
[TPU][V1] Add support for top-logprobs #17072
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: NickLucche <[email protected]>
Signed-off-by: NickLucche <[email protected]>
Signed-off-by: NickLucche <[email protected]>
Signed-off-by: NickLucche <[email protected]>
Signed-off-by: NickLucche <[email protected]>
Signed-off-by: NickLucche <[email protected]>
👋 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 🚀 |
sampler_out = self.sampler(logits, sampling_metadata) | ||
out_tokens = sampler_out.sampled_token_ids | ||
logprobs_tensors = sampler_out.logprobs_tensors | ||
return out_tokens, logprobs_tensors |
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.
please update the function's return type.
if sampling_metadata.all_greedy: | ||
out_tokens = torch.argmax(logits, dim=-1, keepdim=True) | ||
if sampling_metadata.logprobs: |
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.
dumb q: what's the reason of using logprobs given that we already use greedy sampling?
This PR implements top-logprobs support for TPU V1.
The main design decisions I've taken in this first version are:
Akin to what is happening on GPU, when a single request in the batch requires logprobs, the prob tensor is gathered for all requests in the batch (but only streamed back to those that need it).
a graph is generated for when the flag is off (no change from current) and another one when it's on.
model_config.max_logprobs
. Default is 20 as specified by the OpenAI API. Hence (when needed) this impl will gather the top 20 logprobs values, move the batched tensor to host and then slice off the needed ones with the same logic as in GPU.Benchmark+Compile time highlight: