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 1/4] [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( From f96c53e1d3e1376fa715912b4d01146f7538be69 Mon Sep 17 00:00:00 2001 From: cqc-melf <70640934+cqc-melf@users.noreply.github.com> Date: Fri, 13 Oct 2023 17:47:56 +0100 Subject: [PATCH 2/4] fixmypy (#66) --- pytket/extensions/iqm/backends/config.py | 6 +++--- pytket/extensions/iqm/backends/iqm.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pytket/extensions/iqm/backends/config.py b/pytket/extensions/iqm/backends/config.py index 7c14c5b..fb717b9 100644 --- a/pytket/extensions/iqm/backends/config.py +++ b/pytket/extensions/iqm/backends/config.py @@ -48,9 +48,9 @@ def set_iqm_config( """Set default value for IQM API token.""" config = IQMConfig.from_default_config_file() if auth_server_url is not None: - config.auth_server_url = auth_server_url # type: ignore + config.auth_server_url = auth_server_url if username is not None: - config.username = username # type: ignore + config.username = username if password is not None: - config.password = password # type: ignore + config.password = password config.update_default_config_file() diff --git a/pytket/extensions/iqm/backends/iqm.py b/pytket/extensions/iqm/backends/iqm.py index 1e15e5c..472386f 100644 --- a/pytket/extensions/iqm/backends/iqm.py +++ b/pytket/extensions/iqm/backends/iqm.py @@ -114,12 +114,12 @@ def __init__( config = IQMConfig.from_default_config_file() if auth_server_url is None: - auth_server_url = config.auth_server_url # type: ignore + auth_server_url = config.auth_server_url tokens_file = os.getenv("IQM_TOKENS_FILE") if username is None: - username = config.username # type: ignore + username = config.username if password is None: - password = config.password # type: ignore + password = config.password if (username is None or password is None) and tokens_file is None: raise IqmAuthenticationError() From f19f22339350ec2b40d8e2a85810d9c332462a98 Mon Sep 17 00:00:00 2001 From: Melf Date: Tue, 17 Oct 2023 10:46:51 +0100 Subject: [PATCH 3/4] update pyktet version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4ce20d9..a4af4aa 100644 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ license="Apache 2", packages=find_namespace_packages(include=["pytket.*"]), include_package_data=True, - install_requires=["pytket ~= 1.20", "iqm-client ~= 14.0"], + install_requires=["pytket ~= 1.21", "iqm-client ~= 14.0"], classifiers=[ "Environment :: Console", "Programming Language :: Python :: 3.9", From 2c36e4fb55a5e7f337223e3fa9b529d5243d3b78 Mon Sep 17 00:00:00 2001 From: Melf Date: Tue, 17 Oct 2023 11:10:22 +0100 Subject: [PATCH 4/4] update version and changelog --- _metadata.py | 2 +- docs/changelog.rst | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/_metadata.py b/_metadata.py index 323ac76..567207f 100644 --- a/_metadata.py +++ b/_metadata.py @@ -1,2 +1,2 @@ -__extension_version__ = "0.7.0" +__extension_version__ = "0.8.0" __extension_name__ = "pytket-iqm" diff --git a/docs/changelog.rst b/docs/changelog.rst index df68019..d3e9177 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,11 +1,12 @@ Changelog ~~~~~~~~~ -Unreleased ----------- +0.8.0 (October 2023) +-------------------- * Don't include ``SimplifyInitial`` in default passes; instead make it an option to ``process_circuits()``. +* Updated pytket version requirement to 1.21. 0.7.0 (October 2023) --------------------