5050from qiskit .transpiler import CouplingMap
5151from qiskit .transpiler .passes import (
5252 ApplyLayout ,
53- BasicSwap ,
5453 BasisTranslator ,
5554 Collect2qBlocks ,
5655 CollectCliffords ,
@@ -125,6 +124,7 @@ class Action:
125124 pass_type : PassType
126125 transpile_pass : (
127126 list [qiskit_BasePass | tket_BasePass ]
127+ | Callable [..., list [Any ]]
128128 | Callable [..., list [qiskit_BasePass | tket_BasePass ]]
129129 | Callable [
130130 ...,
@@ -144,7 +144,8 @@ class DeviceDependentAction(Action):
144144 """Action that represents a device-specific compilation pass that can be applied to a specific device."""
145145
146146 transpile_pass : (
147- Callable [..., list [qiskit_BasePass | tket_BasePass ]]
147+ Callable [..., list [Any ]]
148+ | Callable [..., list [qiskit_BasePass | tket_BasePass ]]
148149 | Callable [
149150 ...,
150151 Callable [..., tuple [Any , ...] | Circuit ],
@@ -466,7 +467,7 @@ def get_openqasm_gates() -> list[str]:
466467
467468register_action (
468469 DeviceDependentAction (
469- "SabreLayout+BasicSwap " ,
470+ "SabreLayout+AIRouting " ,
470471 CompilationOrigin .QISKIT ,
471472 PassType .MAPPING ,
472473 stochastic = True ,
@@ -482,26 +483,19 @@ def get_openqasm_gates() -> list[str]:
482483 FullAncillaAllocation (coupling_map = CouplingMap (device .build_coupling_map ())),
483484 EnlargeWithAncilla (),
484485 ApplyLayout (),
485- BasicSwap (coupling_map = CouplingMap ( device .build_coupling_map ()) ),
486+ SafeAIRouting (coupling_map = device .build_coupling_map (), optimization_level = 3 , layout_mode = "improve" ),
486487 ],
487488 )
488489)
489490
490491register_action (
491492 DeviceDependentAction (
492- "SabreLayout+ AIRouting" ,
493+ "AIRouting" ,
493494 CompilationOrigin .QISKIT ,
494495 PassType .MAPPING ,
495496 stochastic = True ,
496- transpile_pass = lambda device , max_iteration = (20 , 20 ): [
497- SabreLayout (
498- coupling_map = CouplingMap (device .build_coupling_map ()),
499- skip_routing = True ,
500- layout_trials = max_iteration [0 ],
501- swap_trials = max_iteration [1 ],
502- max_iterations = 4 ,
503- seed = None ,
504- ),
497+ transpile_pass = lambda device : [
498+ TrivialLayout (coupling_map = CouplingMap (device .build_coupling_map ())),
505499 FullAncillaAllocation (coupling_map = CouplingMap (device .build_coupling_map ())),
506500 EnlargeWithAncilla (),
507501 ApplyLayout (),
@@ -532,20 +526,6 @@ def get_openqasm_gates() -> list[str]:
532526 )
533527)
534528
535- register_action (
536- DeviceDependentAction (
537- name = "DenseLayout+BasicSwap" ,
538- origin = CompilationOrigin .QISKIT ,
539- pass_type = PassType .MAPPING ,
540- transpile_pass = lambda device : [
541- DenseLayout (coupling_map = CouplingMap (device .build_coupling_map ())),
542- FullAncillaAllocation (coupling_map = CouplingMap (device .build_coupling_map ())),
543- EnlargeWithAncilla (),
544- ApplyLayout (),
545- BasicSwap (coupling_map = CouplingMap (device .build_coupling_map ())),
546- ],
547- )
548- )
549529
550530register_action (
551531 DeviceDependentAction (
@@ -579,45 +559,11 @@ def get_openqasm_gates() -> list[str]:
579559 FullAncillaAllocation (coupling_map = CouplingMap (device .build_coupling_map ())),
580560 EnlargeWithAncilla (),
581561 ApplyLayout (),
582- SafeAIRouting (coupling_map = device .build_coupling_map (), optimization_level = 3 , layout_mode = "optimize " ),
562+ SafeAIRouting (coupling_map = device .build_coupling_map (), optimization_level = 3 , layout_mode = "improve " ),
583563 ],
584564 )
585565)
586566
587- register_action (
588- DeviceDependentAction (
589- name = "VF2Layout+BasicSwap" ,
590- origin = CompilationOrigin .QISKIT ,
591- pass_type = PassType .MAPPING ,
592- transpile_pass = lambda device : [
593- VF2Layout (
594- coupling_map = CouplingMap (device .build_coupling_map ()),
595- target = device ,
596- ),
597- ConditionalController (
598- [
599- FullAncillaAllocation (coupling_map = CouplingMap (device .build_coupling_map ())),
600- EnlargeWithAncilla (),
601- ApplyLayout (),
602- ],
603- condition = lambda property_set : property_set ["VF2Layout_stop_reason" ]
604- == VF2LayoutStopReason .SOLUTION_FOUND ,
605- ),
606- ConditionalController (
607- [
608- TrivialLayout (coupling_map = CouplingMap (device .build_coupling_map ())),
609- FullAncillaAllocation (coupling_map = CouplingMap (device .build_coupling_map ())),
610- EnlargeWithAncilla (),
611- ApplyLayout (),
612- ],
613- # Run if VF2Layout did not find a solution
614- condition = lambda property_set : property_set ["VF2Layout_stop_reason" ]
615- != VF2LayoutStopReason .SOLUTION_FOUND ,
616- ),
617- BasicSwap (coupling_map = CouplingMap (device .build_coupling_map ())),
618- ],
619- )
620- )
621567
622568register_action (
623569 DeviceDependentAction (
@@ -691,7 +637,7 @@ def get_openqasm_gates() -> list[str]:
691637 condition = lambda property_set : property_set ["VF2Layout_stop_reason" ]
692638 != VF2LayoutStopReason .SOLUTION_FOUND ,
693639 ),
694- SafeAIRouting (coupling_map = device .build_coupling_map (), optimization_level = 3 , layout_mode = "optimize " ),
640+ SafeAIRouting (coupling_map = device .build_coupling_map (), optimization_level = 3 , layout_mode = "improve " ),
695641 ],
696642 )
697643)
0 commit comments