Repository navigation
feat: vLLM prefill/decode disaggregation for GRPO rollouts - #4920
shikicloud wants to merge 38 commits into
Conversation
Signed-off-by: Shiki Wu <[email protected]>
…s in frontend renderer Signed-off-by: Shiki Wu <[email protected]>
…P engine client Signed-off-by: Shiki Wu <[email protected]>
shuyixiong
left a comment
There was a problem hiding this comment.
Two correctness issues found while reviewing the vLLM PD-disagg frontend (details inline).
shikicloud
left a comment
There was a problem hiding this comment.
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
- (C1) The SC path's bidirectional-plus-in-flight refit guard can never fire, and async PPO never calls it.
- (C2) The exemplar and SC default
recompute_kv_cache_after_weight_updates: truekills the decode EngineCore at the first in-flight refit under disaggregation. - (C3) SC token capture plus disaggregation prefills KV for one sequence and decodes another.
- (C4) A restarted frontend answers 503 forever on the NeMo-Gym path.
- (C5)
MOONCAKE_PROFILEcannot work on vLLM 0.29.0 and fails every request with a misleading 502. - (C6) Mamba/hybrid models need
VLLM_SSM_CONV_STATE_LAYOUT=DSunder NixlConnector. - (C7) The equal-TP Mamba guard and its name list rest on a stale premise; delete them.
- (C8) The frontend's hand-kept request-field list drops fields that change the rendered ids.
- (C9) Companion to C8: render with an output budget of 1 like the engine.
- (C10) Refuse
frontend_tokenizefor harmony (gpt-oss) and Mistral-tokenizer models. - (C11) The frontend's ModelConfig ignores the tokenizer-shaping
vllm_kwargsand the role-merged block. - (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
Signed-off-by: Shiki Wu <[email protected]>
shuyixiong
left a comment
There was a problem hiding this comment.
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]>
…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]>
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]>
Picks up the import cleanup that followed the main merge on NVIDIA-NeMo#4920. Co-Authored-By: Claude Fable 5.1 <[email protected]>
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
left a comment
There was a problem hiding this comment.
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/completionsroute can never succeed; delete it, its branch inbuild_decode_leg, and its two tests. - (C64) The
engines_answerdocstring 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'shasherparameter 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_errorcatches 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_pinsrelies 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):
- "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.pyandtests/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. - "All pass; 0 shadow mismatches, 0 frontend-tokenize fallbacks." No nightly checks these yet (C68, C69).
- The hetero-TP and
bidirectional_kv_xferlayouts and the step-boundary reset underbidirectional_kv_xferwere "measured on vLLM 0.29 before the merge of main". vLLM 0.33 split the NIXL worker into push and pull workers, andrelease_kv_transfer_pinsreads its private_reqs_to_send(base_worker.py#L921). No nightly runs that reset on 0.33. Please re-run the hetero-TP andbidirectional_kv_xferlayouts, including the step-boundary reset, on vLLM 0.33 and put the result in the description. - "the reset must succeed": not true end to end today (C61).
Not blocking (follow-ups, no change needed in this PR):
- The width of one engine role is computed in three places (disagg_layout.py#L207-L227, vllm_generation.py#L957-L964, trtllm_generation.py#L313-L335), and the choice between unified and per-node placement is still written once per backend (vllm_generation.py#L996-L1024, trtllm_generation.py#L398-L450). SGLang PD (#5086) will need both; one
disagg_layouthelper for each would cover it. DISAGG_BACKENDScould become asupports_disaggregationclass attribute on the generation classes, defaulting toFalse(an abstract property would read as truthy on the class before instantiation).- The frontend fleet inside
VllmGeneration(start, mark ready, invalidate, shutdown; vllm_generation.py#L1224) could become its own object, likeManagedDynamoRuntime. kv_cache_awareis offered next toconversationin the exemplar comment and the design doc, but has not run on GPU; one "(not yet validated on GPU)" note in each would match the description.- vLLM upstream:
NixlConnectordoes not implementreset_cache()(base.py#L793-L805), soreset_prefix_cache(reset_connector=True)cannot release pending send leases. Worth an issue at https://github.com/vllm-project/vllm/issues/new, sorelease_kv_transfer_pinscan go away.
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
Signed-off-by: Shiki Wu <[email protected]>
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]>
|
/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]>
Signed-off-by: Shiki Wu <[email protected]>
|
/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]>
Signed-off-by: Shiki Wu <[email protected]>
|
/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]>
|
/ok to test 92d9560 |
Signed-off-by: Shiki Wu <[email protected]>
|
/ok to test afd0ebf |
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]>
Signed-off-by: Shiki Wu <[email protected]>
|
/ok to test 0b11ac3 |
Signed-off-by: Shiki Wu <[email protected]>
…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]>
…ller Signed-off-by: Shiki Wu <[email protected]>
|
/ok to test 2a3e290 |
What and why
Adds prefill/decode (PD) disaggregation for the vLLM generation backend, mirroring the TRT-LLM design of #4095: the backend-agnostic
generation.disaggregationblock now drives vLLM too. A replica is M prefill engines + K decode engines (vLLMNixlConnector,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 routersconversation/round_robin/kv_cache_aware, decode routers, optionalbidirectional_kv_xfer, bearer-token forwarding, restart recovery).vllm/chat_render.py: frontend-side rendering that reproduces the engine'sNeMoRLOnlineRendererids (frontend_tokenize), shadow-validated underNRL_TOKENIZE_SHADOW_RATE.vllm/kv_connector_profiles.py,vllm/config.py:vllm_cfg.kv_transfer,vllm_cfg.disagg_frontend, per-roleprefill_engine/decode_engineoverrides, 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.grpo-qwen3-1.7b-2n4g-megatron-vllm-disagg-swe1(GRPO entrypoint) andgrpo-qwen3-1.7b-2n4g-megatron-vllm-disagg-gym-single-controller(SingleController);docs/design-docs/pd-disaggregation-rollout.mdcovers 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_updatesandbidirectional_kv_xferare refused together with in-flight updates.bidirectional_kv_xferis 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;
DisaggConfigbounds the engine and frontend counts and the base port; SingleController refusesgeneration_fleet_healthandtoken_capturewith disaggregation.TrtllmGenerationnow plans, keys and places its engines with the shareddisagg_layoutfunctions.On vLLM 0.33:
NixlConnectorneedsnixl>= 1.5.0, so this PR carries the 1.3.0 -> 1.5.2 bump of #5350 until that one merges; PD is refused withdynamo: trueand withvllm_cfg.http_api_server_count > 1.Issues
Follow-up of #4095 (vLLM counterpart).
Usage
Requires the NeMo-Gym rollout path (
async_engine+expose_http_server). NeMo RL turns on Gym'sforward_session_id_as_conversation_idwhenever the frontends are in use; setting it tofalseis 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.shon the PD run:median(token_mult_prob_error) < 1.1token_mult_prob_error[last] < 1.1mean(gen_kl_error) < 0.02All 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
token_mult_prob_error, mediangen_kl_error, meanBoth 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.pyon 2 GB200 nodes x 4 GPUs: Qwen3-1.7B on workplace_assistant behind NeMo-Gym (the setup ofgrpo-qwen3-1.7b-1n8g-megatron-vllm-gym-single-controller-length_penaltywithout 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.async_rl.recompute_kv_cache_after_weight_updatestoken_mult_prob_error, max over steps 1-10token_mult_prob_error, median / max over 30 stepsgen_kl_error, meanPD 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 mediantoken_mult_prob_error1.022, last step 1.023, meangen_kl_error1.7e-3.The nightly's checks sit close to these values: median and last-step
token_mult_prob_error< 1.05, meangen_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):
timing/train/total_step_timetiming/train/exposed_generationtiming/train/weight_sync(pause, sync, resume)timing/train/prepare_for_generation/sync_policy_paramstiming/train/policy_trainingThe 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)
NCCL_NET_PLUGIN=noneand 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).tool_parser: qwen3_coderdoes 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 recipegrpo-qwen3-1.7b-1n8g-megatron-super-swe1). This PR's recipe setstool_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_automodelis not in the validation image); the per-entrypoint refusal tests intest_grpo.py,test_ppo.py,test_distillation.pyandtests/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/generation1129 passed,test_grpo.py510,test_distillation.py37,test_ppo.py105,tests/unit/single_controller2258,tests/unit/weight_sync458,tests/unit/environments526,test_recipes_and_test_suites.py16. 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.pyran withoutHF_HOME, so the recipes that read it fail on both trees.What the merge changed here: main's #4801 adds a
disagg_layout.pyof its own with a subset of these helpers. The merged module is this branch's, with main'sreplica_width_fromand main'splan_engines(ValueErrorinstead ofassert);validate_disagg_entrypointlets 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: thetests/unit/weight_syncrebuild tests (stubs without the disaggregation fields) andtest_vllm_modelopt_real_quant_config.py(fake vLLM withoutkv_transfer).GPU (1 GB200 node), on vLLM 0.33 at d72df4b, before the merge of main d040a22 and not rerun:
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 underbidirectional_kv_xfer).finish_generationandinvalidate_kv_cachesucceed in ~0.45 s on all three layouts. Underbidirectional_kv_xfera 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:
Not yet exercised on GPU: the
kv_cache_awarerouter against real KV events.Needs upstream changes
#5350 (
nixl1.5.2 for vLLM 0.33'sNixlConnector). This PR carries the same bump until it merges, so it stays runnable; the lines drop out of this diff oncemainis merged back.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.🤖 Generated with Claude Code