efficient_su2
class qiskit.circuit.library.efficient_su2(num_qubits, su2_gates=None, entanglement='reverse_linear', reps=3, skip_unentangled_qubits=False, skip_final_rotation_layer=False, parameter_prefix='θ', insert_barriers=False, name='EfficientSU2')
Bases:
The hardware-efficient 2-local circuit.
The efficient_su2
circuit consists of layers of single qubit operations spanned by and CX entanglements. This is a heuristic pattern that can be used to prepare trial wave functions for variational quantum algorithms or classification circuit for machine learning.
is the special unitary group of degree 2, its elements are unitary matrices with determinant 1, such as the Pauli rotation gates.
On 3 qubits and using the Pauli and rotations as single qubit gates, the this circuit is represented by:
┌──────────┐┌──────────┐ ░ ░ ░ ┌───────────┐┌───────────┐
┤ RY(θ[0]) ├┤ RZ(θ[3]) ├─░────────■───░─ ... ─░─┤ RY(θ[12]) ├┤ RZ(θ[15]) ├
├──────────┤├──────────┤ ░ ┌─┴─┐ ░ ░ ├───────────┤├───────────┤
┤ RY(θ[1]) ├┤ RZ(θ[4]) ├─░───■──┤ X ├─░─ ... ─░─┤ RY(θ[13]) ├┤ RZ(θ[16]) ├
├──────────┤├──────────┤ ░ ┌─┴─┐└───┘ ░ ░ ├───────────┤├───────────┤
┤ RY(θ[2]) ├┤ RZ(θ[5]) ├─░─┤ X ├──────░─ ... ─░─┤ RY(θ[14]) ├┤ RZ(θ[17]) ├
└──────────┘└──────────┘ ░ └───┘ ░ ░ └───────────┘└───────────┘
Examples
Per default, the "reverse_linear"
entanglement is used, which, in the case of CX gates, is equivalent to an all-to-all entanglement:
from qiskit.circuit.library import efficient_su2
circuit = efficient_su2(3, reps=1)
circuit.draw("mpl")
To specify which SU(2) gates should be used in the rotation layer, we can set the su2_gates
argument. In addition, we can change the entanglement structure. For example:
circuit = efficient_su2(4, su2_gates=["rx", "y"], entanglement="circular", reps=1)
circuit.draw("mpl")
Parameters
- num_qubits (int) – The number of qubits.
- su2_gates (str |Gate | Iterable[str |Gate] | None) – The single qubit gates to apply in single qubit gate layers. If only one gate is provided, the same gate is applied to each qubit. If a list of gates is provided, all gates are applied to each qubit in the provided order.
- reps (int) – Specifies how often the structure of a rotation layer followed by an entanglement layer is repeated.
- entanglement (BlockEntanglement | Iterable[BlockEntanglement] | Callable[[int], BlockEntanglement | Iterable[BlockEntanglement]]) – The indices specifying on which qubits the input blocks act. See
n_local()
for detailed information. - skip_final_rotation_layer (bool) – Whether a final rotation layer is added to the circuit.
- skip_unentangled_qubits (bool) – If
True
, the rotation gates act only on qubits that are entangled. IfFalse
, the rotation gates act on all qubits. - parameter_prefix (str) – The name of the free parameters.
- insert_barriers (bool) – If True, barriers are inserted in between each layer. If False, no barriers are inserted.
- name (str) – The name of the circuit.
Returns
An efficient-SU(2) circuit.