Skip to main content

ExactDdnnfProgram

Struct ExactDdnnfProgram 

Source
pub struct ExactDdnnfProgram { /* private fields */ }

Implementations§

Source§

impl ExactDdnnfProgram

Source

pub fn compile_source(source: &str) -> Result<Self>

Source

pub fn compile_source_with_gpu(source: &str, config: GpuConfig) -> Result<Self>

Source

pub fn compile_from_program( program: &Program, config: GpuConfig, ) -> Result<Self>

Source

pub fn uses_gpu_production_backend(&self) -> bool

Source

pub fn last_compile_profile(&self) -> Option<&CircuitCompileProfile>

Get the latest circuit compilation profile (populated when XLOG_WARMUP_PROFILE=1).

Source

pub fn evaluate(&self) -> Result<ExactResult>

Source

pub fn num_vars(&self) -> usize

Source

pub fn random_var_indices(&self) -> Vec<u32>

Returns the indices of random (probabilistic) variables in order.

Random variables are those with non-trivial weights (not (0.0, 0.0)). These correspond to annotated disjunctions in the source program. The order matches the order variables were assigned during CNF encoding.

Source

pub fn neural_backward_nll_buffers( &self, slots: &GpuWeightSlots, query_idx: usize, probs: &[CudaBuffer], out_grads: &mut [CudaBuffer], cfg: NeuralFastPathConfig, ) -> Result<()>

GPU neural fast-path: compute NLL gradients w.r.t. probability tensors (no host reads).

This implements the design in docs/design/2026-01-22-gpu-native-compilation-design.md §5.3:

  • Fill AD conditional-chain log-weights from device-resident p[label].
  • Run XGCF forward+backward on GPU.
  • Scatter gradients back into probability-space via the correct chain rule (uses both grad_true + grad_false).

The output gradient buffers are updated in-place:

  • Base run: out = dlogZ_base/dp
  • Query-forced run: out -= dlogZ_query/dp Result: out = dL/dp for L = -log P(query | evidence) (NLL).
Source

pub fn neural_backward_nll_buffers_with_device_loss( &self, slots: &GpuWeightSlots, query_idx: usize, probs: &[CudaBuffer], out_grads: &mut [CudaBuffer], cfg: NeuralFastPathConfig, expected_true: bool, ) -> Result<TrackedCudaSlice<f64>>

Same as Self::neural_backward_nll_buffers, but also returns the device-resident scalar NLL loss: L = -log P(query | evidence).

The returned slice has length 1 and is written on GPU (no device->host reads).

Source

pub fn neural_backward_nll_buffers_batch_with_device_loss( &self, slots: &GpuWeightSlots, query_indices: &[usize], probs_batch: &[Vec<CudaBuffer>], out_grads_batch: &mut [Vec<CudaBuffer>], cfg: NeuralFastPathConfig, expected_true: bool, ) -> Result<TrackedCudaSlice<f64>>

Batched variant of Self::neural_backward_nll_buffers_with_device_loss.

Computes NLL gradients for batch queries that share one compiled circuit template and returns a device-resident vector of batch scalar losses.

On circuits that require free-variable correction, this falls back to the existing per-query path for correctness.

Source

pub fn evaluate_gpu_with_grads(&self) -> Result<ExactResultWithGrads>

Trait Implementations§

Source§

impl Clone for ExactDdnnfProgram

Source§

fn clone(&self) -> ExactDdnnfProgram

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. 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
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.

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> 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<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,