NVIDIA-NeMo/RL #4265
(stack part 2 of 3, on top of #4264).
RL links pin head ed14402 (base: ad3c9cb); Gym links pin f4fcf8c.
Ten pages on this stack — this one: #4265: how a finished Gym rollout is tracked.
/run is, what Gym keeps, and what an ACK deletes/run is the HTTP call RL makes to a Gym agent to play out one rollout (one sibling)
from start to finish: every model call, every tool call, and the final scoring. It is a single
blocking POST: it returns only when that rollout is done.
RL sends all siblings' /run calls at once and
handles each reply as it arrives. There is no polling./run returns (a
BaseVerifyResponse):
response: the output messages and tool calls, as textreward: the score the environment gave this rolloutmask_sample: "leave this sample out", set when the environment itself failed/run. Without the reply, the rollout has no reward and cannot be trained on./run if the
connection drops. If the first reply was lost after the agent finished, the re-sent call
gets the stored reply back instead of running the rollout
again. This copy lives only in memory: a Gym checkpoint
does not save it, so it does not survive a restore.Gym runs each rollout as an agent. With checkpointing on, Gym keeps every finished result until RL sends an ACK for it (a short "I have saved this result, you can delete your copy" message). Its code says so: results "remain replayable until their receipt is acknowledged", and Gym will not commit a checkpoint while any finished result is still un-ACKed. So RL must ACK each result, but only after the result is safely in RL's own saved state. Otherwise a crash between the two loses the rollout. This PR builds that hand-off.
Where the two paths are the same: the row still goes through
run_rollouts to Gym's /run, and RL still seals it with
mark_sibling_sealed.
What is new sits on either side of that seal: the receipt before it, and the ACK debt after it.
The ACK debt is written in the same locked step as the seal
(rollout_manager.py:2445-2465),
and the network send happens after the lock is released. That order is required: if RL crashed after
sending the ACK but before saving, Gym would have deleted its copy of a result RL never saved. Debts are removed only
after Gym accepts the ACK
(mark_completed_executions_acknowledged).
| Completion receipt | Rollout receipt | |
|---|---|---|
| Made by | Gym, for one finished run | RL, from Gym's token-capture list for that run |
| Holds | ID, try number, a hash of the /run reply, which token list to read, the last model call |
which TQ rows make up this rollout, which call was the last one, the reward |
| Used for | the body of the ACK (and picking the right token list) | rebuilding the training row from TQ |
For each finished row, in this order:
/run returns the reply (nemo_gym.py:1875)._completion_receipt_for)._postprocess_receipt_mode).acknowledge_completed_executions); Gym deletes its
copy of the reply; RL removes its "owe an ACK" note
(mark_completed_executions_acknowledged).By step 5, RL already has everything it needs. The ACK only lets Gym free its copy.
/run | /acknowledge | /retire | |
|---|---|---|---|
| Means | "Play out this rollout (one try) to the end." | "I saved try N's result; delete your stored copy." | "I gave up on try N; stop it and never accept it again." |
| RL calls it | for every try of every rollout | after it seals a finished row (#4266 sends these in the background and flushes the rest before prepare) | never, today. The route exists in Gym, but nothing calls it. The proposed fix on the lost-reply page would call it when RL gives up on a try. |
| Works on | a new try | only a finished try, with its exact receipt | a try that is not finished: running, parked, or never started |
| Gym does | runs the model and tool calls, scores it, returns the reply with the reward | checks the receipt, deletes the stored reply, marks the try done for good | cancels the task, drops any saved turn, blocks that try number |
| On a finished try | the same try sent again gets the stored reply back | the only call that releases it | refuses and answers completed_unacknowledged: True
("use /acknowledge") |