Skip to content

feat(single-controller): SGLang rollout-only simulator (no_op train backend) - #5085

Open
shikicloud wants to merge 57 commits into
NVIDIA-NeMo:mainfrom
shikicloud:shikiw/sc-rollout-only-sglang
Open

shikicloud wants to merge 57 commits into
NVIDIA-NeMo:mainfrom
shikicloud:shikiw/sc-rollout-only-sglang

Conversation

@shikicloud

@shikicloud shikicloud commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor
  • I, the PR author, have personally reviewed every line of this PR.

What and why

Implement SGLang as the rollout backend of a single-controller simulator (rollout-only mode) for #4860, inspired by #4814.

examples/run_single_controller_simulator.py runs an SC recipe's rollouts with a GPU-free trainer stand-in (mode: rollout_only). This extends the simulator from #4914 to the SGLang generation backend from #5282. The native environment, SC pumps, TransferQueue data plane and sampler all run as they do in training.

The launcher takes two YAML files. --config selects the SC recipe and --simulator-config (default examples/configs/simulator/rollout_only.yaml) sets the simulator parameters. simulator.num_steps overrides max_num_steps and raises max_num_epochs when needed. The launcher disables validation for the run. SGLang loads the checkpoint from sglang_cfg.model_path, which the recipe sets to policy.model_name.

Design

  • NoOpTrainer replaces TQPolicy and bootstraps TransferQueue. The train pump consumes each selected chunk and skips logprob evaluation, advantage computation and microbatch training. The native math environment scores the generated rollouts in train/unfiltered_reward.
  • SGLangNoOpWeightSynchronizer pauses generation, flushes the KV cache, holds for refit_time_s and resumes generation. The hold stands in for the weight transfer. A finally block resumes the engines if the flush or hold fails. timing/train/weight_sync covers this sequence.
  • setup_single_controller(simulator=...) creates only the inference cluster. Setting simulator.num_nodes also sets sglang_server_config.num_gpus to the number of inference nodes times the inference GPUs per node.
  • The shared train pump calls simulate_train_step once after all chunks arrive. It holds for up to train_time_s while rollouts are in flight, records the idle time it skipped, then releases the buffer and advances the policy version as in training.

SGLang rollout-only uses the native SC environment path. Setup rejects sglang_server_config.pause_generation_mode: in_place because refit must clear the KV cache. It also rejects sglang_server_config.needs_offload: true because restoring offloaded weights requires a real refit. Simulator guide

Usage

uv run python examples/run_single_controller_simulator.py \
    --config examples/configs/grpo_math_1B_sglang_single_controller.yaml \
    --simulator-config examples/configs/simulator/rollout_only.yaml \
    simulator.num_steps=4 simulator.num_nodes=1 \
    simulator.train_time_s=10 simulator.refit_time_s=3 \
    policy.model_name=Qwen/Qwen3-0.6B \
    'policy.tokenizer.chat_template_kwargs={enable_thinking:false}'

# Reproduce the four-step smoke in the L1 SGLang lane.
bash tests/functional/grpo_dp_single_controller_rollout_only_sglang.sh

Track train/simulated_train_time_s, train/simulated_train_idle_skipped_s, timing/train/weight_sync, timing/train/exposed_generation and train/unfiltered_reward.

Issues

Part of #4860. The issue also tracks train_only and the no_op rollout backend.

Convergence / perf / functionality proof

On 8608d7cd, SC training and rollout-only each ran the same SGLang native math recipe for 20 steps on one GB200 node. Both used Qwen3-0.6B, four prompts per step, four generations per prompt and one SGLang GPU. The training run used Megatron TP1 on a second GPU.

SC + SGLang training rollout-only, train_time_s=10, refit_time_s=3
timing/train/exposed_generation s, mean of steps 2-20 0.730 0.758
timing/train/total_step_time s, mean of steps 2-20 6.53 3.78
timing/train/weight_sync s, mean 0.095 3.010
timing/train/policy_training s, mean of steps 2-20 2.03 0.00
train/simulated_train_idle_skipped_s, mean n/a 10.0
train/token_mult_prob_error, range 1.013 to 1.019 n/a
train/gen_kl_error, range 0.00051 to 0.00071 n/a
train/max_seq_mult_prob_error, max 1.026 n/a
train/unfiltered_reward, mean of 20 steps 0.119 0.138

The mean wait for generation differed by 28 ms per step. The simulated refit accounted for most of the rollout-only step time. With generation idle at the training boundary, the pump skipped almost all of the 10 s training hold.

On 7d18714045, the GB200 smoke passed all six metric checks across four steps with two prompts and four generations per prompt. It disabled Qwen thinking to fit the final answer in the 512-token context. Step rewards were 0.25, 0.00, 0.50 and 0.50, and the shortest weight-sync pause was 3.009 s. All 487 selected simulator, setup, entrypoint and train-pump tests passed.

Curves

curves_5085_round5

Needs upstream changes

None

PR commands and CI
  • CI label, exactly one:
    • 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. Add mode=strict for a stricter review, reset=true for a fresh full review.
  • /resolve-conflict: Autobot merges main into this PR and resolves the conflicts. PRs from forks must allow edits by maintainers.
  • Locally: /review-pr-team <pr-number> for a team review before you ask for human review.
  • Contributor guidelines

shikicloud and others added 8 commits October 26, 2026 04:15
…nly-simulator

Signed-off-by: Shiki Wu <[email protected]>

# Conflicts:
#	nemo_rl/algorithms/single_controller_utils/setup.py
#	tests/unit/single_controller/test_setup.py
Signed-off-by: Shiki Wu <[email protected]>
…imulator driver

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Shiki Wu <[email protected]>
…nly-simulator

Signed-off-by: Shiki Wu <[email protected]>

# Conflicts:
#	nemo_rl/algorithms/single_controller.py
#	nemo_rl/algorithms/single_controller_utils/setup.py
…4/C23/C24)

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Shiki Wu <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Nov 5, 2026
… docstrings and the head-node caveat in the guide

Signed-off-by: Shiki Wu <[email protected]>

@shikicloud shikicloud left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge state. GitHub reports this PR as conflicting with main. It is stacked on #4914. Please rebase once #4914 lands (or onto main) and resolve the conflicts.

Scope. This review covers only this PR's own commit 1d4e3a3 (git diff d9298f435..1d4e3a392). The #4914 part was reviewed on #4914.

PR description. It is still the empty template. Please fill in what the PR does, the linked issue, and the test plan (both new functional scripts and their results).

What works well.

  • The _owns_engines owner/copy split follows the same pattern as MegatronGeneration's _owns_policy, and the branching lives in one place.
  • __getstate__ drops only what cannot move between processes.
  • Rejecting fault tolerance both up front and in __getstate__ covers the config path and any other code that pickles the handle.
  • The no-op SGLang synchronizer keeps the real order — pause, KV cache flush, resume — so the measured refit pause matches a real one.

Evidence request (non-blocking). The guide now lists SGLang as supported on the SC for training. It would help reviewers to see a short reward and gen_kl_error curve for grpo_math_1B_sglang_single_controller.yaml next to the legacy grpo_math_1B_sglang.yaml, plus passing logs of grpo_dp_single_controller_sglang.sh and grpo_dp_single_controller_rollout_only_sglang.sh.

Inline comments.

  1. (C1) needs_offload: true leaves rollout-only SGLang engines without weights or KV cache.
  2. (C2) --num-nodes does not add SGLang engines.
  3. (C3) Move the SGLang fault-tolerance check into validate_settings.
  4. (C4) The guide's fleet-health line does not hold for SGLang.

Generated by Claude Code

Comment thread docs/guides/single-controller.md Resolved
…fore anything builds

- rollout_only rejects sglang_server_config.needs_offload=true: setup's
  finish_generation releases the engine memory and the no-op refit never
  restores it.
- --num-nodes also sets SGLang's sglang_server_config.num_gpus, since SGLang
  counts its engines from it rather than from the cluster.
- Move the SGLang fault-tolerance rejection from _build_generation into
  SGLangGeneration.validate_settings, which setup runs before any build, and
  reject async_rl.generation_fleet_health there too (SGLang has no worker
  group for it to track).
- Docs: fleet health is vLLM-only; list the new rejections.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Shiki Wu <[email protected]>
@terrykong terrykong added CI:L1 Run doctests, unit tests, and functional tests CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) and removed CI:L1 Run doctests, unit tests, and functional tests labels Nov 5, 2026
@shikicloud
shikicloud marked this pull request as ready for review November 12, 2026 07:01
@shikicloud shikicloud changed the title feat(single-controller): run SGLang generation under the SC and in the rollout-only simulator feat(single-controller): run SGLang generation on the SC and in the simulator Nov 13, 2026
@shikicloud shikicloud changed the title feat(single-controller): run SGLang generation on the SC and in the simulator feat(single-controller): SGLang rollout-only simulator (+ SGLang on SC) Nov 13, 2026
…' into shikiw/sc-rollout-only-sglang

Signed-off-by: Shiki Wu <[email protected]>

# Conflicts:
#	docs/guides/single-controller.md
#	nemo_rl/algorithms/single_controller_utils/simulator.py
#	tests/unit/single_controller/test_setup.py
#	tests/unit/single_controller/test_simulator.py
#	tests/unit/test_config_v2.py
…nly-simulator

Signed-off-by: Shiki Wu <[email protected]>

# Conflicts:
#	docs/guides/single-controller.md
#	examples/run_grpo_single_controller.py
#	nemo_rl/algorithms/single_controller_utils/utils.py
#	tests/unit/single_controller/test_entrypoint.py
…' into shikiw/sc-rollout-only-sglang

Signed-off-by: Shiki Wu <[email protected]>
@github-actions github-actions Bot removed the CI Relating to CI label Nov 26, 2026
@shikicloud

Copy link
Copy Markdown
Contributor Author

/ok to test 5bbe421

@shikicloud

Copy link
Copy Markdown
Contributor Author

/ok to test b03f76b

@terrykong terrykong removed the Documentation Improvements or additions to documentation label Nov 28, 2026
…nly-simulator

Conflict in examples/run_grpo_single_controller.py: main reworded one comment
in the setup code this branch moved to single_controller_utils/entrypoint_utils.py.
Kept the branch's file and carried the comment change over.

Signed-off-by: Shiki Wu <[email protected]>
@shikicloud

Copy link
Copy Markdown
Contributor Author

/ok to test 5ae4da9

@svcnvidia-nemo-ci svcnvidia-nemo-ci added complexity:medium Moderate change. Set by Autobot PR classify (skills/pr-classify) convergence-risk:none Cannot change training results. Set by Autobot PR classify (skills/pr-classify) proof:functionality Needs proof that it works. Set by Autobot PR classify (skills/pr-classify) labels Nov 29, 2026
@shikicloud

Copy link
Copy Markdown
Contributor Author

/ok to test 5410af0

…esolves

Review round on NVIDIA-NeMo#4914 (C33, C35, C36):

- simulator.num_nodes was written onto the resolved config dict, so keys the
  recipe computes from cluster.num_nodes (data_plane.simple.num_storage_units,
  Gym's num_processes) kept the recipe's node count. It is now set on the
  OmegaConf object before resolving, as a cluster.num_nodes override is.
- The load_format='dummy' error names the fix (set load_format=auto) instead
  of telling the user to drop an override the recipe may have set itself.
- Rename the train_backend value cpu to no_op, matching NoOpTrainer and
  NoOpWeightSynchronizer.

Signed-off-by: Shiki Wu <[email protected]>
…t-only-sglang

Carries the NVIDIA-NeMo#4914 review fixes (simulator.num_nodes applied before the recipe
resolves, cpu -> no_op). SGLang's num_gpus sizing moves with the node count
into apply_simulator_node_count.

Signed-off-by: Shiki Wu <[email protected]>
@shikicloud

Copy link
Copy Markdown
Contributor Author

/ok to test c2212e2

…mulator code

- validate_simulator_config reads token_capture.forest.enabled (renamed on
  main by NVIDIA-NeMo#5068) and names it in the message.
- NoOpTrainer no longer takes or holds policy_config; nothing reads it.
- Drop the unreachable uses_no_op_trainer early return in
  validate_simulator_config.
- Build the on_policy_distillation test config with keyword arguments.

Signed-off-by: Shiki Wu <[email protected]>
@shikicloud
shikicloud changed the base branch from shikiw/sc-rollout-only-simulator to main December 3, 2026 07:55
@shikicloud shikicloud changed the title feat(single-controller): SGLang rollout-only simulator feat(single-controller): SGLang rollout-only simulator (no_op train backend) Dec 3, 2026
@shikicloud

Copy link
Copy Markdown
Contributor Author

/ok to test 7d18714

@shikicloud shikicloud left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dcoapp recheck

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

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) complexity:medium Moderate change. Set by Autobot PR classify (skills/pr-classify) convergence-risk:none Cannot change training results. Set by Autobot PR classify (skills/pr-classify) proof:functionality Needs proof that it works. Set by Autobot PR classify (skills/pr-classify)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants