Repository navigation
[Perf][Cosmos3] Optimize I2V conditioning transfer (8.63% faster x-inference) - #4467
Conversation
Cosmos3 I2V B300 profile + optimization summaryProfile source: 1. Bottleneck split from the original torch trace
Rank-level split:
Compute-heavy kernels remain the top-level bottleneck:
2. Historical clean A/B runs, no torch profilerThese runs were used to decide where to spend implementation time. They are historical A/B numbers from the profiling branch, not all code changes in this PR.
3. This PR: patch-only comparison against latest upstream/mainSetup: 4x B300,
The identical MP4 SHA across upstream and patched runs confirms this change is lossless for the fixed seed/input smoke case. 4. Optimization points and status
5. Overall readoutThe main bottleneck is still GPU compute, especially CUDNN SDPA + GEMM. Communication is visible and rank-imbalanced, but at ~7% span it is not the first bottleneck. This PR lands the lowest-risk lossless fix found during the CPU/H2D audit: avoid full-video CPU materialization for Cosmos3 I2V conditioning and cache VAE normalization tensors. The remaining larger wins should come from attention/GEMM layout/backend work and a separate parallelism sweep. |
Losslessness check + optimized profile comparisonClarifying the optimization status first:
No quality-related knobs are included in this PR. The historical FP8/config A/B numbers in the previous comment were used for prioritization only; FP8 and other quality/numerical-risk changes are not part of this patch. Baseline commit vs optimized output qualityBaseline:
Commands used: ffmpeg -hide_banner -nostats \
-i upstream_46e0_cfg2_usp2_vae4/measured_2.mp4 \
-i patched_i2v_h2d_cfg2_usp2_vae4/measured_2.mp4 \
-lavfi psnr -f null -
ffmpeg -hide_banner -nostats \
-i upstream_46e0_cfg2_usp2_vae4/measured_2.mp4 \
-i patched_i2v_h2d_cfg2_usp2_vae4/measured_2.mp4 \
-lavfi ssim -f null -Optimized profile comparisonThis comparison uses the clean no-torch-profiler run with the lightweight diffusion pipeline profiler enabled. I am using this view because the original torch profiler was useful for attribution, but it also perturbs end-to-end latency. The low-level original trace still says compute is the main bottleneck; this PR targets the I2V CPU/H2D setup path.
Averaged view:
Readout: the optimized profile does not claim to solve the dominant attention/GEMM compute bottleneck. The measurable improvement is in the surrounding I2V conditioning / host-transfer path and stage overhead while keeping the generated video bit-identical to the baseline commit. |
Signed-off-by: david6666666 <530634352@qq.com>
3e5fd98 to
ef478f3
Compare
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
hsliuustc0106
left a comment
There was a problem hiding this comment.
I2V conditioning transfer optimization looks correct. Moving single frame to GPU with pin_memory before expanding avoids large pageable H2D copies.
|
@lishunyang12 @RuixiangMa ptal thx |
…ference) (vllm-project#4467) Signed-off-by: david6666666 <530634352@qq.com> Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
…ference) (vllm-project#4467) Signed-off-by: david6666666 <530634352@qq.com> Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com>
Summary
#4340
This PR adds a small lossless Cosmos3 I2V input-transfer optimization found while analyzing a 4x B300 Cosmos3 I2V profile.
[1, 3, T, H, W]on CPU and then issuing a large pageable H2D copy.The original trace still shows GPU compute as the primary bottleneck (attention + GEMM), so this PR intentionally keeps the code change scoped to the low-risk CPU/H2D path identified in the I2V conditioning setup.
Validation
python -m pytest tests/diffusion/models/cosmos3/test_cosmos3_pipeline.pypython -m ruff check vllm_omni/diffusion/models/cosmos3/pipeline_cosmos3.py tests/diffusion/models/cosmos3/test_cosmos3_pipeline.pypython -m ruff format --check vllm_omni/diffusion/models/cosmos3/pipeline_cosmos3.py tests/diffusion/models/cosmos3/test_cosmos3_pipeline.pypython -m compileall vllm_omni/diffusion/models/cosmos3/pipeline_cosmos3.py tests/diffusion/models/cosmos3/test_cosmos3_pipeline.pyB300 I2V smoke benchmark
Setup: 4x B300,
nvidia/Cosmos3-Nano, 1280x720, 189 frames, 35 steps, seed 1111,cfg_parallel_size=2,ulysses_degree=2,vae_patch_parallel_size=4, no torch profiler, lightweight diffusion pipeline profiler enabled.452d899a...452d899a...The output MP4 hash is identical across upstream and patched runs for the fixed seed/input.
Note:
ef478f38has the same code tree as the previously benchmarkedef478f38; it only adds the DCOSigned-off-by:trailer.Visual Evidence
GitHub-hosted comparison videos for the fixed seed/input smoke run. Both files are bit-identical (
sha256: 452d899ab8246e33415d27f8c1557551800eff0c06d7da1dfd9fb7b479483d46), matching the PSNR/SSIM check above.46e0b714ef478f38Release asset page: https://github.com/david6666666/vllm-omni/releases/tag/pr-4467-cosmos3-i2v-videos## Reproduction Commands
Baseline and optimized runs used the same request parameters. Run the serve command from the corresponding worktree/commit, then send the curl request below. The benchmark numbers in this PR used no torch profiler and kept only the lightweight diffusion pipeline profiler enabled.
Baseline worktree/commit:
cd /home/zjy/code/david/worktree/vllm-omni-cosmos3-i2v-b300-upstream-verify git checkout 46e0b714Optimized worktree/commit:
cd /home/zjy/code/david/worktree/vllm-omni-cosmos3-i2v-b300-compute-vae-opt git checkout ef478f38Serve command used for the optimized run, port
8012:Serve command used for the baseline run, port
8013:Curl command used for the optimized measured run:
For the baseline measured run, use the same curl command with port
8013and these output paths: