unclear error message when calling cudaq.adjoint outside of a kernel
Opened this issue · 0 comments
mmvandieren commented
Required prerequisites
- 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.
- Make sure you've read the documentation. Your issue may be addressed there.
- 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
There is no (or difficult to find) documentation on the cudaq.adjoint
operator applied to a kernel to indicate that the behaviors below might not be allowed (unless one has a solid understanding of decorators, which I don't think all of our user base will necessarily have). The error message produced doesn't really help since it seems to indicate that this function doesn't even exist.
error message: module 'cudaq' has no attribute 'adjoint'
Steps to reproduce the bug
def quantum_fourier_transform(qubits: cudaq.qview):
qubit_count = len(qubits)
# Apply Hadamard gates and controlled rotation gates.
for i in range(qubit_count):
h(qubits[i])
for j in range(i + 1, qubit_count):
angle = (2 * np.pi) / (2**(j - i + 1))
cr1(angle, [qubits[j]], qubits[i])
@cudaq.kernel
def test(q:int):
qubits = cudaq.qvector(q)
quantum_fourier_transform(qubits)
test_adj = cudaq.adjoint(test,3)
print(cudaq.draw(test_adj))
Expected behavior
An error message that better explains the problem and doesn't mislead the user that this operation isn't defined at all.
Is this a regression? If it is, put the last known working version (or commit) here.
Not a regression
Environment
- CUDA Quantum version: 0.7.1
- Python version:
- C++ compiler:
- Operating system:
Suggestions
No response