Skip to content

Commit 78eaadc

Browse files
kaldaggithub-actions[bot]frankharkins
authored
Changed EfficientSU2 to efficient_su2 (#2841)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Frank Harkins <[email protected]>
1 parent 93c9d31 commit 78eaadc

7 files changed

+33
-34
lines changed

Diff for: docs/guides/ai-transpiler-passes.mdx

+6-6
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ The `AIRouting` pass acts both as a layout stage and a routing stage. It can be
4242

4343
```python
4444
from qiskit.transpiler import PassManager
45-
from qiskit.circuit.library import EfficientSU2
45+
from qiskit.circuit.library import efficient_su2
4646
from qiskit_ibm_transpiler.ai.routing import AIRouting
4747

4848
ai_passmanager = PassManager([
4949
AIRouting(backend_name="ibm_sherbrooke", optimization_level=2, layout_mode="optimize", local_mode=True)
5050
])
5151

52-
circuit = EfficientSU2(101, entanglement="circular", reps=1).decompose()
52+
circuit = efficient_su2(101, entanglement="circular", reps=1)
5353

5454
transpiled_circuit = ai_passmanager.run(circuit)
5555
```
@@ -74,7 +74,7 @@ from qiskit_ibm_transpiler.ai.synthesis import AILinearFunctionSynthesis
7474
from qiskit_ibm_transpiler.ai.collection import CollectLinearFunctions
7575
from qiskit_ibm_transpiler.ai.synthesis import AIPauliNetworkSynthesis
7676
from qiskit_ibm_transpiler.ai.collection import CollectPauliNetworks
77-
from qiskit.circuit.library import EfficientSU2
77+
from qiskit.circuit.library import efficient_su2
7878

7979
ai_passmanager = PassManager([
8080
AIRouting(backend_name="ibm_cairo", optimization_level=3, layout_mode="optimize", local_mode=True), # Route circuit
@@ -84,7 +84,7 @@ ai_passmanager = PassManager([
8484
AIPauliNetworkSynthesis(backend_name="ibm_cairo", local_mode=False), # Re-synthesize Pauli Network blocks. Only available in the Qiskit Transpiler Service
8585
])
8686

87-
circuit = EfficientSU2(10, entanglement="full", reps=1).decompose()
87+
circuit = efficient_su2(10, entanglement="full", reps=1)
8888

8989
transpiled_circuit = ai_passmanager.run(circuit)
9090
```
@@ -125,13 +125,13 @@ The `qiskit-ibm-transpiler` allows you to configure a hybrid pass manager that c
125125

126126
```python
127127
from qiskit_ibm_transpiler import generate_ai_pass_manager
128-
from qiskit.circuit.library import EfficientSU2
128+
from qiskit.circuit.library import efficient_su2
129129
from qiskit_ibm_runtime import QiskitRuntimeService
130130

131131
backend = QiskitRuntimeService().backend("ibm_fez")
132132
fez_coupling_map = backend.coupling_map
133133

134-
su2_circuit = EfficientSU2(101, entanglement="circular", reps=1).decompose()
134+
su2_circuit = efficient_su2(101, entanglement="circular", reps=1)
135135

136136
ai_transpiler_pass_manager = generate_ai_pass_manager(
137137
coupling_map=fez_coupling_map,

Diff for: docs/guides/dynamical-decoupling-pass-manager.ipynb

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"id": "0606fde9-d0d9-4ab5-a941-7ab96de50cc5",
6666
"metadata": {},
6767
"source": [
68-
"Create an `EfficientSU2` circuit as an example. First, transpile the circuit to the backend because dynamical decoupling pulses need to be added after the circuit has been transpiled and scheduled. Dynamical decoupling often works best when there is a lot of idle time in the quantum circuits - that is, there are qubits that are not being used while others are active. This is the case in this circuit because the two-qubit `ecr` gates are applied sequentially in this ansatz."
68+
"Create an `efficient_su2` circuit as an example. First, transpile the circuit to the backend because dynamical decoupling pulses need to be added after the circuit has been transpiled and scheduled. Dynamical decoupling often works best when there is a lot of idle time in the quantum circuits - that is, there are qubits that are not being used while others are active. This is the case in this circuit because the two-qubit `ecr` gates are applied sequentially in this ansatz."
6969
]
7070
},
7171
{
@@ -90,9 +90,9 @@
9090
],
9191
"source": [
9292
"from qiskit.transpiler import generate_preset_pass_manager\n",
93-
"from qiskit.circuit.library import EfficientSU2\n",
93+
"from qiskit.circuit.library import efficient_su2\n",
9494
"\n",
95-
"qc = EfficientSU2(12, entanglement=\"circular\", reps=1)\n",
95+
"qc = efficient_su2(12, entanglement=\"circular\", reps=1)\n",
9696
"pm = generate_preset_pass_manager(1, target=target, seed_transpiler=12345)\n",
9797
"qc_t = pm.run(qc)\n",
9898
"qc_t.draw(\"mpl\", fold=-1, idle_wires=False)"
@@ -157,7 +157,7 @@
157157
"id": "d3fef37d-1c01-4303-be85-1ff90be760ae",
158158
"metadata": {},
159159
"source": [
160-
"Ansatz circuits such as `EfficientSU2` are parameterized, so they must have value bound to them before being sent to the backend. Here, assign random parameters."
160+
"Ansatz circuits such as `efficient_su2` are parameterized, so they must have value bound to them before being sent to the backend. Here, assign random parameters."
161161
]
162162
},
163163
{

Diff for: docs/guides/get-started-with-primitives.ipynb

+2-2
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,9 @@
290290
"outputs": [],
291291
"source": [
292292
"import numpy as np\n",
293-
"from qiskit.circuit.library import EfficientSU2\n",
293+
"from qiskit.circuit.library import efficient_su2\n",
294294
"\n",
295-
"circuit = EfficientSU2(127, entanglement=\"linear\", flatten=True)\n",
295+
"circuit = efficient_su2(127, entanglement=\"linear\")\n",
296296
"circuit.measure_all()\n",
297297
"# The circuit is parametrized, so we will define the parameter values for execution\n",
298298
"param_values = np.random.rand(circuit.num_parameters)"

Diff for: docs/guides/qiskit-transpiler-service.mdx

+6-6
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ The following examples demonstrate how to transpile circuits using the Qiskit Tr
4747
1. Create a circuit and call the Qiskit Transpiler Service to transpile the circuit with `ibm_sherbrooke` as the `backend_name`, 3 as the `optimization_level`, and without using AI during the transpilation.
4848

4949
```python
50-
from qiskit.circuit.library import EfficientSU2
50+
from qiskit.circuit.library import efficient_su2
5151
from qiskit_ibm_transpiler.transpiler_service import TranspilerService
5252

53-
circuit = EfficientSU2(101, entanglement="circular", reps=1).decompose()
53+
circuit = efficient_su2(101, entanglement="circular", reps=1)
5454

5555
cloud_transpiler_service = TranspilerService(
5656
backend_name="ibm_sherbrooke",
@@ -64,10 +64,10 @@ The following examples demonstrate how to transpile circuits using the Qiskit Tr
6464
2. Produce a similar circuit and transpile it, requesting AI transpiling capabilities by setting the flag `ai` to `True`:
6565

6666
```python
67-
from qiskit.circuit.library import EfficientSU2
67+
from qiskit.circuit.library import efficient_su2
6868
from qiskit_ibm_transpiler.transpiler_service import TranspilerService
6969

70-
circuit = EfficientSU2(101, entanglement="circular", reps=1).decompose()
70+
circuit = efficient_su2(101, entanglement="circular", reps=1)
7171

7272
cloud_transpiler_service = TranspilerService(
7373
backend_name="ibm_sherbrooke",
@@ -81,10 +81,10 @@ The following examples demonstrate how to transpile circuits using the Qiskit Tr
8181

8282

8383
```python
84-
from qiskit.circuit.library import EfficientSU2
84+
from qiskit.circuit.library import efficient_su2
8585
from qiskit_ibm_transpiler.transpiler_service import TranspilerService
8686

87-
circuit = EfficientSU2(101, entanglement="circular", reps=1).decompose()
87+
circuit = efficient_su2(101, entanglement="circular", reps=1)
8888

8989
cloud_transpiler_service = TranspilerService(
9090
backend_name="ibm_sherbrooke",

Diff for: docs/guides/represent-quantum-computers.ipynb

+4-5
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@
8080
"id": "4064b5ad-8a3a-462b-ae30-29576230c084",
8181
"metadata": {},
8282
"source": [
83-
"The example circuit uses an instance of [`EfficientSU2`](/api/qiskit/qiskit.circuit.library.EfficientSU2#efficientsu2) from Qiskit's circuit library.\n",
84-
"The following cell decomposes the circuit before drawing it to show its gate structure."
83+
"The example circuit uses an instance of [`efficient_su2`](/api/qiskit/qiskit.circuit.library.efficient_su2) from Qiskit's circuit library."
8584
]
8685
},
8786
{
@@ -105,11 +104,11 @@
105104
}
106105
],
107106
"source": [
108-
"from qiskit.circuit.library import EfficientSU2\n",
107+
"from qiskit.circuit.library import efficient_su2\n",
109108
"\n",
110-
"qc = EfficientSU2(12, entanglement=\"circular\", reps=1)\n",
109+
"qc = efficient_su2(12, entanglement=\"circular\", reps=1)\n",
111110
"\n",
112-
"qc.decompose().draw(\"mpl\")"
111+
"qc.draw(\"mpl\")"
113112
]
114113
},
115114
{

Diff for: docs/guides/simulate-stabilizer-circuits.ipynb

+6-6
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"Stabilizer circuits are important to the study of quantum error correction. Their classical simulability also makes them useful for verifying the output of quantum computers. For example, suppose you want to execute a quantum circuit that uses 100 qubits on a quantum computer. How do you know that the quantum computer is behaving correctly? A quantum circuit on 100 qubits is beyond the reach of brute-force classical simulation. By modifying your circuit so that it becomes a stabilizer circuit, you can run circuits on the quantum computer that have a similar structure to your desired circuit, but which you can simulate on a classical computer. By checking the output of the quantum computer on the stabilizer circuits, you can gain confidence that it is behaving correctly on the non-stabilizer circuits as well. See [*Evidence for the utility of quantum computing before fault tolerance*](https://www.nature.com/articles/s41586-023-06096-3) for an example of this idea in practice.\n",
5050
"\n",
5151
"\n",
52-
"[Exact and noisy simulation with Qiskit Aer primitives](simulate-with-qiskit-aer) shows how to use [Qiskit Aer](https://qiskit.org/ecosystem/aer/) to perform exact and noisy simulations of generic quantum circuits. Consider the example circuit used in that article, an 8-qubit circuit built using [EfficientSU2](../api/qiskit/qiskit.circuit.library.EfficientSU2):"
52+
"[Exact and noisy simulation with Qiskit Aer primitives](simulate-with-qiskit-aer) shows how to use [Qiskit Aer](https://qiskit.org/ecosystem/aer/) to perform exact and noisy simulations of generic quantum circuits. Consider the example circuit used in that article, an 8-qubit circuit built using [efficient_su2](../api/qiskit/qiskit.circuit.library.efficient_su2):"
5353
]
5454
},
5555
{
@@ -73,11 +73,11 @@
7373
}
7474
],
7575
"source": [
76-
"from qiskit.circuit.library import EfficientSU2\n",
76+
"from qiskit.circuit.library import efficient_su2\n",
7777
"\n",
7878
"n_qubits = 8\n",
79-
"circuit = EfficientSU2(n_qubits)\n",
80-
"circuit.decompose().draw(\"mpl\")"
79+
"circuit = efficient_su2(n_qubits)\n",
80+
"circuit.draw(\"mpl\")"
8181
]
8282
},
8383
{
@@ -96,7 +96,7 @@
9696
"outputs": [],
9797
"source": [
9898
"n_qubits = 500\n",
99-
"circuit = EfficientSU2(n_qubits)\n",
99+
"circuit = efficient_su2(n_qubits)\n",
100100
"# don't try to draw the circuit because it's too large"
101101
]
102102
},
@@ -105,7 +105,7 @@
105105
"id": "ecd975b0-2ec0-4a99-a0f6-790d43af19fb",
106106
"metadata": {},
107107
"source": [
108-
"Because the cost of simulating quantum circuits scales exponentially with the number of qubits, such a large circuit would generally exceed the capabilities of even a high-performance simulator like Qiskit Aer. Classical simulation of generic quantum circuits becomes infeasible when the number of qubits exceeds roughly 50 to 100 qubits. However, note that the EfficientSU2 circuit is parameterized by angles on $R_y$ and $R_z$ gates. If all of these angles are contained in the set $\\{0, \\frac{\\pi}{2}, \\pi, \\frac{3\\pi}{2}\\}$, then the circuit is a stabilizer circuit, and it can be efficiently simulated!\n",
108+
"Because the cost of simulating quantum circuits scales exponentially with the number of qubits, such a large circuit would generally exceed the capabilities of even a high-performance simulator like Qiskit Aer. Classical simulation of generic quantum circuits becomes infeasible when the number of qubits exceeds roughly 50 to 100 qubits. However, note that the efficient_su2 circuit is parameterized by angles on $R_y$ and $R_z$ gates. If all of these angles are contained in the set $\\{0, \\frac{\\pi}{2}, \\pi, \\frac{3\\pi}{2}\\}$, then the circuit is a stabilizer circuit, and it can be efficiently simulated!\n",
109109
"\n",
110110
"In the following cell, we run the circuit with the Sampler primitive backed by the stabilizer circuit simulator, using parameters chosen randomly such that the circuit is guaranteed to be a stabilizer circuit."
111111
]

Diff for: docs/guides/simulate-with-qiskit-aer.ipynb

+5-5
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@
6666
}
6767
],
6868
"source": [
69-
"from qiskit.circuit.library import EfficientSU2\n",
69+
"from qiskit.circuit.library import efficient_su2\n",
7070
"\n",
7171
"n_qubits = 8\n",
72-
"circuit = EfficientSU2(n_qubits)\n",
73-
"circuit.decompose().draw(\"mpl\")"
72+
"circuit = efficient_su2(n_qubits)\n",
73+
"circuit.draw(\"mpl\")"
7474
]
7575
},
7676
{
@@ -180,7 +180,7 @@
180180
"\n",
181181
"where $n$ is the number of qubits, in this case, 2. That is, with probability $p$, the state is replaced with the completely mixed state, and the state is preserved with probability $1 - p$. After $m$ applications of the depolarizing channel, the probability of the state being preserved would be $(1 - p)^m$. Therefore, we expect the probability of retaining the correct state at the end of the simulation to go down exponentially with the number of CX gates in our circuit.\n",
182182
"\n",
183-
"Let's count the number of CX gates in our circuit and compute $(1 - p)^m$. Because our circuit uses the EfficientSU2 class, we'll need to call `decompose` once to decompose it into CX gates. We call `count_ops` to get a dictionary that maps gate names to counts, and retrieve the entry for the CX gate."
183+
"Let's count the number of CX gates in our circuit and compute $(1 - p)^m$. We call `count_ops` to get a dictionary that maps gate names to counts, and retrieve the entry for the CX gate."
184184
]
185185
},
186186
{
@@ -201,7 +201,7 @@
201201
}
202202
],
203203
"source": [
204-
"cx_count = circuit.decompose().count_ops()[\"cx\"]\n",
204+
"cx_count = circuit.count_ops()[\"cx\"]\n",
205205
"(1 - cx_depolarizing_prob) ** cx_count"
206206
]
207207
},

0 commit comments

Comments
 (0)