Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate GlobalisePhasedX #1683

Merged
merged 4 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion pytket/binders/passes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand All @@ -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."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to put a specific version, or maybe better a more specific date?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentionally put "after" so as not to be too committal, if we don't want to actually remove it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a date would be better though.

"\n\n:param squash: Whether to squash the circuit in pre-processing "
"(default: true)."
"\n\nIf squash=true (default), the `GlobalisePhasedX` transform's "
Expand Down
12 changes: 11 additions & 1 deletion pytket/binders/transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand All @@ -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 "
Expand Down
1 change: 1 addition & 0 deletions pytket/docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Features:
Deprecations:

* Deprecate `ClassicalExpBox` and related methods, in favour of `ClExprOp`.
* Deprecate `GlobalisePhasedX` pass and transform.

Fixes:

Expand Down
2 changes: 2 additions & 0 deletions pytket/pytket/_tket/passes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions pytket/pytket/_tket/transform.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading