|
91 | 91 | }, |
92 | 92 | { |
93 | 93 | "cell_type": "code", |
94 | | - "execution_count": null, |
| 94 | + "execution_count": 2, |
95 | 95 | "id": "2c462d48-ae45-4528-9b09-cebc869a6812", |
96 | 96 | "metadata": {}, |
97 | 97 | "outputs": [], |
|
216 | 216 | ], |
217 | 217 | "source": [ |
218 | 218 | "# 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", |
220 | 220 | "\n", |
221 | 221 | "# Draw a smaller version of the circuit to get a visual representation\n", |
222 | 222 | "qc_small = efficient_su2(5, entanglement=\"circular\", reps=1).decompose()\n", |
|
232 | 232 | "\n", |
233 | 233 | "### Choose a backend\n", |
234 | 234 | "\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." |
236 | 238 | ] |
237 | 239 | }, |
238 | 240 | { |
239 | 241 | "cell_type": "code", |
240 | 242 | "execution_count": null, |
241 | 243 | "id": "c6b6e55e-9b70-4c94-8bbf-5ea47d0510ff", |
242 | 244 | "metadata": {}, |
243 | | - "outputs": [], |
| 245 | + "outputs": [ |
| 246 | + { |
| 247 | + "name": "stdout", |
| 248 | + "output_type": "stream", |
| 249 | + "text": [ |
| 250 | + "Using backend: ibm_torino\n" |
| 251 | + ] |
| 252 | + } |
| 253 | + ], |
244 | 254 | "source": [ |
245 | 255 | "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}\")" |
248 | 261 | ] |
249 | 262 | }, |
250 | 263 | { |
|
297 | 310 | "name": "stdout", |
298 | 311 | "output_type": "stream", |
299 | 312 | "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" |
302 | 315 | ] |
303 | 316 | } |
304 | 317 | ], |
|
323 | 336 | "id": "d934ebd2-e594-4076-8b21-822087df01ea", |
324 | 337 | "metadata": {}, |
325 | 338 | "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", |
327 | 340 | "\n", |
328 | 341 | "- **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", |
329 | 342 | "\n", |
|
414 | 427 | " <td>Random</td>\n", |
415 | 428 | " <td>37</td>\n", |
416 | 429 | " <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", |
421 | 434 | " </tr>\n", |
422 | 435 | " <tr>\n", |
423 | 436 | " <th>1</th>\n", |
424 | 437 | " <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", |
431 | 444 | " </tr>\n", |
432 | 445 | " <tr>\n", |
433 | 446 | " <th>2</th>\n", |
434 | 447 | " <td>QFT</td>\n", |
435 | 448 | " <td>165</td>\n", |
436 | 449 | " <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", |
441 | 454 | " </tr>\n", |
442 | 455 | " <tr>\n", |
443 | 456 | " <th>3</th>\n", |
444 | 457 | " <td>BV</td>\n", |
445 | 458 | " <td>65</td>\n", |
446 | 459 | " <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", |
451 | 464 | " </tr>\n", |
452 | 465 | " </tbody>\n", |
453 | 466 | "</table>\n", |
454 | 467 | "</div>" |
455 | 468 | ], |
456 | 469 | "text/plain": [ |
457 | 470 | " 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", |
462 | 475 | "\n", |
463 | 476 | " 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 " |
468 | 481 | ] |
469 | 482 | }, |
470 | 483 | "execution_count": 7, |
|
539 | 552 | "name": "stdout", |
540 | 553 | "output_type": "stream", |
541 | 554 | "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" |
545 | 558 | ] |
546 | 559 | } |
547 | 560 | ], |
|
882 | 895 | "=== Average Metrics ===\n", |
883 | 896 | " Depth (2Q) Gates Time (s)\n", |
884 | 897 | "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", |
887 | 900 | "Depth-LNN-KMS 70.8 531.6 0.017\n", |
888 | 901 | "\n", |
889 | 902 | "Best Non-AI Method (based on least average depth): Basic\n", |
|
922 | 935 | " <tr>\n", |
923 | 936 | " <th>0</th>\n", |
924 | 937 | " <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", |
928 | 941 | " </tr>\n", |
929 | 942 | " <tr>\n", |
930 | 943 | " <th>1</th>\n", |
931 | 944 | " <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", |
935 | 948 | " </tr>\n", |
936 | 949 | " <tr>\n", |
937 | 950 | " <th>2</th>\n", |
938 | 951 | " <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", |
942 | 955 | " </tr>\n", |
943 | 956 | " </tbody>\n", |
944 | 957 | "</table>\n", |
945 | 958 | "</div>" |
946 | 959 | ], |
947 | 960 | "text/plain": [ |
948 | 961 | " 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" |
952 | 965 | ] |
953 | 966 | }, |
954 | 967 | "execution_count": 13, |
|
0 commit comments