Skip to content
This repository was archived by the owner on Aug 21, 2023. It is now read-only.

Commit 7912e4d

Browse files
mtreinishjaygambetta
authored andcommitted
Update parallel tools notebook for terra 0.9 (#774)
This commit fixes a few issues in the parallel when running on the latest version of terra. The biggest issues is the qiskit.quantum_info.synthesis.two_qubit_kak() function was renamed prior to the 0.8 release to two_qubit_decompose() (from what I can tell two_qubit_kak() in quantum_info synthesis was never included in a release, although I might have missed it in my git log hunting). This updates the call to use the proper function name. In addition because of Qiskit/qiskit#2414 all bit level access as tuples has been deprecated and will emit a warning, to remove the warnings this changes the access to be attributes instead.
1 parent a2bcabe commit 7912e4d

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

qiskit/advanced/terra/terra_parallel_tools.ipynb

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
"import math\n",
8484
"import numpy as np\n",
8585
"from qiskit.quantum_info.random import random_unitary \n",
86-
"from qiskit.quantum_info.synthesis import two_qubit_kak"
86+
"from qiskit.quantum_info.synthesis import two_qubit_cnot_decompose"
8787
]
8888
},
8989
{
@@ -128,14 +128,14 @@
128128
" for k in range(math.floor(width/2)):\n",
129129
" qubits = [int(perm[2*k]), int(perm[2*k+1])]\n",
130130
" U = random_unitary(4) \n",
131-
" for gate in two_qubit_kak(U):\n",
131+
" for gate in two_qubit_cnot_decompose(U):\n",
132132
" gate_name = gate[0].name\n",
133133
" gate_params = gate[0].params\n",
134134
" # The first qubit argument used in gate\n",
135-
" i0 = qubits[gate[1][0][1]]\n",
135+
" i0 = qubits[gate[1][0].index]\n",
136136
" if gate_name == \"cx\":\n",
137137
" # The second qubit argument used in gate\n",
138-
" i1 = qubits[gate[1][1][1]]\n",
138+
" i1 = qubits[gate[1][1].index]\n",
139139
" qc.cx(q[i0], q[i1])\n",
140140
" elif gate_name == \"u1\":\n",
141141
" qc.u1(gate_params[2], q[i0])\n",
@@ -204,13 +204,6 @@
204204
"HTMLProgressBar()\n",
205205
"parallel_map(build_qv_circuit, np.arange(num_circuits), task_args=(seeds, width, depth));"
206206
]
207-
},
208-
{
209-
"cell_type": "code",
210-
"execution_count": null,
211-
"metadata": {},
212-
"outputs": [],
213-
"source": []
214207
}
215208
],
216209
"metadata": {
@@ -230,7 +223,7 @@
230223
"name": "python",
231224
"nbconvert_exporter": "python",
232225
"pygments_lexer": "ipython3",
233-
"version": "3.7.3"
226+
"version": "3.7.4"
234227
},
235228
"varInspector": {
236229
"cols": {

0 commit comments

Comments
 (0)