Skip to main content

LiveExecution

Trait LiveExecution 

Source
pub trait LiveExecution {
    // Required methods
    fn compute_gate(&mut self, gate: &GateInstruction) -> Result<(), KetError>;
    fn compute_native_gates(
        &mut self,
        gates: &[NativeGate],
    ) -> Result<(), KetError>;
    fn measure(&mut self, qubits: &[usize]) -> Result<u64, KetError>;
    fn dump(&mut self, qubits: &[usize]) -> Result<DumpData, KetError>;
    fn sample(
        &mut self,
        qubits: &[usize],
        shots: usize,
    ) -> Result<SampleData, KetError>;
    fn exp_value(&mut self, hamiltonian: Hamiltonian) -> Result<f64, KetError>;
}
Expand description

A backend that executes gates as they arrive and can return mid-circuit measurement results immediately.

Required Methods§

Source

fn compute_gate(&mut self, gate: &GateInstruction) -> Result<(), KetError>

Dispatches a single logical gate instruction to the backend.

§Errors

Implementations may return a KetError if gate dispatch fails.

Source

fn compute_native_gates(&mut self, gates: &[NativeGate]) -> Result<(), KetError>

Dispatches a sequence of already-translated native gate instructions to the backend.

Called by the live-execution path when a NativeGateSet translation layer is configured. The gates slice contains hardware-specific instructions produced by NativeGateSet::translate or NativeGateSet::cnot.

§Errors

Implementations may return a KetError if native gate dispatch fails.

Source

fn measure(&mut self, qubits: &[usize]) -> Result<u64, KetError>

Collapses and reads out the specified qubits, returning the result as a packed integer (bit i corresponds to qubits[i]).

§Errors

Returns a KetError if measurement fails on the backend.

Source

fn dump(&mut self, qubits: &[usize]) -> Result<DumpData, KetError>

Returns a full state-vector snapshot restricted to qubits.

§Errors

Returns a KetError if state dumping fails on the backend.

Source

fn sample( &mut self, qubits: &[usize], shots: usize, ) -> Result<SampleData, KetError>

Samples the measurement distribution of qubits over shots repetitions.

§Errors

Returns a KetError if sampling fails on the backend.

Source

fn exp_value(&mut self, hamiltonian: Hamiltonian) -> Result<f64, KetError>

Computes the expectation value of hamiltonian with respect to the current quantum state.

§Errors

Returns a KetError if expectation value estimation fails on the backend.

Trait Implementations§

Source§

impl Debug for dyn LiveExecution

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§