Skip to content

[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

Merged
merged 3 commits into from
Mar 25, 2025

Conversation

houseroad
Copy link
Collaborator

@houseroad houseroad commented Mar 24, 2025

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

Signed-off-by: Lu Fang <lufang@fb.com>
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 Mar 24, 2025
@plops655
Copy link

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

@houseroad
Copy link
Collaborator Author

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

@plops655
Copy link

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.

@comaniac comaniac self-assigned this Mar 24, 2025
@comaniac
Copy link
Collaborator

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>
Signed-off-by: Lu Fang <lufang@fb.com>
@houseroad houseroad marked this pull request as ready for review March 25, 2025 07:16
@houseroad houseroad changed the title [v1][wip] Support long_prefill_token_threshold in v1 scheduler [V1] Support long_prefill_token_threshold in v1 scheduler Mar 25, 2025
Copy link
Collaborator

@comaniac comaniac left a comment

Choose a reason for hiding this comment

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

LGTM!
Also cc @joerunde @njhill

@comaniac comaniac added the ready ONLY add when PR is ready to merge/full CI is needed label Mar 25, 2025
@comaniac comaniac merged commit 082ab86 into vllm-project:main Mar 25, 2025
45 checks passed
wrmedford pushed a commit to wrmedford/vllm that referenced this pull request Mar 26, 2025
…ct#15419)

Signed-off-by: Lu Fang <lufang@fb.com>
Signed-off-by: Wes Medford <wryanmedford@gmail.com>
Comment on lines +155 to +158
if self.scheduler_config.long_prefill_token_threshold > 0:
num_new_tokens = min(
num_new_tokens,
self.scheduler_config.long_prefill_token_threshold)
Copy link
Member

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

Copy link
Collaborator

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

lengrongfu pushed a commit to lengrongfu/vllm that referenced this pull request Apr 2, 2025
lulmer pushed a commit to lulmer/vllm that referenced this pull request Apr 7, 2025
…ct#15419)

Signed-off-by: Lu Fang <lufang@fb.com>
Signed-off-by: Louis Ulmer <ulmerlouis@gmail.com>
nishith-fujitsu pushed a commit to nishith-fujitsu/vllm that referenced this pull request Apr 9, 2025
No Sign up for free to join this conversation on GitHub. Already have an account? No 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.

4 participants