Skip to content

Conversation

@sethkimmel3
Copy link
Contributor

@sethkimmel3 sethkimmel3 commented Feb 25, 2025

The deepcopy introduced in #11637 adds a lot of overhead when adding a large number of requests to an llm_engine. This adds a more efficient method of copying the XGrammarLogitsProcessor data structure to remove that overhead.

cc: @mgoin @aarnphm

@github-actions
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.

🚀

Comment on lines 362 to 364
Copy link
Collaborator

Choose a reason for hiding this comment

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

should it be

Suggested change
if hasattr(self, 'token_bitmask') and self.token_bitmask is not None:
new_processor.token_bitmask = xgr.allocate_token_bitmask(
self.batch_size, self.config.vocab_size)
if hasattr(self, 'token_bitmask') and self.token_bitmask is not None:
new_processor.token_bitmask = self.token_bitmask

Copy link
Collaborator

@aarnphm aarnphm left a comment

Choose a reason for hiding this comment

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

one tiny comment, if it passes the tests then LGTM.

@aarnphm
Copy link
Collaborator

aarnphm commented Feb 25, 2025

@sethkimmel3 there are a few pre-commit problem can you fix this? thanks.

Signed-off-by: Seth Kimmel <seth.kimmel3@gmail.com>
Signed-off-by: Seth Kimmel <seth.kimmel3@gmail.com>
Signed-off-by: Seth Kimmel <seth.kimmel3@gmail.com>
Signed-off-by: Seth Kimmel <seth.kimmel3@gmail.com>
Signed-off-by: Seth Kimmel <seth.kimmel3@gmail.com>
@aarnphm
Copy link
Collaborator

aarnphm commented Feb 25, 2025

I cant update the title, but can you make it to [v0][Core] Use shared context to avoid copy overhead for offline engine

otherwise I think this should be ready to bring out of draft

@sethkimmel3 sethkimmel3 changed the title Replace xgrammar deepcopy [v0][Core] Use shared context to avoid copy overhead for offline engine Feb 25, 2025
@sethkimmel3 sethkimmel3 marked this pull request as ready for review February 25, 2025 18:49
@sethkimmel3 sethkimmel3 requested a review from mgoin as a code owner February 25, 2025 18:49
@sethkimmel3
Copy link
Contributor Author

Done and done @aarnphm!

@mgoin mgoin changed the title [v0][Core] Use shared context to avoid copy overhead for offline engine [v0][Core] Use xgrammar shared context to avoid copy overhead for offline engine Feb 25, 2025
@mgoin mgoin added the ready ONLY add when PR is ready to merge/full CI is needed label Feb 25, 2025
@aarnphm
Copy link
Collaborator

aarnphm commented Feb 25, 2025

Thanks. Once all PR pass we can merge this

@DarkLight1337 DarkLight1337 merged commit e206b54 into vllm-project:main Feb 26, 2025
56 of 58 checks passed
Akshat-Tripathi pushed a commit to krai/vllm that referenced this pull request Mar 3, 2025
…line engine (vllm-project#13837)

Signed-off-by: Seth Kimmel <seth.kimmel3@gmail.com>
lulmer pushed a commit to lulmer/vllm that referenced this pull request Apr 7, 2025
…line engine (vllm-project#13837)

Signed-off-by: Seth Kimmel <seth.kimmel3@gmail.com>
Signed-off-by: Louis Ulmer <ulmerlouis@gmail.com>
shreyankg pushed a commit to shreyankg/vllm that referenced this pull request May 3, 2025
…line engine (vllm-project#13837)

Signed-off-by: Seth Kimmel <seth.kimmel3@gmail.com>
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 structured-output

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants