Skip to main content

GpuCircuitCache

Struct GpuCircuitCache 

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

Fixed-capacity device-resident cache of compiled circuits and evaluation state.

Implementations§

Source§

impl GpuCircuitCache

Source

pub fn provider(&self) -> &Arc<CudaKernelProvider> ⓘ

Returns the CUDA provider that owns all cache allocations.

Source

pub fn var_log_weights_mut( &mut self, ) -> (&mut TrackedCudaSlice<f64>, &mut TrackedCudaSlice<f64>)

Returns mutable device-resident log-weight tables.

Device-only callers are responsible for validating numeric inputs and outputs. Positive infinity is valid when it does not enter an undefined normalization; NaN or undefined arithmetic that reaches evaluation is represented by a non-finite device result.

Source

pub fn grad_true(&self) -> &TrackedCudaSlice<f64>

Returns the device gradients for true variable log weights.

Source

pub fn grad_false(&self) -> &TrackedCudaSlice<f64>

Returns the device gradients for false variable log weights.

Source

pub fn values(&self) -> &TrackedCudaSlice<f64>

Returns the device circuit-value workspace.

Source

pub fn meta_num_nodes_device(&self) -> &TrackedCudaSlice<u32>

Returns the device scalar containing the active node count.

Source

pub fn meta_num_levels_device(&self) -> &TrackedCudaSlice<u32>

Returns the device scalar containing the active level count.

Source

pub fn meta_root_device(&self) -> &TrackedCudaSlice<u32>

Returns the device scalar containing the active root node.

Source

pub fn meta_max_var_device(&self) -> &TrackedCudaSlice<u32>

Returns the device scalar containing the active maximum variable.

Source

pub fn num_slots(&self) -> u32

Returns the number of circuit slots allocated by the cache.

Source

pub fn new( provider: &Arc<CudaKernelProvider>, config: GpuCircuitCacheConfig, ) -> Result<Self>

Allocates an empty circuit cache with the requested fixed capacities.

Source

pub fn lookup_or_insert(&mut self, key: u64) -> Result<GpuCacheLookup>

Finds or claims a slot for a host-resident cache key.

Source

pub fn claim_slot(&mut self, key: u64) -> Result<GpuCircuitCacheHandle>

Finds or claims a slot and resolves it into a host-visible handle.

Source

pub fn store_from_xgcf( &mut self, handle: &mut GpuCircuitCacheHandle, xgcf: &GpuXgcf, ) -> Result<()>

Copies a compiled device circuit and its authoritative metadata into a claimed slot.

Source

pub fn store_weights( &mut self, handle: &GpuCircuitCacheHandle, weights_true: &TrackedCudaSlice<f64>, weights_false: &TrackedCudaSlice<f64>, ) -> Result<()>

Initializes the log-weight tables for a claimed slot.

Source

pub fn overwrite_weights( &mut self, handle: &GpuCircuitCacheHandle, weights_true: &TrackedCudaSlice<f64>, weights_false: &TrackedCudaSlice<f64>, ) -> Result<()>

Replaces log-weight tables for an already materialized slot.

Source

pub fn store_free_var_mask( &mut self, handle: &GpuCircuitCacheHandle, mask: &TrackedCudaSlice<u8>, ) -> Result<()>

Stores the free-variable mask associated with a compiled slot.

Source

pub fn eval_log_wmc_device_inplace( &mut self, handle: &GpuCircuitCacheHandle, out_log_z: &mut TrackedCudaSlice<f64>, ) -> Result<()>

Evaluates cached logZ without a host transfer.

Callers must ensure evaluated resident weights are NaN-free. NaN or undefined arithmetic that reaches evaluation is represented by a NaN sentinel in out_log_z; callers must reject that sentinel at an existing readback. Positive infinity remains valid for value-only evaluation.

Source

pub fn eval_log_wmc_device_only( &mut self, handle: &GpuCircuitCacheHandle, out_log_z: &mut TrackedCudaSlice<f64>, ) -> Result<()>

Device-only implementation of cached value evaluation; see Self::eval_log_wmc_device_inplace for its numeric preconditions and sentinel contract.

Source

pub fn eval_grads_inplace( &mut self, handle: &GpuCircuitCacheHandle, ) -> Result<()>

Evaluates cached gradients without a host transfer.

Callers must validate numeric inputs and eventual outputs. Positive infinity is valid when the actual backward path remains finite. This asynchronous API cannot return a host-side numeric error; NaN or undefined normalization that reaches evaluation is observable as a non-finite device result.

Source

pub fn eval_grads_inplace_fused( &mut self, handle: &GpuCircuitCacheHandle, ) -> Result<()>

Like [eval_grads_inplace] but replaces the per-level backward loop with a single launch of xgcf_backward_all_levels_cached, and omits the trailing device().synchronize() so that the caller can batch multiple queries before syncing. The same caller-side numeric validation contract applies.

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.

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.