Why prompt-group mode can stop every later Gym checkpoint
NVIDIA-NeMo/RL #4265.
RL links pin head ed14402; Gym links pin f4fcf8c. Found by reading the code on
both sides; not run against a live Gym.
Before
RL sent Gym no ACKs at all (see page 1).
This PR
Adds ACKs, but in prompt-group mode it records them only once every sibling in the group has finished.
Status
Open โ not fixed in this PR. Raised in the review comments.
Ten pages on this stack โ this one: #4265: the bug in prompt-group mode.
Gym keeps each finished result until RL ACKs it, and its
status()
says "not ready to commit" while any result is un-ACKed. Gym's
retire()
refuses a finished result, so an ACK is the only way to release one. In sibling mode RL records the ACK
debt the moment a sibling finishes. In prompt-group mode (all siblings must succeed, or the whole group is
retried) RL keeps finished siblings in a local dict,
pending_group_results,
and returns early
until all of them are in.
Same group, two modes
What happens in prompt-group mode, step by step
g0 finishes. RL puts its result in a local dict and
returns early, because the group is not complete yet.
No "I owe Gym an ACK" note is written for g0.
The ACK note is written only when the whole group is in, by
record_sealed_group_acknowledgements.
Until then Gym still counts g0 as "finished, not ACKed".
g1 and g2 stay parked. When a prepare fails, Gym
wakes up only runs it had not parked yet. g1 and g2 are already parked, so they
cannot finish, the group cannot complete, and g0 never gets its ACK note.
RL retries prepare until the deadline. Each try gets a 409, and RL
tries again until the prepare deadline (300 s by default),
then gives up on this snapshot.
Worse case, if a sibling fails after g0 finished:
RL throws away the whole group, including g0's result
(_abandon_entire_group), and retries it as try 1.
Gym still holds g0 as finished, and nothing will ever ACK it. Gym's
retire() refuses finished runs, so step 3 now fails on every later
snapshot, for the rest of the process.
Who hits this. Any environment whose group RL retries as a whole while turn-level checkpointing is on. Environments that score each sibling on its own hit it most: their siblings finish at different times, so a group is often half done when a snapshot starts, exactly as drawn above. Under the target-level comment on #4266 that happens when an override forces prompt_group on such an environment. GenRM compare also runs this path, but rarely stalls: its siblings all finish together once the group is scored.
This setup is meant to work, so the fix is to ACK earlier, not to reject the combination. This PR even adds
record_sealed_group_acknowledgements
for it. A lost /run reply strands a finished result the same way; see the lost-reply page.
Where the fix lands: RL only, two files.rollout_manager.py: the prompt-group branch of
_record_streamed_completion records each sibling's ACK note when it arrives.
rollout_recovery.py: one new ledger method, next to
record_sealed_group_acknowledgements, that writes the note without waiting for the group to seal.
No Gym change: Gym already accepts an ACK for any finished run at any time; it does
not know or care about prompt groups.
Nothing below is implemented. Record each sibling's ACK debt as soon as it arrives, like sibling mode does,
and keep only the seal all-or-nothing. That is safe: g0 is ACKed but not yet published, so it is not in
RL's snapshot. On restore it is simply rerun under a new try number; nothing is lost or counted twice.
Scope: this only removes the stall. What the group does on restore (start over, or resume g1 and g2 from their saved turns) is set by the target level in the target-level comment on #4266. This fix works with either.
# rollout_manager.py, PROMPT_GROUP branch of _record_streamed_completion (proposed)
pending_group_results[0] = result_g0 # {0: g0}, 1 of 3 in
async with self._recovery_mutation("sibling_seals") as cut:
ledger.record_unsealed_group_acknowledgement( # new ledger method
cut, "p7", generation_index=0,
completion_receipt=result_g0.completion_receipt)
# ACK debts: {("p7_g0", try 0)}
sink.notify_ready() # ACK sent โ Gym un-ACKed: 1 โ 0
if len(pending_group_results) < 3:
return # g1, g2 still running# snapshot starts: Gym parks g1, g2 at a saved point# status(): running 0, un-ACKed 0 โ ready_to_commit = True โ snapshot commits# group fails later: nothing stranded โ g0 was already released
So what. With prompt-group mode and Gym checkpointing both on, any snapshot taken while
a group is partly done waits out its full prepare deadline (300 s by default in #4266) and fails. One failed group after a sibling finished
blocks every later Gym-aware snapshot for the rest of the process. Recording each sibling's ACK when it
arrives removes both.