Skip to main content

MedianPruner

Struct MedianPruner 

pub struct MedianPruner { /* private fields */ }
Expand description

Median / percentile stopping.

Prunes a trial reporting at step k when its value is worse than the p-th percentile of the values that the completed trials reached at step k.

§Warm-up guards (Optuna’s n_startup_trials / n_warmup_steps)

Two guards keep the pruner from acting on noise or on an empty baseline:

  • with_startup_trials — no pruning until at least this many trials have completed (default 5). Early on there is no trustworthy baseline.
  • with_warmup_steps — no pruning at a step below this (default 0). RL curves are often worst right after initialization.
  • with_min_trials — the percentile is only formed once at least this many competitors reported at the step itself (default 1).

§Direction awareness

“Worse than the percentile” is resolved through Direction::is_better, so a Maximize and a Minimize study prune opposite trials on the same curves. For a Maximize study the (100 − p)-th percentile is used, so p = 50 is the median for both.

§Multi-objective

There is no single “worse than the median” across a Pareto front, so on a multi-objective study this pruner never prunes (returns Decision::Continue) rather than guess a total order and risk pruning a Pareto-optimal trial. Single-objective studies gate on their one objective.

§Determinism

The decision is a pure function of the StudyView the trial was handed at ask time, so it depends on which other trials had completed by then — which under parallelism is completion-order dependent. A median-scheduled study is therefore replayable, not pre-determined, exactly like a history-dependent sampler (where determinism stops). Under a single worker with a fixed seed the completion order is fixed, so the pruning is fully reproducible.

use atune_core::scheduler::MedianPruner;

// Plain median, no pruning until 10 trials have completed.
let pruner = MedianPruner::new().with_startup_trials(10);

// The variance-aware variant: prune only past 1 standard deviation of noise.
let robust = MedianPruner::variance_aware();

Implementations§

§

impl MedianPruner

pub const fn new() -> Self

The plain median pruner: p = 50, startup_trials = 5, warmup_steps = 0, min_trials = 1, no dispersion gate.

pub fn percentile(percentile: f64) -> Result<Self>

A percentile pruner at percentile (in (0, 100)).

§Errors

Error::InvalidSpace if percentile is not strictly inside (0, 100) — 0 or 100 would prune everything or nothing.

pub const fn variance_aware() -> Self

The variance-aware median: prune only when the gap to the median exceeds one Dispersion::Std of the competitors (see the type docs).

pub const fn with_dispersion(self, dispersion: Dispersion) -> Self

Sets the dispersion measure and turns the variance-aware gate on.

pub const fn with_kappa(self, kappa: f64) -> Self

Sets the dispersion multiplier kappa (variance-aware only): the gap must exceed kappa dispersions to prune. Larger is more forgiving.

pub const fn with_startup_trials(self, startup_trials: usize) -> Self

Sets the minimum number of completed trials before any pruning.

pub const fn with_warmup_steps(self, warmup_steps: u64) -> Self

Sets the minimum step before any pruning.

pub const fn with_min_trials(self, min_trials: usize) -> Self

Sets the minimum number of competitors at a step before the percentile is trusted.

pub const fn with_objective(self, obj: usize) -> Self

Selects which objective dimension to gate on (default 0).

Trait Implementations§

§

impl Clone for MedianPruner

§

fn clone(&self) -> MedianPruner

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for MedianPruner

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Default for MedianPruner

§

fn default() -> Self

The plain median with default guards — see MedianPruner::new.

§

impl Scheduler for MedianPruner

§

fn on_report( &self, study: &StudyView, _trial: &TrialMeta, step: u64, values: &[f64], ) -> Result<Decision>

Prunes a trial worse than the percentile at its current step; see the type docs.

§Errors

Error::InvalidSpace if a configuration knob is invalid or the selected objective is not present in the study.

§

fn state(&self) -> Result<Option<SchedulerState>>

None: the pruner keeps no persistent state, deriving every decision from the StudyView (the Tpe pattern).

§

fn fan_report_mode(&self) -> FanReportMode

Declares whether this scheduler accepts aligned aggregate fan reports. Read more
§

fn scripted_capability(&self) -> ScriptedSchedulerCapability

Declares whether scripted ask/tell can recreate this scheduler. Read more
§

fn on_trial_end( &self, study: &StudyView, trial: &FrozenTrial, ) -> Result<Vec<Command>>

Called once a trial reaches a terminal state. Read more
§

fn resume_candidates(&self, study: &StudyView) -> Result<Vec<Command>>

Paused trials worth waking on a freed work slot, in priority order. Read more
§

fn restore_state(&self, blob: &SchedulerState) -> Result<()>

Restores a scheduler from a previously persisted blob. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more