pub struct GpuCircuitCache { /* private fields */ }Expand description
Fixed-capacity device-resident cache of compiled circuits and evaluation state.
Implementations§
Source§impl GpuCircuitCache
impl GpuCircuitCache
Sourcepub fn provider(&self) -> &Arc<CudaKernelProvider> ⓘ
pub fn provider(&self) -> &Arc<CudaKernelProvider> ⓘ
Returns the CUDA provider that owns all cache allocations.
Sourcepub fn var_log_weights_mut(
&mut self,
) -> (&mut TrackedCudaSlice<f64>, &mut TrackedCudaSlice<f64>)
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.
Sourcepub fn grad_true(&self) -> &TrackedCudaSlice<f64>
pub fn grad_true(&self) -> &TrackedCudaSlice<f64>
Returns the device gradients for true variable log weights.
Sourcepub fn grad_false(&self) -> &TrackedCudaSlice<f64>
pub fn grad_false(&self) -> &TrackedCudaSlice<f64>
Returns the device gradients for false variable log weights.
Sourcepub fn values(&self) -> &TrackedCudaSlice<f64>
pub fn values(&self) -> &TrackedCudaSlice<f64>
Returns the device circuit-value workspace.
Sourcepub fn meta_num_nodes_device(&self) -> &TrackedCudaSlice<u32>
pub fn meta_num_nodes_device(&self) -> &TrackedCudaSlice<u32>
Returns the device scalar containing the active node count.
Sourcepub fn meta_num_levels_device(&self) -> &TrackedCudaSlice<u32>
pub fn meta_num_levels_device(&self) -> &TrackedCudaSlice<u32>
Returns the device scalar containing the active level count.
Sourcepub fn meta_root_device(&self) -> &TrackedCudaSlice<u32>
pub fn meta_root_device(&self) -> &TrackedCudaSlice<u32>
Returns the device scalar containing the active root node.
Sourcepub fn meta_max_var_device(&self) -> &TrackedCudaSlice<u32>
pub fn meta_max_var_device(&self) -> &TrackedCudaSlice<u32>
Returns the device scalar containing the active maximum variable.
Sourcepub fn new(
provider: &Arc<CudaKernelProvider>,
config: GpuCircuitCacheConfig,
) -> Result<Self>
pub fn new( provider: &Arc<CudaKernelProvider>, config: GpuCircuitCacheConfig, ) -> Result<Self>
Allocates an empty circuit cache with the requested fixed capacities.
Sourcepub fn lookup_or_insert(&mut self, key: u64) -> Result<GpuCacheLookup>
pub fn lookup_or_insert(&mut self, key: u64) -> Result<GpuCacheLookup>
Finds or claims a slot for a host-resident cache key.
Sourcepub fn claim_slot(&mut self, key: u64) -> Result<GpuCircuitCacheHandle>
pub fn claim_slot(&mut self, key: u64) -> Result<GpuCircuitCacheHandle>
Finds or claims a slot and resolves it into a host-visible handle.
Sourcepub fn store_from_xgcf(
&mut self,
handle: &mut GpuCircuitCacheHandle,
xgcf: &GpuXgcf,
) -> Result<()>
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.
Sourcepub fn store_weights(
&mut self,
handle: &GpuCircuitCacheHandle,
weights_true: &TrackedCudaSlice<f64>,
weights_false: &TrackedCudaSlice<f64>,
) -> Result<()>
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.
Sourcepub fn overwrite_weights(
&mut self,
handle: &GpuCircuitCacheHandle,
weights_true: &TrackedCudaSlice<f64>,
weights_false: &TrackedCudaSlice<f64>,
) -> Result<()>
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.
Sourcepub fn store_free_var_mask(
&mut self,
handle: &GpuCircuitCacheHandle,
mask: &TrackedCudaSlice<u8>,
) -> Result<()>
pub fn store_free_var_mask( &mut self, handle: &GpuCircuitCacheHandle, mask: &TrackedCudaSlice<u8>, ) -> Result<()>
Stores the free-variable mask associated with a compiled slot.
Sourcepub fn eval_log_wmc_device_inplace(
&mut self,
handle: &GpuCircuitCacheHandle,
out_log_z: &mut TrackedCudaSlice<f64>,
) -> Result<()>
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.
Sourcepub fn eval_log_wmc_device_only(
&mut self,
handle: &GpuCircuitCacheHandle,
out_log_z: &mut TrackedCudaSlice<f64>,
) -> Result<()>
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.
Sourcepub fn eval_grads_inplace(
&mut self,
handle: &GpuCircuitCacheHandle,
) -> Result<()>
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.
Sourcepub fn eval_grads_inplace_fused(
&mut self,
handle: &GpuCircuitCacheHandle,
) -> Result<()>
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.