Skip to content

[ci][RLlib] Stop forwarding worker logs in the RLlib doctest target - #67834

Merged
dstrodtman merged 1 commit into
masterfrom
doc-1926-rllib-doctest-worker-logs
Nov 5, 2026
Merged

dstrodtman merged 1 commit into
masterfrom
doc-1926-rllib-doctest-worker-logs

Conversation

@dstrodtman

Copy link
Copy Markdown
Contributor

Description

//python/ray/rllib:doctest fails on master in the APPOConfig and IMPALAConfig examples. #67774 made these examples runnable. Each one builds an algorithm with learners(num_learners=1), and the learner worker sets up a Gloo process group and prints this line:

(_WrappedExecutable pid=5360) [Gloo] Rank 0 is connected to 0 peer ranks. Expected number of connected peer ranks is : 0

Ray forwards worker output to the driver's stdout asynchronously. Stock doctest compares the driver's stdout against each example's expected output, so the line fails algo = config.build(), which expects nothing. Both bazel attempts failed this way in premerge build 76224 on #67627, which doesn't touch these files. Any RLlib PR that runs the full doctest target without the docstring-only label hits the same failure. #67774 passed premerge because it ran with docstring-only, which runs docstring examples in a light image without torch and skips these examples by name.

This PR sets RAY_LOG_TO_DRIVER=0 in the target's env. ray.init() reads that constant when it isn't passed log_to_driver, and these examples don't pass it. #67831 sets the same variable on the Train V2 doctest target for the same Gloo output from TorchTrainer workers. No RLlib docstring example expects worker output: a search of python/ray/rllib outside examples/ and tests/ for pid= and worker-actor prefixes finds none. The examples themselves don't change.

Not a duplicate. I searched open PRs for APPOConfig, IMPALAConfig, doctest, and Gloo. #67775 is the only match. It changes the second, Tune-based example in each of these docstrings and doesn't touch the first example or BUILD.bazel.

Testing

  • pre-commit run --files python/ray/rllib/BUILD.bazel: all hooks pass, including buildifier and buildifier-lint.
  • On macOS arm64 with a Ray nightly wheel, master's appo.py and impala.py, and Ray's default doctest plugin: pytest -p default_doctest_pytest_plugin --doctest-modules --noconftest ray/rllib/algorithms/appo/appo.py ray/rllib/algorithms/impala/impala.py passes with and without RAY_LOG_TO_DRIVER=0 (2 passed each time). The Gloo line doesn't appear on macOS, so this run shows the change doesn't break the examples but doesn't reproduce the failure. This PR's premerge, which runs the full RLlib doctest target on Linux, is the real check.

🤖 Generated with Claude Code

@dstrodtman dstrodtman added the rllib RLlib related issues label Nov 4, 2026
@dstrodtman
dstrodtman requested a review from a team as a code owner November 4, 2026 21:36
@dstrodtman dstrodtman added the go add ONLY when ready to merge, run all tests label Nov 4, 2026

@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 updates the doctest target in python/ray/rllib/BUILD.bazel to set the environment variable RAY_LOG_TO_DRIVER to "0". This prevents worker logs from being forwarded to the driver, which avoids unexpected stdout capture failures during doctests. There are no review comments to address, and the changes look appropriate.

The APPOConfig and IMPALAConfig examples build an algorithm with one
learner, which sets up a Gloo process group in a worker. The worker's
"[Gloo] Rank 0 is connected to 0 peer ranks" line reaches driver stdout
asynchronously, and doctest counts it as output of the running example,
so //python/ray/rllib:doctest fails. Set RAY_LOG_TO_DRIVER=0 for the
target, as the Train V2 doctest target does for the same Gloo output.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Douglas Strodtman <[email protected]>
@dstrodtman
dstrodtman force-pushed the doc-1926-rllib-doctest-worker-logs branch from 8d88982 to 53ccc48 Compare November 5, 2026 13:28
@dstrodtman
dstrodtman merged commit 7dd9a44 into master Nov 5, 2026
6 checks passed
@dstrodtman
dstrodtman deleted the doc-1926-rllib-doctest-worker-logs branch November 5, 2026 16:19
pseudo-rnd-thoughts pushed a commit that referenced this pull request Nov 17, 2026
…the rllib doctest target (#68242)

## Why are these changes needed?

The scheduled postmerge step `:brain: rllib: docs example tests` has
failed on every run since #67774 turned the `rllib.algorithms` docstring
examples into doctests. The failing target is
`//python/ray/rllib:doctest`. #67834 fixed the `APPOConfig` and
`IMPALAConfig` failures, but `BCConfig` still fails, and the target runs
out of time partway through `PPOConfig`. See, for example, [postmerge
21027](https://buildkite.com/ray-project/postmerge/builds/21027).

The second `BCConfig` example deadlocks on CPUs. It runs a `tune.Tuner`
with a `grid_search` over two learning rates, so Tune starts both trials
at once. On the doctest cluster the two trials take every CPU. Each
trial's offline data pipeline, a `MapBatches(OfflinePreLearner)` actor
pool, then never gets a CPU to start. After 1800 seconds, Ray Data's
no-progress timeout fails both trials with `ExecutionTimeoutError`. That
lost half hour is also why the target runs out of time in `PPOConfig`.

This PR passes `tune_config=tune.TuneConfig(max_concurrent_trials=1)` to
the example's `Tuner`. The `grid_search` still runs both learning rates,
one trial after the other, so the example teaches the same thing.

## Testing

Run in a `python:3.12-slim` container (linux/aarch64) capped at 4 CPUs
with `docker run --cpus 4`. The container installs the master wheel
built at 456e286, the base of this branch, plus CPU torch, pytest,
Pillow, and tensorboardX. The command matches what the Bazel target
runs, with its env (`RAY_LOG_TO_DRIVER=0`, `TF_USE_LEGACY_KERAS=1`) and
the default doctest plugin:

```bash
python -m pytest --noconftest --doctest-modules -p default_doctest_pytest_plugin \
  ray/rllib/algorithms/bc/bc.py
```

- Before this change: `1 failed in 1811.24s`. Both trials raise
`ray.data.exceptions.ExecutionTimeoutError: Dataset execution made no
progress for at least 1800s`. While it hung, `ray status` showed
`4.0/4.0 CPU (2.0 used of 2.0 reserved in placement groups)` with
`{'CPU': 1.0}: 4+ pending tasks/actors`.
- After this change: `1 passed in 16.52s`.
- `ray/rllib/algorithms/ppo/ppo.py` on its own: `1 passed in 12.84s`.
`PPOConfig` doesn't hang. On CI it only ran out of time after the
30-minute `BCConfig` stall.

Caveats: the 4-CPU cap is an estimate of what one doctest container gets
on the `medium` instance with `--parallelism-per-worker 2`. I haven't
confirmed CI's exact per-container CPU count. I also haven't run the
full `//python/ray/rllib:doctest` target locally. A scheduled postmerge
run will confirm the fix.

I also tested adding `algo.stop()` after the first example, because that
`Algorithm` stays alive until the module's `ray.shutdown()`. It didn't
help, and the Tuner example deadlocked the same way, so this PR leaves
it out.

## Duplicate check

No open PR or issue touches `rllib/algorithms/bc/bc.py` or this target
failure. Searched open PRs for `BCConfig`, `bc.py`, and `rllib doctest`.
The open `rllib.core` doctest PRs (#67976, #67766) add examples to the
same target but don't change `BCConfig`.

## AI assistance

AI assistance (Claude Code) helped with diagnosis, the local
reproduction, and drafting. I reviewed the change and the test results.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Douglas Strodtman <[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