Skip to content

[diffusion] Plan component residency from calibrated warmup records (2/4) - #37917

Open
mickqian wants to merge 51 commits into
mainfrom
feat/residency-planner-solver
Open

mickqian wants to merge 51 commits into
mainfrom
feat/residency-planner-solver

Conversation

@mickqian

@mickqian mickqian commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator

Second of four stacked PRs split out of #35335. Base: the measurement layer. This layer is a library of pure functions: it plans, but nothing calls it yet.

What it adds

  • Candidate enumeration. collect_residency_targets lists every complete placement a component could take (resident, component offload, layerwise with N resident layers and M pinned layers) with its signed cost on each named resource: per-phase device headroom, transition-time headroom, host pin budget, host repack space.
  • Joint solve. plan_auto_residency picks one complete placement per component across all ranks' reports: consensus candidates, binding phase constraints, a VRAM reserve, latency-equivalence tie-breaks, backed by placement_budget.optimize_placement.
  • Sizing helpers for modules and layerwise managers (including _EstimatedLayerwiseManager for components that were never configured layerwise), the H2D-savings ranking the residency hint reuses, and the plan summary formatters.
  • host_memory_budget: HostPinBudget.release / for_local_worker, the pin reserve, storage-deduplicated tensor sizing. layerwise_offload: the layer byte estimation helpers the planner sizes unconfigured managers with.

Tests

test_placement_budget (the optimizer), test_host_memory_budget, and the solver tests in test_auto_residency (candidate frontiers, phase constraints, pins, consensus, promotions on GB10- and H100-shaped reports). All pure, no GPU.

Stack

  1. [diffusion] Measure warmup memory and layer usage per phase for residency calibration (1/4) #37916 — measurement and record types
  2. [diffusion] Plan component residency from calibrated warmup records (2/4) #37917 — planner as a pure library
  3. [diffusion] Apply, validate and roll back calibrated residency after warmup (3/4) #37918 — apply / validate / rollback wiring
  4. [diffusion] Auto residency: per-pipeline containment fixes and CI baselines (4/4) #35335 — per-pipeline containment fixes and CI baselines

Every layer's tree is a prefix of #35335's; the union is byte-identical to the original branch merged with main.


CI States

Latest PR Test (Base): ✅ Run #37804302290
Latest PR Test (Extra): ❌ Run #37804301772
Latest PR Test (AMD ROCm 10): ❌ Run #37804302462

mickqian and others added 2 commits September 4, 2026 11:00
…ency calibration

First of four layers split out of #35335. This layer only measures: it
records, during synthetic server warmup, what a residency planner needs
to decide a placement, and defines the record types that carry it.

- ComponentResidencyManager tracks a warmup phase key per stage setup /
  use / prefetch / full-weight transition and records the allocator peak
  and active components per phase (WarmupPhasePeak).
- The pipeline stages record their denoising iteration counts against
  the default workload (record_stage_iterations), and the perf metrics
  keep per-stage step timings.
- GPUWorker records one WarmupMemoryRecord per warmup request
  (LayerwiseUsageTracker counts per-layer uses while it runs).
- auto_residency.py carries the record/target/report types and the
  estimators that extrapolate a probe to the default workload (peaks per
  phase, layer uses per iteration, stage timings).
- The warmup request builder gains the full-shape calibration probe, its
  step floor, OOM degradation and --warmup-sampling-params; the gate that
  says whether a deployment can be calibrated lives in auto_tune.
- Control-request structs move from entrypoints/utils.py to
  entrypoints/control_requests.py (a pure move that later layers build on).

Planning, applying and validating a placement follow in the next layers.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Second of four layers split out of #35335: the planner as a library of
pure functions, with no runtime wiring yet.

- collect_residency_targets enumerates every complete placement a
  component could take (resident, component offload, layerwise with N
  resident layers and M pinned layers) with its signed cost on each
  named resource: per-phase device headroom, transition-time headroom,
  host pin budget, host repack space.
- plan_auto_residency solves the joint placement over all ranks'
  reports (consensus candidates, binding phase constraints, VRAM reserve,
  latency-equivalence tie-breaks), backed by placement_budget's
  optimize_placement.
- Sizing helpers for modules and layerwise managers, the H2D savings
  ranking used by the residency hint, and the plan summary formatters.
- host_memory_budget: HostPinBudget release/for_local_worker, pin reserve,
  storage-deduplicated tensor sizing; layerwise_offload: layer byte
  estimation helpers the planner sizes unconfigured managers with.

Applying, validating and rolling back a plan follow in the next layer.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
mickqian and others added 16 commits September 4, 2026 16:29
… in every loop

record_stage_iterations had to be called by hand inside 14 denoising
loops, each redoing the same arithmetic, and a new model that forgot it
silently fell back to "iterations == steps". Now PipelineStage records
the count itself after forward for warmup requests: a stage declares
default_workload_iterations(batch, num_inference_steps) once, the base
class evaluates it at the probe's step count (measured) and at the
default workload's (target).

- DenoisingStage: steps. Cosmos3 and MOVA: steps. DMD: the fixed distilled
  schedule length. MiniMax-H3: steps - 1. LTX-2 refiner: its distilled
  sigma table, which also retires the stage_target_num_inference_steps
  bookkeeping in batch.extra.
- Loops whose length is only known inside them (block-wise causal DMD,
  Helios chunks, SANA-WM refiners) keep the explicit call; an explicit
  record always wins over the formula.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…p_routing

The structs moved to entrypoints/control_requests.py in this layer, but
these two files kept importing them from entrypoints/utils.py: the
server failed to import and the unit-test collection errored.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ent supports

test_dp_routing's warmup fan-out and auto-residency merge tests exercise
the third layer's scheduler client; they return with it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ts' into HEAD

# Conflicts:
#	python/sglang/multimodal_gen/test/unit/test_dp_routing.py
…-measurements

# Conflicts:
#	python/sglang/multimodal_gen/test/test_utils.py
…ts' into feat/residency-warmup-measurements

# Conflicts:
#	python/sglang/multimodal_gen/test/unit/test_dp_routing.py
…-planner-solver

# Conflicts:
#	python/sglang/multimodal_gen/test/unit/test_dp_routing.py
mickqian and others added 8 commits September 6, 2026 13:40
…he bounded shape

The 2-rank IPC all-to-all caches staging buffers keyed by message size and
evicts by count only, so the full-shape probe left ~5 GiB of buffers sized
for 1280x720x81f behind on each rank; wan2_2_t2v_a14b_2gpu then served at
20.3 GiB allocated against main's 15.1 GiB with the same placement. Release
the staging cache together with the allocator pool before the request that
follows the probe.

Probe lightening also walked below the bounded warmup shape down to 16x16x1f,
which models reject; stop at the first shape at or below the smallest
measured record instead.
…ites around the warmup probe"

This reverts commit dddfc33.
Base automatically changed from feat/residency-warmup-measurements to main September 6, 2026 11:42
mickqian added 4 commits September 6, 2026 19:51
…r-solver

# Conflicts:
#	python/sglang/multimodal_gen/runtime/managers/memory_managers/auto_residency.py
#	python/sglang/multimodal_gen/runtime/managers/memory_managers/layerwise_offload.py
#	python/sglang/multimodal_gen/test/unit/test_auto_residency.py
@Jiminator Jiminator closed this Sep 14, 2026
@Jiminator
Jiminator deleted the feat/residency-planner-solver branch September 14, 2026 04:46
@alexnails
alexnails restored the feat/residency-planner-solver branch September 14, 2026 05:45
@hnyls2002 hnyls2002 removed the run-ci CI: run the baseline test suite on this PR label Sep 14, 2026
@hnyls2002 hnyls2002 reopened this Sep 14, 2026
@mickqian

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

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

diffusion SGLang Diffusion run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants