-
-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[Bugfix] Fix #7592 vllm 0.5.4 enable_chunked_prefill throughput is slightly lower than 0.5.3~0.5.0. #7874
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
Conversation
|
👋 Hi! Thank you for contributing to the vLLM project. Once the PR is approved and ready to go, please make sure to run full CI as it is required to merge (or just use auto-merge). To run full CI, you can do one of these:
🚀 |
|
thanks for the contribution! please fix the format issue. |
|
I don't get it though, why this would affect chunked prefill so much 👀 |
|
Thanks for the fix! I have the same question as Kaichao. Why sorting running requests by their arrival time impacts the throughput significantly? |
|
Putting definitions and conventions aside first, let's discuss the pros and cons of chunked_prefill prioritizing scheduling prefill and prioritizing decoding.
So.Scenarios that favor priority scheduling of prefill are difficult to satisfy. In reality, when llm is deployed, the GPU memory is often limited, or max_num_batched_tokens and max_num_seqs are set too large, and preemption inevitably occurs. Priority scheduling decode can finish running tasks as soon as possible and release GPU memory, while priority scheduling prefill increases the number of tasks that are running at the same time, increasing the possibility of preemption. In short, when the GPU memory is limited, scheduling prefill first is Disaster, this is what I encountered.
Prioritize scheduling decode, As mentioned in the documentation, "It improves ITL and generation decode because decode requests are prioritized." Why sorting matters? Give an example init step 1: request 0: num_computed_tokens: 256, num_uncomputed_tokens 255 step 2: step 3: prioritizing scheduling decode (0.5.0~0.5.3 sorting matters |
|
by the way But you can't just reverse the running_queue, you need modify every self.running.extend or as i said 'The easiest fix is sort the running queue.' |
|
Add more It is also a normal performance tuning behavior to set max_num_batched_tokens and max_num_seqs slightly larger (to slightly trigger preemption), increase parallelism, and improve throughput. But prioritizing prefill causes and aggravate system thrashing. |
|
LGTM to add the sorting to get back to the behavior of 0.5.3. Please fix the format. |
|
Submit code to vllm for the first time. Is there anything else I need to do? |
|
as long as it does not break any tests, we can merge it. |
|
Thanks |
|
@noooop I think the issue is that after the refactoring, we should've changed the order of these lines to guarantee the ordering. Before the refactoring, the order was guranteed because we always sorted. Now we should more carefully extend the queue to preserve the right order. I think if we change the order to be The same behavior is preserved. can you test it? Note: without sorting, it may be difficult to always guarantee the right ordering when preemption happens, but I think that's the tradeoff |
|
more specifically, change these lines to can you try testing it and see if it works? |
|
We need to maintain the priority order of the queue. There are at least four methods to choose from. We can choose the best method from efficiency, readability, ease of use, scalability, and maybe minimal modification.
The following methods are not recommended
The performance bottleneck is in the GPU. I think there won't be much performance difference between Sorting and PriorityQueue, even manually maintaining queue order when inqueue. |
This may not be true especially for online serving which we are talking about a few millisecond ITL. In fact, Python overheads like these are the main performance bottleneck. We now even need to pre-allocate and reuse Python objects, use array.array, or add a branch for edge cases (e.g., do not call |
Also to be clear, we used this implementation originally for exactly this reason, but vLLM currently has python overhead, and that's why we removed the sorting logic that requires repetitive queue copy. Often times, model forward only takes 10-20ms overhead only, and having 2-3ms overhead in the scheduler is critical in this kind of scenario. (if we eventually support async scheduler, we can probably come back to this implementation) I think manual sorting is the best workaround. I am not opposed to use priority queue as well if it turns out that it has no perf impact. |
|
I understand that strict orderliness is not necessary. I'm testing to see if certain queues may need to be reversed. |
|
Actually I was implementing async scheduler and stumbled upon this bug |
|
It works, in fact I love is tradeoff . My own manual sorting method required too many changes, so I gave up. |
comaniac
left a comment
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.
LGTM. Thanks
|
this manual sorting comparison with 0.5.3 and sorting on 1,000 requests,scheduling sequence exactly the same |
|
Awesome to hear that! btw I don't know if basic correctness test failure is related. can you try merging the latest master? |
|
ok |
|
By the way I was implementing async scheduler. |
|
I don't know why the test failed. This pr is too simple to break anything. Or the test is set up based on the wrong scheduling method |
|
merg to the latest master Can anyone help me with the test? |
|
Can you give me some suggestions to pass the test. Can I delete test7? How? I can't find example.txt |
|
For this test, try making NUM_LOGPROBS contingent on fp8 dtype and set to 8 if e5m2 and something higher (16 or 32) for e4m3. |
|
If you can't fix it this way, you can mark that specific parameters for the test which fail (model type, dtype) as pytest.mark.skip("flakey test, see: #XXX") or create an issue and link to that and I can fix it in another PR. |
|
# We use float32 for probabilities and log probabilities. In Sampler float32 precise is is high enough. Can NUM_LOGPROBS be enlarged to achieve the original testing purpose? I choose to skip this test and let professionals solve it. |
|
@youkaichao @rkooo567 @comaniac Is it ready to launch? |
|
/ready |
|
thanks for the contribution! I triggered the test again, as long as the tests pass, we can merge it. |
[Bugfix] Fix vllm-project#7592 vllm 0.5.4 enable_chunked_prefill throughput is slightly lower than 0.5.3~0.5.0. (vllm-project#7874)
[Bugfix] Fix vllm-project#7592 vllm 0.5.4 enable_chunked_prefill throughput is slightly lower than 0.5.3~0.5.0. (vllm-project#7874) Signed-off-by: Alvant <[email protected]>
[Bugfix] Fix vllm-project#7592 vllm 0.5.4 enable_chunked_prefill throughput is slightly lower than 0.5.3~0.5.0. (vllm-project#7874) Signed-off-by: LeiWang1999 <[email protected]>
SUMMARY:
vllm 0.5.4 enable_chunked_prefill throughput is slightly lower than 0.5.3~0.5.0.
Prioritizing prefill causes and aggravate system thrashing.
FILL IN THE PR DESCRIPTION HERE
FIX #7592
by definition
The easiest fix is sort the running queue.
Keeping chunked prefill performance the untouched, everyone is happy.
BEFORE SUBMITTING, PLEASE READ THE CHECKLIST BELOW AND FILL IN THE DESCRIPTION ABOVE
PR Checklist (Click to Expand)
Thank you for your contribution to vLLM! Before submitting the pull request, please ensure the PR meets the following criteria. This helps vLLM maintain the code quality and improve the efficiency of the review process.
PR Title and Classification
Only specific types of PRs will be reviewed. The PR title is prefixed appropriately to indicate the type of change. Please use one of the following:
[Bugfix]for bug fixes.[CI/Build]for build or continuous integration improvements.[Doc]for documentation fixes and improvements.[Model]for adding a new model or improving an existing model. Model name should appear in the title.[Frontend]For changes on the vLLM frontend (e.g., OpenAI API server,LLMclass, etc.)[Kernel]for changes affecting CUDA kernels or other compute kernels.[Core]for changes in the core vLLM logic (e.g.,LLMEngine,AsyncLLMEngine,Scheduler, etc.)[Hardware][Vendor]for hardware-specific changes. Vendor name should appear in the prefix (e.g.,[Hardware][AMD]).[Misc]for PRs that do not fit the above categories. Please use this sparingly.Note: If the PR spans more than one category, please include all relevant prefixes.
Code Quality
The PR need to meet the following code quality standards:
format.shto format your code.docs/source/if the PR modifies the user-facing behaviors of vLLM. It helps vLLM user understand and utilize the new features or changes.Notes for Large Changes
Please keep the changes as concise as possible. For major architectural changes (>500 LOC excluding kernel/data/config/test), we would expect a GitHub issue (RFC) discussing the technical design and justification. Otherwise, we will tag it with
rfc-requiredand might not go through the PR.What to Expect for the Reviews
The goal of the vLLM team is to be a transparent reviewing machine. We would like to make the review process transparent and efficient and make sure no contributor feel confused or frustrated. However, the vLLM team is small, so we need to prioritize some PRs over others. Here is what you can expect from the review process:
action-requiredlabel on the PR if there are changes required. The contributor should address the comments and ping the reviewer to re-review the PR.Thank You
Finally, thank you for taking the time to read these guidelines and for your interest in contributing to vLLM. Your contributions make vLLM a great tool for everyone!