cunqa.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, other formats are allowed.
This module also provides global functions that translate form qiskit.QuantumCircuit
[1] to a instructions json (qc_to_json()
) and the other way around (from_json_to_qc()
).
For example, if a user wants to transform a qiskit.QuantumCircuit
into a CunqaCircuit
, one can obtain the instructions and then add them to the CunqaCircuit
object:
>>> qc = QuantumCircuit(4)
>>> ...
>>> circuit_json = qc_to_json(qc)
>>> instruction_set = circuit_json["instructions"]
>>> num_qubits = circuit_json["num_qubits"]
>>> cunqacirc = CunqaCircuit(num_qubits)
>>> cunqacirc.from_instructions(instruction_set)
Be aware that some instructions might not be supported for CunqaCircuit
, for the list of supported instructions check its documentation.
Circuits by json dict
format
A low level way of representing a circuit is by a json dict
with specefic fields that geather the information
needed by the simulator in order to run the circuit.
This structe is presented below:
On the other hand, instructions have some mandatory and optional keys:
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 Circuit
and obtain its intructions by its attribute instructions
,
or you can convert it to the json dict format by the convert()
function.
References:
Classes
Class to define a quantum circuit for the |
Exceptions
Exception for error during circuit desing at |