|
58 | 58 | "metadata": {}, |
59 | 59 | "outputs": [], |
60 | 60 | "source": [ |
| 61 | + "# This import is needed for python versions prior to 3.10\n", |
| 62 | + "from __future__ import annotations\n", |
| 63 | + "\n", |
61 | 64 | "from qiskit.transpiler import PassManager\n", |
62 | 65 | "from qiskit.transpiler.passes import VF2Layout\n", |
63 | 66 | "from qiskit.transpiler.passmanager_config import PassManagerConfig\n", |
|
163 | 166 | "id": "d62c4edb", |
164 | 167 | "metadata": {}, |
165 | 168 | "source": [ |
166 | | - "If our example plugin were installed, then the name `my_layout` would appear in this list." |
| 169 | + "If our example plugin were installed, then the name `my_layout` would appear in this list.\n", |
| 170 | + "\n", |
| 171 | + "If you want to use a built-in transpiler stage as the starting point for your transpiler stage plugin, you can obtain the pass manager for a built-in transpiler stage using [PassManagerStagePluginManager](/api/qiskit/qiskit.transpiler.preset_passmanagers.plugin.PassManagerStagePluginManager#passmanagerstagepluginmanager). The following code cell shows how to do this to obtain the built-in optimization stage for optimization level 3." |
| 172 | + ] |
| 173 | + }, |
| 174 | + { |
| 175 | + "cell_type": "code", |
| 176 | + "execution_count": 3, |
| 177 | + "id": "f4d578d6", |
| 178 | + "metadata": {}, |
| 179 | + "outputs": [], |
| 180 | + "source": [ |
| 181 | + "from qiskit.transpiler.passmanager_config import PassManagerConfig\n", |
| 182 | + "from qiskit.transpiler.preset_passmanagers.plugin import PassManagerStagePluginManager\n", |
| 183 | + "\n", |
| 184 | + "# Initialize the plugin manager\n", |
| 185 | + "plugin_manager = PassManagerStagePluginManager()\n", |
| 186 | + "\n", |
| 187 | + "# Here we create a pass manager config to use as an example.\n", |
| 188 | + "# Instead, you should use the pass manager config that you already received as input\n", |
| 189 | + "# to the pass_manager method of your PassManagerStagePlugin.\n", |
| 190 | + "pass_manager_config = PassManagerConfig()\n", |
| 191 | + "\n", |
| 192 | + "# Obtain the desired built-in transpiler stage\n", |
| 193 | + "optimization = plugin_manager.get_passmanager_stage(\n", |
| 194 | + " \"optimization\", \"default\", pass_manager_config, optimization_level=3\n", |
| 195 | + ")" |
167 | 196 | ] |
168 | 197 | }, |
169 | 198 | { |
|
188 | 217 | }, |
189 | 218 | { |
190 | 219 | "cell_type": "code", |
191 | | - "execution_count": 3, |
| 220 | + "execution_count": 4, |
192 | 221 | "id": "6bc1011c-b15d-4210-973b-d9d530ece880", |
193 | 222 | "metadata": {}, |
194 | 223 | "outputs": [], |
|
324 | 353 | }, |
325 | 354 | { |
326 | 355 | "cell_type": "code", |
327 | | - "execution_count": 4, |
| 356 | + "execution_count": 5, |
328 | 357 | "id": "31bfaf30", |
329 | 358 | "metadata": {}, |
330 | 359 | "outputs": [ |
331 | 360 | { |
332 | 361 | "data": { |
333 | 362 | "text/plain": [ |
334 | | - "['aqc', 'default', 'sk']" |
| 363 | + "['default', 'sk', 'aqc']" |
335 | 364 | ] |
336 | 365 | }, |
337 | | - "execution_count": 4, |
| 366 | + "execution_count": 5, |
338 | 367 | "metadata": {}, |
339 | 368 | "output_type": "execute_result" |
340 | 369 | } |
|
397 | 426 | }, |
398 | 427 | { |
399 | 428 | "cell_type": "code", |
400 | | - "execution_count": 5, |
| 429 | + "execution_count": 6, |
401 | 430 | "id": "3c0e59d4-85b0-4157-824b-b1f6220e83ad", |
402 | 431 | "metadata": {}, |
403 | 432 | "outputs": [], |
|
469 | 498 | }, |
470 | 499 | { |
471 | 500 | "cell_type": "code", |
472 | | - "execution_count": 6, |
| 501 | + "execution_count": 7, |
473 | 502 | "id": "fbe1f265", |
474 | 503 | "metadata": {}, |
475 | 504 | "outputs": [ |
476 | 505 | { |
477 | 506 | "data": { |
478 | 507 | "text/plain": [ |
479 | | - "['ag', 'bm', 'default', 'greedy', 'layers', 'lnn']" |
| 508 | + "['rb_default', 'ag', 'bm', 'default', 'greedy', 'layers', 'lnn']" |
480 | 509 | ] |
481 | 510 | }, |
482 | | - "execution_count": 6, |
| 511 | + "execution_count": 7, |
483 | 512 | "metadata": {}, |
484 | 513 | "output_type": "execute_result" |
485 | 514 | } |
|
0 commit comments