-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Core/DBO][1/N] Add Dual-Batch Overlap mechanism to VLLM #23693
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
[Core/DBO][1/N] Add Dual-Batch Overlap mechanism to VLLM #23693
Conversation
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Sage Moore <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Sage Moore <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Lucas Wilkinson <[email protected]>
Signed-off-by: Sage Moore <[email protected]>
…dbo-full-cudagraphs Signed-off-by: Sage Moore <[email protected]>
This pull request has merge conflicts that must be resolved before it can be |
I thought the Could it be a real problem? @elvircrn, @dougbtv
Edit: Confirmed it's picking up old binaries. |
Signed-off-by: Sage Moore <[email protected]>
…dbo-full-cudagraphs Signed-off-by: Sage Moore <[email protected]>
Hey! Quick question - do you have any performance numbers for this change? Mainly wondering about the efficiency of the communication-computation overlap strategy in the PR. |
ubatch_metadata = self._make_ubatch_metadata( | ||
ubatch_slices=ubatch_slices, | ||
attn_metadata=attn_metadata, | ||
input_ids=input_ids, | ||
positions=positions, | ||
intermediate_tensors=intermediate_tensors, | ||
inputs_embeds=inputs_embeds, | ||
compute_stream=compute_stream, | ||
dp_metadata=dp_metadata, | ||
batch_descriptor=batch_descriptor, | ||
cudagraph_runtime_mode=CUDAGraphMode.NONE) | ||
|
||
return self._capture_ubatches(ubatch_metadata, self.model) |
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.
I think we only have self.runnable
in this wrapper, no self.model
, right? Or am I missing something? Both L286 and L303
…2907) ### What this PR does / why we need it? 1. This pr bump vllm commit to vllm-project/vllm@6d8246a 2. fix upstream changes vllm-project/vllm#24548 abort multi-modal kwargs, make vllm main and `v0.10.2` both adaptable 3. fix metadata_builder changes introduced by vllm-project/vllm#23693 4. fix `structured_outputs_config` changes introduced by vllm-project/vllm#22772 5. fix `moe_config` changes introduced by vllm-project/vllm#22537 Co-authored-by: MengqingCao <[email protected]> Co-authored-by: Yikun Jiang <[email protected]> - vLLM version: v0.10.2 - vLLM main: vllm-project/vllm@c60e613 --------- Signed-off-by: wangli <[email protected]> Signed-off-by: MengqingCao <[email protected]> Co-authored-by: MengqingCao <[email protected]>
…llm-project#2907) ### What this PR does / why we need it? 1. This pr bump vllm commit to vllm-project/vllm@6d8246a 2. fix upstream changes vllm-project/vllm#24548 abort multi-modal kwargs, make vllm main and `v0.10.2` both adaptable 3. fix metadata_builder changes introduced by vllm-project/vllm#23693 4. fix `structured_outputs_config` changes introduced by vllm-project/vllm#22772 5. fix `moe_config` changes introduced by vllm-project/vllm#22537 Co-authored-by: MengqingCao <[email protected]> Co-authored-by: Yikun Jiang <[email protected]> - vLLM version: v0.10.2 - vLLM main: vllm-project/vllm@c60e613 --------- Signed-off-by: wangli <[email protected]> Signed-off-by: MengqingCao <[email protected]> Co-authored-by: MengqingCao <[email protected]>
…llm-project#2907) ### What this PR does / why we need it? 1. This pr bump vllm commit to vllm-project/vllm@6d8246a 2. fix upstream changes vllm-project/vllm#24548 abort multi-modal kwargs, make vllm main and `v0.10.2` both adaptable 3. fix metadata_builder changes introduced by vllm-project/vllm#23693 4. fix `structured_outputs_config` changes introduced by vllm-project/vllm#22772 5. fix `moe_config` changes introduced by vllm-project/vllm#22537 Co-authored-by: MengqingCao <[email protected]> Co-authored-by: Yikun Jiang <[email protected]> - vLLM version: v0.10.2 - vLLM main: vllm-project/vllm@c60e613 --------- Signed-off-by: wangli <[email protected]> Signed-off-by: MengqingCao <[email protected]> Co-authored-by: MengqingCao <[email protected]> Signed-off-by: Che Ruan <[email protected]>
…llm-project#2907) ### What this PR does / why we need it? 1. This pr bump vllm commit to vllm-project/vllm@6d8246a 2. fix upstream changes vllm-project/vllm#24548 abort multi-modal kwargs, make vllm main and `v0.10.2` both adaptable 3. fix metadata_builder changes introduced by vllm-project/vllm#23693 4. fix `structured_outputs_config` changes introduced by vllm-project/vllm#22772 5. fix `moe_config` changes introduced by vllm-project/vllm#22537 Co-authored-by: MengqingCao <[email protected]> Co-authored-by: Yikun Jiang <[email protected]> - vLLM version: v0.10.2 - vLLM main: vllm-project/vllm@c60e613 --------- Signed-off-by: wangli <[email protected]> Signed-off-by: MengqingCao <[email protected]> Co-authored-by: MengqingCao <[email protected]> Signed-off-by: Che Ruan <[email protected]>
@SageMoore @LucasWilkinson Could you provide some performance improvement data? I tested DeepSeek V2 Lite locally and observed a negative performance gain, with the per-step latency increasing from 38ms to 49ms. The process of launching vLLM and the test results are shown below. According to the Nsys profile data, after enabling DBO, the execution time of both kernel config.yaml: model: /path/to/DeepSeek-V2-Lite
tensor-parallel-size: 1
data-parallel-size: 2
enable-expert-parallel: true
served-model-name: vllm_infer_1
enable-dbo: true
dbo-decode-token-threshold: 4 launch vllm: export VLLM_ALL2ALL_BACKEND=deepep_low_latency
vllm serve --config config.yaml launch bench: vllm bench serve \
--model /path/to/DeepSeek-V2-Lite/ \
--served-model-name vllm_infer_1 \
--random-input-len 1 \
--random-output-len 1024 \
--num-prompts 1000 \
--max-concurrency 100 \
--ignore-eos |
Yes this is expected; DBO will increase the GEMM time when running a memory bound workload since the full model weights will have to be loaded twice (once for each microbatch). So DBO is only really beneficial when the communication time is >1x GEMM time; so it's really only intended to be used in multi-node EP setup where the communications costs are much higher. Its not expected to provide speed-up in a single node environment. |
Thank you for the explanation. The proportion of communication time I tested on the H20 is indeed very small, less than 10%. |
…t#23693) Signed-off-by: Lucas Wilkinson <[email protected]> Signed-off-by: Sage Moore <[email protected]> Signed-off-by: Lucas Wilkinson <[email protected]> Signed-off-by: yewentao256 <[email protected]> Co-authored-by: Lucas Wilkinson <[email protected]> Co-authored-by: Lucas Wilkinson <[email protected]> Co-authored-by: yewentao256 <[email protected]> Co-authored-by: Lucas Wilkinson <[email protected]> Co-authored-by: Robert Shaw <[email protected]>
…lap mechanism to VLLM vllm-project#23693
…t#23693) Signed-off-by: Lucas Wilkinson <[email protected]> Signed-off-by: Sage Moore <[email protected]> Signed-off-by: Lucas Wilkinson <[email protected]> Signed-off-by: yewentao256 <[email protected]> Co-authored-by: Lucas Wilkinson <[email protected]> Co-authored-by: Lucas Wilkinson <[email protected]> Co-authored-by: yewentao256 <[email protected]> Co-authored-by: Lucas Wilkinson <[email protected]> Co-authored-by: Robert Shaw <[email protected]> Signed-off-by: xuebwang-amd <[email protected]>
…t#23693) Signed-off-by: Lucas Wilkinson <[email protected]> Signed-off-by: Sage Moore <[email protected]> Signed-off-by: Lucas Wilkinson <[email protected]> Signed-off-by: yewentao256 <[email protected]> Co-authored-by: Lucas Wilkinson <[email protected]> Co-authored-by: Lucas Wilkinson <[email protected]> Co-authored-by: yewentao256 <[email protected]> Co-authored-by: Lucas Wilkinson <[email protected]> Co-authored-by: Robert Shaw <[email protected]>
Purpose
This PR adds support for Dual-Batch Overlap in VLLM. In it's current state it will only be abled when a user provides the --enable-microbatching flag. Furthermore, it will only be used when all DP groups are running full-decode batches. This PR supports running DBO with full cudagraphs, which is essential for minimizing the CPU overhead and getting performance from this feature.
To implement Dual-Batch Overlap (DBO), at a high level, we split the batch into two microbatches. Then using two threads and two cuda streams, one for communication and one for computation, to overlap the dispatch and combine all-to-all kernels of one microbatch with the compute kernels of the other microbatch.
When microbatching is enabled and supported, the GPUModelRunner will split the batch into two token_slices. These token_slices are then passed into the attention meta data builders during _prepare_inputs to generate one attention metadata object per-microbatch. When actually running the model, the model runner will spawn off two microbatching threads that will each communicate with each other using a UBatchContext. Each of these threads will then run self.model with the appropriate attention meta data.
Without any additional modifications to the code, this will just result in one microbatch running to completion before the other microbatch starts. In order to get overlaps, we've added a "yield" call that can be inserted into the all-to-all kernels to interleave the two microbatches. The yield_and_switch_from_compute_to_comm function yield the CPU from this thread (thread A) to the other microbatching thread (thread B). Once thread A has resumed execution, either because thread B yielded the CPU or finished it's execution, it will swap over to the communication stream and start dispatching kernels there. yield_and_switch_from_comm_to_compute behaves similarly but in the opposite direction. It swaps from the communication stream to the compute stream.
There are both GPU and CPU events to synchronize all of this. That being said, it is absolutely critical that only one microbatching thread is running at a time, meaning the other one is waiting on an event. It is also absolutely critical that both microbatches are running the exact same number of yields.
Test Plan
In general my test plan was to run lm_eval with
deepseek-ai/DeepSeek-V2-Lite
. We've also run numerous times with R1 in a multi node setup and verified that lm_eval produces reasonable output.Non-DBO Runs
Eager
Command
VLLM_ALL2ALL_BACKEND=deepep_low_latency vllm serve --model="deepseek-ai/DeepSeek-V2-Lite" --data-parallel-size 2 --enable-expert-parallel --enforce-eager
Result
Default
Command
VLLM_ALL2ALL_BACKEND=deepep_low_latency g2 vllm serve --model="deepseek-ai/DeepSeek-V2-Lite" --data-parallel-size 2 --enable-expert-parallel
Result
DBO Runs
Eager
Command
VLLM_ALL2ALL_BACKEND=deepep_low_latency g2 vllm serve --model="deepseek-ai/DeepSeek-V2-Lite" --data-parallel-size 2 --enable-expert-parallel --enforce-eager --enable-microbatching --microbatching-token-threshold 4
Result
Full cudagraphs
Command
VLLM_ALL2ALL_BACKEND=deepep_low_latency g2 vllm serve --model="deepseek-ai/DeepSeek-V2-Lite" --data-parallel-size 2 --enable-expert-parallel --compilation_config '{"cudagraph_mode": "full_decode_only"}' --enable-microbatching --microbatching-token-threshold 4
Result