OpCache

Struct OpCache 

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

2026-09-25: Memoized kernel handles and scratch allocations for one backend.

Implementations§

Source§

impl OpCache

Source

pub fn new() -> Self

Source

pub fn record_n_tile(&self, kernel: KernelHandle, n_tile: u32)

2026-09-29: Record the N tile kernel publishes; a later value for the same handle replaces it.

Source

pub fn n_tile(&self, kernel: KernelHandle) -> Option<u32>

2026-09-29: The N tile recorded for kernel, or None when it publishes none.

Source

pub fn record_a_e4m3(&self, kernel: KernelHandle)

2026-09-29: Record that kernel casts its A operand to E4M3 with no scale.

Source

pub fn a_e4m3(&self, kernel: KernelHandle) -> bool

2026-09-29: Whether kernel was recorded as casting its A operand to E4M3.

Source

pub fn kernel( &self, gpu: &dyn GpuBackend, module: &'static str, func: &'static str, ) -> Result<KernelHandle>

2026-09-25: Resolve module::func, memoized: gpu.kernel(..) on a miss, a map read on a hit.

Source

pub fn scratch( &self, gpu: &dyn GpuBackend, tag: &'static str, bytes: usize, ) -> Result<DevicePtr>

2026-09-25: A scratch allocation of at least bytes, memoized under tag.

Grow-only: a larger request allocates a new buffer and drops the old pointer from the cache without freeing it. On the CUDA backend the old buffer stays on the allocation ledger until sweep_unreleased frees it when the backend drops.

Source

pub fn alloc_fell_back(&self) -> bool

2026-09-25: Whether a loader latched the managed-memory fallback on this backend. The latch is per backend, so the next model’s load tries device memory again.

Source

pub fn note_alloc_fallback(&self)

2026-09-25: Latch the managed-memory fallback for the rest of this backend’s life.

Source

pub fn first_n(&self, key: &'static str, n: u32) -> bool

2026-09-25: true for the first n times this backend reaches key. Counted per backend, so a second model reports its own.

Source

pub fn once(&self, key: &'static str) -> bool

2026-09-25: true the first time this backend reaches key, false after. Shares first_shape’s set, as (key, 0, 0, 0).

Source

pub fn first_shape(&self, name: &str, m: u32, n: u32, k: u32) -> bool

2026-09-25: true the first time this backend sees (name, m, n, k); used to de-duplicate the GEMM route and shape log lines.

Trait Implementations§

Source§

impl Debug for OpCache

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for OpCache

Source§

fn default() -> OpCache

Returns the “default value” for a type. Read more
Source§

impl ModelResource<dyn GpuBackend> for OpCache

2026-09-25: Frees every scratch allocation and empties the scratch map.

Kernel handles need no release here: they point into the modules of the backend’s MetraleRegistry, which unloads them when it is dropped or passed to cuda_host::release.

Source§

fn label(&self) -> &'static str

2026-09-25: Human name, used to attribute a failure in Teardown::release_all’s error.
Source§

fn release(&mut self, gpu: &dyn GpuBackend) -> Result<()>

2026-09-25: Release everything this owns. Must be idempotent.

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

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