Who calls what in #5176: a new CPU actor next to each vLLM worker does the prefix TQ writes
NVIDIA-NeMo/RL #5176, part 11 of 11 in the partial-checkpointing stack.
Own commit only: 788133a..981376a (also on a mirror PR that shows just this diff).
Permalinks pin 981376a; "before" links pin 788133a.
Before
The vLLM worker process cuts the calls, encodes the rows and writes them to TQ itself, with its own in-process TQ client, on one control thread.
This PR
Adds a prepare thread and a writer thread inside the worker, and an optional CPU-only Ray actor on the same node that does only the prefix writes.
Status
New, off by default. Review open: the shape is sound; the review asks to make it the default with no settings (C15) and to shrink the hop to the actor (C2).
Four pages on this PR. This one: which process and which class does each step, and what crosses each boundary.
Background. At a checkpoint, Gym sends each vLLM worker an inventory.
The worker freezes each call, builds one row of tokens per call, writes the rows to
TQ,
and only after TQ confirms does it seal the rows and answer Gym.
Dashed boxes are OS processes; solid boxes inside are the classes that run each numbered step. Dotted words have a short explanation: hover or tap them.
Processes and classes, before and after
Your questions, answered from the code
Question
Answer
Who starts the writer actor?
The vLLM worker itself, once, in
setup_token_capture, and only on the worker that owns the model, when prefix_writer_actor: true. It is not a detached actor, so the worker that made it owns it; the worker kills it at shutdown.
Isn't there already a TQ client actor on every node?
No. TQ's own actors are the controller and the
storage units. A TQ client is a plain object inside each process that uses TQ: the worker builds one with
build_data_plane_client. The writer actor builds a second client in its own process (L272).
What crosses the boundary?
A PrefixPut: the row keys, the partition name, every column as a flat NumPy byte buffer (plus dtype, shape, and row offsets for ragged columns), and the per-row tags. For the 5-row example: token_ids_delta = all 5 rows' new token ids end to end, as int64 bytes, with 6 offsets marking where each row starts; route columns are [tokens, layers, top-k] int16. It goes through ray.put then actor.put.remote. The reply is the same keys plus timings.
Can it land on another node?
No. It is created with NodeAffinitySchedulingStrategy(node_id, soft=False), so Ray only places it on the worker's node. If that node has no free CPU, it stays pending, and setup gives up after 180 s and fails loudly. A node check after start is a second guard.
Does it do TQ reads?
No. Only prefix PUTs and the cleanup of a failed PUT. Restore reads (PrefixReadBatcher) and the final write when a call finishes keep the worker's own client.
Why a separate process at all?
Encoding and sending the bytes costs CPU and holds Python's lock. Moving the send out of the vLLM worker keeps it free to serve requests. Measured with the actor and the packing added: 31.7 s → 25.2 s for the first snapshot (one run).
So what. The writer actor is a second TQ client in a CPU process pinned to the worker's node; it only writes prefix rows, and the worker still does every read.
The worker hands it ready-made columns and waits for TQ's confirmation before sealing anything, so nothing is acknowledged early.
The packing into NumPy bytes and the client class around the actor are the parts the review asks to remove: Ray can carry the TensorDict, and the sink's _call_dp already calls actor handles.