qat.frontend.circuit_builder module

class CircuitBuilder(num_qubits, num_clbits=None)

Bases: object

The CircuitBuilder is used to construct high-level quantum programs.

It can be used to implement high-level operations such as quantum gates and measure operations.

Parameters:
  • num_qubits (int) – The number of qubits in the circuit.

  • num_clbits (Optional[int]) – The number of classical registers to save measurements too.

CNOT(control, target)
CPhase(control, target, theta=3.141592653589793)

Applies a phase rotation to a target qubit by angle theta, controlled by the state of another qubit.

CRx(control, target, theta=3.141592653589793)

Rotates the target qubit around the x-axis by angle theta, controlled by the state of another qubit.

CRy(control, target, theta=3.141592653589793)

Rotates the target qubit around the y-axis by angle theta, controlled by the state of another qubit.

CRz(control, target, theta=3.141592653589793)

Rotates the target qubit around the z-axis by angle theta, controlled by the state of another qubit.

CX(control, target)
ECR(qubit1, qubit2)
Hadamard(qubit)
Phase(qubit, theta=0.0)

Applies a phase gate to a qubit, which can be considered equivalent to an \(R_{z}(\theta)\) gate up to a global phase.

Rx(qubit, theta=3.141592653589793)

Rotates a qubit around the x-axis by angle theta.

Ry(qubit, theta=3.141592653589793)

Rotates a qubit around the y-axis by angle theta.

Rz(qubit, theta=3.141592653589793)

Rotates a qubit around the z-axis by angle theta.

S(qubit)
SWAP(qubit1, qubit2)
Sdg(qubit)
T(qubit)
Tdg(qubit)
U(qubit, theta=0.0, phi=0.0, lambd=0.0)

Apply a full rotation to a qubit around the Bloch sphere given three rotation angles.

X(qubit)

Adds an \(X\) gate.

Y(qubit)

Adds a \(Y\) gate.

Z(qubit)

Adds a \(Z\) gate.

add(gate)

Adds an operation to the circuit, validating the qubits indices are valid.

barrier(*qubits)

Adds a barrier between circuit operations to prevent optimisation over the barrier and sync qubits.

emit()

Exports the circuit as QatIR.

Currently just wraps the instructions in QatIR. Later the emitter could take on more responsibilities (e.g. some form of validation checks). It could prove benefitical to move this responsibility to a front end that wraps the builder as Qat IR complexity increases.

measure(qubit, clbit=None)

Measures a qubit and saves the result in the specified classical bit. If the classical bit isn’t given, it will be decided automatically.

reset(qubit)