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

[BUG] qml.transforms.to_zx not properly translating adjoint ops #7002

Open
Qottmann opened this issue Feb 25, 2025 · 0 comments
Open

[BUG] qml.transforms.to_zx not properly translating adjoint ops #7002

Qottmann opened this issue Feb 25, 2025 · 0 comments
Labels
bug 🐛 Something isn't working

Comments

@Qottmann
Copy link
Contributor

The main culprit is that pyzx is working with exact fractions whereas pennylane works with float numbers.
In many cases, a proper translation in qml.transforms.to_zx is provided, but some are missing and causing problems.

adjoint ops are not properly translated

def qfunc():
    qml.T(0)
    qml.adjoint(qml.T(0))

import pyzx as zx

g = qml.transforms.to_zx(qfunc)()
zx.draw(g)

Image

We see the first bare T gate is properly translated to a Z_pi/4 spider, but its adjoint is not.
This makes retrieving the PL circuit impossible:

>>> qml.transforms.from_zx(g)
(..)
AttributeError: 'float' object has no attribute 'denominator'

This is a problem because decompositions of e.g. Toffoli gates contain adjoint T and S gates.

@Qottmann Qottmann added the bug 🐛 Something isn't working label Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant