Skip to content

Commit 767cb0a

Browse files
committed
Switch to using least-busy backend instead of hardcoded ibm_torino
- Replaced backend selection with service.least_busy(...) for flexibility - Updated markdown text to remove device-specific references - Added note explaining that transpilation may differ across backends
1 parent f52cc3c commit 767cb0a

File tree

3 files changed

+65
-52
lines changed

3 files changed

+65
-52
lines changed

docs/tutorials/ai-transpiler-introduction.ipynb

Lines changed: 65 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
},
9292
{
9393
"cell_type": "code",
94-
"execution_count": null,
94+
"execution_count": 2,
9595
"id": "2c462d48-ae45-4528-9b09-cebc869a6812",
9696
"metadata": {},
9797
"outputs": [],
@@ -216,7 +216,7 @@
216216
],
217217
"source": [
218218
"# For our transpilation, we will use a large circuit of 101 qubits\n",
219-
"qc = efficient_su2(130, entanglement=\"circular\", reps=1).decompose()\n",
219+
"qc = efficient_su2(90, entanglement=\"circular\", reps=1).decompose()\n",
220220
"\n",
221221
"# Draw a smaller version of the circuit to get a visual representation\n",
222222
"qc_small = efficient_su2(5, entanglement=\"circular\", reps=1).decompose()\n",
@@ -232,19 +232,32 @@
232232
"\n",
233233
"### Choose a backend\n",
234234
"\n",
235-
"For this example, we will use the `ibm_torino` backend. This backend features a heavy-hexagonal topology with 133 qubits, making it a suitable target for large-scale circuit demonstrations, especially when assessing performance on modern quantum hardware."
235+
"For this example, we select the least busy operational IBM Quantum backend that is not a simulator and has at least 100 qubits:\n",
236+
"\n",
237+
"**Note:** Since the least-busy backend can change over time, different devices may be selected on different runs. Device-specific properties such as coupling maps which can lead to differences in the transpiled circuits."
236238
]
237239
},
238240
{
239241
"cell_type": "code",
240242
"execution_count": null,
241243
"id": "c6b6e55e-9b70-4c94-8bbf-5ea47d0510ff",
242244
"metadata": {},
243-
"outputs": [],
245+
"outputs": [
246+
{
247+
"name": "stdout",
248+
"output_type": "stream",
249+
"text": [
250+
"Using backend: ibm_torino\n"
251+
]
252+
}
253+
],
244254
"source": [
245255
"service = QiskitRuntimeService()\n",
246-
"backend = service.backend(\"ibm_torino\")\n",
247-
"cm = backend.coupling_map"
256+
"backend = service.least_busy(\n",
257+
" operational=True, simulator=False, min_num_qubits=100\n",
258+
")\n",
259+
"cm = backend.coupling_map\n",
260+
"print(f\"Using backend: {backend.name}\")"
248261
]
249262
},
250263
{
@@ -297,8 +310,8 @@
297310
"name": "stdout",
298311
"output_type": "stream",
299312
"text": [
300-
"Standard transpilation: Depth (2q) 233, Gate count 765, Time 0.14614295959472656\n",
301-
"AI transpilation : Depth (2q) 198, Gate count 803, Time 2.5871737003326416\n"
313+
"Standard transpilation: Depth (2q) 95, Gate count 458, Time 0.04650712013244629\n",
314+
"AI transpilation : Depth (2q) 90, Gate count 456, Time 0.9342479705810547\n"
302315
]
303316
}
304317
],
@@ -323,7 +336,7 @@
323336
"id": "d934ebd2-e594-4076-8b21-822087df01ea",
324337
"metadata": {},
325338
"source": [
326-
"In this test, we compare the performance of the AI transpiler and the standard transpilation method on the efficient_su2 circuit using the `ibm_trino` backend. The AI transpiler achieves a noticeably shallower circuit depth while maintaining a similar gate count.\n",
339+
"In this test, we compare the performance of the AI transpiler and the standard transpilation method on the efficient_su2 circuit. The AI transpiler achieves a noticeably shallower circuit depth while maintaining a similar gate count.\n",
327340
"\n",
328341
"- **Circuit depth:** The AI transpiler produces a circuit with lower 2-qubit depth. This is expected, as the AI passes are trained to optimize depth by learning qubit interaction patterns and exploiting hardware connectivity more effectively than rule-based heuristics.\n",
329342
"\n",
@@ -414,57 +427,57 @@
414427
" <td>Random</td>\n",
415428
" <td>37</td>\n",
416429
" <td>221</td>\n",
417-
" <td>0.041661</td>\n",
418-
" <td>32</td>\n",
419-
" <td>209</td>\n",
420-
" <td>0.854528</td>\n",
430+
" <td>0.039347</td>\n",
431+
" <td>24</td>\n",
432+
" <td>181</td>\n",
433+
" <td>0.773718</td>\n",
421434
" </tr>\n",
422435
" <tr>\n",
423436
" <th>1</th>\n",
424437
" <td>Clifford</td>\n",
425-
" <td>52</td>\n",
426-
" <td>224</td>\n",
427-
" <td>0.040050</td>\n",
428-
" <td>44</td>\n",
429-
" <td>285</td>\n",
430-
" <td>1.166769</td>\n",
438+
" <td>36</td>\n",
439+
" <td>232</td>\n",
440+
" <td>0.036633</td>\n",
441+
" <td>43</td>\n",
442+
" <td>267</td>\n",
443+
" <td>1.097431</td>\n",
431444
" </tr>\n",
432445
" <tr>\n",
433446
" <th>2</th>\n",
434447
" <td>QFT</td>\n",
435448
" <td>165</td>\n",
436449
" <td>924</td>\n",
437-
" <td>0.081966</td>\n",
438-
" <td>152</td>\n",
439-
" <td>926</td>\n",
440-
" <td>3.792103</td>\n",
450+
" <td>0.077458</td>\n",
451+
" <td>130</td>\n",
452+
" <td>913</td>\n",
453+
" <td>3.660771</td>\n",
441454
" </tr>\n",
442455
" <tr>\n",
443456
" <th>3</th>\n",
444457
" <td>BV</td>\n",
445458
" <td>65</td>\n",
446459
" <td>155</td>\n",
447-
" <td>0.033396</td>\n",
448-
" <td>73</td>\n",
449-
" <td>158</td>\n",
450-
" <td>0.462457</td>\n",
460+
" <td>0.024993</td>\n",
461+
" <td>70</td>\n",
462+
" <td>155</td>\n",
463+
" <td>0.345522</td>\n",
451464
" </tr>\n",
452465
" </tbody>\n",
453466
"</table>\n",
454467
"</div>"
455468
],
456469
"text/plain": [
457470
" Circuit Depth 2Q (No AI) Gate Count (No AI) Time (No AI) \\\n",
458-
"0 Random 37 221 0.041661 \n",
459-
"1 Clifford 52 224 0.040050 \n",
460-
"2 QFT 165 924 0.081966 \n",
461-
"3 BV 65 155 0.033396 \n",
471+
"0 Random 37 221 0.039347 \n",
472+
"1 Clifford 36 232 0.036633 \n",
473+
"2 QFT 165 924 0.077458 \n",
474+
"3 BV 65 155 0.024993 \n",
462475
"\n",
463476
" Depth 2Q (AI) Gate Count (AI) Time (AI) \n",
464-
"0 32 209 0.854528 \n",
465-
"1 44 285 1.166769 \n",
466-
"2 152 926 3.792103 \n",
467-
"3 73 158 0.462457 "
477+
"0 24 181 0.773718 \n",
478+
"1 43 267 1.097431 \n",
479+
"2 130 913 3.660771 \n",
480+
"3 70 155 0.345522 "
468481
]
469482
},
470483
"execution_count": 7,
@@ -539,9 +552,9 @@
539552
"name": "stdout",
540553
"output_type": "stream",
541554
"text": [
542-
"Average reduction in depth: 5.64%\n",
543-
"Average reduction in gate count: -3.54%\n",
544-
"Average reduction in transpilation time: -3084.53%\n"
555+
"Average reduction in depth: 11.88%\n",
556+
"Average reduction in gate count: 1.04%\n",
557+
"Average reduction in transpilation time: -3193.95%\n"
545558
]
546559
}
547560
],
@@ -882,8 +895,8 @@
882895
"=== Average Metrics ===\n",
883896
" Depth (2Q) Gates Time (s)\n",
884897
"Method \n",
885-
"AI 24.4 78.8 0.228\n",
886-
"Basic 29.1 90.1 0.013\n",
898+
"AI 23.9 82.8 0.248\n",
899+
"Basic 29.8 91.0 0.012\n",
887900
"Depth-LNN-KMS 70.8 531.6 0.017\n",
888901
"\n",
889902
"Best Non-AI Method (based on least average depth): Basic\n",
@@ -922,33 +935,33 @@
922935
" <tr>\n",
923936
" <th>0</th>\n",
924937
" <td>Depth (2Q)</td>\n",
925-
" <td>24.400</td>\n",
926-
" <td>29.100</td>\n",
927-
" <td>-4.700</td>\n",
938+
" <td>23.900</td>\n",
939+
" <td>29.800</td>\n",
940+
" <td>-5.900</td>\n",
928941
" </tr>\n",
929942
" <tr>\n",
930943
" <th>1</th>\n",
931944
" <td>Gates</td>\n",
932-
" <td>78.800</td>\n",
933-
" <td>90.100</td>\n",
934-
" <td>-11.300</td>\n",
945+
" <td>82.800</td>\n",
946+
" <td>91.000</td>\n",
947+
" <td>-8.200</td>\n",
935948
" </tr>\n",
936949
" <tr>\n",
937950
" <th>2</th>\n",
938951
" <td>Time (s)</td>\n",
939-
" <td>0.228</td>\n",
940-
" <td>0.013</td>\n",
941-
" <td>0.215</td>\n",
952+
" <td>0.248</td>\n",
953+
" <td>0.012</td>\n",
954+
" <td>0.236</td>\n",
942955
" </tr>\n",
943956
" </tbody>\n",
944957
"</table>\n",
945958
"</div>"
946959
],
947960
"text/plain": [
948961
" Metric AI Basic Improvement (AI vs Best Non-AI)\n",
949-
"0 Depth (2Q) 24.400 29.100 -4.700\n",
950-
"1 Gates 78.800 90.100 -11.300\n",
951-
"2 Time (s) 0.228 0.013 0.215"
962+
"0 Depth (2Q) 23.900 29.800 -5.900\n",
963+
"1 Gates 82.800 91.000 -8.200\n",
964+
"2 Time (s) 0.248 0.012 0.236"
952965
]
953966
},
954967
"execution_count": 13,

0 commit comments

Comments
 (0)