Skip to content

[Feat] diffusion: Plan reversible residency before warmup - #36703

Open
mickqian wants to merge 137 commits into
mick/diffusion-auto-residencyfrom
codex/diffusion-preload-residency-planner
Open

mickqian wants to merge 137 commits into
mick/diffusion-auto-residencyfrom
codex/diffusion-preload-residency-planner

Conversation

@mickqian

@mickqian mickqian commented Aug 27, 2026 •

Copy link
Copy Markdown
Collaborator

Why this change?

With --performance-mode auto, the first warmup in #35335 still starts from model/card defaults. An offloaded DiT may copy weights from CPU on every denoising step even when it fits on the GPU. The opposite shortcut is risky too: fitting the weights does not mean there is room for the activations of a full-size video. This PR uses checkpoint sizes to make an earlier placement decision without locking the deployment into it.

What changes at startup?

When What auto does
Before loading Read checkpoint weight sizes on each rank. Keep eligible native DiTs on GPU when the load budget allows; leave encoders and VAEs on their configured loading paths.
After loading, before the first forward Use actual module sizes to revise that initial choice. A DiT loaded on GPU can still be offloaded.
With a representative warmup Measure memory by execution phase and how often each layer group runs. Choose which components or layers to keep on GPU, offload the rest, and verify at most one adjustment. If validation rejects it, restore the previous placement.

The planner checks GPU memory and pinned CPU memory together: a layout that fits in VRAM is not usable if its offloaded layers exceed the host budget. Ranks in the same replica can use different shares of that budget; separate data-parallel replicas do not borrow from each other. Explicit placement choices still win. This is startup tuning for the warmup workload, not per-request replanning; use --warmup-sampling-params for a different production shape.

Evidence and trade-off

  • B200, Wan2.2 A14B NVFP4, 640×384, 17 frames, 12 steps: An earlier CI run kept both DiTs on GPU from load and moved the text encoder and VAE there after warmup. The consistency check passed; E2E was 2.74 s. This is a placement example, not a before/after speedup measurement.
  • RTX 5090, Turbo Wan2.1 1.3B: Keeping the DiT on GPU from load raised the recorded load-peak baseline from 928 to 3,810 MiB. Earlier residency can reduce weight transfers without reducing peak load memory.

Stacked on #35335. The base CI run for 9dfa5a5 did not pass; the B200 result above is from an earlier revision.


CI States

Latest PR Test (Base): ⏳ Run #47278031391
Latest PR Test (Extra): ⊘ Skipped -- add the run-ci-nv-extra label to opt in.
Latest PR Test (AMD ROCm 10): ⏳ Run #47278033291

Tip

Base CI only covers the core cases, and its workload may not exercise your change. Use /rerun-test to run the tests your change touches, or copy this prompt for an agent:

Find the registered tests this PR affects and run them with /rerun-test, following https://github.com/sgl-project/sglang/blob/main/.agents/skills/rerun-test/SKILL.md

Inventory selected component weights before loading and use them to seed a conservative resident set. The seed changes only ordinary component residency, so post-load planning can replace it before the first serving forward.

Run the same exact multi-resource placement solver after components are sized and again after one representative warmup. Each target state jointly obeys per-rank execution-phase VRAM, placement-transition scratch, per-worker HostPin, and host repacking headroom. The complete target frontier includes resident, component offload, and partial layerwise placements for DiTs, encoders, VAEs, lazy components, and two-stage pipelines.

Keep structural loading decisions such as explicit FSDP outside the reversible planner, cap normal calibration at one adjustment and one verification warmup, and retain bounded OOM recovery. Extend offline startup to use the same sequence and add exhaustive solver, lifecycle, rollback, multi-rank, custom-pipeline, and server-args coverage.
@mickqian

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Aug 27, 2026
@github-actions github-actions Bot added quant LLM Quantization blackwell SM100/SM120 labels Aug 27, 2026
The seed keeps native DiTs resident from load, so the load peaks of the
Wan2.2 A14B 2-GPU cases and the 5090 Wan/Turbo-Wan/FLUX.2-klein cases
rise accordingly (run 34131148154 at a330811); runtime peaks follow the
apply layer's refresh.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@mickqian

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

amd apple-silicon blackwell SM100/SM120 deepseek dependencies Pull requests that update a dependency file deterministic Issues on deterministic inference/kernels diffusion SGLang Diffusion documentation Improvements or additions to documentation hicache Hierarchical Caching for SGLang jit-kernel lora memory-pool model-gateway mthreads Multi-modal multi-modal language model npu piecewise-cuda-graph quant LLM Quantization run-ci CI: run the baseline test suite on this PR sgl-kernel speculative-decoding unified-radix-cache

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants