Skip to content

Add states argument to _read_trials_from_remote_storage#6288

Merged
y0z merged 3 commits intooptuna:masterfrom
not522:read-trials-from-remote-storage-states
Oct 10, 2025
Merged

Add states argument to _read_trials_from_remote_storage#6288
y0z merged 3 commits intooptuna:masterfrom
not522:read-trials-from-remote-storage-states

Conversation

@not522
Copy link
Copy Markdown
Member

@not522 not522 commented Sep 30, 2025

Motivation

Currently, _CachedStorage's _read_trials_from_remote_storage reads all trials even if the states argument is specified. However, performance can be improved by using states as filter.

Description of the changes

  • Add states argument to _read_trials_from_remote_storage

Benchmark

import optuna

def objective(trial: optuna.Trial) -> float:
    x = trial.suggest_float("x", -100, 100)
    y = trial.suggest_int("y", -100, 100)
    return x**2 + y**2

sampler = optuna.samplers.TPESampler(seed=42, multivariate=True, constant_liar=True)
study = optuna.create_study(sampler=sampler, storage="sqlite:///tmp.db")
study.optimize(objective, n_trials=1000)
master PR
10.079s 9.522s

@not522 not522 added the enhancement Change that does not break compatibility and not affect public interfaces, but improves performance. label Sep 30, 2025
@y0z
Copy link
Copy Markdown
Member

y0z commented Oct 1, 2025

@HideakiImamura @sawa3030 Could you review this PR?

Copy link
Copy Markdown
Collaborator

@sawa3030 sawa3030 left a comment

Choose a reason for hiding this comment

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

LGTM

@y0z y0z assigned kAIto47802 and unassigned HideakiImamura Oct 3, 2025
@y0z
Copy link
Copy Markdown
Member

y0z commented Oct 3, 2025

@kAIto47802 Could you review this PR?

Copy link
Copy Markdown
Collaborator

@kAIto47802 kAIto47802 left a comment

Choose a reason for hiding this comment

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

LGTM. I also confirmed that the results are identical.

@y0z y0z merged commit 9adfbfb into optuna:master Oct 10, 2025
14 checks passed
@y0z y0z added this to the v4.6.0 milestone Oct 10, 2025
@not522 not522 deleted the read-trials-from-remote-storage-states branch October 10, 2025 07:07
@not522 not522 changed the title Add states argument to _read_trials_from_remote_storage Add states argument to _read_trials_from_remote_storage Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Change that does not break compatibility and not affect public interfaces, but improves performance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants