Repository navigation
fix(async-grpo): add startup barrier to prevent checkpoint-resume deadlock - #3066
Conversation
|
/ok to test 8c970d4 |
When resuming from a checkpoint whose replay-buffer snapshot already contains a complete batch for the current training step, the startup wait loop broke immediately. The main loop then consumed all target-N trajectories, triggered a refit, and advanced the collector's weight version to N+1. The collector's post-refit _calculate_target_weights takes the non-initial branch and returns [N+2, N+3, ...], skipping N+1 entirely. Training then waited for target N+1 indefinitely — a silent deadlock with no Python traceback. Fix: before breaking out of the startup wait, verify that has_complete_batch(step+1) is also True (or step+1 >= max_num_steps). The collector's initial branch already covers [start_step, start_step + max_age], so it generates the lookahead while the barrier holds. Once both the current and lookahead targets are ready, consuming the current target and refitting is safe. Also add a regression test that constructs the exact precondition state (current target complete, lookahead absent) to document what the barrier is guarding against and to prevent silent regressions. Fixes: async-GRPO resume stall first observed at step 30→31 boundary where replay_buffer.pt was restored from checkpoint but the lookahead target-31 trajectories had not yet been generated before the checkpoint. Signed-off-by: Wenwen Gao <[email protected]>
Removed detailed comments explaining the checkpoint-resume pipeline deadlock and its fix. Signed-off-by: Wenwen Gao <[email protected]> Signed-off-by: Wenwen Gao <[email protected]>
8c970d4 to
3865a85
Compare
macandro96
left a comment
There was a problem hiding this comment.
Thanks for tracking down this silent resume deadlock — the root-cause writeup and timeline table made the fix easy to follow.
The barrier logic checks out against the collector: initial_weight_version = start_step, so on resume the initial branch of _calculate_target_weights covers [step, step+1] and fills the lookahead while the barrier holds. step+1 is exactly the unique orphan target (covered by the initial branch but skipped by the post-refit non-initial branch [step+2, ...]), so the fix is as narrow as it needs to be. The max_num_steps / max_trajectory_age_steps > 0 guards and the fresh-start no-op behavior all look right.
Just one nit
Generated by Claude Code
|
/ok to test 3865a85 |
Signed-off-by: Wenwen Gao <[email protected]>
|
/ok to test 5d76eed |
The if not next_step_ready block only fires during an async-GRPO checkpoint resume in a live Ray cluster with specific buffer state. Unit-testing it would require a full training loop fixture; the buffer-layer precondition is already verified by test_resume_deadlock_precondition_detectable. Co-Authored-By: Claude Sonnet 4.6 (1M context) <[email protected]> Signed-off-by: Wen Weng <[email protected]>
ebaa504 to
e4903a8
Compare
|
/ok to test e4903a8 |
Problem
When resuming async GRPO from a checkpoint whose replay-buffer snapshot already contains a complete batch for the current training step, training silently deadlocks — no Python traceback, no error, just a stall that eventually hits the job timeout.
Root cause:
has_complete_batch(step)and breaks immediately whenTrue._calculate_target_weightstakes the non-initial branch and returns[weight_version+1, ...], skipping the just-refitted step entirely.Timeline on a step-30 resume with 8 trajectories for target 30 in the checkpoint:
load_state_dict(step=30)has_complete_batch(30)→ True, breaksample(weight_version=30)consumes 8 trajectoriesweight_version = 31_calculate_target_weights(31): non-initial → reserves target 32sample(weight_version=31)→ 0 found → stallThis race is invisible during normal uninterrupted training because target N+1 is generated while step N trains, so the lookahead is always present before a refit. On a checkpoint resume, target N is already complete, so startup returns before the lookahead exists. First surfaced by PR #2651 (replay-buffer checkpointing).
Fix
Before breaking out of the startup wait, also require
has_complete_batch(step+1)to be True (orstep+1 >= max_num_steps). The collector's initial branch of_calculate_target_weightsalready covers[start_step, start_step + max_age], so it fills the lookahead while the barrier holds. Once both targets are ready, consuming the current step and refitting is safe.The barrier is a no-op on fresh starts (target 0 is not in the buffer, so the loop never reaches the
if current_step_readybranch until both targets have been filled naturally).Changes
nemo_rl/algorithms/grpo.py— lookahead check inside theif current_step_readybranch, guarded bymax_trajectory_age_steps > 0andstep + 1 < max_num_stepstests/unit/algorithms/test_async_utils.py—test_resume_deadlock_precondition_detectableconstructs the exact buffer state (current complete, lookahead absent) and asserts the readiness values the barrier branches onRelated
Co-authored-by: Claude Sonnet 4.6 [email protected]