Skip to content

[RLlib] Add custom_resources_for_main_process to AlgorithmConfig#62475

Merged
ArturNiederfahrenhorst merged 8 commits into
ray-project:masterfrom
ArturNiederfahrenhorst:custom-resources-for-main-process
Apr 23, 2026
Merged

[RLlib] Add custom_resources_for_main_process to AlgorithmConfig#62475
ArturNiederfahrenhorst merged 8 commits into
ray-project:masterfrom
ArturNiederfahrenhorst:custom-resources-for-main-process

Conversation

@ArturNiederfahrenhorst

Copy link
Copy Markdown
Contributor

Allow users to specify custom Ray resources for the main Algorithm actor's placement bundle via config.resources(custom_resources_for_main_process={"my_custom_resources": 1}).

@ArturNiederfahrenhorst ArturNiederfahrenhorst requested a review from a team as a code owner April 9, 2026 17:24

@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 the custom_resources_for_main_process configuration option to RLlib, allowing for custom Ray resource allocation for the main algorithm process. The changes span AlgorithmConfig, resource utility functions, and include new unit tests. Review feedback recommends defaulting the new parameter to an empty dictionary to avoid potential TypeError during unpacking, clarifying the docstring to specify the target process, and adjusting the order of dictionary merging in _get_main_process_bundle to prevent custom resources from overwriting mandatory CPU and GPU keys.

Comment thread rllib/algorithms/algorithm_config.py
Comment thread rllib/algorithms/algorithm_config.py Outdated
Comment thread rllib/algorithms/utils.py
Comment thread rllib/algorithms/utils.py

@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 and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit eb7a7b613dc6a4fc03b73a2ebea6bd5478d42cde. Configure here.

Comment thread rllib/algorithms/utils.py
@ray-gardener ray-gardener Bot added the rllib RLlib related issues label Apr 9, 2026
@ArturNiederfahrenhorst ArturNiederfahrenhorst added rllib-system system issues, runtime env, oom, etc go add ONLY when ready to merge, run all tests labels Apr 22, 2026
ArturNiederfahrenhorst and others added 7 commits April 22, 2026 17:19
Allow users to specify custom Ray resources for the main Algorithm
actor's placement bundle via `config.resources(custom_resources_for_main_process={"on_demand": 0.001})`.
This enables pinning the Algorithm actor to specific node types
(e.g., on-demand nodes) when `num_learners > 0` and the main process
bundle would otherwise only request `{"CPU": 1, "GPU": 0}`.

The custom resources are unpacked into the main process bundle in
both code paths of `_get_main_process_bundle()` (num_learners == 0
and num_learners > 0).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Artur Niederfahrenhorst <attaismyname@googlemail.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Artur Niederfahrenhorst <artur@anyscale.com>
Signed-off-by: Artur Niederfahrenhorst <artur@anyscale.com>
@ArturNiederfahrenhorst ArturNiederfahrenhorst force-pushed the custom-resources-for-main-process branch from 18106eb to 735624e Compare April 22, 2026 15:20

@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.

LGTM

@ArturNiederfahrenhorst ArturNiederfahrenhorst merged commit 780e736 into ray-project:master Apr 23, 2026
6 checks passed
Lucas61000 pushed a commit to Lucas61000/ray that referenced this pull request May 15, 2026
…-project#62475)

Allow users to specify custom Ray resources for the main Algorithm
actor's placement bundle via
`config.resources(custom_resources_for_main_process={"my_custom_resources":
1})`.

---------

Signed-off-by: Artur Niederfahrenhorst <attaismyname@googlemail.com>
Signed-off-by: Artur Niederfahrenhorst <artur@anyscale.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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 rllib-system system issues, runtime env, oom, etc

2 participants