-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Core] implement disaggregated prefilling via KV cache transfer #6170
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
Summary of the measurement insight:
|
…lt. Much more realistic
A back-to-back comparison between chunked prefill and disaggregated prefill:
|
@KuntaiDu Why are some concurrency TTFT indicators reaching 5000-10000ms? Is it pending? But I feel that under 70b tp4, the qps on the H100 card should not be so low |
Yes, the requests are pending and that's why the TTFT is high. As for the QPS, let me double check. |
It is a nice work! However, I meet some problems in actual use. |
@KuntaiDu @MazarineGlacier Have you ever tested Disaggregated prefill vs normal version (without chunk prefill)? I tested P2D2 vs tp4 and found no benefit. Is this normal? |
In your case, disaggregate prefill will behave worse in TTFT. This is because default VLLM prioritizes prefill and tp4 has (less than) twice the compute capability during prefill than P2D2. I am not certain about TPOT/ITL though, that depends on the real batched tokens. After all, it is possible that no benefit is found. |
In our scenario, disaggregate prefill on TTFT/TPOP/ITL is much worse than TP4. I don’t know where the problem is, so I wonder in which scenarios disaggregate prefill will be beneficial. |
This paper might answer your question: https://arxiv.org/html/2401.11181v1. In this paper, when workload is too large on both prefill and decode, disaggregate prefill failed. |
Me too. But I did it on 4090. Maybe the overhead is too high without nvlink. |
Yes, I am studying the kv cache transmission overhead here. I see the author said it is about 30ms, which is definitely unacceptable. |
In our scenario, there is a barrier in the KV Cache transmission without nvlink, which makes TTFT and ITL (which includes TTFT) increase. |
@KuntaiDu In fact, I don't think it is necessary to do tolist operation for hash calculation, as follows: |
The NVLink or Infinityband is a must for disaggregated prefilling in order for it to be better than chunked prefill. The time delta allowed for data transfer is less than 50ms. |
There are several performance optimization opportunities I am not exploring yet. In the current implementation, the first token has been sampled twice, and the model input data is constructed twice. These overheads can be bypassed by engineering. and will be optimized after the implementation is stable. I am now working on an upcoming vllm performance post, will circle back to this right after that. |
Oh let me double check and fix it. |
I'm interested to build upon this implementation for faster kv cache transfer
|
@KuntaiDu I am very interested in this work. I found that currently only KV cache transmission with flash-attn backend is supported. Is there any plan to support xformers and flashinfer? |
Thanks for your work, I got a question, can I start like 6 prefill instances and 2 decode instances on 8 GPUs and how ? |
I meet a problem when I concat k and v tensor together for each layer to send and recv, Llama-2-7B output results will be random and uncorrect. Why does concating k and v lead to this result? |
Close this PR now (I did a large-scale refactor and it is now in #8498 ) |
Not implemented directly in the new PR but yeah, it is on the roadmap and will soon be implemented. |
Not sure about that thread. I skimmed their code and my implementation is lighter weighted and overhead is tolerable (though definitely will be larger). |
Deprecating this PR in favor of #8498 . |
This is a follow-up PR for #5557 .
Goal: implement disaggregated prefilling by launching 2 vllm instances (one for prefilling, one for decoding), and forward the KV cache from prefilling instance to decoding instance.
A rough roadmap:
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,LLM
class, 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.sh
to 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-required
and 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-required
label 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!