Skip to content

Expose the trial queue through sampler context - #304

Merged
c-bata merged 2 commits into
optuna:mainfrom
c-bata:expose-trial-queue-through-sampler-context
Nov 12, 2026
Merged

c-bata merged 2 commits into
optuna:mainfrom
c-bata:expose-trial-queue-through-sampler-context

Conversation

@c-bata

@c-bata c-bata commented Nov 4, 2026

Copy link
Copy Markdown
Member

Motivation

Samplers receive study and trial metadata through Context, but could not access the study's trial queue. Exposing the shared queue lets samplers enqueue or dequeue trials from their callbacks.

Changes

  • Add the study's shared TrialQueue to the Rust sampler context.
  • Pass the same queue to before_trial, sample_joint, sample_independent, and after_trial.
  • Expose ctx.trial_queue to Python samplers through a TrialQueueProtocol-compatible handle.
  • Keep the Python SamplerContext constructor unchanged; manually constructed contexts receive an in-memory queue.

@c-bata
c-bata force-pushed the expose-trial-queue-through-sampler-context branch 2 times, most recently from c548add to ec5b226 Compare November 4, 2026 08:14
@c-bata
c-bata force-pushed the expose-trial-queue-through-sampler-context branch from ec5b226 to 392863f Compare November 4, 2026 08:26
@c-bata
c-bata marked this pull request as draft November 5, 2026 04:19
@c-bata
c-bata marked this pull request as ready for review November 12, 2026 03:29
@c-bata
c-bata merged commit 727891e into optuna:main Nov 12, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant