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

Conflict between cudaq and collections.OrderedDict causing AttributeError #2531

Open
3 of 4 tasks
anthonysmaldone opened this issue Jan 23, 2025 · 0 comments
Open
3 of 4 tasks

Comments

@anthonysmaldone
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant