NVIDIA-NeMo/RL #5176, part 11 of 11 in the partial-checkpointing stack.
A design proposal from the review, not part of the PR. "Before" links pin 981376a; "after" links pin the draft's a73b857.
AdvantageActor and RolloutReassemblerActor, each build a TQ client and repeat the same start-up, cleanup and checkpoint hooks.PrefixWriterActor. It looks similar but differs in owner, count, placement and how data reaches it.Four pages on this PR. This one: which of the three CPU data-plane actors should share code, before and after.
AdvantageActor and RolloutReassemblerActor | PrefixWriterActor (#5176) | |
|---|---|---|
| Owner | The controller (L459-L464) | Each vLLM worker |
| Count | A pool of N | Exactly 1 per engine |
| Placement | Anywhere: spread off the head node, or its own Python env | Pinned to its engine's node, hard (L390) |
| Data in | Metadata only; it reads TQ itself (assert_metadata_only both ways) | Rows sent through Ray |
| Storage | Lends Mooncake memory, so it has the checkpoint hooks | Holds no rows (segment_size=0) |
| Calls | Many at once, from a queue of free actors | One at a time, in order (max_concurrency=1) |
| Caller sees | The actor handle | A wrapper that looks like a TQ client (put_samples) |
Same in the left column, different in the right: so the first two share a base, and the writer stays its own class.
An earlier version of this page put all three behind one base and one pool; on real code that added a process() rename nobody called generically, a pool of one for the writer, and +128 lines.
Nothing below is merged. #5256 has the real diff and the tests. Red struck lines go, green lines arrive, plain lines stay.
How they are called does not change: setup calls the same two start functions and gets the same list of handles; the controller still calls run and finalize from its own queues of free actors.
AdvantageActor
# AdvantageActor process (1 CPU) x n @ray.remote(num_cpus=1, num_gpus=0, max_restarts=0, max_task_retries=0) class AdvantageActor: @ray.remote(**CPU_ACTOR_OPTIONS) # same four options, written once class AdvantageActor(DataPlaneDelegate): def __init__(self, dp_config, config, estimator, *, label): self._dp_client = build_data_plane_client(dp_config, bootstrap=False) super().__init__(dp_config, label=label) # client, log name, hooks self._computer = AdvantageComputer(self.dp_client, ..., shard_id=label) def mooncake_checkpoint(self, body): ... # now in the base def get_data_plane_snapshot(self): ... # now in the base async def run(self, request) -> AdvantageOutcome # unchanged; the job # driver, setup: same call, same list of handles back def create_advantage_actors(dp_config, config, estimator, *, num_workers): node_ids = _placement_node_ids() # ≈ 20 lines actors = [AdvantageActor.options(spread or soft pin).remote(...) for i in range(n)] try: ray.get([a.__ray_ready__.remote() ...]) except: ray.kill each; raise # ≈ 15 lines placement = spread_off_head() return start_cpu_actors( lambda i: AdvantageActor.options(scheduling_strategy=placement(i)) .remote(dp_config, config, estimator, label=str(i)), n=num_workers) # waits for each; kills all if one fails
RolloutReassemblerActor (the finalizers)
# RolloutReassemblerActor process (1 CPU, own Python env) x k @ray.remote(num_cpus=1, num_gpus=0, max_restarts=0, max_task_retries=0) class RolloutReassemblerActor: @ray.remote(**CPU_ACTOR_OPTIONS) class RolloutReassemblerActor(DataPlaneDelegate): def __init__(self, dp_config, config, *, label): self._dp_client = build_data_plane_client(dp_config, bootstrap=False) super().__init__(dp_config, label=label) self._finalizer = RolloutReassembler(self.dp_client, ...) def mooncake_checkpoint(self, body): ... # now in the base def get_data_plane_snapshot(self): ... # now in the base def check_dependencies(self) # unchanged def finalize(self, request) -> FinalizedGroup # unchanged; the job # driver, setup: same call, same list of handles back def create_rollout_reassembler_actors(dp_config, config, *, num_workers): runtime_env = (the Gym env if it matches, else its own) # unchanged actors = [RolloutReassemblerActor.options(runtime_env=env).remote(...) ...] try: ray.get([a.check_dependencies.remote() ...]) except: ray.kill each; raise # ≈ 15 lines return start_cpu_actors( lambda i: RolloutReassemblerActor.options(runtime_env=runtime_env) .remote(dp_config, config, label=str(i)), n=num_workers, ready='check_dependencies')
The shared piece
# new in #5256: nemo_rl/data_plane/delegate.py (119 lines) CPU_ACTOR_OPTIONS = dict(num_cpus=1, num_gpus=0, max_restarts=0, max_task_retries=0) class DataPlaneDelegate: # base for the two controller-owned actors __init__(dp_config, *, label) # builds the client __repr__() # 'AdvantageActor[2]' in Ray's log prefix mooncake_checkpoint(body); get_data_plane_snapshot() # the copies, written once def spread_off_head() -> placement(index) # moved from advantage_actor.py def start_cpu_actors(make_actor, *, n, ready='__ray_ready__', timeout_s=None) # create, wait, kill all on failure
PrefixWriterActor
No change: it stays as in #5176. Using start_cpu_actors would need an async twin (≈ 22 lines) to save ≈ 8 lines in the writer.
| Change in #5256 (source only) | Lines |
|---|---|
New data_plane/delegate.py: base, start helper, placement, options | +119 |
advantage_actor.py: client, hooks, placement, start, cleanup | −61 |
rollout_reassembler_actor.py: client, hooks, start, cleanup | −21 |
| Net | +37 |
Measured on the draft. Thirteen of the new lines are the license header; the rest roughly breaks even with what the two actors drop.