Simulation

Simulation modalities available are specified in Table 1. Users must specify a simulator for their Guppy program execution, otherwise the Quest simulator will be used by default.

Quest and Stim enable statevector and stabilizer simulation. Coinflip and Classical Replay further enable debugging for Guppy programs.

A 4-qubit GHZ state-preparation is compiled to hugr and used to demonstrate Selene’s simulation capabilities.

Statevector

Statevector simulation is enabled by the Quantum Exact Simulation Toolkit (Quest) plugin. QuEST utilizes multithreading, GPU acceleration and distribution.

The method selene_sim.build.build requires a HUGR object and a name (string) as input and returns a selene_sim.instance.SeleneInstance. The build method internally compiles HUGR into a binary executable.

The statevector simulation is initiated by calling selene_sim.instance.SeleneInstance.run_shots to run \(N\) shots. Alternatively, selene_sim.instance.SeleneInstance.run runs 1 shot. A selene_sim.Quest instance and a kwarg specifying the number of simulation qubits, n_qubits, are required as input to run_shots (run).

run_shots (run) returns a list of results.

Stabilizer

Selene uses Stim to perform stabilizer simulations. A requirement for Stim usage is a Guppy program using Clifford operations exclusively. A user-customizable parameter specifies a numerical threshold to constrain and invalidate illegal gate angle values. The primary benefit is to avoid numerical instability, or to inject approximations.

Coinflip

Classical Replay

The classical replay simulator (selene_sim.ClassicalReplayPlugin) enables debugging of guppy programs. An optional kwarg, measurements, allows users to inject predetermined measurement results, at a per-shot level, to inspect and debug arbitrary conditional branching within a program. There is no quantum simulation with classical replay. The program specified below performs additional quantum operations controlled by an MCMR operation.

There are three main use cases for selene_sim.ClassicalReplayPlugin:

  1. To debug the classical user program without running the quantum simulator.

  2. To perform tests of user code with predetermined results

  3. To validate control flow by ensuring that a set of measurements have been made within a complete shot. E.g. consider a user program that halts on the first measurement result of \(|1\rangle\). This simulator will raise an error if the supplied measurements do not contain a \(|1\rangle\) result, or contain results following a \(|1\rangle\) result.

The code-cell below uses verifies the additive block is conditioned upon a successful True measurement.