-
Notifications
You must be signed in to change notification settings - Fork 715
Add decompositions of RX, RY and RZ into one of the other two + Cliffords
#8569
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #8569 +/- ##
=======================================
Coverage 99.43% 99.43%
=======================================
Files 588 588
Lines 62727 62757 +30
=======================================
+ Hits 62373 62403 +30
Misses 354 354 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| @pytest.mark.parametrize("op", ALL_OPERATIONS) | ||
| def test_assert_valid(self, op): | ||
| kwargs = SKIP_ASSERT_VALID.get(type(op), {}) | ||
| if kwargs is True: | ||
| pytest.skip() | ||
|
|
||
| qml.ops.functions.assert_valid(op, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this!
|
|
||
| add_decomps(RY, _ry_to_rot, _ry_to_rz_rx) | ||
| def _ry_to_rx_cliff_resources(): | ||
| return {change_op_basis_resource_rep(adjoint_resource_rep(qml.S), qml.RX, qml.S): 1} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one checks out!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(checked this one by hand...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
|
|
||
| def _rx_to_rz_cliff_resources(): | ||
| return {change_op_basis_resource_rep(qml.Hadamard, qml.RZ, qml.Hadamard): 1} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know Hadamard transforms between X and Z bases.
| @register_resources(_ry_to_rz_cliff_resources) | ||
| def _ry_to_rz_cliff(phi, wires: WiresLike, **__): | ||
| qml.change_op_basis( | ||
| qml.Hadamard(wires) @ qml.adjoint(qml.S(wires)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one checks out!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wires = 0
phi = 1.5 * 3.14
matrix = qml.matrix(qml.S(wires) @ qml.Hadamard(wires) @ qml.RZ(phi, wires) @ qml.Hadamard(wires) @ qml.adjoint(qml.S(wires)))
ry = qml.matrix(qml.RY(phi, wires))
assert np.allclose(matrix, ry)
| @register_resources(_rz_to_ry_cliff_resources) | ||
| def _rz_to_ry_cliff(phi, wires: WiresLike, **__): | ||
| qml.change_op_basis( | ||
| qml.S(wires) @ qml.Hadamard(wires), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checks out.
wires = 0
phi = 1.5 * 3.14
matrix = qml.matrix(qml.Hadamard(wires) @ qml.adjoint(qml.S(wires)) @ qml.RY(phi, wires) @ qml.S(wires) @ qml.Hadamard(wires))
rz = qml.matrix(qml.RZ(phi, wires))
assert np.allclose(matrix, rz)
comp-phys-marc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the decompositions look right!
|
Does this PR affect ftqc somehow? https://github.com/PennyLaneAI/pennylane/actions/runs/19030113144/job/54341829822?pr=8569 |
doc/releases/changelog-dev.md
Outdated
|
|
||
| <h3>Improvements 🛠</h3> | ||
|
|
||
| <<<<<<< HEAD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops... looks like a bad merge here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is a GH issue. Recently somehow you can't trust the GH entry point from the notifications any more; we have to go back to the PR and click the files section to see the correct diff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc/releases/changelog-dev.md
Outdated
|
|
||
| <h3>Breaking changes 💔</h3> | ||
|
|
||
| <<<<<<< HEAD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bad merge here too.


Context:
The Clifford group by definition can transform Paulis to each other. In particular, we can conjugate
RX,RYandRZby appropriate Cliffords to get either one of the other rotations.Description of the Change:
Add decompositions within the graph-based system that implement this. It amounts to 6 rules (
RX->RYRX->RZ,RY->RXRY->RZ,RZ->RXRZ->RY).Also, add an
assert_validtest to all standard ops.Benefits:
More versatile decomposition, in particular in the context of phase polynomials which prefer
RZoverRXorRYrotations.Possible Drawbacks:
N/A
Related GitHub Issues: