Skip to content

[core][joblib] Support adjustable actor capacity in ray.util.multiprocessing.Pool - #64957

Closed
OneSizeFitsQuorum wants to merge 28 commits into
ray-project:masterfrom
OneSizeFitsQuorum:worktree-joblib-task-backend
Closed

OneSizeFitsQuorum wants to merge 28 commits into
ray-project:masterfrom
OneSizeFitsQuorum:worktree-joblib-task-backend

Conversation

@OneSizeFitsQuorum

@OneSizeFitsQuorum OneSizeFitsQuorum commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #31128. A Pool currently fixes its actor count from the CPUs visible at startup, preventing it from growing with a cluster or releasing idle actors.

This PR adds opt-in capacity control through min_size, max_size, and idle_timeout_s in ray.util.multiprocessing.Pool and the Ray Joblib backend. Calls without capacity options keep the existing fixed scheduler. Actor resources remain explicit:

with joblib.parallel_backend(
    "ray", n_jobs=8, min_size=1, idle_timeout_s=60,
    ray_remote_args={"num_cpus": 1},
):
    results = joblib.Parallel()(joblib.delayed(f)(item) for item in items)

Call register_ray() first. Joblib's n_jobs remains the concurrency ceiling; max_size can lower it. Explicit CPU/GPU/custom-resource requests let pending actors create cluster autoscaler demand.

Behavior and boundaries

  • Adjustable pools submit directly to Ray actor mailboxes, including during startup. A slot retains its actor until exit is confirmed; accepted batches are never migrated or replayed by the Pool.
  • Idle actors retire down to min_size. Resource handoff and actor replacement can briefly fall below that floor so accepted work can progress even when cluster capacity is smaller than min_size.
  • close() preserves accepted work; terminate() may abort it. Confirmed actor death permits replacement; transient actor unavailability fails the affected batch without freeing its slot. Infeasible actor requests can remain pending until termination.
  • Adjustable capacity rejects non-default actor concurrency, restart, retry, and get-or-create options. These remain supported by fixed pools.
  • Joblib constructs a Ray Pool directly, avoiding process-global mutation of Joblib's pool classes, and forwards Pool arguments across supported Joblib versions.

Validation

Local tests use Python 3.11, the changed Python sources over a Ray 2.52.0 wheel, and an equivalent shutdown_only fixture (ray_pr64957_test_fixtures). --noconftest bypasses repository-wide imports incompatible with that wheel; built-source CI remains necessary.

# Joblib 1.5.3: 47 passed
python -m pytest --noconftest -p ray_pr64957_test_fixtures -q \
  python/ray/tests/test_joblib_autoscale.py

# Existing multiprocessing suite + same-instance Joblib reuse: 17 passed
python -m pytest --noconftest -p ray_pr64957_test_fixtures -q \
  python/ray/tests/test_multiprocessing.py \
  python/ray/tests/test_joblib_autoscale.py::test_joblib_backend_can_be_reused_after_task_failure

# Joblib 1.2.0 compatibility: 3 passed
python -m pytest --noconftest -p ray_pr64957_test_fixtures -q \
  python/ray/tests/test_joblib_autoscale.py::test_joblib_forwards_backend_pool_arguments \
  python/ray/tests/test_joblib_autoscale.py::test_joblib_respects_capacity_and_maxtasksperchild \
  python/ray/tests/test_joblib_autoscale.py::test_joblib_backend_can_be_reused_after_task_failure

# Passed
pre-commit run --files python/ray/util/multiprocessing/pool.py \
  python/ray/tests/test_joblib_autoscale.py \
  doc/source/ray-more-libs/joblib.rst doc/source/ray-more-libs/multiprocessing.rst
git diff --check

Contribution checks

Issue #31128 and open Joblib PRs were checked; no competing implementation was found. AI assistance was used for implementation, review, tests, and documentation.

  • Human submitter reviewed every changed line and can defend the change.
  • Human submitter ran the relevant tests locally before requesting review.

@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 introduces an elastic Ray task backend ("ray_tasks") for joblib, allowing each batch to run as a short-lived Ray task instead of using a fixed-size actor pool. This enables better integration with the Ray autoscaler and allows idle workers to scale down. The changes include documentation, unit tests, and the backend implementation itself. Feedback focuses on ensuring thread safety when modifying the in-flight task list concurrently from background threads, wrapping the RayBatchedCalls import in a try-except block to handle potential import failures, and making effective_n_jobs more robust when Ray is not yet initialized or when CPU resources are missing from the cluster state.

@ray-gardener ray-gardener Bot added core Issues that should be addressed in Ray Core community-contribution Contributed by the community labels Jul 23, 2026
Comment thread doc/source/ray-more-libs/joblib.rst Resolved
@edoakes edoakes self-assigned this Jul 23, 2026
@edoakes

edoakes commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

@OneSizeFitsQuorum do you use the joblib backend?

@OneSizeFitsQuorum

Copy link
Copy Markdown
Contributor Author

@edoakes Yes, I’m actively using the joblib backend. My goal is to take tasks that are currently parallelized locally with joblib and scale them out to a Kubernetes-backed Ray cluster by allowing the worker pool to grow with demand. I found that the current pool cannot scale elastically on Kubernetes, which led me to investigate how this could be improved.

I agree that making the actor pool autoscale would be preferable if we can retain a single backend. However, the current pool uses fixed num_cpus=0 actors and follows fixed-size multiprocessing.Pool semantics, so this may affect resource accounting, startup behavior, actor lifetime, and potentially existing default behavior.

I’m happy to explore an autoscaling actor pool, potentially as an opt-in mode first. Would you prefer implementing it in ray.util.multiprocessing.Pool, or keeping it internal to the joblib backend?

@edoakes

edoakes commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

I’m happy to explore an autoscaling actor pool, potentially as an opt-in mode first. Would you prefer implementing it in ray.util.multiprocessing.Pool, or keeping it internal to the joblib backend?

I would suggest prototyping/validating it in whatever way is easiest. Could be in the multiprocessing pool, actor pool, or just hand-written. Once you have validated the behavior/performance, we can decide the best abstraction & layering. Off the top of my head, I would think it probably makes sense to have the actor pool support autoscaling optionally (and use it for the joblib backend), and then the multiprocessing pool could just be a fixed-size actor pool.

@OneSizeFitsQuorum

Copy link
Copy Markdown
Contributor Author

@edoakes Thanks for the idea! I'll test it out and evaluate it.

@OneSizeFitsQuorum
OneSizeFitsQuorum marked this pull request as draft July 27, 2026 15:16
@OneSizeFitsQuorum OneSizeFitsQuorum changed the title [Core] Add elastic Ray task backend for joblib (ray_tasks) [Core] Prototype an elastic Joblib Actor pool backend Jul 27, 2026
@OneSizeFitsQuorum
OneSizeFitsQuorum force-pushed the worktree-joblib-task-backend branch from 5a910c4 to 8be4a0e Compare July 28, 2026 04:19
@OneSizeFitsQuorum OneSizeFitsQuorum changed the title [Core] Prototype an elastic Joblib Actor pool backend [joblib] Add opt-in autoscaling to the default 'ray' actor pool Jul 28, 2026
@OneSizeFitsQuorum
OneSizeFitsQuorum force-pushed the worktree-joblib-task-backend branch from cae607c to fb80fa9 Compare July 29, 2026 01:58
@OneSizeFitsQuorum
OneSizeFitsQuorum marked this pull request as ready for review July 29, 2026 03:17

@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 introduces an experimental opt-in autoscaling mode (autoscale=True) for the Ray joblib backend and ray.util.multiprocessing.Pool, allowing the actor pool to grow on demand and shrink when idle. The feedback highlights several critical issues in the implementation: a strong reference cycle in the background reaper thread that prevents garbage collection of the Pool instance, a bug in task count tracking when replacing actors that reach maxtasksperchild, and a race condition where active actors executing long-running tasks could be prematurely reaped. To address these, it is recommended to use a static method with a weak reference for the reaper thread and to track active object references to ensure only truly idle actors are reaped.

Comment thread python/ray/util/multiprocessing/pool.py Resolved
Comment thread python/ray/util/multiprocessing/pool.py Resolved
Comment thread python/ray/util/multiprocessing/pool.py Resolved
Comment thread python/ray/util/multiprocessing/pool.py Resolved
Comment thread python/ray/util/multiprocessing/pool.py Resolved
Comment thread python/ray/util/multiprocessing/pool.py Resolved
Comment thread python/ray/util/multiprocessing/pool.py Resolved
Comment thread python/ray/util/multiprocessing/pool.py Resolved
Comment thread python/ray/util/joblib/ray_backend.py Resolved
Comment thread python/ray/util/multiprocessing/pool.py Resolved
Comment thread python/ray/util/multiprocessing/pool.py Resolved
Comment thread python/ray/util/multiprocessing/pool.py Resolved
@OneSizeFitsQuorum

Copy link
Copy Markdown
Contributor Author

Additional adversarial validation

I ran two manual adversarial test matrices against the latest pull-based
implementation (3b1712452d). These supplement the focused tests listed in the
PR description.

Local Ray state-machine matrix

Environment: Python 3.11, local Ray cluster with 2 CPUs, using the clean
main-checkout _raylet.so and the PR Python sources.

Scenario Stress condition Result
Graceful close with backlog map_async, 80 one-item batches, max_size=8, then immediate close() and join() All results returned in order; dispatcher exited
Terminate with multiple results Eight independent asynchronous maps, 80 total batches, termination with actors running and work queued Every result became ready with an error; no blocked result thread
Lazy iterator stop race Repeated imap races against both close() and terminate() No stranded queue entries or blocked next() calls
Capacity below max_size plus recycling 2 CPUs, max_size=12, maxtasksperchild=2, 100 one-item batches Completed in order using ready actors; pending actors did not receive work
Immediate idle reaping idle_timeout_s=0, six consecutive bursts with long-running batches Running actors were not reaped; all bursts completed
Concurrent driver threads Eight driver threads sharing one Pool, 400 tasks No lost or duplicated batches
Exact-multiple and empty imap Empty iterator and 10 one-item chunks with only 2 CPUs but max_size=8 All results returned and the dynamic ResultThread exited
Unexpected actor death Kill a ready actor before follow-up work Follow-up result completed or failed within the timeout; no hang
Dropped Pool handle Drop the last Pool reference with four asynchronous results outstanding Results completed; Pool and dispatcher were garbage-collected

The temporary adversarial harness ran 10 test instances successfully after
the fixes below. The permanent correctness suite then passed:

17 passed, 1 deselected

This matrix found two related iterator lifecycle bugs:

  1. An autoscaling imap whose length was an exact multiple of chunksize
    could leave its dynamic ResultThread alive indefinitely.
  2. Sending a plain end sentinel when exhaustion was detected could race ahead
    of ObjectRefs that the pull dispatcher had not registered yet, causing
    premature completion or a blocked iterator.

The final implementation sends the known final chunk count together with a
wakeup, so the ResultThread waits for late-dispatched ObjectRefs without
leaking on empty input. The regression is
test_autoscale_imap_exact_chunks_stops_result_thread.

KubeRay control-plane matrix

Environment:

  • kind single-node cluster with 8 host CPUs
  • KubeRay operator 1.6.2
  • Ray 2.52.0
  • head: 2 CPUs
  • worker group: 0–3 replicas, 2 CPUs per worker
  • actual schedulable Ray capacity: 6 CPUs because Kubernetes system/operator
    pods consume part of the node
Scenario Expected property Result
Head-only workload max_size=2 must not create workers Stayed at 2 Ray CPUs and 0 workers
Partial scale-up Demand for four actors should add one worker Ray CPU reached 4; workload completed
Cold scale-up Start from zero workers and submit sustained demand Ray CPU changed 2 → 6
max_size above cluster capacity max_size=12 with only 6 schedulable Ray CPUs must not strand work on pending actors 120 ordered results completed on 6 ready actors across 3 Ray nodes
Actor scale-to-zero and reuse Reap every Pool actor, then submit another burst to the same Pool Both bursts completed with newly created actors
Shared-Pool client concurrency Eight driver threads submit 200 tasks concurrently All task groups completed without loss or duplication
Graceful close during demand Close immediately after submitting 100 batches All batches completed; join() and dispatcher exited
Terminate during demand Terminate with running actors and a large backlog Returned in 0.12 s; result failed bounded with ActorDiedError
joblib concurrency semantics backend max_size=12, call-level n_jobs=4 Exactly 4 actors processed 80 tasks across head and one worker
Actor churn maxtasksperchild=1 with 40 one-item batches 40 tasks completed on 40 actor IDs
Independent clients Two separate driver processes each create a Pool and submit concurrently Both completed; one used head-only capacity while the other also used a worker

Observed Kubernetes lifecycle:

worker pods:
0
  -> 3 requested (2 Running + 1 Pending due to the kind CPU limit)
  -> 2
  -> 1
  -> 0

Ray CPUs:          2 -> 6 -> 2
desired workers:   0 -> 3 -> 0
pending demands:   none at completion

Two deployment observations are worth calling out:

  • joblib must be installed consistently on the head and worker images. A
    head-only installation correctly failed worker deserialization with
    ModuleNotFoundError; installing joblib 1.2.0 on each active worker made the
    real joblib scenario pass.
  • On this static kind node, the third requested worker could not be scheduled.
    Pool demand disappeared promptly after completion, but KubeRay cleaned up
    the already-allocated pending pod in stages. This delayed pod convergence
    beyond the 60-second Ray-node idle timeout, but it did converge to zero and
    did not block task completion. A Kubernetes Cluster Autoscaler would
    normally add node capacity; hard-quota clusters should set max_size
    accordingly.

No additional Pool correctness issue was found in the KubeRay matrix.

@OneSizeFitsQuorum
OneSizeFitsQuorum force-pushed the worktree-joblib-task-backend branch from 3b17124 to d6f4e68 Compare July 29, 2026 11:34
@OneSizeFitsQuorum OneSizeFitsQuorum changed the title [core][joblib] Add opt-in autoscaling to ray.util.multiprocessing.Pool [core][joblib] Support adjustable actor capacity in ray.util.multiprocessing.Pool Sep 3, 2026
@OneSizeFitsQuorum
OneSizeFitsQuorum marked this pull request as ready for review September 3, 2026 17:08
@OneSizeFitsQuorum
OneSizeFitsQuorum requested a review from a team as a code owner September 3, 2026 17:08
@OneSizeFitsQuorum

Copy link
Copy Markdown
Contributor Author

@edoakes @robertnishihara This PR is now ready for review.

After several iterations, adjustable actor capacity is now integrated as a native part of ray.util.multiprocessing.Pool, rather than being modeled as separate fixed and elastic implementations. The existing default behavior remains unchanged.

I’ve also put significant effort into simplifying the implementation, organizing the main path ahead of compatibility handling, and keeping the code and documentation readable.

Finally, the behavior has been validated across Pool and Joblib integration scenarios, including scaling, idle retirement, pending-resource handoff, actor recycling, failures, and compatibility.

I’d appreciate another review when you have time. Thanks!

@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 introduces dynamic actor capacity management (autoscaling) for the Ray backend in Joblib and multiprocessing.Pool, allowing the pool to scale actors between min_size and max_size and release idle actors after idle_timeout_s. The feedback highlights critical deadlock risks where self._pool_lock is held during blocking submit operations, which would prevent closing or terminating the pool. Additionally, the reviewer suggests using isinstance() instead of direct type comparisons for PEP 8 compliance, and warns that treating transient RayActorErrors as terminal could permanently fail the pool unnecessarily.

Comment thread python/ray/util/multiprocessing/pool.py Resolved
Comment thread python/ray/util/multiprocessing/pool.py Resolved
Comment thread python/ray/util/multiprocessing/pool.py Resolved
Comment thread python/ray/util/multiprocessing/pool.py Resolved

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 2147276. Configure here.

Comment thread python/ray/util/multiprocessing/pool.py Resolved
Comment thread python/ray/util/multiprocessing/pool.py Resolved
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

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.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Sep 23, 2026
dstrodtman added a commit that referenced this pull request Oct 5, 2026
…m RST to MyST (#66673)

## Why are these changes needed?

This PR converts the remaining prose pages under `ray-observability/`,
`ray-more-libs/`, `ray-references/`, and `ray-air/` from
reStructuredText to MyST Markdown. It continues the RST-to-MyST
conversion that already landed for `ray-core/` (#66430), `data/`
(#66375), and the doctest-wired pages (#66461). The conversion is format
only: the goal is for each page's rendered HTML to match `/en/master`.

There are five commits:

1. **Conversion.** This commit converts 25 pages, `git rm`s the `.rst`
sources, and adds one `doc/BUILD.bazel` exclude, which commit 5 reverts.
Prose keeps its source line wrapping, so the diff lines up with the
`.rst` line by line.
2. **Soft-wrap.** This commit reflows whitespace only, to one line per
paragraph and list item. `verify.py` from `ray-soft-wrap` confirms that
the non-whitespace bytes and the rendered HTML don't change on all 25
files.
3. **Render fixes.** This commit fixes six regressions that the render
diff against `/en/master` caught, even though the build was green. In
`modin`, two bare-word RST link references (`Modin_`, `documentation_`)
rendered as literal text. In `getting-started`, a bold URL was
autolinked. In `system-metrics`, a URL in a table cell lost its link. In
`dask-on-ray`, `_not_` rendered as italics. In `glossary`, the inline
`.. TODO: RLlib` text, which `/en/master` shows, had become a comment.
The commit also adds compat anchors to five headings with apostrophes
(see below).
4. **Pseudo-lists.** This commit restores three pseudo-lists that the
soft-wrap merged into one line.
5. **Review feedback.** This commit removes the glossary's placeholder
TODO entries, reverts the `doc/BUILD.bazel` change so the PR stays
docs-only, and fixes defects that the review flagged in the `.rst`
sources: a stray definition list in `dask-on-ray`, an unconverted link
in `system-metrics`, an extra parenthesis in `debug-failures`, typos in
`debug-hangs` and `optimize-performance`, a grammar slip in
`ray-debugging`, and em-dash pseudo-list items in `general-debugging`,
which are now a bulleted list.

### Scope

- `ray-air/`: `getting-started` and `deployment`, converted together.
`getting-started` includes `deployment`, and the include now points at
`deployment.md`.
- `ray-observability/`: 14 pages, including `user-guides/debug-apps/`
and `reference/system-metrics`.
- `ray-more-libs/`: 9 pages.
- `ray-references/`: `glossary` and `faq`.

**Left as RST:** `ray-observability/reference/api.rst` (`autosummary`)
and `ray-observability/reference/cli.rst` (`click`). They're API
reference pages, so they stay RST along with the other `*/api/`
reference trees.

### Construct notes for reviewers

- **Glossary.** The glossary is a native MyST `{glossary}` directive,
not RST wrapped in `{eval-rst}`. Sphinx's `glossary` directive parses
each definition with the host parser, so the definitions are Markdown
now. The glossary's placeholder `.. TODO:` entries are removed. Missing
terms can be identified separately.
- **Glossary doctest.** Nothing ran the glossary's `.. doctest::` block
as `.rst`: `pytest-sphinx` doesn't execute `doctest` sections, and
`--doctest-glob='*.md'` doesn't match `.rst`. As `.md`, the stock
doctest parser would start running its five `>>>` prompts, and the
`[[0],[1],...,[3],[4]]` output can't pass without `ELLIPSIS`. Each
prompt now carries `# doctest: +SKIP`, which keeps coverage the same as
master without a `doc/BUILD.bazel` change. Sphinx's default
`trim_doctest_flags` strips the flag from the rendered page, as in
`data/working-with-tensors.md`. If you'd rather fix the expected output
and start testing it, I can do that in a follow-up.
- **FAQ.** `faq.md` includes `_includes/_help-links.md`, the Markdown
copy of `_help.rst` that #66417 added. `_help.rst` stays, because
`cluster/vms/user-guides/community/yarn.rst` and `tune/key-concepts.rst`
still include it.
- **Comparison table.** The grid table in
`ray-collective-custom-backend` is now a native `{list-table}`.
- **Line blocks.** The line blocks in `dask-on-ray`'s version table are
now Markdown hard line breaks. This is an expected render difference:
`<p>` with `<br>` instead of `div.line-block`.

### Dead links fixed on the way

These links were broken on `/en/master` and fail `fail_on_warning` when
they're transcribed into MyST:

- `joblib` and `multiprocessing` linked to relative `actors.html` and
`installation.html`, which resolve under `ray-more-libs/` and return
404. They now link to `{doc}` `/ray-core/actors` and
`/ray-overview/installation`.
- `ray-collective` linked to `#api-reference`, but the heading's anchor
is `#api-references`.

### Open PRs that edit these pages

Each of these PRs needs to move its change onto the `.md` file: #66363
(`ray-event-export`), #65693 and #65583 (`system-metrics`), and #64957
(`joblib`, `multiprocessing`). #65321 edits `reference/cli.rst`, which
this PR doesn't convert.

## Related issue number

None.

## Checks

- [x] I've signed off every commit (`git commit -s`).
- [x] Duplicate check: no open PR converts these pages. I searched open
PRs for MyST, observability, glossary, and more-libs, and for open PRs
that edit these files.
- **Doctest parity:** `doctest_parity.py` (the `pytest-sphinx` parser,
run against `upstream/master`) reports the same sections and examples on
all 25 pages, before and after the soft-wrap: 12 examples before, 12
after.
- **Local doctest:** `pytest --doctest-modules --doctest-glob='*.md' -c
NO_PYTEST_CONFIG -p doctest_pytest_plugin` on the 24 converted pages in
the main target, with Ray nightly `bc900c2` on Python 3.10: 5 passed.
Those are the 5 files with examples. The glossary, now in the target
too, reports 1 skipped: the stock parser finds 5 examples and all 5
carry `+SKIP`.
- **Static checks:** frontmatter parses, fences balance, every label is
preserved, and there's no leftover RST outside fences or directives.
- **RtD preview:** green under `fail_on_warning` on all three commits.
- **Render diff** (`render_diff.py`, preview against `/en/master`,
filtering the two class-only differences every MyST page shows): 11 of
25 pages are identical. Every difference on the other 14 is one of
these:
- RST comments now emit `<!-- ... -->` HTML comments, which readers
don't see. Pages: `ray-air/*`, `ray-more-libs/index`, `ray-collective`,
`getting-started`, `general-debugging`, `glossary`.
- The `dask-on-ray` version table: Markdown hard line breaks (`<p>` with
`<br>`) replace RST line blocks (`div.line-block`).
- The `dask-on-ray` "Why use Dask on Ray?" item keeps its
definition-list structure. MyST adds a `myst` class to the `<dl>`, and
the class has no styling.
- Same-page fragment and `{doc}` links render as `reference internal`
instead of `reference external`. Pages: `ray-collective`, `joblib`,
`multiprocessing`. This list also includes the dead links fixed above.
- Headings with an apostrophe get a new anchor, because MyST drops the
apostrophe where docutils turned it into a hyphen. For example,
`#what-s-the-out-of-memory-error` becomes
`#whats-the-out-of-memory-error`. Five of these headings had no label,
so each gets a compat target with the old slug, which keeps existing
links working. The sixth, in `optimize-performance`, already carries the
`dashboard-cprofile` label.

This PR was written with AI assistance (Claude Code). I reviewed the
changes and ran the checks above.

🤖 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]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…m RST to MyST (ray-project#66673)

## Why are these changes needed?

This PR converts the remaining prose pages under `ray-observability/`,
`ray-more-libs/`, `ray-references/`, and `ray-air/` from
reStructuredText to MyST Markdown. It continues the RST-to-MyST
conversion that already landed for `ray-core/` (ray-project#66430), `data/`
(ray-project#66375), and the doctest-wired pages (ray-project#66461). The conversion is format
only: the goal is for each page's rendered HTML to match `/en/master`.

There are five commits:

1. **Conversion.** This commit converts 25 pages, `git rm`s the `.rst`
sources, and adds one `doc/BUILD.bazel` exclude, which commit 5 reverts.
Prose keeps its source line wrapping, so the diff lines up with the
`.rst` line by line.
2. **Soft-wrap.** This commit reflows whitespace only, to one line per
paragraph and list item. `verify.py` from `ray-soft-wrap` confirms that
the non-whitespace bytes and the rendered HTML don't change on all 25
files.
3. **Render fixes.** This commit fixes six regressions that the render
diff against `/en/master` caught, even though the build was green. In
`modin`, two bare-word RST link references (`Modin_`, `documentation_`)
rendered as literal text. In `getting-started`, a bold URL was
autolinked. In `system-metrics`, a URL in a table cell lost its link. In
`dask-on-ray`, `_not_` rendered as italics. In `glossary`, the inline
`.. TODO: RLlib` text, which `/en/master` shows, had become a comment.
The commit also adds compat anchors to five headings with apostrophes
(see below).
4. **Pseudo-lists.** This commit restores three pseudo-lists that the
soft-wrap merged into one line.
5. **Review feedback.** This commit removes the glossary's placeholder
TODO entries, reverts the `doc/BUILD.bazel` change so the PR stays
docs-only, and fixes defects that the review flagged in the `.rst`
sources: a stray definition list in `dask-on-ray`, an unconverted link
in `system-metrics`, an extra parenthesis in `debug-failures`, typos in
`debug-hangs` and `optimize-performance`, a grammar slip in
`ray-debugging`, and em-dash pseudo-list items in `general-debugging`,
which are now a bulleted list.

### Scope

- `ray-air/`: `getting-started` and `deployment`, converted together.
`getting-started` includes `deployment`, and the include now points at
`deployment.md`.
- `ray-observability/`: 14 pages, including `user-guides/debug-apps/`
and `reference/system-metrics`.
- `ray-more-libs/`: 9 pages.
- `ray-references/`: `glossary` and `faq`.

**Left as RST:** `ray-observability/reference/api.rst` (`autosummary`)
and `ray-observability/reference/cli.rst` (`click`). They're API
reference pages, so they stay RST along with the other `*/api/`
reference trees.

### Construct notes for reviewers

- **Glossary.** The glossary is a native MyST `{glossary}` directive,
not RST wrapped in `{eval-rst}`. Sphinx's `glossary` directive parses
each definition with the host parser, so the definitions are Markdown
now. The glossary's placeholder `.. TODO:` entries are removed. Missing
terms can be identified separately.
- **Glossary doctest.** Nothing ran the glossary's `.. doctest::` block
as `.rst`: `pytest-sphinx` doesn't execute `doctest` sections, and
`--doctest-glob='*.md'` doesn't match `.rst`. As `.md`, the stock
doctest parser would start running its five `>>>` prompts, and the
`[[0],[1],...,[3],[4]]` output can't pass without `ELLIPSIS`. Each
prompt now carries `# doctest: +SKIP`, which keeps coverage the same as
master without a `doc/BUILD.bazel` change. Sphinx's default
`trim_doctest_flags` strips the flag from the rendered page, as in
`data/working-with-tensors.md`. If you'd rather fix the expected output
and start testing it, I can do that in a follow-up.
- **FAQ.** `faq.md` includes `_includes/_help-links.md`, the Markdown
copy of `_help.rst` that ray-project#66417 added. `_help.rst` stays, because
`cluster/vms/user-guides/community/yarn.rst` and `tune/key-concepts.rst`
still include it.
- **Comparison table.** The grid table in
`ray-collective-custom-backend` is now a native `{list-table}`.
- **Line blocks.** The line blocks in `dask-on-ray`'s version table are
now Markdown hard line breaks. This is an expected render difference:
`<p>` with `<br>` instead of `div.line-block`.

### Dead links fixed on the way

These links were broken on `/en/master` and fail `fail_on_warning` when
they're transcribed into MyST:

- `joblib` and `multiprocessing` linked to relative `actors.html` and
`installation.html`, which resolve under `ray-more-libs/` and return
404. They now link to `{doc}` `/ray-core/actors` and
`/ray-overview/installation`.
- `ray-collective` linked to `#api-reference`, but the heading's anchor
is `#api-references`.

### Open PRs that edit these pages

Each of these PRs needs to move its change onto the `.md` file: ray-project#66363
(`ray-event-export`), ray-project#65693 and ray-project#65583 (`system-metrics`), and ray-project#64957
(`joblib`, `multiprocessing`). ray-project#65321 edits `reference/cli.rst`, which
this PR doesn't convert.

## Related issue number

None.

## Checks

- [x] I've signed off every commit (`git commit -s`).
- [x] Duplicate check: no open PR converts these pages. I searched open
PRs for MyST, observability, glossary, and more-libs, and for open PRs
that edit these files.
- **Doctest parity:** `doctest_parity.py` (the `pytest-sphinx` parser,
run against `upstream/master`) reports the same sections and examples on
all 25 pages, before and after the soft-wrap: 12 examples before, 12
after.
- **Local doctest:** `pytest --doctest-modules --doctest-glob='*.md' -c
NO_PYTEST_CONFIG -p doctest_pytest_plugin` on the 24 converted pages in
the main target, with Ray nightly `bc900c2` on Python 3.10: 5 passed.
Those are the 5 files with examples. The glossary, now in the target
too, reports 1 skipped: the stock parser finds 5 examples and all 5
carry `+SKIP`.
- **Static checks:** frontmatter parses, fences balance, every label is
preserved, and there's no leftover RST outside fences or directives.
- **RtD preview:** green under `fail_on_warning` on all three commits.
- **Render diff** (`render_diff.py`, preview against `/en/master`,
filtering the two class-only differences every MyST page shows): 11 of
25 pages are identical. Every difference on the other 14 is one of
these:
- RST comments now emit `<!-- ... -->` HTML comments, which readers
don't see. Pages: `ray-air/*`, `ray-more-libs/index`, `ray-collective`,
`getting-started`, `general-debugging`, `glossary`.
- The `dask-on-ray` version table: Markdown hard line breaks (`<p>` with
`<br>`) replace RST line blocks (`div.line-block`).
- The `dask-on-ray` "Why use Dask on Ray?" item keeps its
definition-list structure. MyST adds a `myst` class to the `<dl>`, and
the class has no styling.
- Same-page fragment and `{doc}` links render as `reference internal`
instead of `reference external`. Pages: `ray-collective`, `joblib`,
`multiprocessing`. This list also includes the dead links fixed above.
- Headings with an apostrophe get a new anchor, because MyST drops the
apostrophe where docutils turned it into a hyphen. For example,
`#what-s-the-out-of-memory-error` becomes
`#whats-the-out-of-memory-error`. Five of these headings had no label,
so each gets a compat target with the old slug, which keeps existing
links working. The sixth, in `optimize-performance`, already carries the
`dashboard-cprofile` label.

This PR was written with AI assistance (Claude Code). I reviewed the
changes and ran the checks above.

🤖 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]>
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no more activity in the 14 days
since being marked stale.

Please feel free to reopen or open a new pull request if you'd still like this to be addressed.

Again, you can always ask for help on our discussion forum or Ray's public slack channel.

Thanks again for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community core Issues that should be addressed in Ray Core stale The issue is stale. It will be closed within 7 days unless there are further conversation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Ray multiprocessing] ray.util.multiprocessing launches fixed size pool and doesn't support autoscaling

3 participants