-
Notifications
You must be signed in to change notification settings - Fork 346
Closed
Description
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
When importing OrderedDict from the collections module in Python, any attempt to define or use a @cudaq.kernel results in an AttributeError. This appears to be a conflict between cudaq and the standard Python library, specifically the collections module. The issue makes it impossible to use OrderedDict alongside cudaq, which could affect projects relying on both.
Steps to reproduce the bug
import cudaq
from collections import OrderedDict
# Define our kernel.
@cudaq.kernel
def kernel(qubit_count: int):
# Allocate our qubits.
qvector = cudaq.qvector(qubit_count)
# Place the first qubit in the superposition state.
h(qvector[0])
# Loop through the allocated qubits and apply controlled-X,
# or CNOT, operations between them.
for qubit in range(qubit_count - 1):
x.ctrl(qvector[qubit], qvector[qubit + 1])
# Measure the qubits.
mz(qvector)
Expected behavior
The script should execute without errors, as importing OrderedDict from collections is a standard Python operation.
Instead, it fails with the following error:
AttributeError: type object 'collections.OrderedDict' has no attribute '__annotations__'
Is this a regression? If it is, put the last known working version (or commit) here.
No response
Environment
- CUDA-Q version: 0.9.1 (commit hash a3ab722)
- Python version: 3.10.16
- Operating system: HPE Cray OS (SUSE Linux Enterprise Server, SLES)
Suggestions
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels