One prefill/decode interface, stamped out per backend: where the Megatron stack, #4920 and TRT-LLM put each job

Megatron + Dynamo P/D: #4801 → #4912 → #5023 → #5024 → #5025 → #5097 · native vLLM P/D: #4920 · old Dynamo P/D: #4773 · main 5e271174 (vLLM + Dynamo from #4905 and #4979; TRT-LLM P/D)

Pages on this design, one question each. This one: who does each P/D job, and what one shared interface would look like.

Before
P/D runs natively for TRT-LLM on main, and for vLLM in the open #4920. Behind Dynamo, main has only vLLM without P/D: every engine registers as one backend component. Megatron P/D behind Dynamo is the six-PR stack above.
This page
Compares where each design does each P/D job, against the shape main already uses for vLLM + Dynamo: one adapter base that a backend fills in with a few methods, and NeMo RL's own chat engine in the frontend.
Status
Proposed — a design comparison. Nothing in the target section is implemented. The #4801-sized parts are review comments C9–C12; the engine-side asks are staged on #5023, #5024, #5025 and #5097.
Background. In P/D, a replica is P prefill engines plus D decode engines, each with its own width (TP × PP). On main, vLLM behind Dynamo runs NeMo RL's own adapter base inside the native worker, so refit, pause, capture, forest training and prefix recovery work unchanged. Dotted words have a short explanation: hover or tap them.

Where each design does each job

main: vLLM + Dynamo #4905 + #4979, no P/D yet #4920: native vLLM P/D open, base main Megatron + Dynamo P/D #4801 → #5025, #5097 main: TRT-LLM P/D native, the oldest P/D layout config none: no roles DisaggConfig DisaggConfig, 3 keys forced DisaggConfig Per-role engine knobs none vllm_cfg.prefill_engine dynamo_cfg.prefill_engine trtllm_cfg.prefill_engine Roles, widths, placement none disagg_layout.py (shared) own engine_roles, widths own; moves to disagg_layout Generation class VllmGeneration, dynamo mode VllmGeneration + P/D branches sibling class, N engines TrtllmGeneration + roles Frontend, P → D routing Dynamo frontend, KV router own relay actor Dynamo frontend, P → D router TRT-LLM OpenAIDisaggServer Chat render (Gym) NemoRLChatEngine relay renders (chat_render) shared engine + ChatBackend TRT-LLM server renders Engine side of Dynamo DynamoVllmAdapter (4 hooks) n/a: refuses dynamo Megatron-LM adapter subclass n/a Rollouts (no Gym) rollout_client; worker params refused: Gym only copied client, own params refused: Gym only Capture after the call worker's save_capture refused 3rd path: stage_completed refused Refit, pause native worker, unchanged per engine; pause P, then D own fan-out; pause P, then D per engine collective the shared way (main's design) small backend piece, standard place a second way to do a shared job parallel copy of what main has missing or refused Underlined cells link to the code. Megatron cells read the whole stack: #4801 → #5025, plus #5097 for Gym.

Three things stand out:

💬 review comment C10 — dynamo_config.py:47 C11 — dynamo_config.py:179 C12 — dynamo_config.py:89

The target: one interface, two thin backends — proposed, not in any PR

Nothing below is implemented. Everything green is written once. A backend writes only the blue boxes.

Written once, backend-neutral Config DisaggConfig + one dynamo_cfg schema per-role knobs in the backend's own block disagg_layout (from #4920) roles, widths, replica tiling, placement TRT-LLM and vLLM already share it P/D fleet steps refit ranks per engine (worker_offset) pause P then D; full-fleet membership only ManagedDynamoRuntime frontends, KV router; + P → D routing + readiness counted per role NemoRLChatEngine (from #5097) render, capture decision, TQ prefix splice backend plugs in through ChatBackend rollout_client one wire format; the worker builds sampling RolloutResult back, routed experts included DynamoEngineAdapter request handlers: rollout, Gym call (capture begin/save), generation cut · error mapping · start_dynamo_endpoint new for P/D: set disaggregation_mode + component by role · prefill leg returns a handle, decode leg gets it · no KV events on decode Written per backend DynamoVllmAdapter (on main) serve_rollout · start · abort · kv_event_sources + serve_prefill, serve_rollout(handoff=) = NIXL kv_transfer_params VllmChatBackend (renderer + parsers) vllm_cfg.prefill_engine / decode_engine (as in #4920) Runs in the native vLLM worker, on its own event loop. Refit, pause and capture stay the native code. DynamoMegatronAdapter (does not exist yet) serve_rollout · start · abort · kv_event_sources + serve_prefill, serve_rollout(handoff=), release_handoff (claim/pin) MegatronChatBackend (in #5097) Megatron per-role layout keys, in the backend's own block Runs on each engine's rank 0, on the inference loop. Keeps the stack's 3 engine-build hooks, which already fit. written once a backend writes only this Underlined names link to the code.

The four engine methods are the ones main already asks of every backend (engine_adapter.py L148-L169). P/D adds two: the engine's role, which picks the Dynamo component it registers as (main hard-codes backend), and the KV handoff: the prefill leg returns its transfer handle and the decode leg takes it. Dynamo's SDK (ai-dynamo 1.8 on main) already routes both legs: an engine sets WorkerConfig.disaggregation_mode, the prefill leg puts an opaque handle in disaggregated_params on its last chunk, and the frontend passes it to the decode leg as prefill_result. A decode engine never calls prefill. So a backend writes serve_prefill (returns the handle), takes the handle in serve_rollout, and may write release_handoff (Megatron-LM claims and releases prefill blocks; vLLM's NIXL needs nothing). Two things are not checked yet: whether Dynamo's prefill router keeps NeMo RL's request annotations, and what happens when a refit lands between the two legs (the base should refuse a handle from older weights).

The fleet jobs are the same in all three P/D designs: plan the roles, give each engine its own refit ranks (the earlier widths added up, as worker_offset in #4801 does), pause prefill before decode, and refuse partial membership. Each design writes them again today. A backend only needs to supply its engine width and config per role.

What this means for #4801 and the rest of the stack

#4801 sets the config and layout shape every later PR builds on, so its parts are cheap to fix now:

The engine-side asks are staged on the later PRs, for their own reviews:

So what. Half of the "one interface" goal is already built: #5097's shared chat engine and #4920's shared layout. The other half is the engine side, where Megatron still goes around main's adapter. Moving it onto DynamoEngineAdapter plus the two P/D methods would let vLLM P/D behind Dynamo reuse all of it, so it would not need a fourth design. The review links work for others only after the review is published.