NVIDIA-NeMo/RL #4507, part 6 of 11 in the partial-checkpointing stack. It tests the feature added by
#4506. All permalinks pin the PR head 7f7a7a5.
Five pages on this PR. Start here. Pages 2 and 3 are the current review; pages 4 and 5 are the first review, on an older head.
The test launches the same small job three times (Qwen3-1.7B, 4 prompts Ć 2 tries, 1 training step):
once without a crash, once killed mid-reply, and once restored from that kill
(the script's three runs).
Each prompt asks the agent to create one calendar event, then list the numbers 1 to N in its closing reply. That reply is long, so the kill lands inside it.
Sampling uses top_p=1e-6, which makes generation almost greedy, so two runs pick the same tokens and can be compared token by token.
Each run saves the exact rows the trainer trained on, and the test compares the restored run's rows with the reference rows.
| Check | Why it matters | Code |
|---|---|---|
| The snapshot it restores from cut a reply in all 4 prompts, and the save reports no failed or skipped cuts | Otherwise a reply could quietly start over and still pass | snapshot.py L83-120 |
| Each restored episode goes back to the same Gym instance, as its next attempt | Gym holds the calendar the episode already wrote to | snapshot.py L261-331 |
| Each reply is restored once and finished once, writes at least one new token, and its first tokens hash to what the restore logged | Shows phase 2 really continued from the saved tokens | parity.py L285-366 |
| Every trained row matches the reference: token ids, masks, input length, reward, sample mask | The main claim: a crash changes nothing the trainer sees | parity.py L198-282 |
| The saved prefix data is still there at phase 2's first training step, and the next snapshot deletes it | The data neither disappears early nor piles up | parity.py L369-401 |
One exception. vLLM's math is not exactly the same from run to run, so phase 1 can pick a different token at a near-tie before the kill. Phase 2 must then continue phase 1's tokens, not the reference's. Such a row is set aside. Today up to 7 of the 8 restored rows can be set aside and the run still passes; review comment C16 asks to cap that at one. Page 4 shows the looser first version, which the author has since narrowed.
| turn-recovery test (already on the base) | prefix-recovery test (this PR) | |
|---|---|---|
| Where the crash lands | Between model calls: a test proxy holds the call after the tool result | Inside a reply: snapshots every 0.05 s until one cuts a reply in all 4 prompts |
| What the restore reuses | Finished turns; the held call starts over | Finished turns and the tokens of the reply that was cut |
| Run with no crash to compare against | None. It checks Gym identity and metrics. | Yes. Every trained row must match it. |
| Runs, training steps | 2 runs, 3 steps | 3 runs, 1 step (phase 2 trains 2) |
| Time on the author's machine | 260 s | 470 s |
Both tests use the same test hook, the same policy-call proxy and the same snapshot readers (_single_controller_turn_recovery_hook.py, _gym_recovery_snapshot_helpers.py).
top_p=1e-6 the policy-gradient term is 0. Before merge it still needs its first CI run.
Up to 7 of 8 rows can be set aside today without failing (C16 asks for a cap of one). Page 2 covers how much of its code the test needs.