ppvm_vihaco::composite
composite¶
ppvm_vihaco::composite
classPPVM¶source
ppvm_vihaco::composite::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::composite::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::composite::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::composite::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::composite::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::composite::PPVM::init
methodinit_with_seed¶source
ppvm_vihaco::composite::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::composite::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::composite::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::composite::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::composite::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::composite::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::composite::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::composite::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::composite::PPVM::measurement_record
methodrun¶source
ppvm_vihaco::composite::PPVM::run
methodrun_file¶source
ppvm_vihaco::composite::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::composite::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::composite::PPVM::run_with_seed
methodstate_string¶source
ppvm_vihaco::composite::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::composite::PPVM::stdout
methodstep_once¶source
ppvm_vihaco::composite::PPVM::step_once
methodtrace_record¶source
ppvm_vihaco::composite::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::composite::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).
sourceclassPPVMEffect¶source
ppvm_vihaco::composite::PPVMEffect
Bases: Debug, Clone, From<StdoutEffect>, From<MeasurementEffect>, From<TraceEffect>, From<CircuitOutcomeEffect>
Rust enum.
pub enum PPVMEffectVariants
| Name | Type | Description |
|---|---|---|
Step | (StepOutcome) | |
Stdout | (StdoutEffect) | |
Circuit | (Box<CircuitEffect>) | |
Measurement | (MeasurementEffect) | |
Trace | (TraceEffect) |
classPPVMInstruction¶source
ppvm_vihaco::composite::PPVMInstruction
Rust type alias.
pub type PPVMInstruction = Instruction