ppvm_vihaco::prelude
prelude¶
ppvm_vihaco::prelude
classPPVM¶source
ppvm_vihaco::prelude::PPVM
Bases: Default, Composite, HasInstructionSet, LoadBytecodeSection<__VihacoContext>, LoadSstSection<__VihacoContext>, Observe<StdoutEffect>, Observe<CircuitEffect>, Observe<MeasurementEffect>, Observe<TraceEffect>, Reset
Rust struct.
pub struct PPVMmethodapply_circuit_instruction¶source
ppvm_vihaco::prelude::PPVM::apply_circuit_instruction
Signature
pub fn apply_circuit_instruction(&mut self, inst: CircuitInstruction, qubits: &[usize], params: &[f64]) -> Result<()>Parameters
| Name | Type | Description |
|---|---|---|
inst | CircuitInstruction | |
qubits | &[usize] | |
params | &[f64] |
Returns
Result<()>
Lower a single circuit instruction — qubit operands first, then float params, per the push-in-order / pop-in-reverse convention — and execute it against the persistent state. Qubit indices are bounds-checked against the device size first, because the tableau panics (rather than erroring) on an out-of-range qubit.
sourcemethodcurrent_instruction¶source
ppvm_vihaco::prelude::PPVM::current_instruction
pub fn current_instruction(&self) -> Option<PPVMInstruction>Returns
Option<PPVMInstruction>
The next instruction to execute, or `None` once execution has run off the end of the code. Intended for debuggers/inspection.
sourcemethodcurrent_pc¶source
ppvm_vihaco::prelude::PPVM::current_pc
pub fn current_pc(&self) -> u32Returns
u32
Program counter: the index of the next instruction to execute.
sourcemethodexecute_single_instruction¶source
ppvm_vihaco::prelude::PPVM::execute_single_instruction
Signature
pub fn execute_single_instruction(&mut self, instrs: &[PPVMInstruction]) -> Result<()>Parameters
| Name | Type | Description |
|---|---|---|
instrs | &[PPVMInstruction] |
Returns
Result<()>
Append one REPL command’s lowered VM ops and run just that block against the persistent state, advancing the pc through it. NOTE: an out-of-range qubit index panics in the tableau rather than erroring, so callers must bounds-check qubit operands against `n_qubits` first.
sourcemethodinit¶source
ppvm_vihaco::prelude::PPVM::init
methodinit_with_seed¶source
ppvm_vihaco::prelude::PPVM::init_with_seed
pub fn init_with_seed(&mut self, seed: u64) -> Result<()>Parameters
| Name | Type | Description |
|---|---|---|
seed | u64 |
Returns
Result<()>
Like PPVM::init, but seed the circuit RNG deterministically so the run is reproducible.
sourcemethodload¶source
ppvm_vihaco::prelude::PPVM::load
Signature
pub fn load(&mut self, module: &LocalModule<PPVMInstruction, Value, Type, PPVMDeviceInfo>) -> Result<()>Parameters
| Name | Type | Description |
|---|---|---|
module | &LocalModule<PPVMInstruction, Value, Type, PPVMDeviceInfo> |
Returns
Result<()>
methodload_bytecode¶source
ppvm_vihaco::prelude::PPVM::load_bytecode
pub fn load_bytecode(&mut self, bytes: &[u8]) -> Result<()>Parameters
| Name | Type | Description |
|---|---|---|
bytes | &[u8] |
Returns
Result<()>
Load a module from an in-memory `.ssb` byte stream.
sourcemethodload_bytecode_file¶source
ppvm_vihaco::prelude::PPVM::load_bytecode_file
pub fn load_bytecode_file(&mut self, path: &str) -> Result<()>Parameters
| Name | Type | Description |
|---|---|---|
path | &str |
Returns
Result<()>
Read a `.ssb` file and load the module it contains.
sourcemethodload_file¶source
ppvm_vihaco::prelude::PPVM::load_file
pub fn load_file(&mut self, path: &str) -> Result<()>Parameters
| Name | Type | Description |
|---|---|---|
path | &str |
Returns
Result<()>
Load from a file, auto-detecting the format: if it starts with the PPVM magic it is loaded as `.ssb` bytecode, otherwise it is parsed as `.sst` source text. A magic match commits to the bytecode path — a corrupt `.ssb` errors rather than silently falling back to the text parser.
sourcemethodload_generated_bytecode_sections¶source
ppvm_vihaco::prelude::PPVM::load_generated_bytecode_sections
Signature
pub fn load_generated_bytecode_sections<'__vihaco_bc, __VihacoContext>(&mut self, section: BytecodeSectionView<'__vihaco_bc, __VihacoContext>) -> Result<()>Parameters
| Name | Type | Description |
|---|---|---|
section | BytecodeSectionView<'__vihaco_bc, __VihacoContext> |
Returns
Result<()>
methodload_generated_sst_sections¶source
ppvm_vihaco::prelude::PPVM::load_generated_sst_sections
Signature
pub fn load_generated_sst_sections<'__vihaco_bc, __VihacoContext>(&mut self, section: SstSectionView<'__vihaco_bc, __VihacoContext>) -> Result<()>Parameters
| Name | Type | Description |
|---|---|---|
section | SstSectionView<'__vihaco_bc, __VihacoContext> |
Returns
Result<()>
methodload_program¶source
ppvm_vihaco::prelude::PPVM::load_program
pub fn load_program(&mut self, program: &str) -> Result<()>Parameters
| Name | Type | Description |
|---|---|---|
program | &str |
Returns
Result<()>
methodmeasurement_record¶source
ppvm_vihaco::prelude::PPVM::measurement_record
methodrun¶source
ppvm_vihaco::prelude::PPVM::run
methodrun_file¶source
ppvm_vihaco::prelude::PPVM::run_file
pub fn run_file(&mut self, path: &str) -> Result<()>Parameters
| Name | Type | Description |
|---|---|---|
path | &str |
Returns
Result<()>
methodrun_program¶source
ppvm_vihaco::prelude::PPVM::run_program
pub fn run_program(&mut self, program: &str) -> Result<()>Parameters
| Name | Type | Description |
|---|---|---|
program | &str |
Returns
Result<()>
methodrun_with_seed¶source
ppvm_vihaco::prelude::PPVM::run_with_seed
methodstate_string¶source
ppvm_vihaco::prelude::PPVM::state_string
pub fn state_string(&self) -> StringReturns
String
Render the current circuit state (tableau / Pauli sum) for the REPL’s `show` command. Delegates to the circuit’s size-specific tableau.
sourcemethodstdout¶source
ppvm_vihaco::prelude::PPVM::stdout
methodstep_once¶source
ppvm_vihaco::prelude::PPVM::step_once
methodtrace_record¶source
ppvm_vihaco::prelude::PPVM::trace_record
pub fn trace_record(&self) -> Vec<f64>Returns
Vec<f64>
Per-trace values collected by `Trace` instructions during the run. Parallel to PPVM::measurement_record: one f64 per `Trace` executed, in execution order.
sourcemethodwith_qubits¶source
ppvm_vihaco::prelude::PPVM::with_qubits
pub fn with_qubits(n_qubits: usize) -> Result<Self>Parameters
| Name | Type | Description |
|---|---|---|
n_qubits | usize |
Returns
Result<Self>
Build a fresh, initialized `n_qubits`-qubit device with no code. The REPL’s `device` command uses this to (re)create the machine. Errors if `n_qubits` is zero (a device must have at least one qubit).
sourceclassPPVMResolver¶source
ppvm_vihaco::prelude::PPVMResolver
Bases: Debug, Default
Rust struct.
classCircuit¶source
ppvm_vihaco::prelude::Circuit
Bases: HasInstructionSet, GeneratedComponent, Observe<CircuitEffect>, Reset, Default
Rust enum. Outer `Circuit` enum: backend selector. Picks one of the three inner enums based on `info.backend` at construction time; from there, every per-step call routes outer → inner → executor.
pub enum CircuitVariants
| Name | Type | Description |
|---|---|---|
Tableau | (TableauCircuit) | |
PauliSum | (PauliSumCircuit) | |
LossyPauliSum | (LossyPauliSumCircuit) |
methodlossy_paulisum¶source
ppvm_vihaco::prelude::Circuit::lossy_paulisum
Signature
pub fn lossy_paulisum(info: &PPVMDeviceInfo, terms: &[(String, f64)]) -> Result<Self>Parameters
| Name | Type | Description |
|---|---|---|
info | &PPVMDeviceInfo | |
terms | &[(String, f64)] |
Returns
Result<Self>
Build a LossyPauliSum-backed circuit. Same contract as Circuit::paulisum.
sourcemethodpaulisum¶source
ppvm_vihaco::prelude::Circuit::paulisum
Signature
pub fn paulisum(info: &PPVMDeviceInfo, terms: &[(String, f64)]) -> Result<Self>Parameters
| Name | Type | Description |
|---|---|---|
info | &PPVMDeviceInfo | |
terms | &[(String, f64)] |
Returns
Result<Self>
Build a PauliSum-backed circuit, seeding the state with every term in `terms`. Each `(word, coef)` is added via `state += (word, coef)`; the caller is responsible for having parsed/validated the words against `info.n_qubits` (see `parse_observable_terms` in `composite.rs`).
sourcemethodstate_string¶source
ppvm_vihaco::prelude::Circuit::state_string
pub fn state_string(&self) -> StringReturns
String
Render the current state. Used by the REPL’s `show` command.
sourcemethodtableau¶source
ppvm_vihaco::prelude::Circuit::tableau
pub fn tableau(info: &PPVMDeviceInfo) -> Result<Self>Parameters
| Name | Type | Description |
|---|---|---|
info | &PPVMDeviceInfo |
Returns
Result<Self>
Build a Tableau-backed circuit. Tableau init only needs `n_qubits` and `coefficient_threshold` from `info`; no observable required.
sourcemethodtableau_with_seed¶source
ppvm_vihaco::prelude::Circuit::tableau_with_seed
Signature
pub fn tableau_with_seed(info: &PPVMDeviceInfo, seed: u64) -> Result<Self>Parameters
| Name | Type | Description |
|---|---|---|
info | &PPVMDeviceInfo | |
seed | u64 |
Returns
Result<Self>
Same as Circuit::tableau, but seed the tableau RNG deterministically so a shot is reproducible.
sourceclassPPVMHeader¶source
ppvm_vihaco::prelude::PPVMHeader
Bases: Debug, Clone, StructuralPartialEq, PartialEq, Parse<'__vihaco_src>
Rust enum.
pub enum PPVMHeaderVariants
| Name | Type | Description |
|---|---|---|
NumQubits | (usize) | |
CoefficientThreshold | (f64) | |
Backend | (BackendKindSyntax) | |
Observable | (Ident) | |
MaxPauliWeight | (usize) |