From 4f2bfc2ac6c5f473f86bdf4b4f50f065d267d087 Mon Sep 17 00:00:00 2001 From: Alec Edgington Date: Mon, 18 Nov 2024 16:12:59 +0000 Subject: [PATCH 1/4] Deprecate GlobalisePhasedX. --- pytket/binders/passes.cpp | 12 +++++++++++- pytket/binders/transform.cpp | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/pytket/binders/passes.cpp b/pytket/binders/passes.cpp index 081937323d..887a5058c3 100644 --- a/pytket/binders/passes.cpp +++ b/pytket/binders/passes.cpp @@ -489,7 +489,16 @@ PYBIND11_MODULE(passes, m) { "DecomposeMultiQubitsCX", &DecomposeMultiQubitsCX, "Converts all multi-qubit gates into CX and single-qubit gates."); m.def( - "GlobalisePhasedX", &GlobalisePhasedX, + "GlobalisePhasedX", + [](bool squash) { + PyErr_WarnEx( + PyExc_DeprecationWarning, + "The GlobalisePhasedX pass is unreliable and deprecated. It will " + "be " + "removed after pytket version 1.38.", + 1); + return GlobalisePhasedX(squash); + }, "Turns all PhasedX and NPhasedX gates into global gates\n\n" "Replaces any PhasedX gates with global NPhasedX gates. " "By default, this transform will squash all single-qubit gates " @@ -499,6 +508,7 @@ PYBIND11_MODULE(passes, m) { "performance. If squashing is disabled, each non-global PhasedX gate " "will be replaced with two global NPhasedX, but any other gates will " "be left untouched." + "\n\nDEPRECATED: This pass will be removed after pytket version 1.39." "\n\n:param squash: Whether to squash the circuit in pre-processing " "(default: true)." "\n\nIf squash=true (default), the `GlobalisePhasedX` transform's " diff --git a/pytket/binders/transform.cpp b/pytket/binders/transform.cpp index cfd70bcec3..a357b23df8 100644 --- a/pytket/binders/transform.cpp +++ b/pytket/binders/transform.cpp @@ -386,7 +386,15 @@ PYBIND11_MODULE(transform, m) { "DecomposeNPhasedX", &Transforms::decompose_NPhasedX, "Decompose NPhasedX gates into single-qubit PhasedX gates.") .def_static( - "GlobalisePhasedX", &Transforms::globalise_PhasedX, + "GlobalisePhasedX", + [](bool squash) { + PyErr_WarnEx( + PyExc_DeprecationWarning, + "The GlobalisePhasedX transform is unreliable and deprecated. " + "It will be removed after pytket version 1.38.", + 1); + return Transforms::globalise_PhasedX(squash); + }, "Turns all PhasedX and NPhasedX gates into global gates\n\n" "Replaces any PhasedX gates with global NPhasedX gates. " "By default, this transform will squash all single-qubit gates " @@ -396,6 +404,8 @@ PYBIND11_MODULE(transform, m) { "performance. If squashing is disabled, each non-global PhasedX gate " "will be replaced with two global NPhasedX, but any other gates will " "be left untouched." + "\n\nDEPRECATED: This transform will be removed after pytket version " + "1.39." "\n\n:param squash: Whether to squash the circuit in pre-processing " "(default: true)." "\n\nIf squash=true (default), the `GlobalisePhasedX` transform's " From 529fdd33cf8c55c72cf63277d2c69df642f333aa Mon Sep 17 00:00:00 2001 From: Alec Edgington Date: Mon, 18 Nov 2024 16:13:47 +0000 Subject: [PATCH 2/4] Update changelog. --- pytket/docs/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/pytket/docs/changelog.rst b/pytket/docs/changelog.rst index 1e78fcedc6..0c5e383cf0 100644 --- a/pytket/docs/changelog.rst +++ b/pytket/docs/changelog.rst @@ -24,6 +24,7 @@ Features: Deprecations: * Deprecate `ClassicalExpBox` and related methods, in favour of `ClExprOp`. +* Deprecate `GlobalisePhasedX` pass and transform. Fixes: From 58dd29b5e569544c0a6d8de82fbd145cb10a0dd8 Mon Sep 17 00:00:00 2001 From: Alec Edgington Date: Mon, 18 Nov 2024 16:14:07 +0000 Subject: [PATCH 3/4] Regenerate stubs. --- pytket/pytket/_tket/passes.pyi | 2 ++ pytket/pytket/_tket/transform.pyi | 2 ++ 2 files changed, 4 insertions(+) diff --git a/pytket/pytket/_tket/passes.pyi b/pytket/pytket/_tket/passes.pyi index e9fd51a094..ea4a788b17 100644 --- a/pytket/pytket/_tket/passes.pyi +++ b/pytket/pytket/_tket/passes.pyi @@ -439,6 +439,8 @@ def GlobalisePhasedX(squash: bool = True) -> BasePass: Replaces any PhasedX gates with global NPhasedX gates. By default, this transform will squash all single-qubit gates to PhasedX and Rz gates before proceeding further. Existing non-global NPhasedX will not be preserved. This is the recommended setting for best performance. If squashing is disabled, each non-global PhasedX gate will be replaced with two global NPhasedX, but any other gates will be left untouched. + DEPRECATED: This pass will be removed after pytket version 1.39. + :param squash: Whether to squash the circuit in pre-processing (default: true). If squash=true (default), the `GlobalisePhasedX` transform's `apply` method will always return true. For squash=false, `apply()` will return true if the circuit was changed and false otherwise. diff --git a/pytket/pytket/_tket/transform.pyi b/pytket/pytket/_tket/transform.pyi index ce620128b2..385a19b780 100644 --- a/pytket/pytket/_tket/transform.pyi +++ b/pytket/pytket/_tket/transform.pyi @@ -158,6 +158,8 @@ class Transform: Replaces any PhasedX gates with global NPhasedX gates. By default, this transform will squash all single-qubit gates to PhasedX and Rz gates before proceeding further. Existing non-global NPhasedX will not be preserved. This is the recommended setting for best performance. If squashing is disabled, each non-global PhasedX gate will be replaced with two global NPhasedX, but any other gates will be left untouched. + DEPRECATED: This transform will be removed after pytket version 1.39. + :param squash: Whether to squash the circuit in pre-processing (default: true). If squash=true (default), the `GlobalisePhasedX` transform's `apply` method will always return true. For squash=false, `apply()` will return true if the circuit was changed and false otherwise. From 2d72813f2669d3498c07c4f8d42cc406128dc06c Mon Sep 17 00:00:00 2001 From: Alec Edgington Date: Tue, 19 Nov 2024 09:17:55 +0000 Subject: [PATCH 4/4] Update deprecation warnings. --- pytket/binders/passes.cpp | 7 ++++--- pytket/binders/transform.cpp | 7 ++++--- pytket/pytket/_tket/passes.pyi | 2 +- pytket/pytket/_tket/transform.pyi | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pytket/binders/passes.cpp b/pytket/binders/passes.cpp index 887a5058c3..fe3c71a2ca 100644 --- a/pytket/binders/passes.cpp +++ b/pytket/binders/passes.cpp @@ -494,8 +494,8 @@ PYBIND11_MODULE(passes, m) { PyErr_WarnEx( PyExc_DeprecationWarning, "The GlobalisePhasedX pass is unreliable and deprecated. It will " - "be " - "removed after pytket version 1.38.", + "be removed no earlier that three months after the pytket 1.35 " + "release.", 1); return GlobalisePhasedX(squash); }, @@ -508,7 +508,8 @@ PYBIND11_MODULE(passes, m) { "performance. If squashing is disabled, each non-global PhasedX gate " "will be replaced with two global NPhasedX, but any other gates will " "be left untouched." - "\n\nDEPRECATED: This pass will be removed after pytket version 1.39." + "\n\nDEPRECATED: This pass will be removed no earlier than three months " + "after the pytket 1.35 release." "\n\n:param squash: Whether to squash the circuit in pre-processing " "(default: true)." "\n\nIf squash=true (default), the `GlobalisePhasedX` transform's " diff --git a/pytket/binders/transform.cpp b/pytket/binders/transform.cpp index a357b23df8..2aaf153972 100644 --- a/pytket/binders/transform.cpp +++ b/pytket/binders/transform.cpp @@ -391,7 +391,8 @@ PYBIND11_MODULE(transform, m) { PyErr_WarnEx( PyExc_DeprecationWarning, "The GlobalisePhasedX transform is unreliable and deprecated. " - "It will be removed after pytket version 1.38.", + "It will be removed no earlier than three months after the " + "pytket 1.35 release.", 1); return Transforms::globalise_PhasedX(squash); }, @@ -404,8 +405,8 @@ PYBIND11_MODULE(transform, m) { "performance. If squashing is disabled, each non-global PhasedX gate " "will be replaced with two global NPhasedX, but any other gates will " "be left untouched." - "\n\nDEPRECATED: This transform will be removed after pytket version " - "1.39." + "\n\nDEPRECATED: This transform will be removed no earlier than " + "three months after the pytket 1.35 release." "\n\n:param squash: Whether to squash the circuit in pre-processing " "(default: true)." "\n\nIf squash=true (default), the `GlobalisePhasedX` transform's " diff --git a/pytket/pytket/_tket/passes.pyi b/pytket/pytket/_tket/passes.pyi index ea4a788b17..2e19b05c54 100644 --- a/pytket/pytket/_tket/passes.pyi +++ b/pytket/pytket/_tket/passes.pyi @@ -439,7 +439,7 @@ def GlobalisePhasedX(squash: bool = True) -> BasePass: Replaces any PhasedX gates with global NPhasedX gates. By default, this transform will squash all single-qubit gates to PhasedX and Rz gates before proceeding further. Existing non-global NPhasedX will not be preserved. This is the recommended setting for best performance. If squashing is disabled, each non-global PhasedX gate will be replaced with two global NPhasedX, but any other gates will be left untouched. - DEPRECATED: This pass will be removed after pytket version 1.39. + DEPRECATED: This pass will be removed no earlier than three months after the pytket 1.35 release. :param squash: Whether to squash the circuit in pre-processing (default: true). diff --git a/pytket/pytket/_tket/transform.pyi b/pytket/pytket/_tket/transform.pyi index 385a19b780..3648de26da 100644 --- a/pytket/pytket/_tket/transform.pyi +++ b/pytket/pytket/_tket/transform.pyi @@ -158,7 +158,7 @@ class Transform: Replaces any PhasedX gates with global NPhasedX gates. By default, this transform will squash all single-qubit gates to PhasedX and Rz gates before proceeding further. Existing non-global NPhasedX will not be preserved. This is the recommended setting for best performance. If squashing is disabled, each non-global PhasedX gate will be replaced with two global NPhasedX, but any other gates will be left untouched. - DEPRECATED: This transform will be removed after pytket version 1.39. + DEPRECATED: This transform will be removed no earlier than three months after the pytket 1.35 release. :param squash: Whether to squash the circuit in pre-processing (default: true).