Open mmvandieren opened 2 months ago
Don't you need to define the kernel decorator.
@cudaq.kernel
def error_message():
qubits =qvector(2)
ctrl.x(qubits[0], qubits[1])
results = cudaq.sample(error_message)
Yeah, the kernel decorator is needed to get the right error message.
The code example is purposefully wrong. What's the issues is that the error message that gets generated has a problem in it.
I just see this output.
root@6db8d9a389b3:/workspaces/cuda-quantum# python3 examples/python/test.py
cudaq.kernel.ast_bridge.CompilerError: test.py:6: error: Invalid function call - 'ctrl' is unknown.
(offending source -> ctrl.x)
Are you running it in Jupyter notebook?
Yep, I'm in a Jupyter notebook in VS Code on my Mac in a container.
I see the following output when I execute above code to repro the above error message
{
"name": "NameError",
"message": "name 'ctrl' is not defined",
"stack": "---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[5], line 7
4 qubits = cudaq.qvector(2)
5 ctrl.x(qubits[0], qubits[1])
----> 7 results = cudaq.sample(error_message)
File /usr/local/cudaq/cudaq/runtime/sample.py:87, in sample(kernel, shots_count, noise_model, *args)
84 cudaq_runtime.setExecutionContext(ctx)
85 return counts
---> 87 kernel(*args)
88 res = ctx.result
89 cudaq_runtime.resetExecutionContext()
Cell In[5], line 5, in error_message()
3 def error_message():
4 qubits = cudaq.qvector(2)
----> 5 ctrl.x(qubits[0], qubits[1])
NameError: name 'ctrl' is not defined"
}
Required prerequisites
Describe the bug
There seems to be a typo somewhere in the code that generates the error message below because all the formatting commands are displayed instead of executed.
Steps to reproduce the bug