Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions docs/tutorials/ai-transpiler-introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Created 20 circuits with qubit counts: [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n"
"Created 20 circuits with qubit counts from 6 to 25\n"
]
},
{
Expand All @@ -281,7 +281,8 @@
"qubit_range_sim = list(range(6, 26))\n",
"\n",
"circuits_sim = [\n",
" # We have only two qubit gates, as those test how well the transpiler can optimize the circuit.\n",
" # We have only two qubit gates, as those test how well the\n",
" # transpiler can optimize the circuit.\n",
" random_circuit(\n",
" num_qubits=n,\n",
" depth=depth_sim,\n",
Expand All @@ -293,7 +294,8 @@
"]\n",
"\n",
"print(\n",
" f\"Created {len(circuits_sim)} circuits with qubit counts: {qubit_range_sim}\"\n",
" f\"Created {len(circuits_sim)} circuits with qubit counts \"\n",
" f\"from {qubit_range_sim[0]} to {qubit_range_sim[-1]}\"\n",
")\n",
"circuits_sim[0].draw(output=\"mpl\", fold=-1)"
]
Expand Down Expand Up @@ -535,7 +537,8 @@
" survival = counts.get(all_zeros, 0) / shots\n",
" survival_probs[method] = survival\n",
" print(\n",
" f\"{method:8s} P(|00...0>) = {survival:.4f} ({counts.get(all_zeros, 0)}/{shots})\"\n",
" f\"{method:8s} P(|00...0>) = {survival:.4f} \"\n",
" f\"({counts.get(all_zeros, 0)}/{shots})\"\n",
" )"
]
},
Expand Down Expand Up @@ -628,7 +631,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Created 25 circuits with qubit counts: [26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]\n"
"Created 25 circuits with qubit counts from 26 to 50\n"
]
}
],
Expand All @@ -639,7 +642,8 @@
"qubit_range_hw = list(range(26, 51))\n",
"\n",
"circuits_hw = [\n",
" # We have only two qubit gates, as those test how well the transpiler can optimize the circuit.\n",
" # We have only two qubit gates, as those test how well the\n",
" # transpiler can optimize the circuit.\n",
" random_circuit(\n",
" num_qubits=n,\n",
" depth=depth_hw,\n",
Expand All @@ -651,7 +655,8 @@
"]\n",
"\n",
"print(\n",
" f\"Created {len(circuits_hw)} circuits with qubit counts: {qubit_range_hw}\"\n",
" f\"Created {len(circuits_hw)} circuits with qubit counts \"\n",
" f\"from {qubit_range_hw[0]} to {qubit_range_hw[-1]}\"\n",
")"
]
},
Expand Down Expand Up @@ -783,10 +788,12 @@
"mirror_ai_hw = pm_basis.run(mirror_ai_hw)\n",
"\n",
"print(\n",
" f\"Mirror circuit (Default): depth {mirror_default_hw.depth()}, gates {mirror_default_hw.size()}\"\n",
" f\"Mirror circuit (Default): depth {mirror_default_hw.depth()}, \"\n",
" f\"gates {mirror_default_hw.size()}\"\n",
")\n",
"print(\n",
" f\"Mirror circuit (AI): depth {mirror_ai_hw.depth()}, gates {mirror_ai_hw.size()}\"\n",
" f\"Mirror circuit (AI): depth {mirror_ai_hw.depth()}, \"\n",
" f\"gates {mirror_ai_hw.size()}\"\n",
")\n",
"\n",
"# Submit to real hardware\n",
Expand Down Expand Up @@ -834,7 +841,8 @@
" survival = counts.get(all_zeros, 0) / shots_hw\n",
" survival_probs_hw[method] = survival\n",
" print(\n",
" f\"{method:8s} P(|00...0>) = {survival:.4f} ({counts.get(all_zeros, 0)}/{shots_hw})\"\n",
" f\"{method:8s} P(|00...0>) = {survival:.4f} \"\n",
" f\"({counts.get(all_zeros, 0)}/{shots_hw})\"\n",
" )\n",
"\n",
"# Plot 1 - P(|0...0>), the probability of an erroneous (non-zero) outcome.\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,11 @@
],
"source": [
"# Obtain the Hamiltonian JSON from the benchpress repository\n",
"url = \"https://raw.githubusercontent.com/Qiskit/benchpress/e7b29ef7be4cc0d70237b8fdc03edbd698908eff/benchpress/hamiltonian/hamlib/100_representative.json\"\n",
"url = (\n",
" \"https://raw.githubusercontent.com/Qiskit/benchpress/\"\n",
" \"e7b29ef7be4cc0d70237b8fdc03edbd698908eff/\"\n",
" \"benchpress/hamiltonian/hamlib/100_representative.json\"\n",
")\n",
"response = requests.get(url)\n",
"response.raise_for_status()\n",
"ham_records = json.loads(response.text)\n",
Expand All @@ -498,13 +502,14 @@
" qc.append(evo_gate, range(num_qubits))\n",
" qc_ham_list.append(qc)\n",
"\n",
"# Remove circuits whose decomposed size exceeds 1500 gates so that transpilation completes in a reasonable time frame\n",
"# Remove circuits whose decomposed size exceeds 1500 gates so that\n",
"# transpilation completes in a reasonable time frame\n",
"qc_ham_list = [qc for qc in qc_ham_list if qc.decompose().size() <= 1500]\n",
"\n",
"print(f\"Total Hamiltonian circuits loaded: {len(qc_ham_list)}\")\n",
"print(\n",
" f\"Qubit range: {min(qc.num_qubits for qc in qc_ham_list)} to {max(qc.num_qubits for qc in qc_ham_list)}\"\n",
")"
"min_qubits = min(qc.num_qubits for qc in qc_ham_list)\n",
"max_qubits = max(qc.num_qubits for qc in qc_ham_list)\n",
"print(f\"Qubit range: {min_qubits} to {max_qubits}\")"
]
},
{
Expand Down Expand Up @@ -1311,7 +1316,8 @@
" fidelity = counts.get(all_zeros, 0) / shots\n",
" fidelities[method] = fidelity\n",
" print(\n",
" f\"{method:8s} P(|00...0>) = {fidelity:.4f} ({counts.get(all_zeros, 0)}/{shots})\"\n",
" f\"{method:8s} P(|00...0>) = {fidelity:.4f} \"\n",
" f\"({counts.get(all_zeros, 0)}/{shots})\"\n",
" )"
]
},
Expand Down Expand Up @@ -1840,7 +1846,8 @@
" fidelity = counts.get(all_zeros, 0) / shots_hw\n",
" fidelities_large[method] = fidelity\n",
" print(\n",
" f\"{method:8s} P(|00...0>) = {fidelity:.4f} ({counts.get(all_zeros, 0)}/{shots_hw})\"\n",
" f\"{method:8s} P(|00...0>) = {fidelity:.4f} \"\n",
" f\"({counts.get(all_zeros, 0)}/{shots_hw})\"\n",
" )"
]
},
Expand Down
Loading
Loading