cunqa.circuit.circuit

Holds CUNQA’s custom circuit class and functions to translate its instructions into other formats for circuit definition.

Building circuits

Users can define a circuit using CunqaCircuit to then send it to the virtual QPUs. Nevertheless, for the case in which no communications are needed among the circuits sent, qiskit.QuantumCircuit [1] is also allowed. Be aware that some instructions might not be supported for CunqaCircuit, for the list of supported instructions check its documentation. Module py:mod:cunqa.converters contains functions to transform between circuit formats.

Circuits by json dict format

A low level way of representing a circuit is by a json dict with specefic fields that gather the information needed by the simulator in order to run the circuit.

This structe is presented below:

{"id":str, # circuit identificator
 "is_parametric":bool, # weather if the circuit has parametric instructions that can be updated
 "is_dynamic":bool, # weather if the circuit has intermediate measurements or conditioned operations
 "instructions":list[dict], # list of instructions of the circuit in dict format
 "num_qubits":int, # number of qubits of the circuit
 "num_clbits":int, # number of classical bits of the circuit
 "quantum_registers":dict, # dict specifying the grouping of the qubits in registers
 "classical_registers":dict # dict specifying the grouping of the classical bits in registers
 }

On the other hand, instructions have some mandatory and optional keys:

{"name":str, # MANDATORY, name of the instruction, has to be accepted by the simulator
 "qubits":list[int], # MANDATORY, qubits on which the instruction acts
 "params":list[int|float] | list[list[[int|float]]], # OPTIONAL, only required for parametric gates and for 'unitary' instruction.
 "clbits":list[int], # OPTINAL, any classical bits used in the instruction
}

For classical and quantum communications among circuits, we do not recomend working at such low level format, users rather describe this operations through the CunqaCircuit class. If curious, you can always create the CunqaCircuit and obtain its intructions by its attribute instructions, or you can convert it to the json dict format by the convert() function.

References:

Classes

ControlContext

Class to manage the controlled telegate operations from a circuit/virtual QPU to another.

CunqaCircuit

Class to define a quantum circuit for the cunqa api.

InstanceTrackerMeta

Metaclass to track instances of CunqaCircuits and extract the connections between them.

Exceptions

CunqaCircuitError

Exception for error during circuit desing at CunqaCircuit.