pub struct ExactDdnnfProgram { /* private fields */ }Implementations§
Source§impl ExactDdnnfProgram
impl ExactDdnnfProgram
pub fn compile_source(source: &str) -> Result<Self>
pub fn compile_source_with_gpu(source: &str, config: GpuConfig) -> Result<Self>
pub fn compile_from_program( program: &Program, config: GpuConfig, ) -> Result<Self>
pub fn uses_gpu_production_backend(&self) -> bool
Sourcepub fn last_compile_profile(&self) -> Option<&CircuitCompileProfile>
pub fn last_compile_profile(&self) -> Option<&CircuitCompileProfile>
Get the latest circuit compilation profile (populated when XLOG_WARMUP_PROFILE=1).
pub fn evaluate(&self) -> Result<ExactResult>
pub fn num_vars(&self) -> usize
Sourcepub fn random_var_indices(&self) -> Vec<u32>
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.
Sourcepub fn neural_backward_nll_buffers(
&self,
slots: &GpuWeightSlots,
query_idx: usize,
probs: &[CudaBuffer],
out_grads: &mut [CudaBuffer],
cfg: NeuralFastPathConfig,
) -> Result<()>
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/dpResult:out = dL/dpforL = -log P(query | evidence)(NLL).
Sourcepub 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>>
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).
Sourcepub 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>>
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.
pub fn evaluate_gpu_with_grads(&self) -> Result<ExactResultWithGrads>
Trait Implementations§
Source§impl Clone for ExactDdnnfProgram
impl Clone for ExactDdnnfProgram
Source§fn clone(&self) -> ExactDdnnfProgram
fn clone(&self) -> ExactDdnnfProgram
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more