Skip to content

feat: vLLM prefill/decode disaggregation for GRPO rollouts - #4920

Open
shikicloud wants to merge 38 commits into
NVIDIA-NeMo:mainfrom
shikicloud:feat/vllm-pd-disagg
Open

shikicloud wants to merge 38 commits into
NVIDIA-NeMo:mainfrom
shikicloud:feat/vllm-pd-disagg

Conversation

@shikicloud

@shikicloud shikicloud commented Oct 26, 2026 •

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

What and why

Adds prefill/decode (PD) disaggregation for the vLLM generation backend, mirroring the TRT-LLM design of #4095: the backend-agnostic generation.disaggregation block now drives vLLM too. A replica is M prefill engines + K decode engines (vLLM NixlConnector, kv_producer / kv_consumer) behind F CPU-only frontend Ray actors that NeMo-Gym talks to as ordinary OpenAI servers; each frontend relays a request as a one-token prefill leg followed by a decode leg carrying the prefill engine's KV handshake.

Main pieces:

  • nemo_rl/models/generation/disagg_layout.py: layout rules shared by both backends (plan_engines, per-node tiling / unified-PG slicing, role overrides); TRT-LLM now delegates to it.
  • vllm/vllm_disagg_frontend.py: the frontend (FastAPI relay, prefill routers conversation / round_robin / kv_cache_aware, decode routers, optional bidirectional_kv_xfer, bearer-token forwarding, restart recovery).
  • vllm/chat_render.py: frontend-side rendering that reproduces the engine's NeMoRLOnlineRenderer ids (frontend_tokenize), shadow-validated under NRL_TOKENIZE_SHADOW_RATE.
  • vllm/kv_connector_profiles.py, vllm/config.py: vllm_cfg.kv_transfer, vllm_cfg.disagg_frontend, per-role prefill_engine / decode_engine overrides, setup-time guards.
  • vllm_generation.py / vllm_worker*.py: per-engine role, ports and env (NCCL_NET_PLUGIN=none, NIXL side channel), engine-owner fan-out, refit pause/resume ordering (pause prefill then decode, resume decode then prefill), frontend readiness after every refit.
  • Nightly recipes on GB200: grpo-qwen3-1.7b-2n4g-megatron-vllm-disagg-swe1 (GRPO entrypoint) and grpo-qwen3-1.7b-2n4g-megatron-vllm-disagg-gym-single-controller (SingleController); docs/design-docs/pd-disaggregation-rollout.md covers both backends.

Differences from TRT-LLM: in-flight weight updates keep in-flight requests on their old KV and never reset the prefix caches; recompute_kv_cache_after_weight_updates and bidirectional_kv_xfer are refused together with in-flight updates. bidirectional_kv_xfer is opt-in. Between steps the frontends drop their handshakes and every engine releases the blocks its connector still pins before resetting its prefix cache; a reset that fails stops the step. After validation in async GRPO and async PPO the reset is skipped, because rollouts are still in flight there.

Setup checks: every training entrypoint (GRPO, PPO, distillation, SingleController) refuses the block on a backend that does not implement it or without NeMo-Gym; DisaggConfig bounds the engine and frontend counts and the base port; SingleController refuses generation_fleet_health and token_capture with disaggregation. TrtllmGeneration now plans, keys and places its engines with the shared disagg_layout functions.

On vLLM 0.33: NixlConnector needs nixl >= 1.5.0, so this PR carries the 1.3.0 -> 1.5.2 bump of #5350 until that one merges; PD is refused with dynamo: true and with vllm_cfg.http_api_server_count > 1.

Issues

Follow-up of #4095 (vLLM counterpart).

Usage

policy:
  generation:
    backend: vllm
    colocated: {enabled: false, resources: {gpus_per_node: 4, num_nodes: 1}}
    disaggregation:
      enabled: true
      num_prefill_engines: 1
      num_decode_engines: 1
      num_frontend_workers: 2
      frontend_tokenize: true
      frontend_base_port: 8300
    vllm_cfg:
      tensor_parallel_size: 2
      async_engine: true          # required
      expose_http_server: true    # required
      disagg_frontend: {prefill_router: conversation, decode_router: load_balancing}
      kv_transfer: {kv_connector: NixlConnector, kv_connector_extra_config: {backends: [UCX]}, kv_load_failure_policy: fail}

Requires the NeMo-Gym rollout path (async_engine + expose_http_server). NeMo RL turns on Gym's forward_session_id_as_conversation_id whenever the frontends are in use; setting it to false is rejected.

Convergence / perf / functionality proof

Two 100-step runs of e027088 (this branch with main e6449ae merged, vLLM 0.33) on 2 GB200 nodes x 4 GPUs (node 0 Megatron CP4, node 1 rollouts): Qwen3-1.7B on swe1 behind NeMo-Gym, async GRPO, 2 prompts x 8 generations per step, same seed. PD = the nightly recipe (1 TP2 prefill + 1 TP2 decode behind 2 frontends). aggregated = same settings with disaggregation off (2 TP2 engines).

Nightly checks of grpo-qwen3-1.7b-2n4g-megatron-vllm-disagg-swe1.sh on the PD run:

check first 5 steps all 100 steps
median(token_mult_prob_error) < 1.1 1.0158 1.0169
token_mult_prob_error[last] < 1.1 1.0158 1.0114
mean(gen_kl_error) < 0.02 1.10e-3 1.56e-3

All pass; 0 shadow mismatches, 0 frontend-tokenize fallbacks. Both PD nightlies now grep their run log for these two and for requests that reach a frontend without a conversation id.

Convergence: PD vs aggregated

pr4920_vllm_pd_nightly_and_convergence_v033
PD aggregated
invalid tool-call rate, first 5 steps → last 20 0.50 → 0.04 0.50 → 0.04
train reward, first 10 steps → last 20 0.04 → 0.21 0.07 → 0.14
validation reward, step 10 → 100 0.12 → 0.20 0.11 → 0.22
token_mult_prob_error, median 1.0169 1.0184
gen_kl_error, mean 1.56e-3 1.64e-3
step time, median 7.2 s 7.7 s

Both runs learn at the same pace and the mismatch metrics coincide. Train reward is 16 samples per step, so 20-step means are noisy. Wall time (126 vs 151 min) is dominated by single very long generations; this is not a throughput measurement.

SingleController entrypoint

Three 30-step runs through examples/run_grpo_single_controller.py on 2 GB200 nodes x 4 GPUs: Qwen3-1.7B on workplace_assistant behind NeMo-Gym (the setup of grpo-qwen3-1.7b-1n8g-megatron-vllm-gym-single-controller-length_penalty without the penalty), same seed. Every step refits with rollouts in flight (31 pause / sync / resume cycles per run); all three exit 0, PD with 0 shadow mismatches.

PD aggregated, KV kept aggregated, default
async_rl.recompute_kv_cache_after_weight_updates false (required) false true
token_mult_prob_error, max over steps 1-10 1.025 1.031 1.027
token_mult_prob_error, median / max over 30 steps 1.032 / 1.293 1.034 / 1.389 1.023 / 1.038
gen_kl_error, mean 1.03e-2 1.17e-2 2.3e-3
reward, mean 0.158 0.158 0.158

PD tracks the aggregated run that keeps its KV, so the prefill/decode pause, the weight sync and the resume add no mismatch of their own. The growth is what keeping KV across updates costs: on SingleController every update is in flight, PD cannot clear the caches at that pause, and prefix KV computed under earlier weights keeps being reused. This workload shows it clearly because its prompts share almost their whole prefix. The new nightly grpo-qwen3-1.7b-2n4g-megatron-vllm-disagg-gym-single-controller (GB200, 10 steps) covers this entrypoint; a 10-step run of the recipe gives median token_mult_prob_error 1.022, last step 1.023, mean gen_kl_error 1.7e-3.

The nightly's checks sit close to these values: median and last-step token_mult_prob_error < 1.05, mean gen_kl_error < 5e-3, mean reward > 0.1 (observed 0.15; all runs share a seed, so the reward has no repeat-run spread behind it).

Curves of the three runs (from their TensorBoard logs; the runs were not logged to W&B):

curves_4920_sc_metrics curves_4920_sc_timing
mean of steps 2-30, seconds PD aggregated, KV kept aggregated, default
timing/train/total_step_time 3.24 2.31 2.11
timing/train/exposed_generation 1.21 0.47 0.34
timing/train/weight_sync (pause, sync, resume) 0.154 0.111 0.115
timing/train/prepare_for_generation/sync_policy_params 0.009 0.009 0.009
timing/train/policy_training 0.65 0.59 0.54

The refit stays flat over the 30 steps (0.12 to 0.20 s for PD, 0.09 to 0.15 s aggregated). On this small setup PD is slower per step, and the difference is exposed generation. A rerun with per-request timing in the frontend shows where it goes: the prefill leg takes 0.03 to 0.09 s per request, and the decode leg takes 25 to 29 ms per generated token, so a step waits for its longest sample. The two 9 s steps each hold one sample that generated 356 and 386 tokens over several tool-call turns; no aggregated run sampled one above 250. Per generated token PD is about 20% slower than the aggregated runs (26.5 ms against 21 to 22 ms on single-turn steps): here one TP2 decode engine serves all 32 concurrent requests, where the aggregated layout spreads them over two TP2 engines.

Two problems these runs found (fixed on this branch)

  1. Cross-node refit: the engines run with NCCL_NET_PLUGIN=none and the training workers did not, so the refit communicator failed (init_collective: unhandled system error). The training workers now adopt the engines' value (vllm_refit_peer_env, 22c1b33).
  2. Tool parser: the inherited tool_parser: qwen3_coder does not parse Qwen3-1.7B's JSON <tool_call> blocks, so reward was 0 on every step in both arms, and on main as well (parent recipe grpo-qwen3-1.7b-1n8g-megatron-super-swe1). This PR's recipe sets tool_parser: hermes (2d13fed); the parent recipe is left as is.

Test plan

Unit tests (CPU): test_disagg_layout.py, test_vllm_chat_render.py, test_vllm_chat_server_disagg.py, test_vllm_disagg_frontend.py, test_vllm_disagg_config.py, test_vllm_generation_disagg.py, test_vllm_worker_disagg.py, test_nemo_gym_utils.py, test_openai_server_utils.py, test_megatron_setup.py / test_automodel_setup.py (Automodel test not run locally, nemo_automodel is not in the validation image); the per-entrypoint refusal tests in test_grpo.py, test_ppo.py, test_distillation.py and tests/unit/single_controller/test_setup.py; test_vllm_backend.py (pin release, including one test against vLLM's own lease expiry), test_vllm_generation.py, test_vllm_captured_call_progress.py.

After the merge of main d040a22 (04e186f, GB200, CPU only): ruff and pyrefly 1.4.0 clean; tests/unit/models/generation 1129 passed, test_grpo.py 510, test_distillation.py 37, test_ppo.py 105, tests/unit/single_controller 2258, tests/unit/weight_sync 458, tests/unit/environments 526, test_recipes_and_test_suites.py 16. The failures and errors left in these directories are the same tests on a plain-main tree in the same image, which is older than main; test_config_validation.py ran without HF_HOME, so the recipes that read it fail on both trees.

What the merge changed here: main's #4801 adds a disagg_layout.py of its own with a subset of these helpers. The merged module is this branch's, with main's replica_width_from and main's plan_engines (ValueError instead of assert); validate_disagg_entrypoint lets Megatron behind Dynamo through to its own checks. It also repairs 31 older tests this branch had broken and that had not been run before: the tests/unit/weight_sync rebuild tests (stubs without the disaggregation fields) and test_vllm_modelopt_real_quant_config.py (fake vLLM without kv_transfer).

GPU (1 GB200 node), on vLLM 0.33 at d72df4b, before the merge of main d040a22 and not rerun:

  • PD smoke over three layouts (1P+1D TP2 with 2 frontends; 2P TP1 + 1D TP2 hetero-TP; 1P TP1 + 3D TP1 with bidirectional_kv_xfer): 20, 16 and 17 checks pass, none fail; all requests 200, 0 shadow mismatches, greedy PD == aggregated token for token at concurrency 1, streamed turns work, in-flight pause/resume in ~0 s (not applicable under bidirectional_kv_xfer).
  • Step-boundary reset: finish_generation and invalidate_kv_cache succeed in ~0.45 s on all three layouts. Under bidirectional_kv_xfer a plain prefix-cache reset is refused on the engines that still pin blocks, and the reset succeeds once the pins are released.

GPU (1 GB200 node), measured on vLLM 0.29 before the merge of main and not rerun:

  • Same-workload swe1 rollout-only comparison (Qwen3-1.7B, 16x8, 5 steps, sync and async): 640/640 requests OK, step times within noise of aggregated.
  • Throughput sweep (Qwen3-8B, 4 GPUs): PD vs aggregated -9% to -66% depending on prefill share, as expected with 1 of 4 GPUs prefilling; per-decode-GPU rate +21%.

Not yet exercised on GPU: the kv_cache_aware router against real KV events.

Needs upstream changes

#5350 (nixl 1.5.2 for vLLM 0.33's NixlConnector). This PR carries the same bump until it merges, so it stays runnable; the lines drop out of this diff once main is merged back.

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

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Oct 26, 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.

@shuyixiong shuyixiong 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.

Two correctness issues found while reviewing the vLLM PD-disagg frontend (details inline).

@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.

Thanks for this PR: it is a large, carefully written feature. The shared disagg_layout extraction, the derived role whitelists, the connector-profile registry, the prefill-first pause and decode-first resume ordering, and the shadow validation of frontend-rendered ids are good design, and the relay behaves like vLLM's own proxies on the prefill leg.

First, rebase. The branch conflicts with main (6e68b17) in two files. In config.py the import block collides with #3964 (b00632b), which added LoraRefitMode where this PR adds the kv_connector_profiles import: keep both. In vllm_generation.py there are four hunks. #4820 (1c40201) added the validate_vllm_async_actor_settings import next to the names this PR imports: keep both. #2517 (1849f22) introduced resolve_vllm_dp_size and assert self.dp_size % self.vllm_dp_size == 0 on the lines where this PR sets self.dp_size = self.num_replicas: the two meanings of dp_size have to be reconciled, not merged line by line. In init_collective #2517's resolve_vllm_rank_prefixes must stay as the non-disaggregated fallthrough below this PR's early-return branch. In setup_token_capture #4818 (6e68b17) added top_logprobs=top_logprobs on the exact line this PR's _fan_out rewrite deletes; taking the PR side silently drops top-k capture staging, so re-add the kwarg inside the _fan_out("setup_token_capture", ...) call.

CI. Nothing but DCO, triage, semantic-pull-request and the submodule check ran at 27f2bb1. After the rebase please attach CI:L0 at least (CI:L2 given the convergence impact) and comment /ok to test <sha>. The Lint job will be red until C13 to C21 are applied: the pinned ruff import-sorting hook rewrites five files and the configs-minimize-check hook rejects the new recipe. No PR lane runs the new recipe; it is listed in nightly_gb200.txt only.

Scope of this review. No GPU and no project venv were available. Every claim comes from reading the head worktree, the pinned vLLM 0.29.0 source and pure-python repros; the suggested tests were not run. Seven specialised agents reviewed independently and an adversarial pass re-checked each finding against the source before it was staged.

Inline comments

Critical

  1. (C1) The SC path's bidirectional-plus-in-flight refit guard can never fire, and async PPO never calls it.
  2. (C2) The exemplar and SC default recompute_kv_cache_after_weight_updates: true kills the decode EngineCore at the first in-flight refit under disaggregation.
  3. (C3) SC token capture plus disaggregation prefills KV for one sequence and decodes another.
  4. (C4) A restarted frontend answers 503 forever on the NeMo-Gym path.
  5. (C5) MOONCAKE_PROFILE cannot work on vLLM 0.29.0 and fails every request with a misleading 502.
  6. (C6) Mamba/hybrid models need VLLM_SSM_CONV_STATE_LAYOUT=DS under NixlConnector.
  7. (C7) The equal-TP Mamba guard and its name list rest on a stale premise; delete them.
  8. (C8) The frontend's hand-kept request-field list drops fields that change the rendered ids.
  9. (C9) Companion to C8: render with an output budget of 1 like the engine.
  10. (C10) Refuse frontend_tokenize for harmony (gpt-oss) and Mistral-tokenizer models.
  11. (C11) The frontend's ModelConfig ignores the tokenizer-shaping vllm_kwargs and the role-merged block.
  12. (C12) Under a unified placement group the port slots become cluster-wide ordinals.

Suggestions
13. (C13, C14, C15, C16, C17) ruff import sorting (I001) fails on five files.
14. (C18, C19, C20, C21) The recipe restates seven keys of its defaults: chain and fails configs-minimize-check.
15. (C24) The prefix-cache reset on resume is best-effort; the comment and the recipe overstate it.
16. (C25, C26) The streaming relay leaks the decode in-flight slot when the client never reads the stream.
17. (C27) _deep_merge in trtllm/config.py is dead code.
18. (C28) _ROLE_BLOCK_KEYS in disagg_layout.py is dead code.
19. (C29) TRT-LLM's three hand-rolled base64 copies were not switched to the new helpers.
20. (C32) Two vLLM limitations worth filing upstream; the workarounds stay.

Tests and docs
21. (C22) test_disagg_layout.py is collected by no CI lane.
22. (C23) Both error branches of tile_engines_on_per_node_pgs are untested.
23. (C33) chat_render.py has no test; a suggested oracle test file is attached.
24. (C34) The worker-side disaggregation code has no tests; a suggested test file is attached.
25. (C30) The design doc is untouched, still TRT-LLM-only, and the recipe points at a rationale it does not contain.
26. (C31) No numbers and no test plan for a new rollout feature.

Please also fill in the PR description; C31 lists what would help.

Generated by Claude Code

Setup guards: every SingleController refit is in flight; token capture is
refused with disaggregation; recompute_kv_cache_after_weight_updates and
bidirectional_kv_xfer are refused with in-flight updates (vLLM cannot reset
caches while frozen decode requests hold blocks), and resume no longer
pretends to. Frontend: routing keys on Gym's conversation_id (the recipe
turns forward_session_id_as_conversation_id on) with an opening-exchange
fallback that tells tasks behind one system prompt apart; bearer tokens are
forwarded; a Ray-restarted frontend probes its engines instead of answering
503 forever and readiness is re-sent after every refit; the streaming leg
holds its decode slot in one frame. Renderer: forwarded fields derive from
vLLM's request class, the model config comes from the prefill role's
effective vllm_kwargs, harmony/Mistral models are refused. Mooncake profile
dropped (vLLM 0.29 returns no kv_transfer_params), VLLM_SSM_CONV_STATE_LAYOUT=DS
by default, the stale hybrid-SSM equal-TP guard removed. Unified-PG port
slots are keyed per physical node. Lint: isort, recipe minimized, layout and
renderer tests collected by the vLLM shards, dead code removed, TRT-LLM's
base64 helpers shared. Design doc covers both backends; tests added for all
of the above.

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

# Conflicts:
#	nemo_rl/models/generation/vllm/config.py
#	nemo_rl/models/generation/vllm/vllm_generation.py
#	tests/unit/L0_Unit_Tests_Vllm_1.sh
#	tests/unit/L0_Unit_Tests_Vllm_2.sh
#	tests/unit/L0_Unit_Tests_Vllm_3.sh
@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Nov 3, 2026
@shikicloud
shikicloud marked this pull request as ready for review November 3, 2026 05:37
@shikicloud
shikicloud requested a review from yuki-97 November 3, 2026 08:30

@shuyixiong shuyixiong 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.

One correctness issue in the vLLM PD-disaggregation refit guard (C35, inline).

Generated by Claude Code

NeMo RL sets Gym's forward_session_id_as_conversation_id for the vLLM
frontends; the step-boundary cache reset releases connector-pinned KV
blocks and must succeed; the reset verdict is no longer dropped.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Shiki Wu <[email protected]>
shikicloud and others added 3 commits November 4, 2026 22:15
…he disagg recipe

Both adapters read the frontend-tokenize shadow rate through
openai_server_utils.tokenize_shadow_rate() (review C59); the vLLM
disaggregation recipe no longer hard-codes UCX_TLS / UCX_NET_DEVICES
(review C60).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Shiki Wu <[email protected]>
Conflicts: vllm_worker.py (the fp32 LM head helper was renamed on main),
trtllm_disagg_server.py (main's new imports next to the shadow-rate
docstring), tests/unit/L0_Unit_Tests_Vllm_{1,2,3}.sh (main's shard lists
plus the disaggregation test files).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Shiki Wu <[email protected]>
trtllm_disagg_server._build_frontend_tokenizer encodes the ids through the
shared encode_token_ids_b64; main's inline base64/numpy encoding, whose
imports the merge kept, is gone on this branch.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Shiki Wu <[email protected]>
shikicloud added a commit to shikicloud/RL that referenced this pull request Nov 5, 2026
Brings NVIDIA-NeMo#4920's review rounds 2 and 3 and origin/main 4f39fd8 (merged there)
under the SGLang disaggregation commit.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Shiki Wu <[email protected]>
shikicloud added a commit to shikicloud/RL that referenced this pull request Nov 5, 2026
Picks up the import cleanup that followed the main merge on NVIDIA-NeMo#4920.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@terrykong terrykong added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Nov 5, 2026
shikicloud and others added 7 commits November 12, 2026 00:19
The first full run of grpo-qwen3-1.7b-2n4g-megatron-vllm-disagg-swe1 (two
GB200 nodes) died in grpo.setup: MegatronPolicyWorker.init_collective raised
"NCCLError: SystemError (2): unhandled system error" while creating the refit
communicator.

Disaggregated NIXL engines run with NCCL_NET_PLUGIN=none (HPC-X's plugin would
load a UCX without CUDA support into them), the training ranks kept NCCL's
default plugin, and the refit collective is one communicator over both: NCCL
picks its network transport once per process and cannot connect ranks that
picked different ones. The single-node smokes never built that communicator.

The trainer now adopts the engines' effective NCCL_NET_PLUGIN
(vllm_cfg.env_vars over the disaggregation defaults) before its first
communicator, in the Megatron and the Automodel policy setup;
megatron_cfg.env_vars / automodel_cfg.env_vars still choose one explicitly.
disagg_engine_env_defaults moves to vllm/config.py next to the new
vllm_refit_peer_env so the policy workers can import it.

With the change the recipe passes setup and trains; lint, pyrefly and the unit
tests (270 disaggregation tests, 5 Megatron refit-environment tests) pass on a
GB200 node. The Automodel test could not run there (no automodel extra in that
image).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Shiki Wu <[email protected]>
The recipe inherits `tool_parser: qwen3_coder` from the Nemotron stage
config. Qwen3-1.7B writes its tool calls as JSON inside <tool_call> tags,
which that parser (XML <function=...>) leaves in the text, so the
environment flagged every tool call as invalid and the reward stayed 0 in
every step. The nightly gates read token_mult_prob_error and gen_kl_error
only, so this did not fail anything.

Set `tool_parser: hermes`, the vLLM counterpart of the TRT-LLM sibling's
`tool_parser: qwen3`. With it the well-formed tool calls are parsed and
rewarded; the ones still flagged are those the model writes inside an
unclosed <think> block.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Shiki Wu <[email protected]>
Conflicts in eight files:

- grpo.py, generation/__init__.py: main dropped the "dynamo" backend
  (Dynamo is now a switch on the vLLM backend); the disaggregation
  validation moves into the single vLLM branch main keeps.
- nemo_gym.py, single_controller_utils/setup.py: the Gym conversation-id
  knob next to main's generation_prefix_cuts_enabled.
- vllm_generation.py: main's token-capture setup record, data-plane
  snapshots and generation-prefix calls go through the per-engine
  fan-out; set_rollout_weight_version is main's refit-member version,
  which under disaggregation addresses every engine owner.
- vllm_worker.py, vllm_worker_async.py, vllm/config.py: both sides kept
  (compile-cache seeding, prefix recovery, the Dynamo config import).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Shiki Wu <[email protected]>
main now serves the vLLM backend through Dynamo with
policy.generation.dynamo=true: the Dynamo frontend registers every
engine and routes whole requests to them. Under prefill/decode
disaggregation that would send complete requests to prefill-only and
decode-only engines and bypass the PD frontends, so the combination is
rejected at setup next to the other disaggregation checks.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Shiki Wu <[email protected]>
Three of main's tests still asserted the call shape from before the
merge: build_nemo_gym_actors now also receives
forward_session_id_as_conversation_id, and the chat handler reads
return_prompt_token_ids_b64 from the request, which the tests' fake
request did not carry.

Also apply ruff format to two merged hunks, and put main's TensorRT-LLM
NIXL note back beside the TensorRT-LLM config in the PD design doc (the
automatic merge left it after the vLLM section).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: Shiki Wu <[email protected]>
main (e6449ae) bumped vLLM to 0.33 and moved the chat server out of
vllm_worker_async.py into chat_server.py / prompt_and_capture.py, so the
PD changes to the chat path are ported onto the new structure:

- chat_server.py: a leg that carries prompt ids hands them to vLLM's
  renderer and derives no prefix; the prefill leg's shadow check runs the
  shared render and prepare_prompt without starting a capture; a prefill leg
  drops ng_capture and can answer with prompt_token_ids_b64. A supplied-id
  leg whose ids vLLM did not take (echo, non-text content) is refused.
- chat_render.py: the frontend renderer runs the engine's own render
  (_render_chat_call) and splice (prepare_prompt) over the chat server's
  settings instead of a copy of them, which also gives the splice main's
  turn-end ids.
- reasoning_ended comes from the render of the messages: the frontend, or
  the prefill engine in its response, hands it to the decode leg
  (template_reasoning_ended), which cannot read it off spliced ids.
- The frontend forwards NeMo-Gym's x-ng-sampling header to both legs.
- PD refuses vllm_cfg.http_api_server_count > 1.
- main's new per-engine calls (load_model with Dynamo chat settings,
  get_data_plane_snapshots) go through _fan_out; the sync worker's
  reset_prefix_cache keeps main's queue drain and returns vLLM's verdict.
- Tests: test_chat_render.py becomes test_vllm_chat_render.py and the chat
  server's PD paths get test_vllm_chat_server_disagg.py (both need vLLM);
  two of main's tests are given the PD constructor argument and fan-out.
- docs: pd-disaggregation-rollout.md unwrapped to main's one-line
  paragraphs.

Signed-off-by: Shiki Wu <[email protected]>
vLLM 0.33 refuses to build its NixlConnector with nixl < 1.5.0, so
prefill/decode disaggregation cannot start on the current pin
(`NIXL >= 1.5.0 is required, but nixl==1.3.0 is installed`).

Only the nixl, nixl-cu12 and nixl-cu13 entries of uv.lock change. The
nixl-marked data-plane unit tests pass on both 1.3.0 and 1.5.2.

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.

Self-review of aabafdf (round 2; round 1 was C1–C34).

Threads: all 14 RayenTian threads and all shuyixiong threads were re-checked against aabafdf. The replies hold, with two exceptions, now posted inline: the streaming-slot fix promised in the C25 reply is not in the code (C62), and the C35 reply's "the SingleController already raises" holds for invalidate_kv_cache but not for finish_generation (C61). Before merge, link the follow-up issue for the TRT-LLM key rename promised in this thread.

Design: kv_connector_profiles keeps what each connector needs as data; the role-override allow-list is derived from the schema (config.py#L82); one setup check, validate_disagg_entrypoint, runs before anything is built on all four entrypoints; the frontend's relay core is separate from its Ray wrapper and tested on CPU; chat_render.py reuses the engine's own render code; and the TRT-LLM refactor onto disagg_layout changes no layout (checked against the deleted code over 1728 layouts).

Inline comments:

  • (C61) A failed step-boundary reset is swallowed by finish_generation, and async validation runs that reset with rollouts in flight. Fix the callers first, then let the error through.
  • (C62) The streaming branch of relay() still takes the decode slot outside _stream_decode, so a dropped stream leaks it (reopens C25/C26).
  • (C63) The frontend's /v1/completions route can never succeed; delete it, its branch in build_decode_leg, and its two tests.
  • (C64) The engines_answer docstring says the engine server has no /health; it has one.
  • (C65) A stale comment names the hybrid-SSM equal-TP check deleted in round 1.
  • (C66) make_router's hasher parameter is never passed.
  • (C67) Six new tests only check pydantic constraints or defaults; delete them.
  • (C68) The GRPO PD nightly checks nothing that only disaggregation can break; grep for the three frontend fallbacks.
  • (C69) Same for the SingleController PD nightly.
  • (C70) The swe1 nightly comment says token_mult_prob_error catches frontend tokenization drift; it cannot (apply together with C68).
  • (C71) SingleController and PPO still size the NVLink-domain unit as one engine instead of the whole replica.
  • (C72) The new swe1 driver has no copyright header.
  • (C73) release_kv_transfer_pins relies on private vLLM internals that no test runs against real vLLM; add one that does.

PR description fixes (not inline, since the description is not in the diff):

  1. "Unit tests (CPU): test_disagg_layout.py, test_vllm_chat_render.py, …" leaves out test files this PR changes: test_grpo.py, test_ppo.py, test_distillation.py and tests/unit/single_controller/test_setup.py (the per-entrypoint refusal tests), test_vllm_backend.py (pin release), test_vllm_generation.py, test_vllm_captured_call_progress.py.
  2. "All pass; 0 shadow mismatches, 0 frontend-tokenize fallbacks." No nightly checks these yet (C68, C69).
  3. The hetero-TP and bidirectional_kv_xfer layouts and the step-boundary reset under bidirectional_kv_xfer were "measured on vLLM 0.29 before the merge of main". vLLM 0.33 split the NIXL worker into push and pull workers, and release_kv_transfer_pins reads its private _reqs_to_send (base_worker.py#L921). No nightly runs that reset on 0.33. Please re-run the hetero-TP and bidirectional_kv_xfer layouts, including the step-boundary reset, on vLLM 0.33 and put the result in the description.
  4. "the reset must succeed": not true end to end today (C61).

Not blocking (follow-ups, no change needed in this PR):

Tests and lint: no GPU here, so C61, C62's runtime effect and C71 are traced from source, not run. The test proposed in C73 was run against vLLM 0.33.0 on a GB200 node. ruff 0.9.9 check / isort / format pass on the 44 PR .py files; pyrefly was not run (pre-commit cannot run on this host).

nemo-rl-review: kind=self harness=claude-code/2.1.331 model=claude-opus-5-5 effort=medium review-pr-team=v3 reviewed=aabafdf

Comment thread nemo_rl/models/generation/__init__.py Resolved
Comment thread nemo_rl/algorithms/grpo.py Resolved
main d040a22 brings NVIDIA-NeMo#4801 (Megatron prefill/decode behind Dynamo), which adds
its own disagg_layout.py with a subset of this branch's helpers, plus NVIDIA-NeMo#5267
(prefix counts per HTTP frontend) and NVIDIA-NeMo#5158 (multi-harness).

- disagg_layout.py: this branch's module, with main's replica_width_from and
  main's plan_engines (ValueError instead of assert, role-count check).
  validate_disagg_entrypoint lets megatron + dynamo through to its own checks.
- trtllm/config.py, trtllm_generation.py, grpo.py: keep the shared-module
  wrappers of this branch.
- vllm_generation.py: fan the per-frontend prefix counts out per engine.
- nemo_gym.py: pass both forward_session_id_as_conversation_id and
  multi_harness.

Signed-off-by: Shiki Wu <[email protected]>
resolve_disagg_layout in trtllm_generation.py and as_dict in trtllm/config.py:
main now imports both from disagg_layout, this branch goes through the
trtllm.config wrappers.

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

- weight_sync rebuild tests drive VllmGeneration methods on a SimpleNamespace;
  give it the disaggregation layout and the shard-restart guard those methods
  now read.
- the real-quant import test fakes the vLLM modules; add the KV-transfer
  module vllm_backend imports.

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

Copy link
Copy Markdown
Contributor Author

/ok to test 04e186f

DisaggConfig takes num_prefill_engines / num_decode_engines as positive
integers on this branch, so a zero count is refused when the layout block
is read, before the Megatron Dynamo check and plan_engines see it. The
three cases from NVIDIA-NeMo#4801 matched the later messages.

Signed-off-by: Shiki Wu <[email protected]>
shikicloud added a commit to shikicloud/RL that referenced this pull request Nov 27, 2026
@shikicloud

Copy link
Copy Markdown
Contributor Author

/ok to test 863a30d

…s read

resolve_role_overrides reads the disaggregation block first, so the schema
refuses a zero count there and the test never reached plan_engines.

Signed-off-by: Shiki Wu <[email protected]>
shikicloud added a commit to shikicloud/RL that referenced this pull request Nov 27, 2026
@shikicloud

Copy link
Copy Markdown
Contributor Author

/ok to test 049841a

…start helpers

codecov/patch sat at 79.18% against the 80% target. These helpers had no
unit test: _parse_engine_body, wait_ready, _is_reconstructed_actor and the
KV event subscriber's start/stop.

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

Copy link
Copy Markdown
Contributor Author

/ok to test 92d9560

@terrykong terrykong removed the Documentation Improvements or additions to documentation label Nov 28, 2026
@shikicloud

Copy link
Copy Markdown
Contributor Author

/ok to test afd0ebf

shikicloud added a commit to shikicloud/RL that referenced this pull request Nov 29, 2026
Conflict in tests/unit/test_recipes_and_test_suites.py: main raised the nightly
budget to 5722 GPU hours; this branch's SGLang nightly adds 8, so the cap is 5730
(tools/launch dry run reports 5730).

Signed-off-by: Shiki Wu <[email protected]>
@shikicloud
shikicloud requested a review from RayenTian November 29, 2026 07:49
@svcnvidia-nemo-ci svcnvidia-nemo-ci added complexity:high Large or cross-cutting change. Set by Autobot PR classify (skills/pr-classify) convergence-risk:high Likely to 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) proof:convergence Needs convergence proof (W&B runs). Set by Autobot PR classify (skills/pr-classify) proof:perf Needs performance proof. Set by Autobot PR classify (skills/pr-classify) labels Nov 29, 2026
@shikicloud

Copy link
Copy Markdown
Contributor Author

/ok to test 0b11ac3

…tributes

_load_model reads engine_cfg and _disagg_role, which __init__ sets on this
branch; the SimpleNamespace worker in main's
test_load_model_preserves_native_quant_loader lacked both and raised
AttributeError. Set them as __init__ does without disaggregation.

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

Copy link
Copy Markdown
Contributor Author

/ok to test 2a3e290

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:high Large or cross-cutting change. Set by Autobot PR classify (skills/pr-classify) convergence-risk:high Likely to change training results. Set by Autobot PR classify (skills/pr-classify) proof:convergence Needs convergence proof (W&B runs). Set by Autobot PR classify (skills/pr-classify) proof:functionality Needs proof that it works. Set by Autobot PR classify (skills/pr-classify) proof:perf Needs performance proof. Set by Autobot PR classify (skills/pr-classify)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants