Skip to content

Commit

Permalink
Update parallel tools notebook for terra 0.9
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mtreinish committed Aug 20, 2019
1 parent ac1c885 commit e65d5ba
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions qiskit/advanced/terra/terra_parallel_tools.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"import math\n",
"import numpy as np\n",
"from qiskit.quantum_info.random import random_unitary \n",
"from qiskit.quantum_info.synthesis import two_qubit_kak"
"from qiskit.quantum_info.synthesis import two_qubit_cnot_decompose"
]
},
{
Expand Down Expand Up @@ -128,14 +128,14 @@
" for k in range(math.floor(width/2)):\n",
" qubits = [int(perm[2*k]), int(perm[2*k+1])]\n",
" U = random_unitary(4) \n",
" for gate in two_qubit_kak(U):\n",
" for gate in two_qubit_cnot_decompose(U):\n",
" gate_name = gate[0].name\n",
" gate_params = gate[0].params\n",
" # The first qubit argument used in gate\n",
" i0 = qubits[gate[1][0][1]]\n",
" i0 = qubits[gate[1][0].index]\n",
" if gate_name == \"cx\":\n",
" # The second qubit argument used in gate\n",
" i1 = qubits[gate[1][1][1]]\n",
" i1 = qubits[gate[1][1].index]\n",
" qc.cx(q[i0], q[i1])\n",
" elif gate_name == \"u1\":\n",
" qc.u1(gate_params[2], q[i0])\n",
Expand Down Expand Up @@ -204,13 +204,6 @@
"HTMLProgressBar()\n",
"parallel_map(build_qv_circuit, np.arange(num_circuits), task_args=(seeds, width, depth));"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -230,7 +223,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.7.4"
},
"varInspector": {
"cols": {
Expand Down

0 comments on commit e65d5ba

Please sign in to comment.