From 7af4e424f0dcff3fe886a4891881e65b00e40bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elena=20Pe=C3=B1a=20Tapia?= <epenatap@gmail.com> Date: Wed, 15 Jan 2025 09:15:32 +0100 Subject: [PATCH] Restore synthesis pm logic --- .../transpiler/preset_passmanagers/common.py | 50 ++++++++++++++----- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/qiskit/transpiler/preset_passmanagers/common.py b/qiskit/transpiler/preset_passmanagers/common.py index a2c479257698..51428fe8aa59 100644 --- a/qiskit/transpiler/preset_passmanagers/common.py +++ b/qiskit/transpiler/preset_passmanagers/common.py @@ -508,7 +508,7 @@ def generate_translation_passmanager( ] elif method == "synthesis": if target is not None and len(target.operation_names) == 0: - synth_block = [ + unroll = [ HighLevelSynthesis( hls_config=hls_config, coupling_map=coupling_map, @@ -517,12 +517,28 @@ def generate_translation_passmanager( basis_gates=basis_gates, min_qubits=3, qubits_initially_zero=qubits_initially_zero, - ) + ), + Unroll3qOrMore(target=target, basis_gates=basis_gates), + Collect2qBlocks(), + Collect1qRuns(), + ConsolidateBlocks( + basis_gates=basis_gates, + target=target, + approximation_degree=approximation_degree, + ), + HighLevelSynthesis( + hls_config=hls_config, + coupling_map=coupling_map, + target=target, + use_qubit_indices=True, + basis_gates=basis_gates, + qubits_initially_zero=qubits_initially_zero, + ), ] else: - # Use unitary synthesis for basis aware decomposition of - # UnitaryGates > 2q before collection - synth_block = [ + unroll = [ + # # Use unitary synthesis for basis aware decomposition of + # UnitaryGates > 2q before collection UnitarySynthesis( basis_gates, approximation_degree=approximation_degree, @@ -542,11 +558,6 @@ def generate_translation_passmanager( min_qubits=3, qubits_initially_zero=qubits_initially_zero, ), - ] - - unroll = ( - synth_block - + [ Unroll3qOrMore(target=target, basis_gates=basis_gates), Collect2qBlocks(), Collect1qRuns(), @@ -555,9 +566,24 @@ def generate_translation_passmanager( target=target, approximation_degree=approximation_degree, ), + UnitarySynthesis( + basis_gates=basis_gates, + approximation_degree=approximation_degree, + coupling_map=coupling_map, + backend_props=backend_props, + plugin_config=unitary_synthesis_plugin_config, + method=unitary_synthesis_method, + target=target, + ), + HighLevelSynthesis( + hls_config=hls_config, + coupling_map=coupling_map, + target=target, + use_qubit_indices=True, + basis_gates=basis_gates, + qubits_initially_zero=qubits_initially_zero, + ), ] - + synth_block - ) else: raise TranspilerError(f"Invalid translation method {method}.") return PassManager(unroll)