The Megatron prefill/decode stack: what each of the 6 PRs does, and what works after it

NVIDIA-NeMo/RL · #4801 → #4912 → #5023 → #5024 → #5025 → #5097 · each PR is reviewed against the one below it · state as of 2026-11-23

The goal. Serve NeMo RL's Megatron inference as separate prefill and decode engines behind one Dynamo frontend, with weights pushed from the trainer after every step (a refit), the same way vLLM already runs behind Dynamo on main. Turned on with policy.generation.backend: megatron + dynamo: true. Dotted words: hover or tap.

The six PRs at a glance

dynamo: true is refused at setup — nothing runs on main yet rollouts run ▸ then NeMo-Gym runs 1 · #4801 Config and math dynamo switch per-role TP/PP engine widths, roles refit offsets for mixed widths starts nothing 2 · #4912 Engines + refit side MegatronDynamo- Generation: one engine per role, own cluster Dynamo worker class refit fan-out engines built, not served 3 · #5023 Register with Dynamo Megatron-LM's Dynamo adapter on each engine's rank 0 etcd, NATS, frontend started by NeMo RL frontend lists engines 4 · #5024 Safe pause, shutdown refit order: stop new handoffs, drain pinned KV, suspend, resume shutdown frees pins bounded control calls refit survives in-flight 5 · #5025 Turn it on: rollouts generate_async posts token ids to the frontend /v1/completions validate_settings now checks instead of refusing GRPO runs on P/D 6 · #5097 NeMo-Gym on P/D shared chat engine with vLLM, Megatron's ChatRenderer token capture written once on decode Gym runs on P/D Merge order left to right. Each PR builds on the one before it. Underlined numbers open the PR.

Each PR in two lines, with its explainer pages

PRWhat it doesWhat works after itExplainer pages
1 · #4801 Adds the dynamo: true switch for Megatron, the per-role prefill/decode layouts, and the math for engine widths. Teaches refit that engines can have different widths. Config and arithmetic only. where the switch sitsone P/D interfacerefit widths
2 · #4912 Adds MegatronDynamoGeneration: it builds one MegatronGeneration per prefill or decode engine, each on its own node, and fans every refit call out to them. Adds a Dynamo worker class that builds Megatron-LM's handoff engine. Engines can be built and refit; still refused at setup. old path vs new pathengine build at the pin
3 · #5023 Runs Megatron-LM's Dynamo adapter inside each engine's rank 0, and starts etcd, NATS and the frontend from NeMo RL, so the engines register with the frontend after the first refit. Frontend sees the engines; still refused at setup. how an engine registersthe adapter, before and after C1every class, side by side
4 · #5024 Orders refit so in-flight KV handoffs finish first (stop new prefills, drain pinned blocks, suspend, resume), and makes shutdown release prefill's pinned blocks. Refit is safe with traffic; still refused at setup. refit and shutdown ordershutdown report
5 · #5025 Turns the feature on. Rollouts post token ids to the frontend; validate_settings checks what P/D cannot serve instead of refusing everything. Ships an example config, a functional test and docs. GRPO rollouts run on prefill/decode engines. direct vs. through Dynamo
6 · #5097 Serves NeMo-Gym chat calls through the frontend's chat engine, shared with vLLM; renders with Megatron-LM's ChatRenderer and writes token capture once, on the decode engine. NeMo-Gym runs on prefill/decode engines (text only). two backends, one chat enginefaults as 400TQ steps on each pathmedia under P/D
What to keep in mind while reviewing. PRs 1–4 change nothing on main at run time: setup refuses dynamo: true until #5025. So a bug in 1–4 usually shows up only once #5025 turns the feature on, and the fix can live in the PR that wrote the code even if it is not reachable yet. Two needs reach outside this repo: the pinned Megatron-LM lacks a field #4912 uses and a class #5097 uses, so both are asked to fail early with a clear message rather than bump Megatron-LM inside the stack.