Circuit Construction#

The circuit construction module allows the user to implement low level functions to integrate them in routines of higher complexity. For classical languages, this is a common feature of many compilers. Since QuantumSession is an inheritor of QuantumCircuit, it also exposes an append method, implying that once a QuantumCircuit is created it can be smoothly integrated into Qrisps high-level infrastructure using the to_gate method:

from qrisp import QuantumCircuit
from third_party_qiskit_module import some_quantum_function_qc

def some_quantum_function(qv, parameters):
   qc = QuantumCircuit.from_qiskit(some_quantum_function_qc(parameters))
   qv.qs.append(qc.to_gate(), qv)

This snippet demonstrates how a Qiskit quantum circuit generated by a third party module can be turned into a Qrisp function of a QuantumVariable.

There are 5 important classes here:

  • The QuantumCircuit class, which describes quantum circuits in a very similar way as Qiskit (ie. it contains a list of qubit objects, a list of classical bit objects and a list of instructions)

  • The Operation class, which corresponds to the gate object from Qiskit. This class describes arbitrary gates and measurements.

  • The Instruction class, which combines Operation objects and the qubit/classical bits it operates on.

  • The Qubit class, which represents qubits.

  • The Clbit class, which represents classical bits.

Note

In order to allow an easy transition, this module’s architecture and naming is close to Qiskit.