Repository navigation
[Model Loading] Overlap checkpoint staging with CUDA graph capture during startup - #32017
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
@codex review |
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
3b71cb6 to
7206fe9
Compare
72c28fb to
c5753d9
Compare
…tup weight overlap Co-authored-by: Wenhui Zhu <[email protected]>
…ight commit Co-authored-by: Wenhui Zhu <[email protected]>
…e explicit Start checkpoint prefetch only after constructor work completes, so Scheduler and one_batch explicitly own the active lifetime. Replace broad exception handlers with fail-closed states and cleanup-only finally blocks. Co-authored-by: Wenhui Zhu <[email protected]>
…near Route overlap with explicit mode checks and remove failure-only cancellation plumbing. Startup failures already terminate Scheduler and one_batch, while successful finalization still joins prefetch before serving. Co-authored-by: Wenhui Zhu <[email protected]>
alexnails
left a comment
There was a problem hiding this comment.
do a look over on the comments and docstrings, other than that LGTM
…_mode a namespace
The ServerArgs namespace coverage lint landed after this branch was cut, so the
new field was missing its NS(...) marker. Use NS("model"), matching the other
weight-loading fields in the same block.
Co-authored-by: Wenhui Zhu <[email protected]>
Keep the storage-ordering and rollout constraints concise while preserving the reasons behind both invariants. Remove process-specific PR follow-up wording from the production comment. Co-authored-by: Wenhui Zhu <[email protected]>
|
Thanks @alexnails! I did another pass over the comments/docstrings and pushed the cleanup. The PR-related CI paths, including the overlap E2E test, are green. The only Base root failure was the upstream post-capture KV sizing CI regression, which was fixed after this run in #33847; the remaining Base failures are fast-fail cascades. Could you take one final look and refresh your approval when you get a chance? |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
Resolve the ServerArgs migration test conflict by preserving both the image processor backend coverage and startup weight-load mode coverage. Co-authored-by: Wenhui Zhu <[email protected]>
|
/rerun-failed-ci |
1 similar comment
|
/rerun-failed-ci |
…ring startup (sgl-project#32017) Co-authored-by: Wenhui Zhu <[email protected]> Co-authored-by: Alex Nails <[email protected]>
…ring startup (sgl-project#32017) Co-authored-by: Wenhui Zhu <[email protected]> Co-authored-by: Alex Nails <[email protected]>
Motivation
The native/default model-loading path currently finishes loading and post-processing the real weights before CUDA graph capture begins. For large checkpoints, checkpoint I/O and CUDA graph capture are both material parts of engine startup, but they run serially.
This PR introduces an opt-in startup path that stages safetensors checkpoint pages while the runtime initializes and CUDA graphs are captured. It then loads and post-processes the real weights in place, without changing the tensor storage referenced by the captured graphs.
The existing behavior remains the default:
This PR does not enable overlap by default.
Modifications
Startup flow
Existing serial startup
flowchart LR S1["Load and post-process<br/>real weights"] S2["Initialize runtime and<br/>capture CUDA graphs"] S3["Ready to serve"] S1 --> S2 --> S3Opt-in overlap startup
flowchart TB O1["Allocate final GPU storage<br/>and resolve safetensors shards"] O2["Initialize capture-safe weights<br/>and required post-processing"] O3["Explicitly start checkpoint prefetch"] O4["Storage-to-OS-page-cache staging"] O5["Initialize memory pools and attention backends<br/>and capture CUDA graphs"] O6["Load and post-process real weights<br/>in the existing storage"] O7["CUDA synchronize and verify storage identity,<br/>stop/join prefetch, and run the TP barrier"] O8["Ready to serve"] O1 --> O2 --> O3 --> O5 --> O6 --> O7 --> O8 O3 --> O4 O4 -. "runs concurrently" .-> O5 O4 -. "warms pages consumed by" .-> O6The overlapped work is checkpoint staging from storage into the OS page cache. Real checkpoint iteration, GPU weight commit, and post-load processing still happen after CUDA graph capture.
--startup-weight-load-mode {serial,overlap}, defaulting toserial.DefaultModelLoaderstartup lifecycle into model/storage initialization, checkpoint resolution, capture-safe initialization, and post-capture in-place commit.ModelRunner/TP-worker construction completes; scheduler startup andsglang.benchmark.one_batchexplicitly own the active lifetime.ModelRunnerand TP workers.--weight-loader-prefetch-checkpointsas an independent serial-path control and avoid starting a second prefetch when overlap already owns staging.Scope and rollout plan
This is PR 1 of a staged three-PR rollout. The overlap path is intentionally opt-in and explicitly gated here. Its initial supported scope is:
DefaultModelLoaderauto/safetensorsloading with mmap enabledUnsupported configurations raise an explicit error instead of silently changing startup behavior. The existing serial path remains unchanged.
Planned follow-ups:
autopolicy and make it the default after broader CI and benchmark burn-in. Validated configurations select overlap automatically; unsupported configurations retain the serial path, with an explicit serial escape hatch.Accuracy Tests
1e-5tolerance).sglang.benchmark.one_batchoverlap path on H100. A focused latest-code smoke produced identical serial/overlap input IDs, prefill logits, and decoded text through real decode CUDA graphs; this smoke is not used for performance claims.scripts/ci/check_registered_tests.py, Python compilation, formatting/lint, andgit diff --checkpass.Speed Tests and Profiling
Configuration: Qwen3-32B BF16 on H100, Triton decode CUDA graphs through batch size 256, prefill CUDA graphs disabled, three timed samples per configuration with A/B/C scheduled in Latin-square order, and warmed compiler/graph caches. Reported values are mean ± sample standard deviation. Checkpoint files were present on the local NVMe filesystem before timing; before every run,
POSIX_FADV_DONTNEEDwas applied andmincoreverified zero resident checkpoint pages. Prefetch used four threads per rank unless otherwise noted. These results were collected against commit0dbcd4199.Primary result: incremental overlap benefit
The primary comparison is B → C. Both configurations use the same coordinated page-cache prefetch mechanism; C changes the startup order so runtime initialization and CUDA graph capture occur before the real-weight commit. This is the closest measured control for the additional overlap benefit.
Across the refreshed local-NVMe configurations, overlap reduced startup by 8.6–11.7% relative to serial startup with coordinated prefetch. Each of the three paired B → C samples favored C for both TP1 and TP2. With three repeats per configuration, these results characterize the observed startup behavior but are not intended to establish tight statistical confidence.
A latest-code TP2 NFS rerun passed output parity but was excluded from the performance table because shared-storage contention made the samples unsuitable for a stable mean comparison: default-serial startup ranged from 148.70 to 1093.41 s, and overlap ranged from 53.72 to 118.67 s. No NFS speed claim is made from that run.
End-to-end context
For context, the complete opt-in path also includes the existing coordinated-prefetch gain:
Most of the A → C reduction comes from coordinated checkpoint prefetching. A → C describes the end-to-end opt-in startup path; B → C is the main result attributable to the new startup ordering. The sequential percentage reductions are not additive because they use different baselines.
These measurements do not establish monotonic scaling with TP size. TP1 and TP2 were measured in separate executions on different nodes. Matching eight aggregate prefetch threads on TP1 produced means of 43.25 s for B and 36.71 s for C, a 15.1% reduction (1.18x), compared with 11.7% (1.13x) on TP2 using four threads per rank, also eight aggregate threads. Each TP rank captures its own CUDA graph concurrently, so capture time is not summed across ranks. The results demonstrate a benefit at TP1 and TP2, but do not imply increasing percentage savings as TP rank grows.
Checklist
CI States
Latest PR Test (Base): ✅ Run #31526564021
Latest PR Test (Extra): ⏳ Run #32449179602
Latest PR Test (AMD ROCm 7.2): ➖ No AMD PR run found for this commit.