Skip to content

ppvm_vihaco::composite

composite

ppvm_vihaco::composite

classPPVMsource

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 PPVM
source

methodapply_circuit_instructionsource

ppvm_vihaco::composite::PPVM::apply_circuit_instruction

Signature
pub fn apply_circuit_instruction(&mut self, inst: CircuitInstruction, qubits: &[usize], params: &[f64]) -> Result<()>

Parameters

NameTypeDescription
instCircuitInstruction
qubits&amp;[usize]
params&amp;[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.

source

methodcurrent_instructionsource

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.

source

methodcurrent_pcsource

ppvm_vihaco::composite::PPVM::current_pc

pub fn current_pc(&self) -> u32

Returns

u32

Program counter: the index of the next instruction to execute.

source

methodexecute_single_instructionsource

ppvm_vihaco::composite::PPVM::execute_single_instruction

Signature
pub fn execute_single_instruction(&mut self, instrs: &[PPVMInstruction]) -> Result<()>

Parameters

NameTypeDescription
instrs&amp;[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.

source

methodinitsource

ppvm_vihaco::composite::PPVM::init

pub fn init(&mut self) -> Result<()>

Returns

Result<()>

source

methodinit_with_seedsource

ppvm_vihaco::composite::PPVM::init_with_seed

pub fn init_with_seed(&mut self, seed: u64) -> Result<()>

Parameters

NameTypeDescription
seedu64

Returns

Result<()>

Like PPVM::init, but seed the circuit RNG deterministically so the run is reproducible.

source

methodloadsource

ppvm_vihaco::composite::PPVM::load

Signature
pub fn load(&mut self, module: &LocalModule<PPVMInstruction, Value, Type, PPVMDeviceInfo>) -> Result<()>

Parameters

NameTypeDescription
module&amp;LocalModule&lt;PPVMInstruction, Value, Type, PPVMDeviceInfo&gt;

Returns

Result<()>

source

methodload_bytecodesource

ppvm_vihaco::composite::PPVM::load_bytecode

pub fn load_bytecode(&mut self, bytes: &[u8]) -> Result<()>

Parameters

NameTypeDescription
bytes&amp;[u8]

Returns

Result<()>

Load a module from an in-memory `.ssb` byte stream.

source

methodload_bytecode_filesource

ppvm_vihaco::composite::PPVM::load_bytecode_file

pub fn load_bytecode_file(&mut self, path: &str) -> Result<()>

Parameters

NameTypeDescription
path&amp;str

Returns

Result<()>

Read a `.ssb` file and load the module it contains.

source

methodload_filesource

ppvm_vihaco::composite::PPVM::load_file

pub fn load_file(&mut self, path: &str) -> Result<()>

Parameters

NameTypeDescription
path&amp;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.

source

methodload_generated_bytecode_sectionssource

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

NameTypeDescription
sectionBytecodeSectionView&lt;'__vihaco_bc, __VihacoContext&gt;

Returns

Result<()>

source

methodload_generated_sst_sectionssource

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

NameTypeDescription
sectionSstSectionView&lt;'__vihaco_bc, __VihacoContext&gt;

Returns

Result<()>

source

methodload_programsource

ppvm_vihaco::composite::PPVM::load_program

pub fn load_program(&mut self, program: &str) -> Result<()>

Parameters

NameTypeDescription
program&amp;str

Returns

Result<()>

source

methodmeasurement_recordsource

ppvm_vihaco::composite::PPVM::measurement_record

pub fn measurement_record(&self) -> Vec<MeasurementResult>

Returns

Vec<MeasurementResult>

source

methodrunsource

ppvm_vihaco::composite::PPVM::run

pub fn run(&mut self) -> Result<StepOutcome>

Returns

Result<StepOutcome>

source

methodrun_filesource

ppvm_vihaco::composite::PPVM::run_file

pub fn run_file(&mut self, path: &str) -> Result<()>

Parameters

NameTypeDescription
path&amp;str

Returns

Result<()>

source

methodrun_programsource

ppvm_vihaco::composite::PPVM::run_program

pub fn run_program(&mut self, program: &str) -> Result<()>

Parameters

NameTypeDescription
program&amp;str

Returns

Result<()>

source

methodrun_with_seedsource

ppvm_vihaco::composite::PPVM::run_with_seed

Signature
pub fn run_with_seed(&mut self, seed: Option<u64>) -> Result<StepOutcome>

Parameters

NameTypeDescription
seedOption&lt;u64&gt;

Returns

Result<StepOutcome>

Like PPVM::run, but seed the circuit RNG deterministically when `seed` is `Some`, making the run reproducible.

source

methodstate_stringsource

ppvm_vihaco::composite::PPVM::state_string

pub fn state_string(&self) -> String

Returns

String

Render the current circuit state (tableau / Pauli sum) for the REPL’s `show` command. Delegates to the circuit’s size-specific tableau.

source

methodstdoutsource

ppvm_vihaco::composite::PPVM::stdout

pub fn stdout(&self) -> &[u8]

Returns

&[u8]

source

methodstep_oncesource

ppvm_vihaco::composite::PPVM::step_once

pub fn step_once(&mut self) -> Result<StepOutcome>

Returns

Result<StepOutcome>

source

methodtrace_recordsource

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.

source

methodwith_qubitssource

ppvm_vihaco::composite::PPVM::with_qubits

pub fn with_qubits(n_qubits: usize) -> Result<Self>

Parameters

NameTypeDescription
n_qubitsusize

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).

source

classPPVMEffectsource

ppvm_vihaco::composite::PPVMEffect

Bases: Debug, Clone, From&lt;StdoutEffect&gt;, From&lt;MeasurementEffect&gt;, From&lt;TraceEffect&gt;, From&lt;CircuitOutcomeEffect&gt;

Rust enum.

pub enum PPVMEffect

Variants

NameTypeDescription
Step(StepOutcome)
Stdout(StdoutEffect)
Circuit(Box&lt;CircuitEffect&gt;)
Measurement(MeasurementEffect)
Trace(TraceEffect)
source

classPPVMInstructionsource

ppvm_vihaco::composite::PPVMInstruction

Rust type alias.

pub type PPVMInstruction = Instruction
source