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

Enhance merge_rotations transform #7009

Closed
andrijapau opened this issue Feb 26, 2025 · 1 comment
Closed

Enhance merge_rotations transform #7009

andrijapau opened this issue Feb 26, 2025 · 1 comment
Labels
enhancement ✨ New feature or request

Comments

@andrijapau
Copy link
Contributor

Feature details

We currently have the behaviour,

@qml.transforms.optimization.merge_rotations
@qml.qnode(dev)
def qfunc_decomposed():
    qml.RZ(-1., 0)
    qml.RY(0, 0)
    qml.RZ(1, 0)
    qml.RZ(-1, 0)
    qml.RY(0, 0)
    qml.RZ(1., 0)

>>> print(qml.draw(qfunc_decomposed)())
0: ──RZ(-1.00)──RZ(1.00)─┤ # Should cancel! 

Which suggests the algorithm is unable to collapse and merge rotation gates correctly. This can be remedied by another pass with the transform but ideally it should happen all at once.

Implementation

Requires modifying the algorithmic implementation found in pennylane/transforms/optimization/merge_rotations.py.

How important would you say this feature is?

1: Not important. Would be nice to have.

Additional information

Once the enhancement has been made, relevant tests should be added.

@andrijapau
Copy link
Contributor Author

Closing this issue after internal discussion. 🥳

Summary: According to the docstring of this transform,

"""Quantum transform to combine rotation gates of the same type that act sequentially."""

this is expected behaviour. If the user wishes to merge all of them they would have to use single_qubit_fusion or multiple compilation passes with this transform. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant