Skip to content

Conversation

houseroad
Copy link
Collaborator

@houseroad houseroad commented Feb 13, 2025

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.

  • add test
  • move some verification in _get_allowed_token_ids_logits_processor to SamplingParam.

Test with

  • pytest tests/v1/sample/test_sampler.py
  • pytest tests/v1/worker/test_gpu_input_batch.py

Copy link

👋 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 fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

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 ready label to the PR or enable auto-merge.

🚀

@mergify mergify bot added the v1 label Feb 13, 2025
@houseroad houseroad force-pushed the v1_allowed_token_ids branch from 9b044a4 to ee1d1a0 Compare February 14, 2025 22:16
@houseroad houseroad changed the title Support allowed_token_ids in v1 Sampler [v1] Support allowed_token_ids in v1 Sampler Feb 14, 2025
Copy link

mergify bot commented Feb 16, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @houseroad.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@WoosukKwon
Copy link
Collaborator

cc @njhill Could you please take a look?

Copy link
Member

@njhill njhill left a 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.

Copy link
Member

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!!

Copy link

mergify bot commented Feb 19, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @houseroad.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Feb 19, 2025
@houseroad houseroad force-pushed the v1_allowed_token_ids branch from 1793e7a to 77c8db6 Compare February 19, 2025 05:39
@mergify mergify bot removed the needs-rebase label Feb 19, 2025
@houseroad houseroad force-pushed the v1_allowed_token_ids branch 3 times, most recently from 9c0d832 to 2bdd559 Compare February 19, 2025 06:56
Copy link
Member

@njhill njhill left a 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.

Copy link
Member

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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...

Copy link
Member

@njhill njhill left a 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.

Copy link
Member

@njhill njhill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @houseroad!

@houseroad houseroad closed this Feb 21, 2025
@houseroad houseroad reopened this Feb 21, 2025
@ywang96 ywang96 added the ready ONLY add when PR is ready to merge/full CI is needed label Feb 21, 2025
@houseroad houseroad force-pushed the v1_allowed_token_ids branch from 444d719 to 7c63284 Compare February 21, 2025 05:54
Signed-off-by: Lu Fang <[email protected]>

Complete the main logic for allowed_token_ids in v1 sampler

Signed-off-by: Lu Fang <[email protected]>

lint the code

Signed-off-by: Lu Fang <[email protected]>

Add boundary checks for allowed_token_ids

Signed-off-by: Lu Fang <[email protected]>

address the comments

Signed-off-by: Lu Fang <[email protected]>
Signed-off-by: Lu Fang <[email protected]>
@houseroad houseroad force-pushed the v1_allowed_token_ids branch from 7c63284 to 60b4393 Compare February 21, 2025 20:04
Signed-off-by: Lu Fang <[email protected]>
@DarkLight1337 DarkLight1337 merged commit bb78fb3 into vllm-project:main Feb 22, 2025
42 checks passed
Akshat-Tripathi pushed a commit to krai/vllm that referenced this pull request Mar 3, 2025
lulmer pushed a commit to lulmer/vllm that referenced this pull request Apr 7, 2025
shreyankg pushed a commit to shreyankg/vllm that referenced this pull request May 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready ONLY add when PR is ready to merge/full CI is needed v1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants