pub struct CompiledProgram { /* private fields */ }Implementations§
Source§impl CompiledProgram
impl CompiledProgram
pub fn evaluate( &self, _py: Python<'_>, return_grads: bool, samples: Option<usize>, seed: Option<u64>, confidence: f64, max_nonmonotone_iterations: usize, sampling_method: Option<String>, memory_mb: Option<u64>, allow_cpu_oracle: bool, ) -> PyResult<EvalResult>
Sourcepub fn prob_var_map(&self, py: Python<'_>) -> PyResult<Vec<Py<PyAny>>>
pub fn prob_var_map(&self, py: Python<'_>) -> PyResult<Vec<Py<PyAny>>>
Which probabilistic fact each CNF variable stands for.
The returned list’s length is the CNF encoder’s variable capacity,
not the number of CNF variables in use and not the number of random
variables in the program — a real fraction of entries are
{"kind": "other"} padding (do not use len() of the result as a
variable count). Entry i describes CNF variable i — the same
position i that the grad_true / grad_false vectors of
evaluate(return_grads=True) use (index 0 is unused padding, since
CNF variables are 1-indexed).
For a "choice" entry (one Bernoulli decision of an annotated
disjunction’s chain), probs[choice_index] is the disjunction’s
declared, marginal probability and is display context only; prob
is the conditional Bernoulli parameter actually assigned to this
variable’s weight, and prob * (1 - prob) — not
probs[choice_index] * (1 - probs[choice_index]) — is the correct
Jacobian for grad_true / grad_false at this position.
Raises ValueError for Monte Carlo programs, and for exact programs
compiled through the GPU count-lift fast path (count aggregates
without evidence or annotated disjunctions), since that path never
builds a CNF encoding and therefore has no variable map to report —
this is not the same as the program having no probabilistic facts.
Sourcepub fn evaluate_device(
&self,
py: Python<'_>,
samples: Option<usize>,
seed: Option<u64>,
confidence: f64,
max_nonmonotone_iterations: usize,
sampling_method: Option<String>,
memory_mb: Option<u64>,
) -> PyResult<McDeviceEvalResult>
pub fn evaluate_device( &self, py: Python<'_>, samples: Option<usize>, seed: Option<u64>, confidence: f64, max_nonmonotone_iterations: usize, sampling_method: Option<String>, memory_mb: Option<u64>, ) -> PyResult<McDeviceEvalResult>
Evaluate Monte Carlo programs and return device-only result counts via DLPack.
This is the primary GPU-native API surface for MC inference. It never performs device->host reads for result data (only returns device buffers).
Sourcepub fn zero_grad(&self, py: Python<'_>) -> PyResult<()>
pub fn zero_grad(&self, py: Python<'_>) -> PyResult<()>
Zero gradients for all registered networks.
This should be called at the start of each training iteration to clear accumulated gradients from previous iterations.
Sourcepub fn optimizer_step(&self, py: Python<'_>) -> PyResult<()>
pub fn optimizer_step(&self, py: Python<'_>) -> PyResult<()>
Perform optimizer step for all registered networks.
This applies the accumulated gradients to update network parameters. Should be called after forward_backward().
Sourcepub fn clip_grad_norms(&self, py: Python<'_>, max_norm: f64) -> PyResult<()>
pub fn clip_grad_norms(&self, py: Python<'_>, max_norm: f64) -> PyResult<()>
Clip gradient norms for all registered networks.
Uses torch.nn.utils.clip_grad_norm_.
Sourcepub fn evaluate_loss(&self, queries: Vec<String>) -> PyResult<f64>
pub fn evaluate_loss(&self, queries: Vec<String>) -> PyResult<f64>
Sourcepub fn memory_stats(&self, py: Python<'_>) -> PyResult<Py<PyAny>>
pub fn memory_stats(&self, py: Python<'_>) -> PyResult<Py<PyAny>>
Return memory diagnostics including allocated_bytes and memory_limit_bytes.
pub fn rule_provenance(&self, py: Python<'_>) -> PyResult<Py<PyAny>>
pub fn proof_traces(&self, py: Python<'_>) -> PyResult<Py<PyAny>>
pub fn host_transfer_stats(&self, py: Python<'_>) -> PyResult<Py<PyAny>>
pub fn reset_host_transfer_stats(&self)
pub fn neural_hot_loop_diagnostics(&self, py: Python<'_>) -> PyResult<Py<PyAny>>
pub fn cuda_graph_stats(&self, py: Python<'_>) -> PyResult<Py<PyAny>>
Trait Implementations§
impl DerefToPyAny for CompiledProgram
impl ExtractPyClassWithClone for CompiledProgram
Source§impl<'py> IntoPyObject<'py> for CompiledProgram
impl<'py> IntoPyObject<'py> for CompiledProgram
Source§type Target = CompiledProgram
type Target = CompiledProgram
Source§type Output = Bound<'py, <CompiledProgram as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <CompiledProgram as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PyClass for CompiledProgram
impl PyClass for CompiledProgram
Source§impl PyClassImpl for CompiledProgram
impl PyClassImpl for CompiledProgram
Source§const MODULE: Option<&str> = ::core::option::Option::None
const MODULE: Option<&str> = ::core::option::Option::None
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = c"\x00"
const RAW_DOC: &'static CStr = c"\x00"
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type Layout = <<CompiledProgram as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<CompiledProgram>
type Layout = <<CompiledProgram as PyClassImpl>::BaseNativeType as PyClassBaseType>::Layout<CompiledProgram>
Source§type ThreadChecker = NoopThreadChecker
type ThreadChecker = NoopThreadChecker
type Inventory = Pyo3MethodsInventoryForCompiledProgram
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
§fn dict_offset() -> Option<PyObjectOffset>
fn dict_offset() -> Option<PyObjectOffset>
§fn weaklist_offset() -> Option<PyObjectOffset>
fn weaklist_offset() -> Option<PyObjectOffset>
Source§impl PyTypeInfo for CompiledProgram
impl PyTypeInfo for CompiledProgram
Source§const NAME: &str = <Self as ::pyo3::PyClass>::NAME
const NAME: &str = <Self as ::pyo3::PyClass>::NAME
prefer using ::type_object(py).name() to get the correct runtime value
Source§const MODULE: Option<&str> = <Self as ::pyo3::impl_::pyclass::PyClassImpl>::MODULE
const MODULE: Option<&str> = <Self as ::pyo3::impl_::pyclass::PyClassImpl>::MODULE
prefer using ::type_object(py).module() to get the correct runtime value
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type.Auto Trait Implementations§
impl !RefUnwindSafe for CompiledProgram
impl Freeze for CompiledProgram
impl Send for CompiledProgram
impl Sync for CompiledProgram
impl Unpin for CompiledProgram
impl UnsafeUnpin for CompiledProgram
impl UnwindSafe for CompiledProgram
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self into an owned Python object, dropping type information and unbinding it
from the 'py lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self into a Python object. Read more§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
§fn type_check(object: &Bound<'_, PyAny>) -> bool
fn type_check(object: &Bound<'_, PyAny>) -> bool
§fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
isinstance and issubclass function. Read more