cuda-quantum icon indicating copy to clipboard operation
cuda-quantum copied to clipboard

[compiler bug] Python MLIR doesn't catch incorrect arguments to rotation gates

Open anthony-santana opened this issue 9 months ago • 2 comments

Required prerequisites

  • [X] Consult the security policy. If reporting a security vulnerability, do not report the bug using this form. Use the process described in the policy to report the issue.
  • [X] Make sure you've read the documentation. Your issue may be addressed there.
  • [X] Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.
  • [ ] If possible, make a PR with a failing test to give us a starting point to work on!

Describe the bug

In python MLIR, we aren't catching when a user calls rotation gates with incorrect arguments.

Steps to reproduce the bug

@cudaq.kernel
def kernel():
    q = cudaq.qubit()
    # Examples of things we can get away with without error:
    rx(3.14)
    rx("random_argument")
    # Our regular gates do throw an error like this:
    # x("random_argument") 
   

print(kernel)

result = cudaq.sample(kernel)
print(result)

Expected behavior

Expect an error similar to the conventional gates, such as:

cudaq.kernel.ast_bridge.CompilerError: test.py:37: error: quantum operation x on incorrect quantum type <TYPENAME>.
         (offending source -> <VALUE>)

Is this a regression? If it is, put the last known working version (or commit) here.

Not a regression

Environment

  • CUDA Quantum version:
  • Python version:
  • C++ compiler:
  • Operating system: All latest

Suggestions

No response

anthony-santana avatar May 08 '24 15:05 anthony-santana