Skip to content

[diffusion] CI: guard the anonymous-host budget alongside peak VRAM - #36051

Merged
mickqian merged 4 commits into
sgl-project:mainfrom
mickqian:test-host-anon-budget-guard
Aug 23, 2026
Merged

mickqian merged 4 commits into
sgl-project:mainfrom
mickqian:test-host-anon-budget-guard

Conversation

@mickqian

@mickqian mickqian commented Aug 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Peak-VRAM checks say nothing about the host budget. The live counterexample: merging a LoRA into layerwise-offloaded weights rewrites the checkpoint-mapping copy on write, turning the 61.7 GB DiT into anonymous host memory — every VRAM number stays green, host memory available reads 0.0 GiB, all pin plans collapse to zero, and a real 32 GB machine dies where CI passes.

This adds the host half of the budget guard:

  • A 1 s sampler thread in the worker tracks peak RssAnon (anonymous only — file-backed pages are droppable and not a budget cost; 1 s resolution is plenty for weight-sized, seconds-long growth).
  • MemorySnapshot carries peak_host_anon_mb; every existing capture point picks it up.
  • Baselines may declare load_peak_host_anon_mb / runtime_peak_host_anon_mb; the validator enforces them one-sided with the same shape as the VRAM caps (2% rel, 256 MiB pad). Scenarios without the fields skip the check, so adoption is incremental; records without host peaks (non-Linux) log and skip.
  • The 5090 H3 consumer case declares its 32 GiB pretend-host as the cap, so a LoRA-style anonymous blow-up now fails the case instead of passing silently.

Sampler verified live on Linux: a 300 MB allocation raises the reported peak by exactly 300 MB.

🤖 Generated with Claude Code

The guard's first catch, and the product fix

The first CI round failed the H3 consumer case at 65.9 GiB of host anon against the 32 GiB budget — a real defect, not a flaky test. The 5090 runner installs the runai streamer extra, whose reader was preferred even for host-bound loads; it materializes anonymous copies, so the whole 61.7 GB DiT bypassed the checkpoint mapping and every downstream budget (mapped gate, pinning) ran on nothing. Anyone who installed the streamer extra and followed the cookbook recipe would have hit the same thing on a real 32 GB machine.

The fix is in the loader, not the test: a load whose destination is the CPU now defaults to the mapped reader — mapped pages are the zero-copy optimum for host-bound weights, and the streamer's strengths (direct-to-GPU, remote streaming) do not apply there. An explicit use_runai_model_streamer=True still wins. No environment variable, and the recipe behaves identically however the wheel was installed.


CI States

Latest PR Test (Base): ✅ Run #32635190444
Latest PR Test (Extra): ❌ Run #32635190364
Latest PR Test (AMD ROCm 7.2): ⏳ Run #32635190460

Peak-VRAM checks say nothing about the host: merging a LoRA into
layerwise-offloaded weights rewrites the checkpoint mapping copy-on-write,
turning 61.7 GB into anonymous host memory while every VRAM number stays
green -- a real 32 GB machine dies where CI passes.

A 1 s sampler thread in the worker tracks peak RssAnon (anonymous only:
file-backed pages are droppable and not a budget cost). Snapshots carry
peak_host_anon_mb, baselines may declare load/runtime host budgets, and
the validator enforces them one-sided like the VRAM caps. Baselines
without the fields skip the check, so adoption is per-scenario; the H3
consumer case declares its 32 GiB world as the cap.

Co-Authored-By: Claude Fable 5 <[email protected]>
@github-actions github-actions Bot added the diffusion SGLang Diffusion label Aug 23, 2026
@mickqian mickqian added the run-ci CI: run the baseline test suite on this PR label Aug 23, 2026
mickqian and others added 3 commits August 23, 2026 18:48
…reamer

The mapped/pinned host economy is the thing under test. The 5090 runner
installs the runai streamer extra, whose loader bypasses the checkpoint
mapping and turns the whole DiT into anonymous copies -- 65.9 GiB of
host anon that the new budget check rightly failed. Pin the loader to
the mapping for this case, as every measured run of the recipe does.

Co-Authored-By: Claude Fable 5 <[email protected]>
A load whose destination is the CPU has one optimal reader: the mapped
safetensors file, whose pages are page cache the kernel can drop and
every host-memory budget downstream (layerwise offload, pinning, the
mapped-weight gate) assumes. When the runai streamer extra is installed
its reader was preferred even for these loads, materializing anonymous
copies instead -- on the 5090 CI runner the whole 61.7 GB DiT landed in
host anon and the new budget guard rightly failed the consumer case.
The streamer's strengths (direct-to-GPU, remote streaming) do not apply
to a local file headed for the CPU, so host-bound loads now default to
the mapping; an explicit use_runai_model_streamer=True still wins.

This is the product fix for what the guard caught: the recipe behaves
the same however the wheel was installed, with no environment variable.

Co-Authored-By: Claude Fable 5 <[email protected]>
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.

1 participant