Qibo tools¶
Tools connecting mpstab and qibo, in both directions.
Provided backends¶
What mpstab gives qibo: mpstab as a qibo backend, see MPSTAB as a Qibo Backend Provider.
The qibo backend that evaluates expectation values through an HSMPO.
- class mpstab.qibo_tools.provided_backends.mpstab_backend.MPStabBackend(stab_engine: StabilizersEngine = None, tn_engine: TensorNetworkEngine = None)[source]¶
Qibo backend backed by the hybrid stabilizer-MPO surrogate.
- exp_value_observable_symbolic(circuit, operators_list, sites_list, coeffs_list, nqubits)[source]¶
Expectation value of a symbolic Hamiltonian on
circuit, via an HSMPO.- Parameters:
circuit – the qibo circuit to evaluate.
operators_list – Pauli labels per term, e.g.
["XYZ", "XYZ"].sites_list – the qubits each term’s operators act on, e.g.
[(1, 2, 3), (1, 2, 3)]. Within a term they must be distinct.coeffs_list – one coefficient per term.
nqubits – circuit width.
- Returns:
The expectation value of the Hamiltonian.
- class mpstab.qibo_tools.provided_backends.mpstab_backend.MetaBackend[source]¶
Backend loader qibo calls to obtain an mpstab backend.
- static load(backend_name: str = 'mpstab', **kwargs)[source]¶
Build an
MPStabBackend.- Parameters:
backend_name – must be
"mpstab".stab_engine – stabilizers engine,
StimEngineby default.tn_engine – tensor-network engine,
QuimbEngineby default.
- Raises:
ValueError – if
backend_nameis anything else.
Utilized backends¶
What mpstab gets from qibo: its simulators, running the circuits of a measurement plan in place of a device. On a device, run the plan’s circuits there instead.
StatevectorExactSimulator, a backend running measurement-plan circuits
with qibo’s exact statevector simulator, as
run_plan() expects:
execute_circuits(circuits, nshots) returning one frequency dict per circuit.
- class mpstab.qibo_tools.utilized_backends.statevector_exact_simulator.StatevectorExactSimulator[source]¶
Runs circuits with qibo’s exact statevector simulator. The default backend.
Measurement plans run one state preparation under many measurement bases, so circuits are grouped by their preparation, everything before the basis rotations of their final
gates.M: each preparation is simulated once, and each circuit then only rotates that state into its own basis and samples it. Every circuit still gets its ownnshotsindependent samples, so the results are distributed exactly as if every circuit had been run separately. Circuits of any other shape (density matrices, noise channels, several or mid-circuit measurements) are simulated as they are, identical ones once.
A noisy stand-in for a device, to validate error mitigation on a plan.
- class mpstab.qibo_tools.utilized_backends.density_matrix_noise_simulator.DensityMatrixNoiseSimulator(noise, seed: int | None = None)[source]¶
Runs plan circuits under a
NoiseModel, on a qibo density matrix.Each circuit’s preparation and basis rotations are run as one noisy circuit (
apply()), so the basis rotations of the measurement layer are as noisy as any other gate. Readout errors then flip the sampled bits. Density matrices limit it to small circuits, about ten qubits: it is a reference for testing, not a simulator for production runs.- Parameters:
noise – the noise model.
seed – seed of the sampled shots and readout flips.