NVIDIA-NeMo/RL · #4801 → #4912 → #5023 → #5024 → #5025 → #5097 · this page: PR #5025, reviewed against #5024 · permalinks at head 00d52a2c, base 9df434a7
backend: megatron and dynamo: true, startup refused the config: the prefill and decode engines were built and registered with the Dynamo frontend, but nothing sent them rollouts.One page for this PR. The ★ page links the pages for every PR in the stack.
Background. A rollout is one prompt sent to the inference engine to get a completion back, with the log-probability of each new token. Dynamo's frontend can split one request across two engines: a prefill engine reads the prompt and builds its KV cache, then hands that cache to a decode engine over NIXL, which writes the answer. PRs 1–4 of this stack built those engines. Dotted words have a short explanation: hover or tap them.
Both paths start from the same call, generate_async, made by the trainer's rollout loop for one prompt. The direct path makes a Ray call to one Megatron worker, which runs prefill and decode in one engine. The new path builds an OpenAI completion request in generate_through_frontend and posts it over HTTP. The two meet again in the rollout loop, which reads only the new tokens and their log-probabilities. The example below is the PR's own unit test: prompt [1, 2, 3] padded to 4, one new token 8 with log-probability -0.5.
max_tokens:2 is the configured 16 cut to what fits: the test's max_model_len is 5 and the prompt is 3 tokens (allowed_new_tokens). top_k:-1 and top_k=0 both mean "off" in their own API.
Rollout call, before (#5024)
# driver, rollout event loop async def generate_async(data): raise NotImplementedError("do not serve rollouts yet")
Rollout call, after
# driver, rollout event loop; one call per prompt, many run at once async def generate_async(data): raise NotImplementedError("do not serve rollouts yet") if data is empty: return url = random.choice(frontend_urls) # every frontend reaches the whole fleet out = await generate_through_frontend(cfg, url, data) out["gen_leader_worker_idx"] = [0] # same as the direct path yield 0, out # generate_through_frontend, same event loop body = completion_payload(prompt ids, max_tokens = min(16, 5 - 3)) for attempt in 1..3: # post_completion resp = await POST url + "/completions" # new aiohttp session each try if not is_retryable(resp): break # C1: timeouts retried, unlike main's client sleep 1 s ids, lps, truncated = parse(resp) # nvext.completion_token_ids, token_logprobs return single_sample_output(...)
Real code: async_http_post_json, parse_completion_response, single_sample_output. The vLLM Dynamo path already has its own client for this in rollout_client.py.
Startup check, before → after
# driver, setup_single_controller(), before anything is built validate_single_controller_config(cfg) # C7: its penalty checks call should_use_nemo_gym() ... if token_capture.enabled and not should_use_nemo_gym(cfg): … # C7: asserts expose_http_server first ... MegatronDynamoGeneration.validate_settings(cfg) # moved up from after the Gym check raise NotImplementedError("not served by MegatronGeneration yet") if env.should_use_nemo_gym: raise NotImplementedError # follow-up PR 6 if policy.is_vlm: raise ValueError if router_replay: raise ValueError # kept from #5024 if storage units on "inference": raise ValueError use_nemo_gym = should_use_nemo_gym(cfg)
The trainer only reads output_ids and logprobs between the prompt length and unpadded_sequence_lengths, so the narrower output width on the Dynamo path changes nothing. These do differ after the two paths meet:
| What | Direct | Through Dynamo |
|---|---|---|
truncated | not set | set from finish_reason == "length" (noted in the author's own review) |
ignore_eos: true | honoured with termination_id=-1 | dropped from the request (covered by C1) |
| a failed request | a Ray error | retried up to 3 times, timeouts too; C1 asks to use main's rollout client instead |
| CI | run in L1 | functional test written, not in any lane until the Megatron-LM pin moves (C3); its preflight still expects ai-dynamo 1.5.1 (C16) |
InferenceConfig.disaggregation_role, so a run dies at the first refit; make the worker's startup check catch that (C17), and add the 3-GPU functional test to L1 once the pin moves (C3). Move the startup check to the start of setup, so Gym configs get the clear error (C7). Send rollouts through main's rollout client and delete this module (C1), so retries, errors and sampling settings match native Megatron generation. Fix the functional test's ai-dynamo version check first, since the base now pins 1.8 (C16).Review comments: C1 · dynamo_rollouts.py:309 C17 · dynamo_generation.py:334 C7 · setup.py:1831 C3 · L1_Functional_Tests_Dynamo.sh:54 C16 · functional test:39-40
These links open for everyone once the review is published.