Repository navigation
[RLlib] Sync newly cloned self-play module weights immediately - #67103
lindicaphxag-tech wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request ensures that newly cloned opponent modules in the self-play league-based callback have their weights synchronized immediately to prevent playing with stale weights, and adds a unit test to verify this. The review feedback correctly identifies that sync_weights must explicitly specify from_worker_or_learner_group=algorithm.learner_group and inference_only=True to avoid propagating default/random weights from the local EnvRunner, and suggests updating the test assertion accordingly.
|
Addressed the review feedback. The new module is now synchronized explicitly from |
|
Addressed the review feedback in the latest commit. The cloned module is now synchronized directly through EnvRunner.set_state() with a module-only state that intentionally omits WEIGHTS_SEQ_NO, so the first initialization cannot be discarded by the global sequence gate. The regression test now verifies the forced state path and object-store reference. This keeps the fix scoped to newly cloned self-play modules without changing global weight-version semantics. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit e383e4c. Configure here.
|
Thanks for the review. The latest commit addresses the synchronization-source and sequence-gate concerns: the newly cloned module is initialized from the learner-side state, then pushed through the module-only EnvRunner state path without |
f0bed32 to
9b632d8
Compare
Fixes ray-project#61960. Signed-off-by: Zhibo Zhang <[email protected]>
9b632d8 to
9ba8e0d
Compare
|
CI/review follow-up on the latest single-commit head |
Signed-off-by: Zhibo Zhang <[email protected]>
Signed-off-by: Zhibo Zhang <[email protected]>
Signed-off-by: Zhibo Zhang <[email protected]>
|
I strengthened the callback regression so it executes the mocked |
Signed-off-by: Zhibo Zhang <[email protected]>
368c724 to
4444ffc
Compare
|
Follow-up on the latest two-file PR head I audited the first-time self-play initialization branch as well as the later-clone path. The original The two branches now share one synchronous, module-only Source-driven CPU regression: Success, independent fork CI PR #6: executes the production The final source tree was preserved exactly while squashing the two incrementals into a correctly author-matched |
|
CI status update for exact current PR head As independent positive evidence, fork GitHub Actions #39815603690 completed successfully. It executes the production method bodies of Could a maintainer identify the failing Microcheck job and its first actionable traceback (or advise whether a rerun is appropriate)? I'd prefer fixing that exact blocker rather than broadening a two-file production/test diff or repeatedly pushing blind CI changes. No additional upstream commit is needed just to reference this evidence. |
4444ffc to
639c812
Compare
|
Updated official head: Source audit found an additional race in the earlier design: The candidate now uses one synchronous callback per EnvRunner, calling Evidence: passing CPU red/green GitHub Actions #39820293020, fork-only source/health-change test #7. The fixture executes the actual Review scope: the improvement over Current checks: DCO and Release success; new exact-head Microcheck #56891 pending. The previous head's Microcheck #56887 failed but its failing job trace isn't available through my connection, so I am not guessing whether this new patch addresses that failure. I'd appreciate the failing job/trace if #56891 also fails and a maintainer re-review of the per-runner activation contract. |
Clone the existing behavior policy's state, not the default weights of a newly added local opponent. For both initial and later opponents, install source weights and publish the mapping in one synchronous per-runner call, including when the remote healthy set changes between separate dispatches. Native regression tests model a fresh module with different default weights, reject accidental weight substitution, and check first-init/mapping order. Signed-off-by: Zhibo Zhang <[email protected]>
639c812 to
7795d64
Compare
|
Native regression fixed on current PR head An actual RLlib pytest run exposed a production correctness regression that source-extracted ordering tests missed: on the later-clone path, The fix snapshots Reproducible native red/green: passing fork CI #39902396461, with a released Ray 2.59.0 binary wheel as the native extension/runtime and the candidate callback/test files overlaid in a fresh runner: 4/4 native tests passed. Replacing only the callback with the unchanged previous official head The current upstream head's new Buildkite Microcheck #56950 is pending; earlier Microchecks failed, and their private job trace remains unavailable to me, so I am not claiming the patch eliminates every CI failure. If #56950 fails, could a maintainer please point to the first actionable failing job/log for a focused fix? Stronger real-Ray-actor follow-up (2026-10-23): GitHub Actions #39903425393 — Success, fork-only script. This goes beyond source-extracted simulation: the test starts an actual local Ray cluster, two real remote actors, the released native |
…ts, bounded game-server startup (#67594) Before this PR: - The `learning_tests_appo_footsies_*` postmerge tests time out often. Each Learner update takes `4096 * num_env_runners` = 81,920 env steps at `lr=1e-4`, but the game server answers one env step per 60 FPS frame (~57 steps/s per EnvRunner). The policy gets its first gradient update after ~3 minutes, and the target network never updates. Against the frozen copy the training win rate stays at 0.5, so the test passes only when a 10-episode eval happens to exceed 0.8 (e.g. eval 0.81 at training win rate 0.49). - `MixManagerCallback` initializes each new frozen opponent with `Algorithm.set_state()`. The EnvRunners skip those weights because the weights version doesn't change (#67131 fixes that in the Learner). The training EnvRunners therefore play the opponent's random init, while evaluation uses the real copy. - If a game server never gets ready, `FootsiesBinary.start_game_server()` polls forever (no deadline, no liveness check, no gRPC timeout), and setup hangs until the 900 s timeout. In a stress test, 3 of 240 concurrent server starts never got ready. After this PR: - 2048 env steps per Learner update, minibatches of 256, `lr=5e-4`, `target_network_update_freq=0.5`. - `MixManagerCallback` pushes the copied weights to all (eval) EnvRunners. An eval round without a decisive episode no longer raises a `KeyError`. - The game server gets 120 s to get ready (5 s gRPC timeouts, process liveness check); otherwise it's killed and relaunched, up to 3 times. Validation on Anyscale (nightly image + this PR's three files, no #67131), each seed the CI test's args in a fresh driver with a 900 s cap including startup: | CI target | hardware | passed | wall time | |---|---|---|---| | `learning_tests_appo_footsies_single_gpu` | 4×L4, 48 vCPU | 10/10 | 174–419 s | | `learning_tests_appo_footsies_multi_gpu` | 4×L4, 48 vCPU | 10/10 | 239–422 s | | `learning_tests_appo_footsies_single_gpu_no_aggregator_actors` | 4×L4, 48 vCPU | 10/10 | 174–418 s | | `multi_gpu` args, 2 Learners on 2 nodes (1×L4 each) + CPU EnvRunner nodes | 4 nodes | 10/10 | 217–357 s | Stock master on a 1×L4 node passed 1 of 1 attempt by eval luck, and `+#67131` alone failed in 1,500 s. A 4 h run on the 4-node cluster kept Learner, aggregator, EnvRunner and Algorithm memory flat. The game-server launcher fix started 360/360 servers in a stress test, relaunching one server twice. `pre-commit run --files` passes on all three files. Not a duplicate: no open PR touches the footsies example. #67131 fixes the weights-version root cause in `Learner.set_state`, and #67103 only fixes the league-based self-play callback; this PR doesn't depend on either. AI assistance (Claude Code) was used for the investigation, the experiments and the change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Artur Niederfahrenhorst <[email protected]> Signed-off-by: Artur Niederfahrenhorst <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
This pull request has been automatically marked as stale because it has not had You can always ask for help on our discussion forum or Ray's public slack channel. If you'd like to keep this open, just leave any comment, and the stale label will be removed. |
|
Keeping this scoped two-file self-play correctness patch active while the upstream Microcheck blocker is triaged. The current signed head Could a maintainer identify the first actionable failing step/traceback in Microcheck #56950, or confirm whether a targeted rerun is appropriate? I will keep changes focused on that result rather than expanding scope or guessing at CI failures. |
|
Converting this to draft. The blocker has been Buildkite Microcheck on every head since 10-17 ( What is settled: the diff is two files, DCO and Release pass, the fix is per-EnvRunner installation of source-policy weights before publishing the new mapping, and there is a reproducible red/green on the fork (4/4 native tests, real Ray-actor recovery case). What is not settled: Ray appears to require a maintainer present at the pilot stage, and no maintainer has responded in 6 weeks, so leaving this as an open merge request just adds queue noise. Keeping it as a draft rather than closing, because the technical record is worth keeping. If a maintainer can share the first actionable Microcheck failure, I will rebase onto current main and finish it; otherwise it stays parked. |

Summary
Fixes #61960. Newly created self-play opponents are initialized by
Algorithm.add_module()on EnvRunners, while the intended cloned weights come from the existing source policy. Activating a new policy mapping before installing those source weights can route episodes to default-initialized opponents.Mechanism
add_module(), rather than reading the new module's default state afterward.COMPONENT_RL_MODULEpayload withoutWEIGHTS_SEQ_NO, because the global sequence gate may skip an uninitialized module whose EnvRunner already holds the current global version.foreach_env_runnercallback installs weights withset_state()and only then activatespolicy_mapping_fnandpolicies_to_train. Two separate calls could hit different healthy runner sets during recovery.Regression coverage
set_state→ mapping order.MultiAgentEnvRunner.set_state()on a lightweight mock: an equal-sequence update is skipped, whereas a module-only unversioned update is applied without changing the global version.Validation (2026-10-23; current head)
7795d644673b4a4ed4d407fd9e7b0ca981e9606b.