cunqa.circuit

This module defines CunqaCircuit. Many circuit design models already exist, the best-known being Qiskit’s QuantumCircuit. The motivation behind the design of CunqaCircuit does not stem from identifying problems in existing models, but from the lack of communication directives, which are so vital in CUNQA as a DQC platform. In this way, CunqaCircuit class allows users to describe quantum circuits that include not only local quantum operations, but also classical and quantum communication directives between distributed circuits. A CunqaCircuit can, therefore, represent both computation and communication in DQC scenarios.

class CunqaCircuit(num_qubits, num_clbits=None, id=None)

Quantum circuit abstraction for the CUNQA API. This class allows the design of quantum circuits to be executed in the vQPUs. Upon initialization, the circuit is defined by its number of qubits and, optionally, its number of classical bits and a user-defined identifier. If no identifier is provided, a unique one is generated automatically. The circuit identifier is later used to reference the circuit in communication-related instructions.

Once created, instructions can be appended to the circuit using the provided methods, including single- and multi-qubit gates, measurements, classically controlled operations, and remote communication primitives.

Supported operations

Group

Category

Operations

Unitary operations

Single-qubit gates with no parameters

id, x, y, z, h, s, sdg, sx, sxdg, sy, sydg, sz, szdg, t, tdg, p0, p1, v, vdg, k

Single-qubit gates with one parameter

u1, p, rx, ry, rz, rotinvx, rotinvy, rotinvz

Single-qubit gates with two parameters

u2, r

Single-qubit gates with three parameters

u3

Single-qubit gates with four parameters

u

Two-qubit gates with no parameters

swap, iswap, fusedswap, cx, cy, cz, ch, csx, csxdg, csy, csz, cs, csdg, ecr, ct, dcx

Two-qubit gates with one parameter

cu1, cp, crx, cry, crz, rxx, ryy, rzz, rzx

Two-qubit gates with two parameters

cu2, cr, xxmyy, xxpyy

Two-qubit gates with three parameters

cu3

Two-qubit gates with four parameters

cu

Three-qubit gates with no parameters

ccx, ccy, ccz, cswap, cecr

Multicontrol gates with no parameters

mcx, mcy, mcz, mcsx

Multicontrol gates with one parameter

mcu1, mcp, mcphase, mcrx, mcry, mcrz

Multicontrol gates with two parameters

mcu2, mcr

Multicontrol gates with three parameters

mcu3

Multicontrol gates with four parameters

mcu

Special gates

unitary, randomunitary, diagonal, multiplexer, multipauli, multipaulirotation, sparsematrix, amplitudedampingnoise, bitflipnoise, dephasingnoise, depolarizingnoise, independentxznoise, twoqubitdepolarizingnoise

Local non-unitary operations

Local non-unitary operations

cif, measure, measure_all, reset

Remote operations

Classical communication

send, recv

Quantum communication

qsend, qrecv, expose

Attributes

id : str

Returns circuit id.

info : dict

Information of the instance attributes, given in a dictionary.

num_qubits : int

Number of qubits of the circuit.

num_clbits : int

Number of classical bits of the circuit.

instructions: list[dict]

Set of operations applied to the circuit.

is_dynamic: bool

Whether the circuit has local non-unitary operations.

quantum_regs: dict

Dictionary of quantum registers as {"name": [assigned qubits]}.

classical_regs: dict

Dictionary of classical registers of the circuit as {"name": [assigned clbits]}.

sending_to: set[str]

Set of circuit ids to which the current circuit is sending measurement outcomes or qubits.

Operations

Classical communication directives

Classical communication directives
send(clbits, recving_circuit)

Class method to send a bit (previously measured from a qubit) from the current circuit to a remote one.

Parameters:
  • clbits (int) – bits to be sent.

  • recving_circuit (str | CunqaCircuit) – id of the circuit or circuit object to which the bit is sent.

Return type:

None

recv(clbits, sending_circuit)

Class method to receive a bit (previously measured from a qubit) from a remote circuit into a classical register of the receiving circuit.

Parameters:
  • clbits (int | list[int]) – indexes of the cl registers where the bits will be stored.

  • sending_circuit (str | CunqaCircuit) – id of the circuit or circuit object from which the bit is sent.

Return type:

None

Quantum communication directives

Quantum communication directives
qsend(qubit, recving_circuit)

Class method to send a qubit from the current circuit to another one.

Parameters:
  • qubit (int) – qubit to be sent.

  • recving_circuit (str | CunqaCircuit) – id of the circuit or circuit to which the qubit is sent.

Return type:

None

qrecv(qubit, control_circuit)

Class method to receive a qubit from a remote circuit into an ancilla qubit.

Parameters:
  • qubit (int) – ancilla to which the received qubit is assigned.

  • control_circuit (str | CunqaCircuit) – id of the circuit from which the qubit is received.

Return type:

None

expose(qubit, target_circuit)

Class method to expose a qubit from the current circuit to another one for a telegate operation. The exposed qubit will be used at the target circuit as the control qubit in controlled operations.

Parameters:
  • qubit (int) – qubit to be exposed.

  • target_circuit (str | CunqaCircuit) – id of the circuit or circuit object where the exposed qubit is used.

Returns:

A QuantumControlContext object to manage remotly controlled operations in the given circuit.

Return type:

QuantumControlContext

Usage example:

with origin_circ.expose(0, target_circuit) as rqubit, subcircuit:
    subcircuit.cx(rqubit, 1)

Non-unitary operations

Non-unitary operations
measure_all()

Class to apply a global measurement of all of the qubits of the circuit. An additional classcial register will be added and labeled as “measure”.

Return type:

None

measure(qubits, clbits)

Class method to add a measurement of a qubit or a list of qubits and to register that measurement in the given classical bits.

Parameters:
  • qubits (int | list[int]) – qubits to measure.

  • clbits (int | list[int]) – clasical bits where the measurement will be registered.

Return type:

None

reset(qubit)

Class method to add reset to zero instruction to a qubit or list of qubits (use after measure).

Parameters:

qubit (int, list[int]]) – qubits to which the reset operation is applied.

cif(clbits)

Method for implementing a gate conditioned to a classical measurement. The control qubit provided is measured, if it’s 1 the gate provided is applied to the given qubits. In order to do this, cif context manager is introduced, which enables a more expressive and readable way to define classically controlled blocks:

c = CunqaCircuit(2, 2)
c.h(0)
c.measure(0, 0)

with c.cif(0) as cgates:
    cgates.x(1)

In this example, the operations defined inside the cif block are executed only if the value of classical bit 0 is equal to 1. Currently, this construct does not support an explicit else branch. This design decision is based on the observation that none of the reviewed algorithms or protocols require such functionality. Support for an else branch may be added in future versions if needed.

Parameters:

clbits (int | list[int]) – clbits employed as the condition.

Return type:

ClassicalControlContext

Unitary operations

Single-qubit gates
i(qubit)

Class method to apply id gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

x(qubit)

Class method to apply x gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

y(qubit)

Class method to apply y gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

z(qubit)

Class method to apply z gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

h(qubit)

Class method to apply h gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

s(qubit)

Class method to apply s gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

sdg(qubit)

Class method to apply sdg gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

sx(qubit)

Class method to apply sx gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

sxdg(qubit)

Class method to apply sxdg gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

sy(qubit)

Class method to apply sy gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

sydg(qubit)

Class method to apply sydg gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

sz(qubit)

Class method to apply sz gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

szdg(qubit)

Class method to apply szdg gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

t(qubit)

Class method to apply t gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

tdg(qubit)

Class method to apply tdg gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

p0(qubit)

Class method to apply P0 gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

p1(qubit)

Class method to apply P1 gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

v(qubit)

Class method to apply v gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

vdg(qubit)

Class method to apply vdg gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

k(qubit)

Class method to apply k gate to the given qubit.

Parameters:

qubit (int) – qubit in which the gate is applied.

Return type:

None

u1(param, qubit)

Class method to apply u1 gate to the given qubit.

Parameters:
  • param (float | int | str) – parameter for the parametric gate.

  • qubit (int) – qubit in which the gate is applied.

Return type:

None

u2(theta, phi, qubit)

Class method to apply u2 gate to the given qubit.

Parameters:
  • theta (float | int | str) – angle.

  • phi (float | int | str) – angle.

  • qubit (int) – qubit in which the gate is applied.

Return type:

None

u3(theta, phi, lam, qubit)

Class method to apply u3 gate to the given qubit.

Parameters:
  • theta (float | int) – angle.

  • phi (float | int) – angle.

  • lam (float | int) – angle.

  • qubit (int) – qubit in which the gate is applied.

Return type:

None

u(theta, phi, lam, qubit)

Class method to apply u gate to the given qubit.

Parameters:
  • theta (float | int) – angle.

  • phi (float | int) – angle.

  • lam (float | int) – angle.

  • qubit (int) – qubit in which the gate is applied.

Return type:

None

p(param, qubit)

Class method to apply p gate to the given qubit.

Parameters:
  • param (float | int | str) – parameter for the parametric gate.

  • qubit (int) – qubit in which the gate is applied.

Return type:

None

r(theta, phi, qubit)

Class method to apply r gate to the given qubit.

Parameters:
  • theta (float | int) – angle.

  • phi (float | int) – angle.

  • qubit (int) – qubit in which the gate is applied.

Return type:

None

rx(param, qubit)

Class method to apply rx gate to the given qubit.

Parameters:
  • param (float | int | str) – parameter for the parametric gate.

  • qubit (int) – qubit in which the gate is applied.

Return type:

None

ry(param, qubit)

Class method to apply ry gate to the given qubit.

Parameters:
  • param (float | int | str) – parameter for the parametric gate.

  • qubit (int) – qubit in which the gate is applied.

Return type:

None

rz(param, qubit)

Class method to apply rz gate to the given qubit.

Parameters:
  • param (float | int | str) – parameter for the parametric gate.

  • qubit (int) – qubit in which the gate is applied.

Return type:

None

rotinvx(param, qubit)

Class method to apply rotinvx gate to the given qubit.

Parameters:
  • param (float | int | str) – parameter for the parametric gate.

  • qubit (int) – qubit in which the gate is applied.

Return type:

None

rotinvy(param, qubit)

Class method to apply rotinvy gate to the given qubit.

Parameters:
  • param (float | int | str) – parameter for the parametric gate.

  • qubit (int) – qubit in which the gate is applied.

Return type:

None

rotinvz(param, qubit)

Class method to apply rotinvz gate to the given qubit.

Parameters:
  • param (float | int | str) – parameter for the parametric gate.

  • qubit (int) – qubit in which the gate is applied.

Return type:

None

Two-qubit gates
swap(*qubits)

Class method to apply swap gate to the given qubits.

Parameters:

qubits (list[int]) – qubits in which the gate is applied.

Return type:

None

iswap(*qubits)

Class method to apply iswap gate to the given qubits.

Parameters:

qubits (list[int]) – qubits in which the gate is applied.

Return type:

None

fusedswap(*qubits)

Class method to apply fusedswap gate to the given qubits.

Parameters:

qubits (list[int]) – qubits in which the gate is applied.

Return type:

None

ecr(*qubits)

Class method to apply ecr gate to the given qubits.

Parameters:

qubits (int) – qubits in which the gate is applied.

Return type:

None

cx(*qubits)

Class method to apply cx gate to the given qubits.

Parameters:

qubits (int) – qubits in which the gate is applied, first one will be control qubit and second one target qubit.

Return type:

None

cy(*qubits)

Class method to apply cy gate to the given qubits.

Parameters:

qubits (int) – qubits in which the gate is applied, first one will be control qubit and second one target qubit.

Return type:

None

cz(*qubits)

Class method to apply cz gate to the given qubits.

Parameters:

qubits (int) – qubits in which the gate is applied, first one will be control qubit and second one target qubit.

Return type:

None

ch(*qubits)

Class method to apply ch gate to the given qubits.

Parameters:

qubits (int) – qubits in which the gate is applied, first one will be control qubit and second one target qubit.

Return type:

None

csx(*qubits)

Class method to apply csx gate to the given qubits.

Parameters:

qubits (int) – qubits in which the gate is applied, first one will be control qubit and second one target qubit.

Return type:

None

csxdg(*qubits)

Class method to apply csxdg gate to the given qubits.

Parameters:

qubits (int) – qubits in which the gate is applied, first one will be control qubit and second one target qubit.

Return type:

None

cs(*qubits)

Class method to apply cs gate to the given qubits.

Parameters:

qubits (int) – qubits in which the gate is applied, first one will be control qubit and second one target qubit.

Return type:

None

csdg(*qubits)

Class method to apply csdg gate to the given qubits.

Parameters:

qubits (int) – qubits in which the gate is applied, first one will be control qubit and second one target qubit.

Return type:

None

ct(*qubits)

Class method to apply ct gate to the given qubits.

Parameters:

qubits (int) – qubits in which the gate is applied, first one will be control qubit and second one target qubit.

Return type:

None

dcx(*qubits)

Class method to apply dcx gate to the given qubits.

Parameters:

qubits (int) – qubits in which the gate is applied, first one will be control qubit and second one target qubit.

Return type:

None

rxx(param, *qubits)

Class method to apply rxx gate to the given qubits.

Parameters:
  • param (float | int | str) – parameter for the parametric gate.

  • qubits (int) – qubits in which the gate is applied.

Return type:

None

ryy(param, *qubits)

Class method to apply ryy gate to the given qubits.

Parameters:
  • param (float | int | str) – parameter for the parametric gate.

  • qubits (int) – qubits in which the gate is applied.

Return type:

None

rzz(param, *qubits)

Class method to apply rzz gate to the given qubits.

Parameters:
  • param (float | int | str) – parameter for the parametric gate.

  • qubits (int) – qubits in which the gate is applied.

Return type:

None

rzx(param, *qubits)

Class method to apply rzx gate to the given qubits.

Parameters:
  • param (float | int | str) – parameter for the parametric gate.

  • qubits (int) – qubits in which the gate is applied.

Return type:

None

cr(param, *qubits)

Class method to apply cr gate to the given qubits.

Parameters:
  • param (float | int | str) – parameter for the parametric gate.

  • qubits (int) – qubits in which the gate is applied, first one will be the control qubit and second one the target qubit.

Return type:

None

crx(param, *qubits)

Class method to apply crx gate to the given qubits.

Parameters:
  • param (float | int | str) – parameter for the parametric gate.

  • qubits (int) – qubits in which the gate is applied, first one will be the control qubit and second one the target qubit.

Return type:

None

cry(param, *qubits)

Class method to apply cry gate to the given qubits.

Parameters:
  • param (float | int | str) – parameter for the parametric gate.

  • qubits (int) – qubits in which the gate is applied, first one will be the control qubit and second one the target qubit.

Return type:

None

crz(param, *qubits)

Class method to apply crz gate to the given qubits.

Parameters:
  • param (float | int | str) – parameter for the parametric gate.

  • qubits (int) – qubits in which the gate is applied, first one will be the control qubit and second one the target qubit.

Return type:

None

cp(param, *qubits)

Class method to apply cp gate to the given qubits.

Parameters:
  • param (float | int | str) – parameter for the parametric gate.

  • qubits (int) – qubits in which the gate is applied, first one will be the control qubit and second one the target qubit.

Return type:

None

cu1(param, *qubits)

Class method to apply cu1 gate to the given qubits.

Parameters:
  • param (float | int | str) – parameter for the parametric gate.

  • qubits (int) – qubits in which the gate is applied, first one will be the control qubit and second one the target qubit.

Return type:

None

cu2(theta, phi, *qubits)

Class method to apply cu2 gate to the given qubits.

Parameters:
  • theta (float | int) – angle.

  • phi (float | int) – angle.

  • qubits (int) – qubits in which the gate is applied, first one will be the control qubit and second one the target qubit.

Return type:

None

cu3(theta, phi, lam, *qubits)

Class method to apply cu3 gate to the given qubits.

Parameters:
  • theta (float | int) – angle.

  • phi (float | int) – angle.

  • lam (float | int) – angle.

  • qubits (int) – qubits in which the gate is applied, first one will be the control qubit and second one the target qubit.

Return type:

None

cu(theta, phi, lam, gamma, *qubits)

Class method to apply cu gate to the given qubits.

Parameters:
  • theta (float | int) – angle.

  • phi (float | int) – angle.

  • lam (float | int) – angle.

  • gamma (float | int) – angle.

  • qubits (int | list[int]) – qubits in which the gate is applied, first one will be the control qubit and second one the target qubit.

Return type:

None

xxmyy(theta, phi, *qubits)

Class method to apply XX - YY gate to the given qubits.

Parameters:
  • theta (float | int) – angle.

  • phi (float | int) – angle.

  • qubits (int) – qubits in which the gate is applied, first one will be the control qubit and second one the target qubit.

Return type:

None

xxpyy(theta, phi, *qubits)

Class method to apply XX + YY gate to the given qubits.

Parameters:
  • theta (float | int) – angle.

  • phi (float | int) – angle.

  • qubits (int) – qubits in which the gate is applied, first one will be the control qubit and second one the target qubit.

Return type:

None

Three-qubit gates
ccx(*qubits)

Class method to apply ccx gate to the given qubits.

Parameters:

qubits (int) – qubits in which the gate is applied, first two will be control qubits and the following one will be target qubit.

Return type:

None

ccy(*qubits)

Class method to apply ccy gate to the given qubits. Gate is decomposed as follows as it is not commonly supported by simulators.

q_0: ──────────────■─────────────
                   │
q_1: ──────────────■─────────────
     ┌──────────┐┌─┴─┐┌─────────┐
q_2: ┤ Rz(-π/2) ├┤ X ├┤ Rz(π/2) ├
     └──────────┘└───┘└─────────┘
Parameters:

qubits (int) – qubits in which the gate is applied, first two will be control qubits and the following one will be target qubit.

Return type:

None

ccz(*qubits)

Class method to apply ccz gate to the given qubits.

Parameters:

qubits (int) – qubits in which the gate is applied, first two will be control qubits and the following one will be target qubit.

Return type:

None

cecr(*qubits)

Class method to apply cecr gate to the given qubits.

Parameters:

qubits (int) – qubits in which the gate is applied, first one will be control qubit and second one target qubit.

Return type:

None

cswap(*qubits)

Class method to apply cswap gate to the given qubits.

Parameters:

qubits (int) – qubits in which the gate is applied, first two will be control qubits and the following one will be target qubit.

Return type:

None

Multicontrol gates
multicontrol(base_gate, num_ctrl_qubits, qubits, params=[])

Class method to apply a multicontrolled gate to the given qubits.

Parameters:
  • base_gate (str) – name of the gate to convert to multicontrolled.

  • num_ctrl_qubits (int) – number of qubits that control the gate.

  • qubits (list[int]) – qubits in which the gate is applied, first num_ctrl_qubits will be

  • qubits. (the control qubits and the remaining the target)

  • params (list[float | int | Parameter]) – list of parameters for the gate.

Warning

This instructions is currently only supported for Aer simulator.

Special gates
unitary(matrix, *qubits)

Class method to apply a unitary gate created from an unitary matrix provided.

Parameters:
  • matrix (list | numpy.ndarray) – unitary operator in matrix form to be applied to the given qubits.

  • qubits (int) – qubits to which the unitary operator will be applied.

Return type:

None

randomunitary(*qubits, seed=None)

Class method to apply a randomunitary gate.

Parameters:
  • qubits (int) – qubits to which the unitary operator will be applied.

  • seed (None | int) – seed.

Return type:

None

multipauli(pauli_id_list, *qubits)

Class method to apply a multipauli gate.

Parameters:
  • pauli_id_list (list[int]) – list of Pauli ids.

  • qubits (int) – qubits to which the unitary operator will be applied.

Return type:

None

multipaulirotation(param, pauli_id_list, *qubits)

Class method to apply a multipaulirotation gate.

Parameters:
  • param (float) – parameter

  • pauli_id_list (list[int]) – list of Pauli ids.

  • qubits (int) – qubits to which the unitary operator will be applied.

Return type:

None

amplitudedampingnoise(prob, *qubits, seed=None)

Class method to apply a amplitudedampingnoise gate.

Parameters:
  • prob (float) – probability.

  • qubits (int) – qubits to which the unitary operator will be applied.

  • seed (None | int) – seed.

Return type:

None

bitflipnoise(prob, *qubits, seed=None)

Class method to apply a bitflipnoise gate.

Parameters:
  • prob (float) – probability.

  • qubits (int) – qubits to which the unitary operator will be applied.

  • seed (None | int) – seed.

Return type:

None

dephasingnoise(prob, *qubits, seed=None)

Class method to apply a dephasingnoise gate.

Parameters:
  • prob (float) – probability.

  • qubits (int) – qubits to which the unitary operator will be applied.

  • seed (None | int) – seed.

Return type:

None

depolarizingnoise(prob, *qubits, seed=None)

Class method to apply a depolarizingnoise gate.

Parameters:
  • prob (float) – probability.

  • qubits (int) – qubits to which the unitary operator will be applied.

  • seed (None | int) – seed.

Return type:

None

independentxznoise(prob, *qubits, seed=None)

Class method to apply a independentxznoise gate.

Parameters:
  • prob (float) – probability.

  • qubits (int) – qubits to which the unitary operator will be applied.

  • seed (None | int) – seed.

Return type:

None

twoqubitdepolarizingnoise(prob, *qubits, seed=None)

Class method to apply a twoqubitdepolarizingnoise gate.

Parameters:
  • prob (float) – probability.

  • qubits (int) – qubits to which the unitary operator will be applied.

  • seed (None | int) – seed.

Return type:

None

Parameters:
  • num_qubits (int)

  • num_clbits (Optional[int])

  • id (Optional[str])

Transformations

Besides all quantum operations and communication directives, it is common for users to want to combine two circuits or, conversely, to create several circuits from a single one. This module exists to enable this capability, defining the following functions.

vsplit()

TODO: Vertical split of a quantum circuit.

hsplit(circuit, qubits_or_sections)

Horizontal split of a quantum circuit.

This function splits a circuit into a given number of subcircuits. This number is determined by the qubits_or_sections argument. If it is a list, then it specifies the number of qubits each subcircuit will have; however, if it is an int, it specifies the number of subcircuits to be created (each having the same number of qubits, except for one in case the split is not exact, which will take the remainder as its number of qubits).

If a controlled gate is divided an expose quantum directive will be used in order to maintain the global state intact.

This operation is the inverse of the union.

Parameters:
  • circuit (CunqaCircuit) – circuit to be splited.

  • qubits_or_sections (list[int], int) – if is a list, qubits in which to split, if an int, number of subcircuits that result of the split.

Return type:

list[CunqaCircuit]

union(circuits)

Union of circuits (addition of qubits).

This function joins the qubits of several CunqaCircuit objects. These circuits may be connected via communication directives which will be replaced as follows:

  • expose. The gates applied remotely simply switch to local operations.

  • qrecv and qsend. Switch to be a swap operation between local qubits.

  • send and recv. They provoke a special copy operation among classical registers called copy. For now, this operation is not available in the public API of CunqaCircuit.

This operation is the inverse of the hsplit.

Parameters:

circuits (list[CunqaCircuit]) – circuits to join.

Return type:

CunqaCircuit

add(circuits)

This function concatenates the instructions of two circuits.

It appends the gates from a list of circuits into a final resulting circuit. The order of the list passed as an argument is important, since the instructions will be appended in that same order.

In this operation, if two circuits in the list contain communication directives between them, an exception will be raised to prevent potential deadlocks and undefined or incorrectly specified behavior.

This operation is the inverse of the vsplit.

Parameters:

circuits (list[CunqaCircuit])

Return type:

CunqaCircuit