diff --git a/docs/changelog.rst b/docs/changelog.rst index b766bec..203daa2 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -5,6 +5,9 @@ Changelog ------------ * Add simple automatic placement and routing for multi-zone architectures +* Don't include ``SimplifyInitial`` in default passes; instead make it an option + to ``process_circuits()``. + 0.29.0rc0 (July 2023) --------------------- diff --git a/pytket/extensions/aqt/backends/aqt.py b/pytket/extensions/aqt/backends/aqt.py index 629530f..c1761fe 100644 --- a/pytket/extensions/aqt/backends/aqt.py +++ b/pytket/extensions/aqt/backends/aqt.py @@ -216,9 +216,6 @@ def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass: FlattenRegisters(), RenameQubitsPass(self._qm), self.rebase_pass(), - SimplifyInitial( - allow_classical=False, create_all_qubits=True, xcirc=_xcirc - ), EulerAngleReduction(OpType.Ry, OpType.Rx), ] ) @@ -230,9 +227,6 @@ def default_compilation_pass(self, optimisation_level: int = 2) -> BasePass: FlattenRegisters(), RenameQubitsPass(self._qm), self.rebase_pass(), - SimplifyInitial( - allow_classical=False, create_all_qubits=True, xcirc=_xcirc - ), EulerAngleReduction(OpType.Ry, OpType.Rx), ] ) @@ -250,7 +244,13 @@ def process_circuits( ) -> List[ResultHandle]: """ See :py:meth:`pytket.backends.Backend.process_circuits`. - Supported kwargs: none. + + Supported kwargs: + - `postprocess`: apply end-of-circuit simplifications and classical + postprocessing to improve fidelity of results (bool, default False) + - `simplify_initial`: apply the pytket ``SimplifyInitial`` pass to improve + fidelity of results assuming all qubits initialized to zero (bool, default + False) """ circuits = list(circuits) n_shots_list = Backend._get_n_shots_as_list( @@ -263,6 +263,7 @@ def process_circuits( self._check_all_circuits(circuits) postprocess = kwargs.get("postprocess", False) + simplify_initial = kwargs.get("postprocess", False) handles = [] for i, (c, n_shots) in enumerate(zip(circuits, n_shots_list)): @@ -271,6 +272,10 @@ def process_circuits( ppcirc_rep = ppcirc.to_dict() else: c0, ppcirc_rep = c, None + if simplify_initial: + SimplifyInitial( + allow_classical=False, create_all_qubits=True, xcirc=_xcirc + ).apply(c0) (aqt_circ, measures) = _translate_aqt(c0) if self._MACHINE_DEBUG: handles.append( diff --git a/pytket/extensions/aqt/backends/aqt_multi_zone.py b/pytket/extensions/aqt/backends/aqt_multi_zone.py index f37cd0a..cd75e53 100644 --- a/pytket/extensions/aqt/backends/aqt_multi_zone.py +++ b/pytket/extensions/aqt/backends/aqt_multi_zone.py @@ -42,7 +42,6 @@ from pytket.passes import FullPeepholeOptimise from pytket.passes import RenameQubitsPass from pytket.passes import SequencePass -from pytket.passes import SimplifyInitial from pytket.passes import SynthesiseTket from pytket.predicates import GateSetPredicate from pytket.predicates import MaxNQubitsPredicate @@ -200,9 +199,6 @@ def default_compilation_pass(self, optimisation_level: int = 2) -> SequencePass: FlattenRegisters(), RenameQubitsPass(self._qm), self.rebase_pass(), - SimplifyInitial( - allow_classical=False, create_all_qubits=True, xcirc=_xcirc - ), EulerAngleReduction(OpType.Ry, OpType.Rx), ] ) @@ -214,9 +210,6 @@ def default_compilation_pass(self, optimisation_level: int = 2) -> SequencePass: FlattenRegisters(), RenameQubitsPass(self._qm), self.rebase_pass(), - SimplifyInitial( - allow_classical=False, create_all_qubits=True, xcirc=_xcirc - ), EulerAngleReduction(OpType.Ry, OpType.Rx), ] ) @@ -495,7 +488,3 @@ def swap_position(qubit_1_: int, qubit_2_: int) -> None: def _aqt_rebase() -> BasePass: return auto_rebase_pass({OpType.XXPhase, OpType.Rx, OpType.Ry}) - - -_xcirc = Circuit(1).Rx(1, 0) -_xcirc.add_phase(0.5)