[Perf] feat: (OffloaderV2, >5x thrpt↑) Support CUDA Graph and all weights offloading#24531
Open
xiaobao520123 wants to merge 1 commit intosgl-project:mainfrom
Open
[Perf] feat: (OffloaderV2, >5x thrpt↑) Support CUDA Graph and all weights offloading#24531xiaobao520123 wants to merge 1 commit intosgl-project:mainfrom
xiaobao520123 wants to merge 1 commit intosgl-project:mainfrom
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
Author
|
@fzyzcjy, @Hide-on-bushsh, @ping1jing2 Please take a look, thanks! |
1ddd97b to
5989c69
Compare
5989c69 to
14d74b5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Current implementation of
OffloaderV2has following issues and limitations:DeepSeekV2and MoE weights only. This is due to models must explicitly specify parameter names towhitelist_param_names_creatorto select which weights to offload.torch.compileare NOT supported or NOT correctly supported.To resolve these issues, I added a help function which can find all names of parameters to offload. Enhanced naming function allows more types of models to offload, such as
Densemodels. Moreover, inspired by [offloader] v2: Hide weight onloading latency via prefetching #29941, I implemented a N buffer pool plus a cross-event synchronization mechanism to support CUDA Graph and torch.compile.Briefly speaking, this PR contributes:
offloader_kwargs=ALL_MODEL_PARAMSwhen loading models.Modifications
.in parameter names to support models different from MoE.ALL_MODEL_PARAMSto support full model weights offloading.torch.compileforOffloaderV2.Accuracy Tests
Serve command:
python -m sglang.launch_server \ --model-path Qwen/Qwen3-8B \ --host 0.0.0.0 \ --port 8000 \ --tp 1 \ --enable-metricspython -m sglang.launch_server \ --model-path Qwen/Qwen3-8B \ --host 0.0.0.0 \ --port 8000 \ --tp 1 \ --enable-metrics \ --offload-group-size 4 \ --offload-num-in-group 1 \ --offload-prefetch-step 1Test command:
Result:
Speed Tests and Profiling
Test environment
Hardware
Software
0.5.10.post2.dev974+ge5df44d5fOffload Configurations
deepseek-ai/DeepSeek-V2-Lite(MoE, 27 layers, 1 Dense, 26 MoE)cpu--offload-group-size 4--offload-num-in-group 1--offload-prefetch-step 2Baseline
(NOTICE): CUDA Graph, as well as piecewise CUDA Graph, is disabled because
OffloaderV2doesn't support it.python -m sglang.launch_server \ --model-path deepseek-ai/DeepSeek-V2-Lite \ --host 0.0.0.0 --port 8000 \ --tp 1 \ --context-length 4096 \ --chunked-prefill-size 2048 \ --piecewise-cuda-graph-max-tokens 2048 \ --enable-metrics \ --offload-group-size 4 \ --offload-num-in-group 1 \ --offload-prefetch-step 2 \ --offload-mode cpu \ --disable-cuda-graph \ --disable-piecewise-cuda-graphThis PR
python -m sglang.launch_server \ --model-path deepseek-ai/DeepSeek-V2-Lite \ --host 0.0.0.0 \ --port 8000 \ --tp 1 \ --context-length 4096 \ --chunked-prefill-size 2048 \ --piecewise-cuda-graph-max-tokens 2048 \ --enable-metrics \ --offload-group-size 4 \ --offload-num-in-group 1 \ --offload-prefetch-step 2 \ --offload-mode cpuBenchmark
python -m sglang.bench_serving \ --backend sglang \ --port 8000 \ --num-prompts 16 \ --max-concurrency {1, 2, 4, 8, 16} \ --dataset-name random \ --random-input-len 128 \ --random-output-len 128 \ --random-range-ratio 1.0 \ --profile \ --profile-output-dir [PLACEHOLDER] \ --output-file [PLACEHOLDER]Evaluation
Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ci