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] CNOT decomposes to CNOT #5711

Closed
1 task done
lillian542 opened this issue May 17, 2024 · 0 comments · Fixed by #6039
Closed
1 task done

[BUG] CNOT decomposes to CNOT #5711

lillian542 opened this issue May 17, 2024 · 0 comments · Fixed by #6039
Assignees
Labels
bug 🐛 Something isn't working

Comments

@lillian542
Copy link
Contributor

Expected behavior

A decomposition should always return either an error, or a decomposition into other operators

Actual behavior

CNOT decomposes into CNOT

Additional information

No response

Source code

>>> qml.CNOT([0, 1]).decomposition()
[CNOT(wires=[0, 1])]

Tracebacks

-

System information

pl dev

Existing GitHub issues

  • I have searched existing GitHub issues to make sure the issue does not already exist.
@lillian542 lillian542 added the bug 🐛 Something isn't working label May 17, 2024
@lillian542 lillian542 self-assigned this May 17, 2024
lillian542 added a commit that referenced this issue Jul 26, 2024
**Context:**
Before CNOT inherited from `Controlled`, its decomposition method
returned a `DecompositionUndefinedError`. Now it uses the smart
decomposition functions from `Controlled`, which in this case make it
decompose to itself.

```
>>> op = qml.CNOT([0, 1])
>>> op.decomposition()
[CNOT(wires=[0, 1])]
```

The change in the decomposition method of CNOT was unintentional, and
operators should not decompose to themselves.

**Description of the Change:**
We put it back how it was:

```
>>> op = qml.CNOT([0, 1])
>>> op.decomposition()
DecompositionUndefinedError
```

**Related GitHub Issues:**
#5711

---------

Co-authored-by: David Wierichs <david.wierichs@xanadu.ai>
Co-authored-by: Christina Lee <christina@xanadu.ai>
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

Successfully merging a pull request may close this issue.

1 participant