Repository navigation
[Bugfix] Reduce Cosmos3 and Wan VAE peak memory - #9424
Conversation
Release obsolete conditioning, cache, decoded-chunk and runner-output references at their last use while preserving async consumer ownership. Avoid full-size spatial-padding probes for internal channels-last decoder convolutions, retaining lossless, encoder and output-projection checks. Add focused lifetime and policy regressions and document the ownership and numerical contracts. Signed-off-by: rsteiger <rsteiger@nsc-lhr-slurm-1-vscode-02.nvidia.com>
Drop decoded tile references after packing and send buffers after gathering. Clear Wan causal history after the temporal tile loop, including failures, before concatenation and communication. Preserve gathered views and temporal dependencies. Add six regression cases that fail before the fix; all 14 focused tests pass. Document ownership. On the same four-GB300 tiled Cosmos3 workload, reserved peak falls from 12.717 to 11.742 GiB, with matching output hashes and no demonstrated latency change. Signed-off-by: rsteiger <rsteiger@nsc-lhr-slurm-1-vscode-02.nvidia.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
This PR appears to belong to: docs/design/module/diffusion/index.md. Module owners: @david6666666 @Isotr0py @princepride Routing: @david6666666 via module of the changed files, CODEOWNERS; @Isotr0py via module of the changed files; @princepride via module of the changed files @rahul-steiger-nv, please review your own changes and leave a short self-review comment describing what you checked. PRs without author self-review may not be assigned a reviewer. Please take a look when you have a chance. If you would like an automated review, mention @vllm-omni-review-bot in a comment. |
Omni ReviewBot: three questions on the performance claim@rahul-steiger-nv this PR reads as a performance or value claim:
Before the full evidence checklist, three short questions:
When you answer, the evidence that settles it is: base and head SHA, hardware, model, workload, warm-up and repeat count, mean or percentiles with their spread, and a correctness/quality-equivalence signal; an end-to-end claim also needs stage attribution. |
|
Thanks! The release points look safe to me, and keeping the probe on
|
Gather padded tiles only to the merging rank, preallocate raw Wan tile outputs, and release replaced history in normalization and output-convolution paths. Preserve causal history and blend/unpatchify/clamp ordering. Restore the decode helper header requested in review. Cover root-only allocation, real NCCL gathering and OOM recovery, temporal chunk release and exact output layout, and cache/probe lifetimes. Document the updated ownership rules. Signed-off-by: rsteiger <rsteiger@nsc-lhr-slurm-1-vscode-02.nvidia.com>
Signed-off-by: rsteiger <rsteiger@nsc-lhr-slurm-1-vscode-02.nvidia.com>
Signed-off-by: rsteiger <rsteiger@nsc-lhr-slurm-1-vscode-02.nvidia.com>
Signed-off-by: rsteiger <rsteiger@nsc-lhr-slurm-1-vscode-02.nvidia.com>
Signed-off-by: rsteiger <rsteiger@nsc-lhr-slurm-1-vscode-02.nvidia.com>
|
@princepride Thank you for the review. I updated the PR including the description. Would it be possible for you take another look at it? |
Contributor intent (required human answers)
1. What outcome do you want to achieve?
Lower the VRAM required for Cosmos3 generation
2. What is the highest-leverage variable for that outcome?
The lifetime of unused GPU buffers
3. How will this work move that variable?
Release buffers once they are no longer needed, reducing peak memory usage
4. Whose customer or user needs does this address, and what are those needs?
People who want to run Cosmos3 models with less VRAM.
Purpose
Reduce Cosmos3 memory by releasing obsolete conditioning, VAE cache/chunk references and delivered engine outputs while preserving consumer ownership. Internal
channels_lastdecoder padding probes are skipped; lossless, encoder andconv_outchecks remain.Distributed tiling now gathers only to rank 0, preallocates temporal tile output, and releases consumed tile/send/cache buffers. HCCL retains guarded
all_gatherfor compatibility. Temporal history and gathered views remain valid through decoding/merging. Reverted the unrelateddecode.pycopyright change.Test Plan
Cosmos3-Nano BF16, GB300 node
nvl72d037-T03, 1280×720, 189 frames, 35 steps, seed 42, guidance 6, flow shift 10; FA4, regional compilation, channels-last VAE, layerwise DiT offload. ARM64 Enroot v0.32.0rc1, PyTorch 2.13.0+cu130. Variants ran sequentially on the same node, each with 1 warmup + 3 measured requests. Allocated-memory/probe diagnostics ran separately.Test Result
Fresh full-PR comparison
Baseline
ad3a730e8→ head437ecb192. All results below are from the fresh rerun, with identical primed compiler kernels per topology and unchanged kernel-choice audits. The independent-autotuning trial was excluded because it selected different kernels.Single GPU, untiled attribution (CFG/Ulysses/VAE parallelism 1). Lifetime/buffer-only:
1287a65c5; probe-only:7eed6f2be. Cold means the first full-size request with cold VAE verdicts and a primed compiler cache.Lifetime/buffer fixes save 1.822 GiB steady allocated memory. Probe skipping mainly reduces first-use allocations and retained reservation; its steady allocated saving is only 1.85 MiB. The non-probe variant includes all current buffer fixes; distributed tile changes are inactive in this single-GPU case.
Four GPUs, tiled: CFG2 × Ulysses2, VAE tile parallelism 4, 256×256 tiles.
Reserved memory falls 2,522 MiB (18.65%). Repeating the baseline confirmed 13,522 MiB (median 24.199 s, range 24.191–24.242). No meaningful speedup is claimed. Non-root VAE allocated peaks fall to approximately 5.24 GiB; diagnostics verify actual tiled execution and zero non-root receive buffers, versus 2,080,899,072 bytes per rank before.
All compared raw BF16 VAE and returned float32 output hashes match; maximum error, MAE and RMSE are zero on this workload. Reserved memory is the reporting worker's PyTorch allocator pool, not total device VRAM; allocated peaks come from separate diagnostics.
Validation: 135 integrated CPU tests passed; final gather/backend suite 18 passed; real 2/4-GPU gather smoke passed. Targeted GPU tests: 16 passed, two FP16 posterior cases fail identically on baseline. CI selectors cover the added CPU and distributed tests; hosted execution is not claimed. Existing mypy errors remain; restored legacy copyright is the requested header-check exception.
AI assistance: Codex assisted with code, tests, documentation, and validation.
Need help on this PR? Tag
@codesmith-botwith what you need.