Skip to content

[RLlib] Skip the MARWILConfig doctest instead of PPOConfig - #68478

Merged
pseudo-rnd-thoughts merged 1 commit into
ray-project:masterfrom
pseudo-rnd-thoughts:rllib/fix-doctest-marwil
Nov 23, 2026
Merged

pseudo-rnd-thoughts merged 1 commit into
ray-project:masterfrom
pseudo-rnd-thoughts:rllib/fix-doctest-marwil

Conversation

@pseudo-rnd-thoughts

@pseudo-rnd-thoughts pseudo-rnd-thoughts commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Why are these changes needed?

:brain: rllib: docs example tests (//python/ray/rllib:doctest) crashes with exit code 1 and no traceback. #68306 skipped PPOConfig for this, and the crash moved to SACConfig, the next module. Neither example is at fault: the crash happens in whichever module runs after MARWILConfig.

The first MARWILConfig example builds an Algorithm in the driver with num_learners=0 and dataset_num_iters_per_learner=1, so OfflineData.sample() keeps a partly consumed iter_batches() generator, and its Ray Data prefetch threads stay alive. The example never calls algo.stop(), and Algorithm.cleanup() doesn't close that generator anyway. When the plugin's module fixture calls ray.shutdown() before the next module, one of those threads releases an ObjectRef after the core worker is gone, and the process exits through QuickExit(). The driver's core-worker log shows it, from a non-main thread about 120 ms after shutdown:

core_worker_process.cc:1083: Driver shutdown complete. Removing the global worker.
core_worker_process.cc:1115: The core worker has already been shutdown. This happens when the language frontend accesses the Ray's worker after it is shutdown. The process will exit

This matches the diagnosis @vishalkotak posted on #68305.

This PR:

Follow-ups, not in this PR:

  • RLlib: close the offline data iterator in Algorithm.cleanup() and call algo.stop() in the MARWIL example, then remove this skip. I have a local patch; with it, MARWIL → PPO → SAC passed 3/3 locally, and without it the run crashed 2/2.
  • Core: releasing an ObjectRef during ray.shutdown() shouldn't _Exit(1) the process. [Data] Wait for iter_threaded workers to exit when the consumer stops #67868 (a Data-side workaround) was closed in favor of a core fix.

Related issue number

Related to #68305. Supersedes the skip from #68306.

Duplicate check

No open PR references #68305 or touches MARWILConfig's doctest. I searched open PRs for 68305 in:body, rllib doctest, and MARWIL doctest.

Testing

Locally on macOS, Python 3.12, editable build, using the target's arguments and plugin (from python/):

RAY_LOG_TO_DRIVER=0 TF_USE_LEGACY_KERAS=1 PYTHONPATH=../bazel \
python -m pytest --doctest-modules --disable-warnings -v -c NO_PYTEST_CONFIG \
  -p default_doctest_pytest_plugin \
  ray/rllib/algorithms/marwil/marwil.py ray/rllib/algorithms/ppo/ppo.py ray/rllib/algorithms/sac/sac.py
  • Before (MARWIL and PPO enabled): MARWIL passes, then the process exits with code 1 at the start of the next module, 3/3 runs (MARWIL → SAC) and 2/2 (MARWIL → PPO → SAC). SAC alone passes.
  • After: 2 passed, 1 skipped (MARWIL skipped, PPO and SAC passed), 4/4 runs.
  • The whole target's file set (the BUILD glob, --continue-on-collection-errors): 84 passed, 29 skipped, 5 failed, 2 errors, and the run completed. The 5 failures are RolloutWorker.* examples that need TensorFlow, and the 2 errors are open_spiel.py needing pyspiel. Neither package is in my local env, but both are on CI.

My local run collected 118 examples against CI's 262, so it doesn't stand in for CI. Premerge skips this target while it's flaky, so a scheduled postmerge run will confirm it.

pre-commit run on the changed files passes.

AI assistance

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

🤖 Generated with Claude Code

The //python/ray/rllib:doctest crash blamed on PPOConfig (ray-project#68306) comes from
the MARWILConfig example that runs before it. That example builds an
Algorithm in the driver and leaves a partly consumed Ray Data iter_batches
generator, whose prefetch threads are still alive when the next module's
ray.shutdown() runs. One of them releases an ObjectRef after the core worker
is gone, which hits QuickExit and kills the process with no traceback. With
PPOConfig skipped, the crash moved to SACConfig.

Skip MARWILConfig, the source, and re-enable PPOConfig.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Mark Towers <[email protected]>
@pseudo-rnd-thoughts
pseudo-rnd-thoughts requested a review from a team as a code owner November 23, 2026 13:32

@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 documentation examples for MARWILConfig and PPOConfig. It adds a descriptive comment and skips the gymnasium import example in MARWILConfig to address CI issues, while removing the skip directive and the associated explanation comment from the PPOConfig examples. I have no feedback to provide.

@pseudo-rnd-thoughts pseudo-rnd-thoughts added rllib RLlib related issues docs An issue or change related to documentation go add ONLY when ready to merge, run all tests labels Nov 23, 2026
@pseudo-rnd-thoughts
pseudo-rnd-thoughts enabled auto-merge (squash) November 23, 2026 13:43
@pseudo-rnd-thoughts
pseudo-rnd-thoughts merged commit bebbc6e into ray-project:master Nov 23, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs An issue or change related to documentation 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.

3 participants