@@ -989,37 +989,49 @@ def build_multi_qudit_retarget_workflow(
989989 """
990990 Build standard workflow for circuit multi-qudit gate set retargeting.
991991
992- This workflow assumes that SetModelPass will be run earlier in the full
993- workflow and doesn't add it in here.
992+ Notes:
993+ - This workflow assumes that SetModelPass will be run earlier in the
994+ full workflow and doesn't add it in here.
995+
996+ - For the most part, circuit connectivity isn't a concern during
997+ retargeting. However, if the circuit contains many-qudit (>= 3)
998+ gates, then the workflow will not preserve connectivity during
999+ the decomposition of those gates. If your input contains many-qudit
1000+ gates, consider following this with a mapping workflow.
9941001 """
1002+
1003+ core_retarget_workflow = [
1004+ FillSingleQuditGatesPass (),
1005+ IfThenElsePass (
1006+ NotPredicate (MultiPhysicalPredicate ()),
1007+ IfThenElsePass (
1008+ ManyQuditGatesPredicate (),
1009+ [
1010+ ExtractModelConnectivityPass (),
1011+ build_standard_search_synthesis_workflow (
1012+ optimization_level ,
1013+ synthesis_epsilon ,
1014+ ),
1015+ RestoreModelConnevtivityPass (),
1016+ ],
1017+ AutoRebase2QuditGatePass (3 , 5 ),
1018+ ),
1019+ ScanningGateRemovalPass (
1020+ success_threshold = synthesis_epsilon ,
1021+ collection_filter = _mq_gate_collection_filter ,
1022+ instantiate_options = get_instantiate_options (optimization_level ),
1023+ ),
1024+ ),
1025+ ]
1026+
9951027 return Workflow (
9961028 [
9971029 IfThenElsePass (
9981030 NotPredicate (WidthPredicate (2 )),
9991031 [
10001032 LogPass ('Retargeting multi-qudit gates.' ),
10011033 build_partitioning_workflow (
1002- [
1003- FillSingleQuditGatesPass (),
1004- IfThenElsePass (
1005- NotPredicate (MultiPhysicalPredicate ()),
1006- IfThenElsePass (
1007- ManyQuditGatesPredicate (),
1008- build_standard_search_synthesis_workflow (
1009- optimization_level ,
1010- synthesis_epsilon ,
1011- ),
1012- AutoRebase2QuditGatePass (3 , 5 ),
1013- ),
1014- ScanningGateRemovalPass (
1015- success_threshold = synthesis_epsilon ,
1016- collection_filter = _mq_gate_collection_filter , # noqa: E501
1017- instantiate_options = get_instantiate_options (
1018- optimization_level ,
1019- ),
1020- ),
1021- ),
1022- ],
1034+ core_retarget_workflow ,
10231035 max_synthesis_size ,
10241036 None if error_threshold is None else error_sim_size ,
10251037 ),
@@ -1221,6 +1233,7 @@ def build_seqpam_mapping_optimization_workflow(
12211233 IfThenElsePass (
12221234 NotPredicate (WidthPredicate (2 )),
12231235 [
1236+ LogPass ('Caching permutation-aware synthesis results.' ),
12241237 ExtractModelConnectivityPass (),
12251238 QuickPartitioner (block_size ),
12261239 ForEachBlockPass (
@@ -1240,11 +1253,13 @@ def build_seqpam_mapping_optimization_workflow(
12401253 ),
12411254 ),
12421255 ),
1256+ LogPass ('Preoptimizing with permutation-aware mapping.' ),
12431257 PAMRoutingPass (),
12441258 post_pam_seq ,
12451259 UnfoldPass (),
12461260 RestoreModelConnevtivityPass (),
12471261
1262+ LogPass ('Recaching permutation-aware synthesis results.' ),
12481263 SubtopologySelectionPass (block_size ),
12491264 QuickPartitioner (block_size ),
12501265 ForEachBlockPass (
@@ -1264,6 +1279,7 @@ def build_seqpam_mapping_optimization_workflow(
12641279 ),
12651280 ),
12661281 ),
1282+ LogPass ('Performing permutation-aware mapping.' ),
12671283 ApplyPlacement (),
12681284 PAMLayoutPass (num_layout_passes ),
12691285 PAMRoutingPass (0.1 ),
0 commit comments