gulps.decomposition.GulpsDecomposer

class gulps.decomposition.GulpsDecomposer(gates, costs, local_layer_cost=0.0, max_depth=Ellipsis)[source]

Bases: object

Synthesizes a two-qubit unitary exactly, as the sequence of the given gates with the least total cost.

Calling the decomposer on a two-qubit unitary (a Qiskit gate, an Operator, or a 4-by-4 array) returns a QuantumCircuit of the native gates between single-qubit unitaries, or a DAGCircuit with use_dag=True.

Of gates with exactly the same computed class, only the cheapest is kept, the first on ties, with a warning. A class is emitted as its canonical gate in a UnitaryGate.

Parameters:
  • gates (Sequence[qiskit.circuit.Gate | LocalEquivalenceClass]) – Each gate is a Qiskit standard gate under its own name or a UnitaryGate, with no unbound parameters.

  • costs (Sequence[float]) – Finite and nonnegative, one per gate.

  • local_layer_cost (float) – Cost of each layer of single-qubit gates before, between, and after the two-qubit gates.

  • max_depth (int) – Maximum number of two-qubit gates in a sequence.

Example

>>> decomposer = GulpsDecomposer([CXGate(), iSwapGate()], [1.0, 1.0])
>>> circuit = decomposer(random_unitary(4))
costs

The cost of each gate in gates.

Type:

tuple[float, …]

gates

The kept gates, as the decomposer’s own copies, which select also returns. Do not mutate them.

Type:

tuple[qiskit.circuit.Gate, …]

local_layer_cost

Cost of each layer of single-qubit gates.

Type:

float

max_depth

Maximum number of two-qubit gates in a sequence.

Type:

int

select(targets)

The cost and gates of the least-cost sequence for each target, without synthesizing a circuit.

Parameters:

targets (qiskit.circuit.Gate | qiskit.quantum_info.Operator | np.ndarray | LocalEquivalenceClass | list) – One target, or a list, tuple, or (N, 4, 4) array of targets.

Returns:

The sequence’s cost and gates, or a list with one such pair per target.

Return type:

tuple[float, tuple[qiskit.circuit.Gate, …]] | list[…]