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

Controlled rotation gates don't check that target and controls are distinct qubits #1339

Open
tcNickolas opened this issue Mar 29, 2024 · 2 comments
Labels
bug Something isn't working needs triage

Comments

@tcNickolas
Copy link
Member

Describe the bug

It is possible to apply Controlled Ry and Rz gates with 2 controls and target that is the same as one of the controls, and have no exception happen.

To Reproduce

The smallest repro I could find was:

operation BugDemo() : Unit {
    use qs = Qubit[2];
    ApplyToEach(H, qs);
    Controlled Ry(qs, (0.5, qs[1]));
    ResetAll(qs);
}

BugDemo()

Using only one control doesn't trigger the bug (the exception is thrown correctly), and using X instead of Ry also doesn't trigger it.

Expected behavior

Controlled gates are not defined for targets that are the same as controls, so I expect an exception for any combination of gates and control/targets that have overlapping controls and targets. (This was the case in Classic QDK too.)

System information

  • qsharp 1.3.1
@tcNickolas tcNickolas added bug Something isn't working needs triage labels Mar 29, 2024
@saram-aman
Copy link

@tcNickolas can you please assign the task to me?

@swernli
Copy link
Collaborator

swernli commented Apr 15, 2024

@saram-aman This one has some subtlety related to the way that decompositions use qubits that makes it far from easy to resolve. We might need to do some refactoring to actually accomplish this, if it's possible at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

3 participants