qiskit-documentation/docs/api/qiskit/qiskit.circuit.library.effi...

73 lines
5.4 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: efficient_su2 (latest version)
description: API reference for qiskit.circuit.library.efficient_su2 in the latest version of qiskit
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.circuit.library.efficient_su2
---
<span id="efficient-su2" />
# efficient\_su2
<Class id="qiskit.circuit.library.efficient_su2" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.3/qiskit/circuit/library/n_local/efficient_su2.py#L31-L134" signature="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')" modifiers="class">
Bases:
The hardware-efficient $SU(2)$ 2-local circuit.
The `efficient_su2` circuit consists of layers of single qubit operations spanned by $SU(2)$ 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.
$SU(2)$ is the special unitary group of degree 2, its elements are $2 \times 2$ unitary matrices with determinant 1, such as the Pauli rotation gates.
On 3 qubits and using the Pauli $Y$ and $Z$ rotations as single qubit gates, the this circuit is represented by:
```python
┌──────────┐┌──────────┐ ░ ░ ░ ┌───────────┐┌───────────┐
┤ 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:
```python
from qiskit.circuit.library import efficient_su2
circuit = efficient_su2(3, reps=1)
circuit.draw("mpl")
```
![Circuit diagram output by the previous code.](/images/api/qiskit/qiskit-circuit-library-efficient_su2-1.avif)
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:
```python
circuit = efficient_su2(4, su2_gates=["rx", "y"], entanglement="circular", reps=1)
circuit.draw("mpl")
```
![Circuit diagram output by the previous code.](/images/api/qiskit/qiskit-circuit-library-efficient_su2-2.avif)
**Parameters**
* **num\_qubits** ([*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) The number of qubits.
* **su2\_gates** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)") *|*[*Gate*](qiskit.circuit.Gate "qiskit.circuit.Gate") *| Iterable\[*[*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)") *|*[*Gate*](qiskit.circuit.Gate "qiskit.circuit.Gate")*] | None*) The $SU(2)$ 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*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")) Specifies how often the structure of a rotation layer followed by an entanglement layer is repeated.
* **entanglement** (*BlockEntanglement | Iterable\[BlockEntanglement] | Callable\[\[*[*int*](https://docs.python.org/3/library/functions.html#int "(in Python v3.13)")*], BlockEntanglement | Iterable\[BlockEntanglement]]*) The indices specifying on which qubits the input blocks act. See `n_local()` for detailed information.
* **skip\_final\_rotation\_layer** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)")) Whether a final rotation layer is added to the circuit.
* **skip\_unentangled\_qubits** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)")) If `True`, the rotation gates act only on qubits that are entangled. If `False`, the rotation gates act on all qubits.
* **parameter\_prefix** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")) The name of the free parameters.
* **insert\_barriers** ([*bool*](https://docs.python.org/3/library/functions.html#bool "(in Python v3.13)")) If True, barriers are inserted in between each layer. If False, no barriers are inserted.
* **name** ([*str*](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")) The name of the circuit.
**Returns**
An efficient-SU(2) circuit.
</Class>