qat.lang

This module provides a powerful API to create quantum circuits. Quantum circuits can be composed of quantum gates (including user defined gates), intermediate measurements, classically controlled gates, etc.

Programming tools

This module provide tools to create advanced quantum circuit. Designed quantum circuit is detailed in the user guide, section gate-based programming

qat.lang.Program

Program class, to create quantum circuit

qat.lang.qfunc()

qfunc decorator, to define a gate-based quantum function

qat.lang.qrout()

qrout decorator, to define a circuit using a function

Default gate set

myQLM provides a set of predefined gates, which can be used to create quantum circuits.

qat.lang.CCNOT

Definition of the Toffoli gate

qat.lang.CNOT

Definition of the Controlled NOT gate

qat.lang.CSIGN

Definition of the Controlled Z gate

qat.lang.H

Definition of the H gate

qat.lang.I

Definition of the I gate

qat.lang.ISWAP

Definition of the iSWAP gate

qat.lang.PH

Definition of the Phase shift gate

qat.lang.RX

Definition of the RX gate

qat.lang.RY

Definition of the RY gate

qat.lang.RZ

Definition of the RZ gate

qat.lang.S

Definition of the S gate

qat.lang.SQRTSWAP

Definition of the \(\sqrt{SWAP}\) gate

qat.lang.SWAP

Definition of the SWAP gate

qat.lang.T

Definition of the T gate

qat.lang.X

Definition of the X gate

qat.lang.Y

Definition of the Y gate

qat.lang.Z

Definition of the Z gate

Additionally, myQLM provides somes gates which can be used to directly build a Program.

qat.lang.RZ

RZ gate similar to the one in default gate set

qat.lang.vendors.PRX

R gate from AQT gate set (also known as PRX)

qat.lang.vendors.RXX

RXX gate from AQT gate set

qat.lang.CSIGN

CZ gate similar to the one in default gate set

qat.lang.I

I gate similar to the one in default gate set

qat.lang.RX

RX gate similar to the one in default gate set

qat.lang.RZ

RZ gate similar to the one in default gate set

qat.lang.X

X gate similar to the one in default gate set

qat.lang.vendors.ECR

ECR gate from IBM gate set

qat.lang.vendors.RZZ

RZZ gate from IBM gate set

qat.lang.vendors.SX

\(\sqrt{X}\) gate from IBM gate set

qat.lang.vendors.ZZ

ZZ gate from IBM gate set

qat.lang.vendors.GPi2

GPi2 gate (Gate Pi/2) from IonQ gate set

qat.lang.vendors.GPi

GPi gate (Gate Pi) from IonQ gate set

qat.lang.vendors.PMS

PMS (Phased Mølmer-Sørensen gate) gate from IonQ gate set

qat.lang.vendors.ZZ

ZZ gate from IonQ gate set

qat.lang.CSIGN

CZ gate similar to the one in default gate set

qat.lang.RZ

RZ gate similar to the one in default gate set

qat.lang.vendors.PRX

PRX gate from IQM gate set

qat.lang.RZ

RZ gate similar to the one in default gate set

qat.lang.vendors.K

K gate from Quobly gate set

qat.lang.vendors.ZZ

ZZ gate from Quobly gate set

Gate structures

All classes describing unitary operators inherit from the Gate class.

qat.lang.AbstractGate

User defined gate

qat.lang.build_gate()

Decorator creating a quantum gate

qat.lang.QRoutine

Subcircuit behaving as a gate object

qat.lang.AQASM.gates.Gate

Parent class for all quantum gates / unitary operators

qat.lang.AQASM.gates.ParamGate

Parametrized gate

Quantum types

Quantum boolean and expressions

qat.lang.AQASM.qbool.QBool

Quantum bool

qat.lang.AQASM.qbool.QBoolArray

Array of quantum bool

qat.lang.AQASM.qbool.QClause

Quantul clause

Quantum integers

qat.lang.AQASM.qint.QArithExp

Arithmetic expression

qat.lang.AQASM.qint.QCompExp

Comparison expression

qat.lang.AQASM.qint.QInt

Quantum integer

Managing registers

qat.lang.AQASM.bits.BoolFormula

Clasical formula

qat.lang.AQASM.bits.Cbit

Classical bit class

qat.lang.AQASM.bits.CRegister

Register of cbits

qat.lang.AQASM.bits.Qbit

Quantum bit class

qat.lang.AQASM.bits.QRegister

Register of qubits

Gate set management

qat.lang.AQASM.misc.generate_gate_set()

Gate set generator

External gate sets

myQLM provides some gate set builder, corresponding to the gate set of known QPUs:

qat.lang.vendors.aqt_gate_set()

Generate a gate set corresponding to AQT’s hardware

qat.lang.vendors.ibm_gate_set()

Generate a gate set corresponding to IBM’s hardware

qat.lang.vendors.ionq_gate_set()

Generate a gate set corresponding to IonQ’s hardware

qat.lang.vendors.iqm_gate_set()

Generate a gate set corresponding to IQM’s hardware

qat.lang.vendors.quobly_gate_set()

Generate a gate set corresponding to Quobly’s hardware

Linker and low level circuit manipulation

In pyAQASM, gates can be specified using various representations. They can be purely abstract (a name and a set of parameter values, such as RZ, [PI/2]). To this abstract syntax, one can attach a matrix, or even a subcircuit that implements this gate (this is the case of adders of the arithmetic library for instance).

Circuits are generated in two steps:

  • first a skeleton of the circuit is generated (for instance adders will be gates called ADD in this skeleton)

  • then a subcircuit is generated and attached to this abtract gate.

This second step is handled by a class called Linker. It can be useful in some settings to manipulate this Linker object in order to replace gates by subcircuits, or to generate matrices in order to simulate the circuit.

qat.lang.linking.Linker

pyAQASM linker

Quantum labraries and basic algorithms

This module provides a set of routine to simplify the implementation of quantum circuits

Arithmetic routines

pyAQASM comes with a pre-implemented set of arithmetic routines. Since there are different approaches to implement arithmetic routines, we provide various implementation of some low-level routines such as additions and additions by a classical constant. Higher level routines are then implemented by calling some implementation of these lower level routines.

The following diagram sums up the various routines and their implementation. Arrows mean “uses”, green boxes indicates the implementation strategy:

  • QFT means QFT-based arithmetic

  • CARRY means ripple-carry based arithmetic

  • INDEP means agnostic. These routines call lower level routines, indepentently from their implementation.

../../images/arithmetic.png

The routines are separated into three distinct namespaces according to these three types of implementation strategy: QFT, CARRY, INDEP.

Warning

All methods are decorated using @build_gate which turn them into AbstractGates. To access the underlying routine instead of the wrapping gates, the method name can be prefixed with ‘~’.

# will generate a call to an AbstractGate having the QFT as circuit
# implementation
QFT(3)

# will generate a QRoutine object
(~QFT)(3)

The two behaviors are comparable, except that using the U notation allows to skip the inlining step when extracting the circuit (.to_circ method with inline=False) and to link another implementation of gate U later on. Using (~U) will effectively inline the gate no matter what

State preparatation and QRAM

qat.lang.models.KPTree

A class representing a Kerinidis-Prakash tree for a QRAM

Algorithms

There are a few basic algorithms present in the qat.lang.algorithms module:

qat.lang.algorithms.amplification_step()

Single amplification step of Grover’s algorithm

qat.lang.algorithms.phase_estimation()

Phase estimation routine

qat.lang.algorithms.quantum_counting()

Performs a quantum counting on some oracle

Additionally, the submodule qat.lang.algorithms.amplification contains some functions that might be useful:

qat.lang.algorithms.amplification.grover_diffusion()

Grover diffusion

qat.lang.algorithms.amplification.householder()

Performs a Householder for any unitary

qat.lang.algorithms.amplification.uniform_distribution()

Prepare a uniform distribution from state \(|0...0\rangle\)