From 8177183086b646126100124d2cd99c0894c4e5e8 Mon Sep 17 00:00:00 2001 From: Alec Edgington <54802828+cqc-alec@users.noreply.github.com> Date: Thu, 5 Oct 2023 13:30:07 +0100 Subject: [PATCH] [feature] Make `SimplifyInitial` opt-in (#65) --- docs/changelog.rst | 6 ++++++ pytket/extensions/iqm/backends/iqm.py | 19 ++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index c34bddf..df68019 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,12 @@ Changelog ~~~~~~~~~ +Unreleased +---------- + +* Don't include ``SimplifyInitial`` in default passes; instead make it an option + to ``process_circuits()``. + 0.7.0 (October 2023) -------------------- diff --git a/pytket/extensions/iqm/backends/iqm.py b/pytket/extensions/iqm/backends/iqm.py index 43585a6..1e15e5c 100644 --- a/pytket/extensions/iqm/backends/iqm.py +++ b/pytket/extensions/iqm/backends/iqm.py @@ -182,12 +182,6 @@ def default_compilation_pass(self, optimisation_level: int = 1) -> BasePass: passes.append(DelayMeasures()) passes.append(self.rebase_pass()) passes.append(RemoveRedundancies()) - if optimisation_level >= 1: - passes.append( - SimplifyInitial( - allow_classical=False, create_all_qubits=True, xcirc=_xcirc - ) - ) return SequencePass(passes) @property @@ -203,7 +197,13 @@ def process_circuits( ) -> List[ResultHandle]: """ See :py:meth:`pytket.backends.Backend.process_circuits`. - Supported kwargs: `postprocess`. + + 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( @@ -216,6 +216,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)): @@ -224,6 +225,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) instrs = _translate_iqm(c0) qm = {str(qb): _as_name(cast(Node, qb)) for qb in c.qubits} iqmc = IQMCircuit(