gulps.decomposition.GulpsDecomposer¶
- class gulps.decomposition.GulpsDecomposer(gates, costs, local_layer_cost=0.0, max_depth=Ellipsis)[source]¶
Bases:
objectSynthesizes 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, anOperator, or a 4-by-4 array) returns aQuantumCircuitof the native gates between single-qubit unitaries, or aDAGCircuitwithuse_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 aUnitaryGate, 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))
- gates¶
The kept gates, as the decomposer’s own copies, which
selectalso returns. Do not mutate them.- Type:
- 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[…]