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,29 +483,18 @@ 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- ),
505- FullAncillaAllocation (coupling_map = CouplingMap (device .build_coupling_map ())),
506- EnlargeWithAncilla (),
507- ApplyLayout (),
497+ transpile_pass = lambda device : [
508498 SafeAIRouting (coupling_map = device .build_coupling_map (), optimization_level = 3 , layout_mode = "optimize" ),
509499 ],
510500 )
@@ -532,20 +522,6 @@ def get_openqasm_gates() -> list[str]:
532522 )
533523)
534524
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- )
549525
550526register_action (
551527 DeviceDependentAction (
@@ -579,45 +555,11 @@ def get_openqasm_gates() -> list[str]:
579555 FullAncillaAllocation (coupling_map = CouplingMap (device .build_coupling_map ())),
580556 EnlargeWithAncilla (),
581557 ApplyLayout (),
582- SafeAIRouting (coupling_map = device .build_coupling_map (), optimization_level = 3 , layout_mode = "optimize " ),
558+ SafeAIRouting (coupling_map = device .build_coupling_map (), optimization_level = 3 , layout_mode = "improve " ),
583559 ],
584560 )
585561)
586562
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- )
621563
622564register_action (
623565 DeviceDependentAction (
@@ -691,7 +633,7 @@ def get_openqasm_gates() -> list[str]:
691633 condition = lambda property_set : property_set ["VF2Layout_stop_reason" ]
692634 != VF2LayoutStopReason .SOLUTION_FOUND ,
693635 ),
694- SafeAIRouting (coupling_map = device .build_coupling_map (), optimization_level = 3 , layout_mode = "optimize " ),
636+ SafeAIRouting (coupling_map = device .build_coupling_map (), optimization_level = 3 , layout_mode = "improve " ),
695637 ],
696638 )
697639)
@@ -707,22 +649,22 @@ def get_openqasm_gates() -> list[str]:
707649 )
708650)
709651
710- register_action (
711- DeviceDependentAction (
712- "BQSKitSynthesis" ,
713- CompilationOrigin .BQSKIT ,
714- PassType .SYNTHESIS ,
715- transpile_pass = lambda device : lambda bqskit_circuit : bqskit_compile (
716- bqskit_circuit ,
717- model = MachineModel (bqskit_circuit .num_qudits , gate_set = get_bqskit_native_gates (device )),
718- optimization_level = 1 if os .getenv ("GITHUB_ACTIONS" ) == "true" else 2 ,
719- synthesis_epsilon = 1e-1 if os .getenv ("GITHUB_ACTIONS" ) == "true" else 1e-8 ,
720- max_synthesis_size = 2 if os .getenv ("GITHUB_ACTIONS" ) == "true" else 3 ,
721- seed = 10 ,
722- num_workers = 1 if os .getenv ("GITHUB_ACTIONS" ) == "true" else - 1 ,
723- ),
724- )
725- )
652+ # register_action(
653+ # DeviceDependentAction(
654+ # "BQSKitSynthesis",
655+ # CompilationOrigin.BQSKIT,
656+ # PassType.SYNTHESIS,
657+ # transpile_pass=lambda device: lambda bqskit_circuit: bqskit_compile(
658+ # bqskit_circuit,
659+ # model=MachineModel(bqskit_circuit.num_qudits, gate_set=get_bqskit_native_gates(device)),
660+ # optimization_level=1 if os.getenv("GITHUB_ACTIONS") == "true" else 2,
661+ # synthesis_epsilon=1e-1 if os.getenv("GITHUB_ACTIONS") == "true" else 1e-8,
662+ # max_synthesis_size=2 if os.getenv("GITHUB_ACTIONS") == "true" else 3,
663+ # seed=10,
664+ # num_workers=1 if os.getenv("GITHUB_ACTIONS") == "true" else -1,
665+ # ),
666+ # )
667+ # )
726668
727669register_action (
728670 DeviceIndependentAction (
0 commit comments