420
420
C3XGate ,
421
421
C4XGate ,
422
422
PauliEvolutionGate ,
423
+ PermutationGate ,
424
+ MCMTGate ,
423
425
ModularAdderGate ,
424
426
HalfAdderGate ,
425
427
FullAdderGate ,
426
428
MultiplierGate ,
427
429
)
428
- from qiskit .transpiler .exceptions import TranspilerError
429
430
from qiskit .transpiler .coupling import CouplingMap
430
431
431
432
from qiskit .synthesis .clifford import (
467
468
multiplier_qft_r17 ,
468
469
multiplier_cumulative_h18 ,
469
470
)
471
+ from qiskit .quantum_info .operators import Clifford
470
472
from qiskit .transpiler .passes .routing .algorithms import ApproximateTokenSwapper
471
473
from .plugin import HighLevelSynthesisPlugin
472
474
@@ -484,6 +486,9 @@ class DefaultSynthesisClifford(HighLevelSynthesisPlugin):
484
486
485
487
def run (self , high_level_object , coupling_map = None , target = None , qubits = None , ** options ):
486
488
"""Run synthesis for the given Clifford."""
489
+ if not isinstance (high_level_object , Clifford ):
490
+ return None
491
+
487
492
decomposition = synth_clifford_full (high_level_object )
488
493
return decomposition
489
494
@@ -497,6 +502,9 @@ class AGSynthesisClifford(HighLevelSynthesisPlugin):
497
502
498
503
def run (self , high_level_object , coupling_map = None , target = None , qubits = None , ** options ):
499
504
"""Run synthesis for the given Clifford."""
505
+ if not isinstance (high_level_object , Clifford ):
506
+ return None
507
+
500
508
decomposition = synth_clifford_ag (high_level_object )
501
509
return decomposition
502
510
@@ -513,10 +521,14 @@ class BMSynthesisClifford(HighLevelSynthesisPlugin):
513
521
514
522
def run (self , high_level_object , coupling_map = None , target = None , qubits = None , ** options ):
515
523
"""Run synthesis for the given Clifford."""
524
+ if not isinstance (high_level_object , Clifford ):
525
+ return None
526
+
516
527
if high_level_object .num_qubits <= 3 :
517
528
decomposition = synth_clifford_bm (high_level_object )
518
529
else :
519
530
decomposition = None
531
+
520
532
return decomposition
521
533
522
534
@@ -530,6 +542,9 @@ class GreedySynthesisClifford(HighLevelSynthesisPlugin):
530
542
531
543
def run (self , high_level_object , coupling_map = None , target = None , qubits = None , ** options ):
532
544
"""Run synthesis for the given Clifford."""
545
+ if not isinstance (high_level_object , Clifford ):
546
+ return None
547
+
533
548
decomposition = synth_clifford_greedy (high_level_object )
534
549
return decomposition
535
550
@@ -544,6 +559,9 @@ class LayerSynthesisClifford(HighLevelSynthesisPlugin):
544
559
545
560
def run (self , high_level_object , coupling_map = None , target = None , qubits = None , ** options ):
546
561
"""Run synthesis for the given Clifford."""
562
+ if not isinstance (high_level_object , Clifford ):
563
+ return None
564
+
547
565
decomposition = synth_clifford_layers (high_level_object )
548
566
return decomposition
549
567
@@ -559,6 +577,9 @@ class LayerLnnSynthesisClifford(HighLevelSynthesisPlugin):
559
577
560
578
def run (self , high_level_object , coupling_map = None , target = None , qubits = None , ** options ):
561
579
"""Run synthesis for the given Clifford."""
580
+ if not isinstance (high_level_object , Clifford ):
581
+ return None
582
+
562
583
decomposition = synth_clifford_depth_lnn (high_level_object )
563
584
return decomposition
564
585
@@ -572,6 +593,9 @@ class DefaultSynthesisLinearFunction(HighLevelSynthesisPlugin):
572
593
573
594
def run (self , high_level_object , coupling_map = None , target = None , qubits = None , ** options ):
574
595
"""Run synthesis for the given LinearFunction."""
596
+ if not isinstance (high_level_object , LinearFunction ):
597
+ return None
598
+
575
599
decomposition = synth_cnot_count_full_pmh (high_level_object .linear )
576
600
return decomposition
577
601
@@ -595,11 +619,8 @@ class KMSSynthesisLinearFunction(HighLevelSynthesisPlugin):
595
619
596
620
def run (self , high_level_object , coupling_map = None , target = None , qubits = None , ** options ):
597
621
"""Run synthesis for the given LinearFunction."""
598
-
599
622
if not isinstance (high_level_object , LinearFunction ):
600
- raise TranspilerError (
601
- "PMHSynthesisLinearFunction only accepts objects of type LinearFunction"
602
- )
623
+ return None
603
624
604
625
use_inverted = options .get ("use_inverted" , False )
605
626
use_transposed = options .get ("use_transposed" , False )
@@ -646,11 +667,8 @@ class PMHSynthesisLinearFunction(HighLevelSynthesisPlugin):
646
667
647
668
def run (self , high_level_object , coupling_map = None , target = None , qubits = None , ** options ):
648
669
"""Run synthesis for the given LinearFunction."""
649
-
650
670
if not isinstance (high_level_object , LinearFunction ):
651
- raise TranspilerError (
652
- "PMHSynthesisLinearFunction only accepts objects of type LinearFunction"
653
- )
671
+ return None
654
672
655
673
section_size = options .get ("section_size" , 2 )
656
674
use_inverted = options .get ("use_inverted" , False )
@@ -682,6 +700,9 @@ class KMSSynthesisPermutation(HighLevelSynthesisPlugin):
682
700
683
701
def run (self , high_level_object , coupling_map = None , target = None , qubits = None , ** options ):
684
702
"""Run synthesis for the given Permutation."""
703
+ if not isinstance (high_level_object , PermutationGate ):
704
+ return None
705
+
685
706
decomposition = synth_permutation_depth_lnn_kms (high_level_object .pattern )
686
707
return decomposition
687
708
@@ -695,6 +716,9 @@ class BasicSynthesisPermutation(HighLevelSynthesisPlugin):
695
716
696
717
def run (self , high_level_object , coupling_map = None , target = None , qubits = None , ** options ):
697
718
"""Run synthesis for the given Permutation."""
719
+ if not isinstance (high_level_object , PermutationGate ):
720
+ return None
721
+
698
722
decomposition = synth_permutation_basic (high_level_object .pattern )
699
723
return decomposition
700
724
@@ -708,6 +732,9 @@ class ACGSynthesisPermutation(HighLevelSynthesisPlugin):
708
732
709
733
def run (self , high_level_object , coupling_map = None , target = None , qubits = None , ** options ):
710
734
"""Run synthesis for the given Permutation."""
735
+ if not isinstance (high_level_object , PermutationGate ):
736
+ return None
737
+
711
738
decomposition = synth_permutation_acg (high_level_object .pattern )
712
739
return decomposition
713
740
@@ -858,6 +885,9 @@ class TokenSwapperSynthesisPermutation(HighLevelSynthesisPlugin):
858
885
def run (self , high_level_object , coupling_map = None , target = None , qubits = None , ** options ):
859
886
"""Run synthesis for the given Permutation."""
860
887
888
+ if not isinstance (high_level_object , PermutationGate ):
889
+ return None
890
+
861
891
trials = options .get ("trials" , 5 )
862
892
seed = options .get ("seed" , 0 )
863
893
parallel_threshold = options .get ("parallel_threshold" , 50 )
@@ -1156,6 +1186,9 @@ class MCMTSynthesisDefault(HighLevelSynthesisPlugin):
1156
1186
1157
1187
def run (self , high_level_object , coupling_map = None , target = None , qubits = None , ** options ):
1158
1188
# first try to use the V-chain synthesis if enough auxiliary qubits are available
1189
+ if not isinstance (high_level_object , MCMTGate ):
1190
+ return None
1191
+
1159
1192
if (
1160
1193
decomposition := MCMTSynthesisVChain ().run (
1161
1194
high_level_object , coupling_map , target , qubits , ** options
@@ -1170,6 +1203,9 @@ class MCMTSynthesisNoAux(HighLevelSynthesisPlugin):
1170
1203
"""A V-chain based synthesis for ``MCMTGate``."""
1171
1204
1172
1205
def run (self , high_level_object , coupling_map = None , target = None , qubits = None , ** options ):
1206
+ if not isinstance (high_level_object , MCMTGate ):
1207
+ return None
1208
+
1173
1209
base_gate = high_level_object .base_gate
1174
1210
ctrl_state = options .get ("ctrl_state" , None )
1175
1211
@@ -1195,6 +1231,9 @@ class MCMTSynthesisVChain(HighLevelSynthesisPlugin):
1195
1231
"""A V-chain based synthesis for ``MCMTGate``."""
1196
1232
1197
1233
def run (self , high_level_object , coupling_map = None , target = None , qubits = None , ** options ):
1234
+ if not isinstance (high_level_object , MCMTGate ):
1235
+ return None
1236
+
1198
1237
if options .get ("num_clean_ancillas" , 0 ) < high_level_object .num_ctrl_qubits - 1 :
1199
1238
return None # insufficient number of auxiliary qubits
1200
1239
0 commit comments