qat.qpus.CLinalg

For a general description of linear-algebra-based simulators, please refer to the PyLinalg documentation page.

High-level Quantum Processing Unit

class qat.qpus.CLinalg(use_nbthreads_heuristic: bool = True, precision: int = 2, sparse: bool = False, light_circuit: bool = False, tqdm: bool = False, readonly_statevector: bool = False, seed: int = None)

CLinalg simulator

Parameters
  • use_nbthreads_heuristic (bool) – use heuristic for choosing the number of threads setting this parameter to False will result in using OMP_NUM_THREADS Default: True

  • precision (int) – precision used for the simulation, either 1(single) or 2(double) Default: 2

  • sparse (bool) – whether or not to return a sparse result Default: False

  • light_circuit (bool) – option still in development Default: False

  • tqdm (bool) – use tqdm to display progress in simulating the circuit Default: False

  • readonly_statevector (bool) – the statevector included in the result is returned directly in memory from the C++ array. This statevector will then be in convention lsb first. This option only makes sense for perfect sampling where all qubits are measured. Default: False

  • seed (int) – seed of the random number generator Default: None (will use a random seed)

submit(batch: Batch, meta_data: Optional[dict] = None) BatchResult

Executes a batch of jobs and returns the corresponding list of Results.

Parameters

batch (Batch) – a batch of jobs. If a single job is provided, the job is embedded into a Batch, executed, and the first result is returned.

Returns

a batch result

Return type

(BatchResult)

This high-level class wrapping the simulator follows the convention of the qat.qpus.QPUHandler structure.

C++ Low-level Statevector

Though not the standard or recommended way of using qat.qpus.CLinalg, the C++ statevector object underneath this QPU can be accessed throught the statevector parameter, for instance:

from qat.clinalg import CLinalg
qpu = CLinalg()
# change number of qubits to 2
qpu.statevector.resize(2)
# reset the state to |00> and print the state
qpu.statevector.reset()
qpu.statevector.print()
0: (1,0)
1: (0,0)
2: (0,0)
3: (0,0)

Warning

Do consider that the bit convention used in this lower-level statevector is reversed compared to the more intuitive one supported by the QPU interface. Intuitively, you will consider a state \(|i_0i_1i_2i_3\rangle\) (with qubit 0 being the most significant bit); however the ordering used by the low-level statevector instance \(|i_3i_2i_1i_0\rangle\) (with qubit 0 being the least significant bit). This influences the statevector methods print, reset (if a value is provided) and the way in which the statevector is interacted with through the array property.

Pybind interface