#4979 at a2c74e6, which has merged #4905 (at c6a4c66b). All links are pinned to a2c74e6; links to deleted code use the SHA it lived at. First written against #4905 at 44671d3b and #4979 at c4fe2bd5.
c4fe2bd5, #4979's Dynamo engine re-ran its own copy of the native chat server's capture steps on token ids alone. The copy skipped the forest-training "candidate" step, so those calls failed. It called the prefix splice with different inputs (explained below), and it never ran the retained-media check.790feb77, 0b7894a4, 43efaba3) moved the render, the capture decision, the TQ read and the splice into NeMo RL's own chat engine inside Dynamo's frontend. It runs the native render code and passes the splice the same inputs. The engine side keeps only the steps after the render.Nine pages on this stack (#4905, #4979 and #5115), one question each. This one: does the Dynamo path reuse NCCL refit, TQ token capture and the prefix splice, or copy them?
Gym's chat calls reach vLLM one of two ways. Natively, each vLLM worker runs its own chat server (chat_server.py). Through Dynamo, NeMo RL's chat engine runs in Dynamo's frontend process, and an engine adapter runs inside the vLLM worker. Token capture and the prefix splice run on both. Dotted words have a short explanation: hover or tap them.
| Piece | Shared or copied at a2c74e6 |
|---|---|
| NCCL refit | Shared. Dynamo serves the worker's own vLLM engine, so refit is the worker's update_weights_from_collective_async. #4905 deleted the old Dynamo refit. |
| Rollouts (token ids in) | Shared. The adapter calls the worker's _serve_rollout, the same function the Ray path uses. |
| Capture core | Shared. Begin, media snapshot, TQ write and abort are the worker's own methods (vllm_worker_async.py L809-L1135). So are the TQ prefix read, splice_prefix_tokens, the turn-end ids, the candidate decision, the chat render, the on-policy sampling check and vLLM's tool and reasoning parsers. |
| Post-render step order | Written twice. TQ read → splice → fit max_tokens → media snapshot → move image placeholders → begin capture: native chat_server.py L339-L436; Dynamo chat_engine.py L286-L306, L361-L383 and adapter.py L319-L360. |
| The staged message | Written twice. Native builds it from vLLM's reply (L597-L621); the adapter builds it by hand (_stage L487-L520). |
| SamplingParams | Copied from vLLM's chat server into adapter._generate L406-L445. |
| Errors and aborts | Mapped by hand on each side: native routes L799-L948; Dynamo chat_engine.py L231-L255, adapter.py L263-L289, L396-L404. Dynamo never records the context_length abort reason; an overflow there is recorded as engine_error. |
| "top_logprobs must be set" | Native only (L539-L544). Through Dynamo the check never runs, and the parity test always sets top_logprobs, so it does not notice. |
Each row is one step. The middle column is the shared code both sides call. The example is turn 2 of a chat on a checkpoint whose turns end on <|im_end|> (151645) but whose tokenizer's EOS is <|endoftext|> (151643), the shape the parity test builds for its turn_end_not_eos case.
The earlier version of this page said the splice on the two paths was "same function, different inputs". It meant this. At c4fe2bd5 both paths called splice_prefix_tokens. It counts how many turn-end tokens the old history holds (N), then cuts the new prompt at its N-th turn end and puts the model's own tokens before the cut. The native server called it at vllm_worker_async.py L1432, the Dynamo engine at native_engine.py L559. Only the model's own tokens from TQ were the same on both. The other three inputs came from different places:
| Argument | Native at c4fe2bd5 | Dynamo at c4fe2bd5 |
|---|---|---|
eos_token_idwhich ids end a turn | configured stop_token_ids + the generation config's EOS list + the tokenizer's EOS (L1188-L1194, L1439) | not passed, so the tokenizer's EOS only |
template_prefix_token_idswhere to count N | the history re-rendered up to the last assistant message (L1416) | None: the engine had no messages, so N was counted in the model's own prefix, plus one EOS if it did not end on one (L163-L168) |
template_token_idsthe new prompt | vLLM's renderer with the checkpoint's template | Dynamo's Rust renderer in the frontend, then vLLM's processor (L741-L748) |
The turn-end ids are the input that broke. Same turn-2 call as the figure, run through the old function (shortened to the tokens that matter):
| Native: turn ends = {151643, 151645} | Dynamo: turn ends = {151643} | |
|---|---|---|
| model's prefix from TQ | [user … 151645, assistant 220, 17, 151645], same on both | |
| N, the turn ends to skip | 2 (in the history render) | 1 (no 151643 in the prefix, plus the one it adds) |
| the new prompt holds | 151645 three times; the 2nd closes turn 1 | no 151643 at all: Qwen's template never writes it |
| result | [… 220, 17, 151645, user 21, 22, 151645, assistant] | AssertionError: EOS token #1 not found: the call fails |
So every turn-2 call with a prefix failed through Dynamo on such a model, while the native path served it. gpt-oss has the same shape: a tool-call turn ends on <|call|>, which is not its tokenizer's EOS. That was review comment C16. The other two inputs did not break this example, but they could make the two paths cut in different places: counting in the model's prefix goes wrong if the model wrote an EOS id as ordinary text, and the Rust renderer is a different program from the checkpoint's own template.
Fixed at a2c74e6, in #4979, RL only. 0b7894a4 added turn_end_token_ids (stop ids + generation-config EOS + tokenizer EOS) and made eos_token_id required. 43efaba3 moved Dynamo's splice into the frontend, where the render pool runs the same _render_chat_call as native, so both get the same new prompt and the same history render. 53d7c9df deleted the None mode. The turn_end_not_eos parity case now checks the prompt matches.
@@ Dynamo's splice call · native_engine.py L559-L564 at c4fe2bd5 → chat_engine.py L376-L382 at a2c74e6 splice = splice_prefix_tokens( - tokenizer=self._llm.tokenizer, - model_prefix_token_ids=prefix_token_ids, - template_prefix_token_ids=None, - template_token_ids=template_token_ids, + tokenizer=None, + model_prefix_token_ids=prefix, + template_prefix_token_ids=rendered.history_token_ids, + template_token_ids=rendered.template_token_ids, + eos_token_id=turn_end_token_ids, )
history_token_ids and template_token_ids come from _render_chat_call, and turn_end_token_ids from the render pool, built with the same two functions the native server uses at L386. One difference is left: Dynamo passes tokenizer=None, which only drops the decoded text from the error message.
✅ review comment C16 — resolved C26 forest training — resolved
top_logprobs check. The next change to land there is #4506 (prefix recovery). It adds restore steps between the TQ read and the splice, but only in the native chat path (vllm_worker_async.py L1568-L1600 at 7d75696). Moving steps 2–6 into one shared method before #4506 lands would give it one place to go.