Skip to content

[diffusion] launch_server: accept pre-started scheduler workers - #8

Draft
OnePunchMonk wants to merge 1 commit into
mmgen-prespawn-schedulers-basefrom
mmgen-prespawn-schedulers
Draft

OnePunchMonk wants to merge 1 commit into
mmgen-prespawn-schedulers-basefrom
mmgen-prespawn-schedulers

Conversation

@OnePunchMonk

@OnePunchMonk OnePunchMonk commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Draft in my fork for discussion with the miles-diffusion maintainers before proposing it upstream. Context: radixark/miles_diffusion#310 (startup time).

Problem: on an sglang-d engine start, the server process imports torch, transformers, diffusers and sglang (about 35 to 40 s), then spawns the scheduler workers, which import the same stack again (another 35 to 40 s). The two imports run back to back.

Change: launch_server.register_prespawned_schedulers(factories) lets a caller start the workers first, before its own import, and register them. launch_server then hands each worker its args instead of spawning a new process. Without registration nothing changes.

Result (MiniMax-H3 t2va, 2x H200, measured through miles-diffusion, two runs each): engine boot from server spawn to healthy went from about 138 s to 104 s; the worker import overlapped the server import almost fully (worker import 2.2 to 39.8 s, server import 1.0 to 40.4 s), and the scheduler bound the moment the server started instead of 31 s later.

Notes:

  • Base branch here is sglang 571212b, the commit in the image I benchmarked on, not current main.
  • The caller side (starting the workers before importing sglang) lives in miles-diffusion; a CLI entry in sglang could do the same.
  • Forking the workers instead would avoid the second import entirely, but the server process already has CUDA initialized at that point (during imports), so fork is not an option today.
  • Tests: python/sglang/multimodal_gen/test/unit/test_launch_server_prespawn.py (2 passed).

CI States

Latest PR Test (Base): ❌ Run #38160090073
Latest PR Test (Extra): ❌ Run #38160089869
Latest PR Test (AMD ROCm 10): ❌ Run #38160090009

A scheduler worker spends most of its start-up importing torch, transformers,
diffusers and sglang, and the server process imports the same stack before it
spawns the workers, so the two imports run back to back. Callers can now start
the workers first and register them with register_prespawned_schedulers();
launch_server then hands each worker its args instead of spawning a new
process, and the imports overlap. Without registration nothing changes.
OnePunchMonk added a commit to OnePunchMonk/miles_diffusion that referenced this pull request Oct 11, 2026
…mports sglang

--rollout-prespawn-schedulers starts the scheduler workers in the sglang server process before its
own sglang import, so the workers' import of the same stack runs in parallel instead of after it.
Needs sglang's launch_server.register_prespawned_schedulers (OnePunchMonk/sglang#8); with an
sglang that lacks it the waiting workers are told to exit and startup falls back to the old path.
On H3 t2va (2x H200) engine boot went from about 138 s to 104 s.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant