Skip to content

feat: Sglang Rollout Refactor - #2267

Merged
yuki-97 merged 4 commits into
NVIDIA-NeMo:mainfrom
xiuhu17:zhw/refactor_sglang
Jun 20, 2026
Merged

feat: Sglang Rollout Refactor#2267
yuki-97 merged 4 commits into
NVIDIA-NeMo:mainfrom
xiuhu17:zhw/refactor_sglang

Conversation

@xiuhu17

@xiuhu17 xiuhu17 commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Refactor SGLang Rollout with the New Design

Overview

This PR refactors the SGLang rollout stack to support the new rollout architecture while preserving backward compatibility with the previous interface.

The new design focuses on improving scalability, reliability, and maintainability of the rollout system. In particular, it introduces support for:

  • Redesign the old sglang rollout
  • SGLang router
  • Multi-node SGLang deployment
  • Weight / KV cache / CUDA graph onload and offload
  • Pause/Continue generation
  • Weight check: snapshot, reset, compare for weight update check.
  • async def generate_async(...) for asynchronous multi-turn rollout
  • Refactored colocated weight update

The goal is to make the rollout layer production-ready for larger-scale serving and training integration, while minimizing disruption to existing callers.


Tests:

Thorough tests(around 75 tests):


Summary by CodeRabbit

Release Notes

  • New Features

    • Added pause and continue generation control to all generation backends
    • Introduced async generation support for streaming token output
    • Enhanced weight and memory management for optimized generation
  • Improvements

    • Updated training configuration recipes for improved cluster utilization

Review Change Stack

@copy-pr-bot

copy-pr-bot Bot commented Apr 14, 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.

@xiuhu17 xiuhu17 changed the title [WIP] Sglang Rollout Refactor Sglang Rollout Refactor Apr 17, 2026
@xiuhu17
xiuhu17 marked this pull request as ready for review April 17, 2026 01:29
@xiuhu17
xiuhu17 requested review from a team as code owners April 17, 2026 01:29

@yuki-97 yuki-97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hi @xiuhu17 , thanks for the refactor and many new features! great work! I reviewed partly and left some comments.

Comment thread nemo_rl/models/generation/sglang/utils/async_utils.py
Comment thread nemo_rl/models/generation/sglang/utils/async_utils.py Outdated
Comment thread nemo_rl/models/generation/redesign/config.py Outdated
Comment thread nemo_rl/models/generation/sglang/sglang-nemo-rl-compat.patch Outdated
Comment thread nemo_rl/models/generation/sglang/utils/async_utils.py
Comment thread nemo_rl/distributed/virtual_cluster.py Outdated
Comment thread nemo_rl/models/generation/redesign/sglang_generation.py Outdated
Comment thread nemo_rl/algorithms/grpo.py Outdated
@chtruong814 chtruong814 added the waiting-on-customer Waiting on the original author to respond label Apr 18, 2026
@xiuhu17
xiuhu17 requested a review from a team as a code owner April 20, 2026 00:01
Comment thread tests/unit/excluded_unit_tests.sh Outdated
Comment thread tests/unit/L0_Unit_Tests_Generation.sh Outdated
Comment thread nemo_rl/models/policy/torch_reductions_utils.py Outdated
Comment thread nemo_rl/models/policy/utils.py Outdated
Comment thread examples/configs/grpo_math_1B_sglang.yaml
Comment thread nemo_rl/distributed/virtual_cluster.py Outdated
Comment thread nemo_rl/algorithms/grpo.py Outdated
Comment thread nemo_rl/models/generation/sglang/sglang_worker.py Outdated
Comment thread nemo_rl/models/generation/sglang/sglang_generation.py Outdated
Comment thread nemo_rl/models/policy/utils.py
Comment thread nemo_rl/models/generation/sglang/fault_tolerance.py Outdated
@chtruong814 chtruong814 removed the waiting-on-customer Waiting on the original author to respond label Apr 20, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added waiting-on-maintainers Waiting on maintainers to respond waiting-on-customer Waiting on the original author to respond and removed waiting-on-maintainers Waiting on maintainers to respond labels Apr 22, 2026
@terrykong terrykong added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Apr 30, 2026
@terrykong

Copy link
Copy Markdown
Collaborator

/ok to test 4d0c640

@terrykong terrykong left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

SGLang Rollout Refactor — Review

Thanks for this substantial refactoring effort, @xiuhu17! The new architecture (router, multi-node support, fault tolerance, weight/KV offload) is a meaningful step toward production readiness. Below are findings grouped by priority.

Merge Conflicts

This PR currently has merge conflicts with main (mergeable: CONFLICTING). Please rebase on main and resolve conflicts before further review iterations.

Missing Copyright Headers

8 new/modified source files under nemo_rl/ are missing the NVIDIA Apache 2.0 copyright header (required per project guidelines for non-test files):

  • sglang_generation.py, sglang_worker.py, fault_tolerance.py, sglang_router.py
  • utils/async_utils.py, utils/http_utils.py, utils/misc.py, utils/ray_utils.py

Missing # pragma: no cover

3 @ray.remote classes are missing the coverage pragma (required for Ray actors per testing conventions):

  • RouterActor in sglang_router.py:10
  • Lock in utils/ray_utils.py:22
  • _HttpPosterActor in utils/http_utils.py:106

Performance / Convergence Evidence

This PR rewrites the weight-streaming protocol, adds CUDA-graph/KV offload, multi-node SGLang, and a new router — but provides no quantitative evidence (throughput, refit latency, memory, convergence curves). The test link is to an external Google Doc. Could you share tokens/sec or step-time numbers (with and without the new features on a representative model) directly in the PR description?

Documentation

No docs/ updates for the user-facing additions (router config, fault tolerance, pause/continue, weight check, async generation). Per project conventions, new features should include in-repo documentation.

Test Deletions

332 lines deleted from test_grpo.py and 224 lines from test_policy_utils.py — could you clarify what coverage replaces these? They don't appear to be SGLang-specific tests.

Generated by Claude Code

Comment thread nemo_rl/models/policy/utils.py
Comment thread nemo_rl/models/generation/sglang/sglang_generation.py Outdated
Comment thread nemo_rl/models/generation/sglang/sglang_worker.py Outdated
Comment thread nemo_rl/models/generation/sglang/sglang_generation.py Outdated
Comment thread nemo_rl/models/generation/sglang/utils/async_utils.py Outdated
Comment thread nemo_rl/models/generation/sglang/sglang_worker.py Outdated
Comment thread nemo_rl/models/generation/sglang/sglang_worker.py Outdated
Comment thread nemo_rl/models/generation/sglang/sglang_worker.py Outdated
Comment thread nemo_rl/models/generation/sglang/config.py
Comment thread nemo_rl/models/generation/sglang/config.py Outdated

@yuki-97 yuki-97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

mainly some style things.

Comment thread nemo_rl/models/generation/sglang/config.py Outdated
Comment thread nemo_rl/algorithms/grpo.py Outdated
Comment thread nemo_rl/algorithms/grpo.py Outdated
Comment thread nemo_rl/models/generation/sglang/utils/http_utils.py Outdated
Comment thread nemo_rl/models/generation/sglang/utils/http_utils.py Outdated
Comment thread nemo_rl/models/generation/sglang/sglang_worker.py Outdated
Comment thread nemo_rl/models/generation/sglang/sglang_worker.py
Comment thread nemo_rl/models/generation/sglang/sglang_worker.py
Comment thread nemo_rl/models/generation/sglang/utils/http_utils.py Outdated
Comment thread nemo_rl/models/generation/sglang/utils/train_utils.py
Comment thread nemo_rl/models/generation/sglang/sglang_generation.py Outdated
Comment thread nemo_rl/models/generation/sglang/sglang_generation.py Outdated
@yuki-97

yuki-97 commented May 7, 2026

Copy link
Copy Markdown
Contributor

hi @xiuhu17 , I finished review, sorry so many comments. could you help to solve them and the remaining previous comments? also please lmk if you need help.

besides there're some other fails will need you to fix.

  1. there's a conflict with main, need to do a rebase.
  2. PR title: https://github.com/NVIDIA-NeMo/RL/actions/runs/25301027605/job/74167878729?pr=2267
  3. DCO: https://github.com/NVIDIA-NeMo/RL/pull/2267/checks?check_run_id=74167877728

@yuki-97 yuki-97 mentioned this pull request May 13, 2026
4 tasks
@xiuhu17 xiuhu17 changed the title Sglang Rollout Refactor feat: Sglang Rollout Refactor May 15, 2026
@xiuhu17
xiuhu17 force-pushed the zhw/refactor_sglang branch from e5d8496 to d6017ff Compare May 15, 2026 06:29
@svcnvidia-nemo-ci svcnvidia-nemo-ci added waiting-on-customer Waiting on the original author to respond and removed waiting-on-customer Waiting on the original author to respond labels Jun 4, 2026
@xiuhu17
xiuhu17 force-pushed the zhw/refactor_sglang branch 3 times, most recently from 7d5f0b4 to 2deff62 Compare June 5, 2026 03:05
@yuki-97

yuki-97 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

/ok to test 2deff62

@yuki-97

yuki-97 commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

/ok to test 3979db4

@yuki-97

yuki-97 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

/ok to test a051b72

@yuki-97

yuki-97 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

/ok to test c620535

@yuki-97

yuki-97 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

/ok to test 9f3948c

xiuhu17 added 3 commits June 17, 2026 17:02
Signed-off-by: zhihaow6 <zhihaow6@illinois.edu>
Signed-off-by: zhihaow6 <zhihaow6@illinois.edu>
Signed-off-by: zhihaow6 <zhihaow6@illinois.edu>
@yuki-97

yuki-97 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

/ok to test 749fb1a

Signed-off-by: Yuki Huang <yukih@nvidia.com>
@yuki-97

yuki-97 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

/ok to test 9f09507

@yuki-97 yuki-97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@xiuhu17 thanks so much for the efforts!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:L1 Run doctests, unit tests, and functional tests community-request Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants