Skip to content

[Tune] Fix Repeater crash when search finishes - #65960

Merged
matthewdeng merged 2 commits into
ray-project:masterfrom
Arnavsharma2:fix-tune-repeater-finished
Sep 21, 2026
Merged

matthewdeng merged 2 commits into
ray-project:masterfrom
Arnavsharma2:fix-tune-repeater-finished

Conversation

@Arnavsharma2

@Arnavsharma2 Arnavsharma2 commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #43489.

Handle Searcher.FINISHED in Repeater.suggest() so a finished search stops cleanly instead of raising an assertion. Adds regression coverage for completion, temporary pauses, and pending result aggregation.

Tests

  • RAY_TRAIN_V2_ENABLED=1 python -m pytest --import-mode=importlib -q python/ray/tune/tests/test_searcher_utils.py — 12 passed.
  • pre-commit run --files python/ray/tune/search/repeater.py python/ray/tune/tests/test_searcher_utils.py — passed.

Both new regression cases and a real BayesOpt/Tuner reproduction fail before the fix and pass afterward. Tested locally on macOS with Python 3.12.

Checked upstream and related/open PRs; no equivalent fix found.

AI assistance was used.

@Arnavsharma2 Arnavsharma2 changed the title [Tune] Propagate searcher completion through Repeater [Tune] Fix Repeater crash when search finishes Sep 5, 2026
@Arnavsharma2
Arnavsharma2 marked this pull request as ready for review September 5, 2026 18:07
@Arnavsharma2
Arnavsharma2 requested a review from a team as a code owner September 5, 2026 18:07
Copilot AI lite review requested due to automatic review settings September 5, 2026 18:07

@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 Repeater searcher in Ray Tune to correctly handle the Searcher.FINISHED sentinel value when generating suggestions, preventing it from attempting to wrap a finished state in a trial group. Additionally, a comprehensive unit test test_repeater_searcher_finished has been added to verify this behavior and ensure that result aggregation for pending trials is preserved when suggestions are exhausted. There are no review comments to address, and the changes look solid.

Copilot AI 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.

🟢 Approval recommended

The change is small, directly addresses the reported crash mode, and is backed by targeted regression tests covering the completion and aggregation edge cases.

Pull request overview

This PR fixes a crash in Tune’s Repeater wrapper when an underlying searcher signals completion via Searcher.FINISHED, ensuring Repeater.suggest() passes the sentinel through instead of asserting on a non-dict config. It also adds regression coverage to confirm correct behavior for temporary None suggestions, clean termination on FINISHED, and correct aggregation of pending repeated-trial results after the search finishes.

Changes:

  • Treat Searcher.FINISHED the same as None in Repeater.suggest() (return early, don’t create a _TrialGroup).
  • Add a regression test covering: transient None suggestions (no premature finish), FINISHED (clean finish), and post-finish result aggregation for pending repeats.
File summaries
File Description
python/ray/tune/search/repeater.py Return early from suggest() when the wrapped searcher returns Searcher.FINISHED, preventing _TrialGroup construction on a non-dict.
python/ray/tune/tests/test_searcher_utils.py Add regression test validating Repeater behavior for None vs FINISHED suggestions and verifying pending repeated-trial aggregation still completes after finish.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ray-gardener ray-gardener Bot added tune Tune-related issues community-contribution Contributed by the community labels Sep 5, 2026
@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 20, 2026
@pseudo-rnd-thoughts pseudo-rnd-thoughts added the go add ONLY when ready to merge, run all tests label Sep 21, 2026

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

Thanks for the PR, I checked the original issue and confirmed its still an issue and the fix resolves the issue

@pseudo-rnd-thoughts pseudo-rnd-thoughts removed the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Sep 21, 2026
@matthewdeng
matthewdeng merged commit 473325b into ray-project:master Sep 21, 2026
7 checks passed
owenowenisme pushed a commit to owenowenisme/ray that referenced this pull request Sep 23, 2026
Fixes ray-project#43489.

Handle `Searcher.FINISHED` in `Repeater.suggest()` so a finished search
stops cleanly instead of raising an assertion. Adds regression coverage
for completion, temporary pauses, and pending result aggregation.

### Tests

- `RAY_TRAIN_V2_ENABLED=1 python -m pytest --import-mode=importlib -q
python/ray/tune/tests/test_searcher_utils.py` — **12 passed**.
- `pre-commit run --files python/ray/tune/search/repeater.py
python/ray/tune/tests/test_searcher_utils.py` — **passed**.

Both new regression cases and a real BayesOpt/Tuner reproduction fail
before the fix and pass afterward. Tested locally on macOS with Python
3.12.

Checked upstream and related/open PRs; no equivalent fix found.

AI assistance was used.

Signed-off-by: Arnav Sharma <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
Fixes ray-project#43489.

Handle `Searcher.FINISHED` in `Repeater.suggest()` so a finished search
stops cleanly instead of raising an assertion. Adds regression coverage
for completion, temporary pauses, and pending result aggregation.

### Tests

- `RAY_TRAIN_V2_ENABLED=1 python -m pytest --import-mode=importlib -q
python/ray/tune/tests/test_searcher_utils.py` — **12 passed**.
- `pre-commit run --files python/ray/tune/search/repeater.py
python/ray/tune/tests/test_searcher_utils.py` — **passed**.

Both new regression cases and a real BayesOpt/Tuner reproduction fail
before the fix and pass afterward. Tested locally on macOS with Python
3.12.

Checked upstream and related/open PRs; no equivalent fix found.

AI assistance was used.

Signed-off-by: Arnav Sharma <[email protected]>
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 go add ONLY when ready to merge, run all tests tune Tune-related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Tune] Repeater doesn't work with BayesOptSearch due to the patience argument

4 participants