Where the Megatron Dynamo switch in #4801 sits next to main's vLLM Dynamo path

PR #4801 (first of five: #4912 โ†’ #5023 โ†’ #5024 โ†’ #5025) ยท builds on the merged #4905 ยท permalinks pinned to head 1a2eca34; the removed path links to main before #4905 (95095b71)

Pages on this design, one question each. This one: how the Megatron switch fits next to main's Dynamo path.

Before
On main, dynamo: true means NeMo RL's own vLLM workers behind a Dynamo frontend (#4905, merged). Main's config check allows it only for backend: vllm.
This PR
Lets dynamo: true also mean Megatron prefill/decode engines, adds their config and engine-width math, and teaches refit about shards of different widths. The switch itself is refused until #5025.
Status
Open โ€” the backend checks now agree; two things are left. Main still rejects this PR's control_timeout_s as "removed" (review comment C9), and part of the Megatron config is a hand copy of main's (C10).
Background. Dynamo puts one HTTP frontend in front of many inference engines and routes each request. A prefill/decode split runs prompt reading and answer writing on different engines. A refit pushes new weights from the trainer into the engines after every step. Dotted words have a short explanation: hover or tap them.

Three ways Dynamo has fronted NeMo RL's engines

All three end at a Dynamo frontend. They differ in who owns the engine workers. The first was removed by #4905. The second is main today. This stack adds the third, using the same dynamo: true switch.

before #4905 โ€” removed backend: dynamo main today (#4905) vLLM behind Dynamo #4801 stack โ€” this PR Megatron prefill/decode behind Dynamo backend: dynamo dynamo_cfg: {engine: โ€ฆ} backend: vllm dynamo: true backend: megatron dynamo: true disaggregation: 1 P + 2 D no flag; picked the class by name resolve_generation_class Both checks allow vllm and megatron (reconciled in this PR) configure_generation_config resolve_generation_class DynamoGeneration started Dynamo's own vLLM workers VllmGeneration NeMo RL's own vLLM workers join MegatronGeneration refuses for now; #5025 builds the fleet frontend โ†’ dynamo.vllm frontend โ†’ NeMo RL vLLM frontend โ†’ Megatron P + D Still open between this PR and main C9: main rejects dynamo_cfg.control_timeout_s as "removed" C10: Megatron frontend args copy main's by hand runs on main / agreed planned, later in the stack still open removed by #4905 Underlined names link to the code.

C9. This PR adds dynamo_cfg.control_timeout_s for Megatron. #4905 put the same key on main's list of removed keys, and the check ignores the backend. It runs first at startup (run_grpo_single_controller.py), so a Megatron config that sets the field stops with "refit and pause use the vLLM backend's own controls".

C10. MegatronDynamoFrontendArgs repeats five fields of main's DynamoFrontendArgs, and dynamo_enabled is defined twice. This PR's Dynamo 1.8 commit already had to copy main's changes over by hand.

๐Ÿ’ฌ review comment C9 โ€” dynamo_config.py:83 C10 โ€” dynamo_config.py:47

What happens at startup with dynamo: true โ€” before, after, and the C9 fix (proposed)

Three checks run in order on the driver before any engine starts. Before this PR, a Megatron config with dynamo: true stopped at the second one. After it, the config gets through the backend checks and is refused on purpose by MegatronGeneration until #5025 builds the engines. On the way, it now requires P/D: there is no Megatron + Dynamo without disaggregation, while vLLM + Dynamo on main has no P/D yet.

Startup, before (main)

# driver, run_grpo_single_controller.py, in this order
check_outdated_config(config)                       # dynamo_cfg.control_timeout_s: 'was removed'
configure_generation_config(gen)
    if gen.dynamo and gen.backend != "vllm": raise  # megatron + dynamo stops here
    if gen.dynamo_cfg and not gen.dynamo: raise
resolve_generation_class(gen)                       # picks the class by backend name
    .validate_settings(master)                      # MegatronGeneration: no Dynamo branch

Startup, after (this PR)

# driver, same order
check_outdated_config(config)                                     # C9: still rejects control_timeout_s
configure_generation_config(gen)
    if gen.dynamo and gen.backend != "vllm": raise
    if gen.dynamo and gen.backend not in ("vllm", "megatron"): raise
    if gen.dynamo_cfg and not gen.dynamo: raise
resolve_generation_class(gen)
    if gen.dynamo and backend not in ("vllm", "megatron"): raise  # same check, a second copy
    .validate_settings(master)                                    # MegatronGeneration
        if gen.dynamo:
            validate_megatron_dynamo_generation(gen)              # needs disaggregation on
            raise NotImplementedError("fleet not built")          # #5025 removes this

Real code: check_outdated_config, configure_generation_config, resolve_generation_class, MegatronGeneration.validate_settings, validate_megatron_dynamo_generation (the P/D requirement is at L233-L238).

The fix for C9, as pseudocode (proposed, not run)

Where the fix lands: this PR's config, two lines. Remove the key, as main did for vLLM. On main the caller passes each control call its timeout (pause_generation_for_refit(timeout_s=โ€ฆ), filled by the SingleController from async_rl.generation_fleet_health). The engine calls that read the key come later in the stack, so that part is staged on #5024. Main's check, its test and its migration note stay as they are.

# this PR, dynamo_config.py
class MegatronDynamoCfg(BaseModel):
    startup_timeout_s: PositiveFloat = 600.0
    request_timeout_s: PositiveFloat | None = None
    control_timeout_s: PositiveFloat = 600.0   # main already rejects this key

# #5024, MegatronDynamoGeneration (staged there)
    timeout_s = self._control_timeout_s if timeout_s is None else timeout_s
    deadline = None if timeout_s is None else time.monotonic() + timeout_s   # caller decides, as on main

๐Ÿ’ฌ review comment C9 โ€” dynamo_config.py:83

This PR also changes how refit numbers engines of different widths. That, and how all three refit transports work, is on one refit page.

So what. This PR is groundwork: nothing new runs on main, and it now agrees with main on which backends may set dynamo: true. Two things to settle before #5025 turns the switch on: fix C9 by removing control_timeout_s, or every Megatron Dynamo config that sets it fails at startup with a vLLM error; and decide whether Megatron + Dynamo should exist without P/D, as vLLM + Dynamo does today. The review links work for others only after the review is published.