Skip to main content

Tuner

Struct Tuner 

Source
pub struct Tuner { /* private fields */ }
Expand description

Workgroup-size autotuner.

Implementations§

Source§

impl Tuner

Source

pub fn new(adapter_fp: &str, mode: Mode) -> Self

Build a new tuner for the adapter fingerprinted as adapter_fp.

Source

pub fn cache_path_for_adapter(adapter_fp: &str) -> PathBuf

Cache file path for a given adapter fingerprint.

Source

pub fn candidates_for(&self, max_invocations: u32) -> Vec<u32>

Candidate workgroup sizes bounded by max_invocations.

Source

pub const fn default_workgroup_size() -> [u32; 3]

Default workgroup size used without cache data.

Source

pub const fn mode(&self) -> Mode

Mode this tuner is running in.

Source

pub fn resolve(&self, program_fp: &str) -> [u32; 3]

Resolve the workgroup size for a program key.

Source

pub fn resolve_key(&self, key: &TunerProgramKey) -> [u32; 3]

Resolve the workgroup size for a typed program/static-shape key.

Source

pub fn record_decision(&mut self, program_fp: impl Into<String>, size: [u32; 3])

Record a sweep outcome in memory.

Source

pub fn record_key_decision(&mut self, key: TunerProgramKey, size: [u32; 3])

Record a sweep outcome for a typed key.

Source

pub fn best_of<T: BackendTimer>( &self, program: &Program, candidates: impl IntoIterator<Item = [u32; 3]>, timer: &mut T, ) -> Result<Option<TuningMeasurement>, T::Error>

Measure candidate sizes and choose the fastest one.

§Errors

Returns a backend timing error from BackendTimer.

Source

pub fn best_of_natural_gradient<T: BackendTimer>( &self, program: &Program, candidates: impl IntoIterator<Item = [u32; 3]>, timer: &mut T, fisher_inv_sqrt_q16: &[u32], policy: NaturalGradientPolicy, ) -> Result<Result<NaturalGradientTuningStep, NaturalGradientTuningError>, T::Error>

Measure candidates, then choose the next probe with a Fisher-preconditioned natural-gradient policy.

This is the concrete runtime handoff for VYRE_AUTOTUNER=natural. It reuses the same backend timer as Self::best_of, records every measured candidate, and feeds those measurements into NaturalGradientPolicy. The returned step includes both the raw fastest measurement and the Fisher-directed next candidate.

§Errors

Returns backend timing errors from BackendTimer or policy errors from NaturalGradientPolicy.

Source

pub fn natural_gradient_step( &self, measurements: &[TuningMeasurement], fisher_inv_sqrt_q16: &[u32], policy: NaturalGradientPolicy, ) -> Result<NaturalGradientTuningStep, NaturalGradientTuningError>

Convert measured candidates into a Fisher-preconditioned next probe.

This keeps the best-of-N timing hook compatible while giving CUDA and other GPU backends a richer update rule than “pick the current fastest sample forever.” Backends can feed fisher_inv_sqrt_q16 from the primitive-backed natural-gradient self-substrate path.

§Errors

Returns NaturalGradientTuningError when the policy input is malformed.

Source

pub fn persist(&self) -> Result<(), String>

Write the cache to disk.

§Errors

Returns the structured error from TunerCache::save.

Auto Trait Implementations§

§

impl Freeze for Tuner

§

impl RefUnwindSafe for Tuner

§

impl Send for Tuner

§

impl Sync for Tuner

§

impl Unpin for Tuner

§

impl UnsafeUnpin for Tuner

§

impl UnwindSafe for Tuner

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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