-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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] Support allowed_token_ids in v1 Sampler #13210
[v1] Support allowed_token_ids in v1 Sampler #13210
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 🚀 |
9b044a4
to
ee1d1a0
Compare
This pull request has merge conflicts that must be resolved before it can be |
3a5f408
to
1d7bcfc
Compare
cc @njhill Could you please take a look? |
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 @houseroad!
I have a few comments, mainly to keep the tensor manipulation on cpu and apply mask to the batch rather than individual rows.
Also you might want to take a look at #13360, I'm hoping to get that into shape soon and have all the sampling params like this encapsulated as vectorized logits processors.
@pytest.mark.parametrize("device", CUDA_DEVICES) | ||
@pytest.mark.parametrize("batch_size", [1, 2, 32]) | ||
@pytest.mark.parametrize("num_allowed_token_ids", [0, 1, 2]) | ||
def test_sampler_allowed_token_ids(device: str, batch_size: int, |
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.
Thank you for adding this test!!
This pull request has merge conflicts that must be resolved before it can be |
1793e7a
to
77c8db6
Compare
9c0d832
to
2bdd559
Compare
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 @lu-wang-dl for the updates, I think it's close, just a few more things.
sampling_metadata.presence_penalties, | ||
sampling_metadata.frequency_penalties, | ||
sampling_metadata.repetition_penalties, | ||
sampling_metadata.output_token_ids) | ||
sampling_metadata.output_token_ids, | ||
) |
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.
Same general comment, it's best not to include unrelated formatting changes, looks like there are a couple above and some in the other file.
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.
yeah, it's done by my VSCode, sorry.
I will be more cautious next time.
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.
okay, confirmed, actually it's done by the yapf in the pre-commit hooks. It forced me to do such change...
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 @houseroad looks great now, just one remaining thing.
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 again @houseroad!
444d719
to
7c63284
Compare
Signed-off-by: Lu Fang <lufang@fb.com> Complete the main logic for allowed_token_ids in v1 sampler Signed-off-by: Lu Fang <lufang@fb.com> lint the code Signed-off-by: Lu Fang <lufang@fb.com> Add boundary checks for allowed_token_ids Signed-off-by: Lu Fang <lufang@fb.com> address the comments Signed-off-by: Lu Fang <lufang@fb.com>
Signed-off-by: Lu Fang <lufang@fb.com>
Signed-off-by: Lu Fang <lufang@fb.com>
7c63284
to
60b4393
Compare
Signed-off-by: Lu Fang <lufang@fb.com>
Signed-off-by: Lu Fang <lufang@fb.com>
Follow the implementation in vllm/entrypoints/openai/logits_processors.py.
The idea is straightforward, adding a [batch_size x vocab_size] mask tensor, and leverage a list of bools to determine whether to do the inplace masked fill.
Test with