Design proposal for #4979, first written at a1659e9d; updated for #4979 at a2c74e6, which has merged #4905. Links are pinned to a2c74e6; links to deleted code use a1659e9d. Dynamo 1.5.1, vLLM 0.29.0.
Nine pages on this stack (#4905, #4979 and #5115), one question each. This one: the design asked for, and how much of it was built.
a1659e9d, Dynamo's Rust frontend rendered Gym's chat calls, and the engine re-ran a copy of the capture steps on tokens alone. (#4905's rollouts are not affected: they send token ids to /v1/completions, which Dynamo passes through without a template.)790feb77, 0b7894a4 and 43efaba3 build the proposal: a launcher starts Dynamo's frontend with NeMo RL's chat_engine_factory; our chat engine renders with the checkpoint's own template and processor, reads the TQ prefix and splices; the engine does the one TQ write; Dynamo's Rust renderer is refused.a2c74e6. Three differences from the proposal: (1) pixels travel pickled inside the call, not through Dynamo's shared-memory / NIXL sender; (2) only the vLLM halves are shared, Megatron's capture classes were not generalized; (3) the native chat server kept its own copy of the steps after the render (see shared or copied). C27 (the design) and its parts are resolved.Each column follows one Gym call through seven steps: ①receive the call, ② apply the chat template, ③ read the earlier tokens from TQ and splice them in, ④ pick an engine, ⑤ turn images into pixels, ⑥ run the model and write the call to TQ, ⑦ reply. Dashed boxes are OS processes, and the boxes inside are the classes that run each step. Without Dynamo, all of it runs in one process per vLLM worker. Before the redesign, #4979 moved ② into Dynamo's Rust code and ran a copy of ③ after routing. The proposal, now built, keeps Dynamo's frontend and router, but runs our own Python inside the frontend process, through Dynamo's chat_engine_factory hook.
Where each piece lives, as built. The Dynamo frontend is one process. Its HTTP server and KV router are Rust, and our chat engine is a Python object in that same process: Dynamo's Rust code calls into it. It renders in a pool of helper processes (render_pool.py) with the native server's render code, so ② and ⑤ match native. The TQ read for ③ happens in the chat engine, through a read-only TQTokenSource (_CaptureSource). It hands the spliced ids to the KV router in the same process (④). The call then crosses the network to one vLLM worker, a Ray actor process. There, Dynamo's Rust Worker calls DynamoVllmAdapter, which wraps vLLM's AsyncLLM in that same process. It begins capture, runs the model and does the one TQ write (⑥), using the same worker methods as the native server. The reply goes back with only the text and where the call was stored, so routed experts never leave the worker.
| Term | What it is |
|---|---|
| Chat template + processor | Turns chat messages into token ids. The template (Jinja text from the checkpoint) lays out the turns. The processor (Python from the checkpoint, can be custom) turns each image or video into pixel values and into the right number of image tokens. |
| Prefix splice | On turn 2+, the earlier turns are swapped for the exact tokens the model produced, so training sees what the model really generated, not a re-render. splice_prefix_tokens. |
| TQ prefix read | Fetches those earlier tokens from TQ, using the chain of earlier calls Gym names. |
| Capture decision | Not "capture on or off". With forest training, Gym says "this call may continue an earlier one" (mode="candidate"). decide_capture_input checks the messages and decides: continue from the earlier tokens, or start fresh. It needs the messages, so it must run where the messages are: in the frontend. |
| Capture plan | The small record the frontend attaches for the engine (GymCallPlan): the decided capture context, how long the earlier part is, and where the splice cut. No token arrays: the earlier tokens are already the start of the prompt. |
_stage → _finish_request_capture L1046-L1130). One small change: the retained-media check (L868-L984) reads TQ in the engine, not the frontend.logprobs and top_logprobs with a 400 (L584-L600); ours does not copy that check. Score centering has Gym add logprobs: true, top_logprobs: K to every call (score_centering.py L39-L56), and the adapter stages the sampler's top-K with extract_score_centering_samples in the same TQ write.reasoning_content as <think> when the template doesn't use it (oai.rs L628), keeps tool arguments as strings where vLLM makes them dicts, and never reads processor code. The launcher and the config now fail if a run asks for it (frontend.py L38-L43, config.py L53-L64).Where it landed: RL only, in #4979. No Gym change: Gym already sends the chat call and the ng_capture context to the frontend. No Dynamo change: the hook exists in 1.5.1, but it is marked experimental.
790feb77: the classes that lived in _setup_vllm_openai_api_server are now chat_server.py.0b7894a4 shares the render and capture decision (_render_chat_call) and the turn-end ids. Two differences: Megatron's TQMegatronPromptPreparer and TQMegatronTokenStager (L124, L443) were not generalized, and the native server kept its own copy of the steps after the render (chat_server.py L339-L436) next to Dynamo's.43efaba3: a launcher starts Dynamo's frontend with ChatEngineFactory.DynamoVllmAdapter on the DynamoEngineAdapter base runs only the "after" half (L263-L404). The old _generate_gym copy is gone.✅ all resolved: C27 design C26 forest training C28 Rust renderer C29 logprobs C30 mixed media C31 config messages #4905 C61 groundwork · open: #5119 Megatron forest training