Repository navigation
feat(single-controller): run SGLang generation on the SingleController - #5282
Conversation
Signed-off-by: Shiki Wu <[email protected]>
yuki-97
left a comment
There was a problem hiding this comment.
Merge blockers — please rebase on main; the PR is 74 commits behind and the "Check if PR branch is up to date" job allows at most 10.
This lands SGLang generation on the SingleController with a clean ownership story: the handle is pickled into the actor with an explicit owner/copy split, so the unpickled copy never tears down the shared engines, and fault tolerance, fleet health and a refit deadline are refused at setup before anything is built.
The 20-step GB200 run and its metrics table in the description make the refit-from-the-copy behaviour easy to check: token_mult_prob_error stays flat across refits.
Scope: the SGLang pickling/ownership change, validate_settings, the new SC SGLang exemplar, the smoke and the unit tests, at 98fe644
Checked:
- pickled copy —
__getstate__drops only the loop thread and flips_owns_engines(sglang_generation.py:607–626); every method the SingleController actor and the SGLang synchronizer call on the copy reads intact state, and the driver instance keeps teardown (run_grpo_single_controller.py:245–255) - setup-time rejections — fault tolerance, fleet health and a refit deadline are refused in
validate_settings(sglang_generation.py:82–112) before any cluster or engine is built; the existing SC colocated, Gym and token-capture rejections cover the other unsupported SGLang cells - test doubles —
_owns_enginesis assigned at sglang_generation.py:124 before any__init__raise, so theobject.__new__double in test_config.py:196–201 still shuts down cleanly - smoke and exemplar — grpo_dp_single_controller_sglang.sh mirrors
grpo_dp_single_controller.shplus the legacytoken_mult_prob_errorgate and runsfastin the SGLang lane on H100 and GB200; the exemplar inherits the SC Megatron exemplar and overrides only the generation block andrefit_timeout_s
nit
- reusing the refit-deadline helper, which is the only place the deadline is enforced for SGLang on SC
- a tracking issue for the fault-tolerance follow-up
- a per-backend sub-list for the generation-backend bullet in the SC guide
- a nightly test for SC + SGLang, matching the legacy non-colocated SGLang nightly
Generated by Claude Code
…neration Signed-off-by: Shiki Wu <[email protected]>
…adline helper Signed-off-by: Shiki Wu <[email protected]>
shikicloud
left a comment
There was a problem hiding this comment.
Self review of this PR.
The design holds up:
- The owner/copy split matches
MegatronGeneration._owns_policyand is stricter than the vLLM/Dynamo copy: the copy never tears down shared engines. __getstate__overrides only two keys.- The
aclose/aclose_localsplit lets the copy close only its own client. - Unsupported settings are refused at setup by each backend's own
validate_settingshook, before anything is built.
yuki-97's 4 threads are all fixed as replied, and the rebase blocker is cleared (1 commit behind main).
Validation on GB200 at this commit: pre-commit and pyrefly clean; 2212 SC unit tests pass; 71 unmarked sglang unit tests pass, including the 3 new ones; the smoke passes 8/8 checks; the 90-step nightly passes 3/3. Not run: the --sglang-only unit tests and the legacy SGLang functional tests.
Inline comments:
- (C1) The guide names only the fault-tolerance requirement; it misses fleet health and
refit_timeout_s: null, so switching the default exemplar to SGLang fails at setup. - (C2) The pickling test's fake has no POST actors, so it cannot tell
aclose()fromaclose_local(); add one test. - (C3) Raise
NotImplementedErrorfor fleet health, like the other backends, and update the test. - (C4) Make
_owns_enginesa class default soshutdown()is safe on instances that never ran__init__. - (C5) The nightly recipe is not a synchronous "twin": it runs one version ahead.
Follow-up, outside this PR: _check_single_controller_config never calls the backend validate_settings. This already applies to vLLM and Megatron; worth a tracking issue.
Generated by Claude Code
Signed-off-by: Shiki Wu <[email protected]>
…neration Signed-off-by: Shiki Wu <[email protected]>
There was a problem hiding this comment.
Self-review of 0ce198e.
All 4 threads from yuki-97 and the 5 comments from the previous self-review (C1–C5) were re-checked at 0ce198e and are fixed; none needs another reply. The PR-description wording from C5 stays as is, on purpose.
The pickled copy keeps the engine, router and lock handles but cannot shut them down, as with MegatronGeneration._owns_policy. Setup calls validate_settings once before anything is built, so it refuses fault tolerance, fleet health and a refit deadline up front.
Inline comments: none. No finding from this round reached the posting bar.
PR description fixes (not inline, since the description is not in the diff):
- The Testing paragraph describes an older tree:
- "with main 5e27117 merged": head 0ce198e merges upstream main da067f1.
- "71 passed": 25322c2 added
test_client_copy_shutdown_keeps_the_shared_post_actors, and the reply on C2 reports 72. - "it ran before the last edits (a typing
cast, …)": the list stops at 243b72d. 25322c2 also changed the fleet-health error toNotImplementedError, made_owns_enginesa class default, and edited the docs line and the nightly recipe header. None of these changes the run; add them to the list.
Not blocking, follow-ups outside this PR:
- Setup sizes SGLang inference segments from
sglang_cfg.get("gpus_per_server", 1), a key no SGLang config sets. Onlycluster.segment_sizetopologies reach it. - The token-capture and NeMo-Gym backend checks keep their own lists of backend names;
validate_settingscould own them.
No tests were run for this review (no GPU or test environment on the review host). CI has not run on 0ce198e yet.
nemo-rl-review: kind=self harness=claude-code/2.1.331 model=claude-opus-5-5 effort=medium review-pr-team=v2 reviewed=0ce198e
|
/ok to test 0ce198e |
yuki-97
left a comment
There was a problem hiding this comment.
Thanks for resolving the comments from the previous round.
Scope: fix commits 243b72d through 0ce198e, checked against the open threads from the previous review, plus a scan of the changed files for new issues.
Checked:
- previous comments — the refit-deadline helper, the #5354 citation and the per-backend docs sub-list all hold at the head
validate_settings— the only SingleController entry point runs it before anything is built (setup.py:1834), and the legacy entrypoints never call it, so legacy fault-tolerance runs are not rejected- changes merged from main since the last pass — the refit actor rejects SGLang at setup, and the other new SingleController options are off by default or gated to backends other than SGLang
- CI at the head — the SingleController SGLang smoke passed its 8 metric checks, and the new pickling and setup tests ran and passed
nit
- a run of the new nightly on the one-node shape it declares
nemo-rl-review: kind=expert harness=claude-code/2.1.331 model=claude-fable-5-2 effort=medium review-pr-team=v2 reviewed=0ce198e
…neration Conflict: tests/unit/test_recipes_and_test_suites.py (nightly GPU-hour budget). Takes main's 5524; the next commit moves this branch's nightly out of nightly.txt, so the branch no longer raises the budget. Signed-off-by: Shiki Wu <[email protected]>
The nightly result in the PR description came from two 4-GPU GB200 nodes (4 trainer GPUs on one, two tp_size 2 engines on the other); the 1n8g shape the driver declared has not run. Rename the recipe and driver to 2n4g, set cluster 2 x 4, and list them in nightly_gb200.txt and nightly_mcore_gb200.txt instead of nightly.txt and nightly_mcore.txt. The nightly.txt GPU-hour budget is main's again. Signed-off-by: Shiki Wu <[email protected]>
…y-sglang Sync with NVIDIA-NeMo#5282 cb838df (main a03ffa1 merged, SC SGLang nightly renamed to 2n4g). Conflict in single_controller.py: main dropped the forest completeness check before the empty-step error; keep this branch's no_op_trainer guard on that error. Signed-off-by: Shiki Wu <[email protected]>
|
/ok to test cb838df |
…o feat/sglang-pd-disagg Conflicts with NVIDIA-NeMo#5282 (SGLang on the SingleController), now on main: - sglang_generation.py: validate_settings keeps main's SingleController checks and then refuses disaggregation; both sets of class defaults stay. - grpo.py: both import groups. Signed-off-by: Shiki Wu <[email protected]>
…elds validate_settings now runs the SingleController checks of NVIDIA-NeMo#5282 before it refuses disaggregation. Signed-off-by: Shiki Wu <[email protected]>
What and why
Problem. SGLang generation had never run under the SingleController (the SGLang item of #5044).
SingleControllerActor.remote(...)pickles the generation handle, andSGLangGenerationcarries an event-loop thread, a loop-boundhttpx.AsyncClientand the health-monitor thread (TypeError: cannot pickle '_contextvars.Context'). Split out of #5085, which keeps only the rollout-only simulator part.Change.
SGLangGeneration.__getstate__/__setstate__(theDynamoGenerationprecedent): the copy keeps the engine, router and lock actor handles and starts its ownAsyncLoopThread. It does not own the engines; itsshutdownreleases only its loop and HTTP client.HttpClient.__getstate__drops the loop-bound client;aclose_localcloses it without killing the shared POST actors.SGLangGeneration.validate_settingsrejects, before any engine starts, what the SC cannot honor with SGLang: fault tolerance (the health monitor would restart engines in the driver while the copy drives stale handles; tracked in SingleController: support SGLang fault tolerance #5354),generation_fleet_health.enabled(vLLM-only) and a non-nullgeneration_fleet_health.refit_timeout_s(SGLang cannot abort a refit; refused throughreject_unenforceable_refit_deadline).examples/configs/grpo_math_1B_sglang_single_controller.yaml: the Megatron SC recipe with the generation block ofgrpo_math_1B_sglang.yaml, non-colocated (1 trainer GPU + 1 SGLang engine GPU),refit_timeout_s: null.tests/functional/grpo_dp_single_controller_sglang.shinL1_Functional_Tests_SGLang.sh.grpo-qwen2.5-math-1.5b-instruct-2n4g-megatrontp1-sglang-noncolocated-single-controller(recipe and driver, listed innightly_gb200.txtandnightly_mcore_gb200.txt): the SC twin of the legacygrpo-qwen2.5-math-1.5b-instruct-2n4g-megatrontp1-sglang-noncolocatednightly, with 4 trainer GPUs on one node and two tp_size 2 engines on the other node's 4, 90 steps. Thenightly.txtGPU-hour budget is unchanged.grpo_sglang_async.shtrain/token_mult_prob_error < 1.05) and adds the SC gates ofgrpo_dp_single_controller.sh. Non-colocated, because SC colocation is Megatron-generation only.grpo_sglang_fault_tolerance_chaos.shIssues
Part of #5044 (SGLang generation on SC); does not close it. Follow-ups: SGLang fault tolerance on SC (#5354); the SC NeMo-Gym path still allows vllm/megatron only.
Convergence / perf / functionality proof
Smoke: GB200, one node,
grpo_math_1B_sglang_single_controller.yamlwith the smoke's overrides (Qwen3-0.6B, 2 prompts x 4 generations, 1 SGLang engine, Megatron TP1 on the second GPU), 20 steps.train/token_mult_prob_error, rangetrain/gen_kl_error, rangetrain/max_seq_mult_prob_error, maxtrain/num_masked_seqs_by_logprob_error, maxtiming/train/weight_syncs, meantiming/train/exposed_generations, mean of steps 2-20timing/train/total_step_times, mean of steps 2-20Legacy path, same branch:
grpo-qwen2.5-math-1.5b-instruct-1n4g-megatrontp1-sglang.yamlthroughrun_grpo.py, 3 steps,train/token_mult_prob_errormax 1.004.Nightly: driver
tests/test_suites/llm/grpo-qwen2.5-math-1.5b-instruct-2n4g-megatrontp1-sglang-noncolocated-single-controller.sh, 90 steps, on two GB200 nodes of 4 GPUs: 4 trainer GPUs on one, the two tp_size 2 engines on the other. The run was made before the rename, from the then-1n8g recipe withcluster.num_nodes=2 cluster.gpus_per_node=4, which is what the recipe now sets; the renamed files have not been rerun. The step-time bound is the legacy twin's. Non-colocated SGLang withtp_sizeabove 1 on a single node is not covered here and is tracked in #5438.train/token_mult_prob_error, mediantrain/token_mult_prob_error, step 90timing/train/total_step_times, mean of steps 2-90train/gen_kl_error, rangetrain/reward, mean of the first / last 10 stepstiming/train/weight_syncs, meantiming/train/exposed_generations, mean of steps 2-90Testing on GB200 on this branch's tree (with main 5e27117 merged): pre-commit and pyrefly 1.4.0 clean;
tests/unit/single_controller2212 passed; the unmarked tests undertests/unit/models/generation/sglang72 passed (after 25322c2); the new smoke passes its 8 checks. The nightly passes its 3 checks; it ran before the last edits (a typingcast, the 45 min limit with its budget number, the issue link in the error message; then, in 25322c2, theNotImplementedErrorfor fleet health, the_owns_enginesclass default, the docs line and the nightly recipe header comment), which do not change the run. The head then merged main a03ffa1 and renamed the nightly to 2n4g (cb838df); on that tree, on GB200:test_recipes_and_test_suites.py16 passed,config_cli.py minimize-checkof the renamed recipe clean, the dry run of the renamed driver reports 6 GPU-hours, the unmarked SGLang tests 72 passed, andtests/unit/single_controller/test_setup.py369 passed with 19 failures that are the same 19 on plain main a03ffa1 in my image (MOPD/OPD tests). The smoke and the nightly were not rerun on it. Not run locally: the SGLang-marked unit tests (--sglang-only) and the legacy SGLang functional tests, which train with Automodel; my image has neither environment.Needs upstream changes
None
PR commands and CI
CI:Lfast: the default for most PRs. Runs a fast test subset.CI:L1: dependency or container changes (pyproject.toml,uv.lock,Dockerfile) or broad core changes. Builds a new image and runs unit and functional tests.CI:docs: docs-only changes. Runs doc tests only./ok to test <full-commit-sha>: start CI for that commit. Post again after each push./review: automated review comments. Addmode=strictfor a stricter review,reset=truefor a fresh full review./resolve-conflict: Autobot mergesmaininto this PR and resolves the conflicts. PRs from forks must allow edits by maintainers./review-pr-team <pr-number>for a team review before you ask for human review.