Skip to content

[RLlib] Footsies APPO: many small updates, real frozen-opponent weights, bounded game-server startup - #67594

Merged
pseudo-rnd-thoughts merged 2 commits into
ray-project:masterfrom
ArturNiederfahrenhorst:rllib-footsies-appo-stable
Nov 4, 2026
Merged

pseudo-rnd-thoughts merged 2 commits into
ray-project:masterfrom
ArturNiederfahrenhorst:rllib-footsies-appo-stable

Conversation

@ArturNiederfahrenhorst

Copy link
Copy Markdown
Contributor

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 ([RLlib] Advance weights version after unversioned module state updates #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

…ts, bounded game-server startup

The footsies APPO learning tests time out often:
- Each Learner update used 4096 * num_env_runners = 81,920 env steps at
  lr 1e-4. The game server answers one env step per 60 FPS frame, so the
  policy got its first update after ~3 minutes, the target network never
  updated, and the test passed only when a 10-episode eval of a ~50%
  policy happened to exceed 0.8.
- The frozen opponents got the main policy's weights only on the Learner.
  `Algorithm.set_state()` doesn't change the weights version, so the
  EnvRunners skipped them and trained against the opponent's random init.
- If a game server never got ready, `start_game_server()` polled forever.

Use 2048-step batches with 256-step minibatches, lr 5e-4 and frequent
target network updates. Push the copied opponent weights to all
EnvRunners. Bound the game server's readiness wait and relaunch a server
that doesn't get ready. Don't raise on an eval round without a decisive
episode.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request optimizes APPO training hyperparameters, refactors the game server startup logic with retries and timeouts, and ensures weights are pushed directly to the environment runner groups. The review feedback points out two important issues: a potential AttributeError if eval_env_runner_group is None, and a potential crash when calling process.kill() on an already terminated process.

@ray-gardener ray-gardener Bot added the rllib RLlib related issues label Oct 30, 2026
…ils.py

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Artur Niederfahrenhorst <[email protected]>

@pseudo-rnd-thoughts pseudo-rnd-thoughts left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I look forward to having this passing more regularly. My primary worry is the batch size reduction but we'll see

@pseudo-rnd-thoughts pseudo-rnd-thoughts added the go add ONLY when ready to merge, run all tests label Nov 4, 2026
@pseudo-rnd-thoughts
pseudo-rnd-thoughts enabled auto-merge (squash) November 4, 2026 12:17
@pseudo-rnd-thoughts
pseudo-rnd-thoughts merged commit 5d4a354 into ray-project:master Nov 4, 2026
8 checks passed
elliot-barn pushed a commit that referenced this pull request Nov 17, 2026
Before this PR:
- No release test checks RLlib's process memory over a training run.
Leaks in the Learner, AggregatorActors or EnvRunners only showed up in
long customer jobs (e.g. the per-update leaks fixed in #67299 and
#67300).
- No RLlib release test runs Learners on separate nodes.

After this PR:
- New weekly release test `rllib_footsies_appo_memory_multi_node`: APPO
on Footsies in self-play, so there is no reward target and the module
set never changes. It runs on a 4-node cluster: a CPU head, 2 single-GPU
nodes with one Learner and its 2 AggregatorActors each, and a CPU node,
for 24 EnvRunners in total.
- Every iteration, a probe actor on each node reads the USS of every
Learner, AggregatorActor and EnvRunner process. After a 3-minute warmup,
the test fits each process's USS over the remaining 7 minutes and fails
if any slope exceeds its category's limit (Learners 50, AggregatorActors
100, EnvRunners 50 MiB/h). The max and median slope per category, and
the sample and train throughput, are reported as perf metrics.
- The Footsies env takes its type aliases from `ray.rllib.utils.typing`
instead of pettingzoo, so the test runs on the bare ray-torch cu133
image.

Calibration: 3 runs of the script on the L4 equivalent of the new
compute config (2× g6.4xlarge + 2× m5.4xlarge), 43 readings over a
7-minute window each. Slopes per process, in MiB/h:

| | Learners (6) | AggregatorActors (12) | EnvRunners (72) |
|---|---|---|---|
| range | 1.6 to 4.0 | 1.1 to 26.0 (all others ≤1.5) | −7.9 to 13.8 |
| limit | 50 | 100 | 50 |

Gate check (CPU, 8 EnvRunners): a control run passes (EnvRunners ≤19
MiB/h). The same run with each EnvRunner keeping 512 KiB per `sample()`
call fails, flagging all 8 EnvRunners at +410 to +417 MiB/h. That's the
injected rate.

Note: until #67594 lands, about 1 in 300 game servers never gets ready
at startup, and the launcher waits for it forever. In this test that
shows up as a timeout; that PR bounds the wait and relaunches the
server.

Not a duplicate: no open PR adds an RLlib memory or multi-node release
test.

Testing: ran the script on Anyscale (nightly image) like the release
harness does (`TEST_OUTPUT_JSON` set, all 4 nodes up first): the 3
calibration runs above, plus 2 runs that showed Tune needs shared
storage on multi-node clusters (now `/mnt/cluster_storage`), plus the
CPU gate check. The release-test entry validates against
`release/ray_release/schema.json`, and `pre-commit run --files` passes.

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]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go add ONLY when ready to merge, run all tests rllib RLlib related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants