-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
[V1] Support long_prefill_token_threshold in v1 scheduler #15419
New issue
Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “No 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? No Sign in to your account
[V1] Support long_prefill_token_threshold in v1 scheduler #15419
Conversation
Signed-off-by: Lu Fang <lufang@fb.com>
👋 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 🚀 |
I am confused as to whether this PR properly enables chunked prefill for v1. In the original issue, my understanding is that concurrent partial prefills are used only when chunked prefills are enabled. Also, within the original scheduler code, we made sure that prefills that are scheduled to finish so that these sequences are prioritized over unfinished prefills upon transitioning to decode stage. # Because multiple prefills may be running concurrently, we need to
# make sure that prefills which are scheduled to finish are listed
# before those that won't. This is so that on the next scheduling
# iteration when they have transitioned to the decode stage, they are
# properly prioritized over sequences that are still in the prefill
# stage.
self.running.extend(
self._order_finishing_prefills_first(
running_scheduled.prefill_seq_groups))
self.running.extend([s.seq_group for s in prefills.seq_groups]) in vllm/core/scheduler.py _schedule_chunked_prefill |
This PR is only for concurrent partial prefills, not for chunked prefill. The assumption is that v1 always has the chunked prefill, so no difference between prefill and decoding. Feel free to suggest any fix if something is wrong. :-) |
Thanks for responding. I have one more question I would be grateful to know, as I am relatively new to vLLM. In v0, chunked prefill is explicitly run in _schedule_chunked_prefill. This function creates a PartiallPrefillMetadata object for controlling the number of concurrent partial prefills, and batches both chunked prefills and decodes together. I do not see any explicit chunking happening in the v1 schedule() code, and was wondering if you could enlighten me as to how chunked prefill is the default in v1. |
Chunked prefill is the first class citizen in v1 scheduler so there's no explicit flag to configure it. There are some places you can observe this behavior:
|
Signed-off-by: Lu Fang <lufang@fb.com>
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.
…ct#15419) Signed-off-by: Lu Fang <lufang@fb.com> Signed-off-by: Wes Medford <wryanmedford@gmail.com>
if self.scheduler_config.long_prefill_token_threshold > 0: | ||
num_new_tokens = min( | ||
num_new_tokens, | ||
self.scheduler_config.long_prefill_token_threshold) |
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.
Just looking at this now.. small nit that this could be simplified slightly
if 0 < self.scheduler_config.long_prefill_token_threshold < num_new_tokens:
num_new_tokens = self.scheduler_config.long_prefill_token_threshold
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.
Good point. Fixed in #15307
…ct#15419) Signed-off-by: Lu Fang <lufang@fb.com>
…ct#15419) Signed-off-by: Lu Fang <lufang@fb.com> Signed-off-by: Louis Ulmer <ulmerlouis@gmail.com>
…ct#15419) Signed-off-by: Lu Fang <lufang@fb.com>
To address #14003
To support concurrent partial prefill, we need to define long_prefill_token_threshold. Then the tokens from different prefill requests can be added. Since there is no difference between prefill and decode, just need to control the token threshold.
pytest tests/v1/core/test_scheduler.py
e2e test: VLLM_USE_V1=1 pytest tests/v1/core/test_scheduler_e2e.py