Why a group restored mid-episode can switch harness after a config change

NVIDIA-NeMo/RL #5158 · all links pinned to head 824c116 (the PR's code is the same at the newer head 18d98e6)

Before
No multi-harness routing, so a resume could not move a group to another harness.
This PR
Recomputes a resumed group's harness from its saved group ID, and stops the run if a finished sibling ran on a different agent type.
Status
Open, not fixed in this PR. Only when multi_harness changes across a resume, which the PR calls unsupported but says it guards. Raised in review comment C5.

Three pages on this PR, one question each. This one: what the resume check misses.

Background. With token capture, a checkpoint can save a prompt group halfway. With sibling-level recovery and turn or prefix restore, a generation that was mid-episode resumes from the state Gym saved on the server that ran it. A sealed sibling is one that already finished. Dotted words have a short explanation: hover or tap them.

The PR's design doc promises:

With token capture, a restored group that would finish on a different agent type stops the run

The checkpoint never records which harness a group was on. The only label is each sealed row's metric name. So _require_unchanged_harness can only compare sealed siblings, and it returns early when there are none.

Save: group g8, 4 generations, weights opencode 2 · pi 1 hash(g8) = 0.519 < 2/3 → OpenCode. Gym saved each mid-episode generation's state on the OpenCode server. A · one generation already sealed B · none sealed yet done mid mid mid mid mid mid mid Restart with weights opencode 1 · pi 1 → hash(g8) = 0.519 ≥ 1/2 → now Pi _require_unchanged_harness sealed row says swe/opencode_agent current pick is swe/pi_agent RestoredHarnessChanged: run stops _require_unchanged_harness sealed = [] if not sealed: return no check: the run continues restore keeps the 4 as RESERVED → sent to the pinned actor, routed to Pi saved state is on the OpenCode server no clear stop; Gym's response not traced Green box: the guard works. Red boxes: the gap. Orange "mid" = generation saved mid-episode. Green "done" = sealed. The hash value for g8 is a real output of select()'s formula.

What Gym does in case B was not traced. It may fail with an unclear error, or carry on an episode that a different harness started. Either way the run does not stop with the clear RestoredHarnessChanged error the doc promises. Prompt-group recovery is safe: it drops the whole unfinished group. With the config unchanged, every resume lands on the same harness.

The fix, as pseudocode (proposed, not in the PR)

Where the fix lands: RL only. The rollout checkpoint save and restore, next to the recovery ledger. No Gym change. Nothing below is implemented.

# driver, at checkpoint save
ckpt["multi_harness_fingerprint"] = sha256(routes.candidates)  # taskset, agent, server, weight

# driver, at resume, before any group is re-dispatched
if multi_harness and ckpt["multi_harness_fingerprint"] != sha256(routes.candidates):
    raise RestoredHarnessChanged("multi_harness changed since the checkpoint")  # covers A and B

# per group, at finalize (today's check)
def _require_unchanged_harness(group):
    sealed = [s for s in group.siblings if s.sealed]
    if not sealed: return                                          # the gap; fine once the check above exists
    ...

Real code: _require_unchanged_harness, called from _generate_for_finalization_attempt. The fingerprint also catches the case the doc already admits it misses: a server swapped for another of the same agent type.

🔴 review comment C5 — rollout_manager.py:3101

So what. Changing multi_harness across a resume is unsupported, and the PR says it stops such a run. It does stop it once any sibling has finished. It does not when every sibling was saved mid-episode, which is exactly when the saved state belongs to the old harness. One fingerprint check at resume closes the gap.