Skip to content

feat: overlap NeMo Gym init with vLLM init in distillation - #2793

Merged
yuki-97 merged 5 commits into
mainfrom
mxin/nemo-gym-distill-fix
Jun 13, 2026
Merged

feat: overlap NeMo Gym init with vLLM init in distillation#2793
yuki-97 merged 5 commits into
mainfrom
mxin/nemo-gym-distill-fix

Conversation

@mxinO

@mxinO mxinO commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What does this PR do ?

align nemo-gym distillation with #2741

This PR ports the core NeMo-Gym startup ownership model from #2741 to distillation: the Gym actor is created inside distillation.setup(), spun up via _spinup(), and returned to the runner instead of being constructed in run_distillation_nemo_gym.py.

The current implementation overlaps deferred vLLM model load with NeMo-Gym startup, which fixes the removed health_check path and avoids runner-side Gym construction.

One remaining parity gap with #2741 is startup overlap with policy initialization. GRPO overlaps Gym startup with vLLM/policy initialization. For distillation, teacher policy setup is separate and should likely stay sequential/offloaded first, but student policy initialization can follow the GRPO pattern:

  • colocated: run vLLM -> student_policy sequentially in one task while Gym spins up concurrently
  • non-colocated: run deferred vLLM, student policy, and Gym concurrently

This is not required for functional correctness, but it would make distillation match the intended #2741 startup design more closely and reduce setup time.

Issues

List issues that this PR closes (syntax):

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you run the unit tests and functional tests locally? Visit our Testing Guide for how to run tests
  • Did you add or update any necessary documentation? Visit our Document Development Guide for how to write, build and test the docs.

Additional Information

  • ...

NeMo-Gym distillation needs the Gym actor to share the deferred vLLM server URLs produced during setup. Moving actor creation into distillation setup keeps the runner from constructing a second environment path and matches the setup-owned initialization used by GRPO-style NeMo-Gym flows.

Constraint: origin/main already contains the deferred vLLM load API

Rejected: Keep actor construction in the runner | duplicates setup responsibility and misses the overlapped vLLM/Gym initialization path

Confidence: high

Scope-risk: narrow

Tested: uv run ruff format --check on changed files

Tested: uv run --group dev pre-commit run --files examples/nemo_gym/run_distillation_nemo_gym.py examples/run_distillation.py nemo_rl/algorithms/distillation.py tests/unit/algorithms/test_distillation.py

Tested: uv run --all-groups focused distillation NeMo-Gym unit checks

Tested: Slurm qwen3-0.6B NeMo-Gym distillation functional smoke job 212974

Not-tested: full unit suite due local pytest/Ray fixture setup cost
Signed-off-by: Meng Xin <mxin@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@mxinO mxinO changed the title Initialize NeMo Gym inside distillation setup feat: Initialize NeMo Gym inside distillation setup Jun 12, 2026
…-fix

Signed-off-by: Meng Xin <mxin@nvidia.com>

# Conflicts:
#	examples/nemo_gym/run_distillation_nemo_gym.py
@mxinO mxinO changed the title feat: Initialize NeMo Gym inside distillation setup feat: overlap NeMo Gym init with vLLM init in distillation Jun 12, 2026
@mxinO
mxinO requested review from yfw and yuki-97 June 12, 2026 05:32
@mxinO
mxinO marked this pull request as ready for review June 12, 2026 05:33
@mxinO
mxinO requested review from a team as code owners June 12, 2026 05:33
@copy-pr-bot

copy-pr-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@mxinO mxinO added the CI:L1 Run doctests, unit tests, and functional tests label Jun 12, 2026
@mxinO

mxinO commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test

Comment thread nemo_rl/algorithms/distillation.py
mxinO added 3 commits June 12, 2026 17:40
Distillation now mirrors the GRPO NeMo-Gym startup config added with the release-image venv caching work. The Gym actor reads uv cache and venv locations from its global config, so relying only on actor runtime environment inheritance can still rebuild server venvs during spinup.

Constraint: NeMo-Gym consumes uv_cache_dir and uv_venv_dir from initial_global_config_dict.

Rejected: Rely on make_actor_runtime_env environment inheritance | the Gym server config path does not read these values from environment variables.

Confidence: high

Scope-risk: narrow

Tested: uv run --no-sync ruff format --check nemo_rl/algorithms/distillation.py tests/unit/algorithms/test_distillation.py

Tested: uv run --no-sync ruff check nemo_rl/algorithms/distillation.py tests/unit/algorithms/test_distillation.py

Tested: uv run --no-sync python -m py_compile nemo_rl/algorithms/distillation.py tests/unit/algorithms/test_distillation.py

Not-tested: pytest in this local worktree; torch is not installed in the local uv environment.
Signed-off-by: Meng Xin <mxin@nvidia.com>
The distillation startup path now mirrors GRPO by forwarding image-baked uv cache and venv paths into NeMo-Gym. Cover both default insertion and explicit user override preservation so future edits do not accidentally replace setdefault semantics.

Constraint: Reviewer requested parity with GRPO's NeMo-Gym release-image venv config path.

Confidence: high

Scope-risk: narrow

Tested: uv run --no-sync python -m py_compile nemo_rl/algorithms/distillation.py tests/unit/algorithms/test_distillation.py

Tested: uv run --no-sync ruff format --check nemo_rl/algorithms/distillation.py tests/unit/algorithms/test_distillation.py

Tested: uv run --no-sync ruff check nemo_rl/algorithms/distillation.py tests/unit/algorithms/test_distillation.py

Not-tested: targeted pytest; local uv environment lacks torch imported by tests/unit/conftest.py.
Signed-off-by: Meng Xin <mxin@nvidia.com>
…-fix

Signed-off-by: Meng Xin <mxin@nvidia.com>
@mxinO

mxinO commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test

@yuki-97 yuki-97 added 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 Jun 13, 2026
@yuki-97

yuki-97 commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

L1_Functional_Tests_Megatron_3 also fails in main L1_Functional_Tests_Megatron_3 and unrelated to this PR, so change to CI:Lfast to merge.

FYI @mxinO we can use CI:Lfast in general which is faster a lot than CI:L1 if there's no huge changes. (so that for new added functional tests we need to label "fast")

@yuki-97
yuki-97 enabled auto-merge (squash) June 13, 2026 07:37
@yuki-97
yuki-97 merged commit 018a047 into main Jun 13, 2026
298 of 307 checks passed
@yuki-97
yuki-97 deleted the mxin/nemo-gym-distill-fix branch June 13, 2026 08:27
@mxinO mxinO mentioned this pull request Jun 13, 2026
5 tasks
ashors1 pushed a commit that referenced this pull request Jun 27, 2026
Signed-off-by: Meng Xin <mxin@nvidia.com>
Signed-off-by: Anna Shors <ashors@nvidia.com>
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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants