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

module 'qiskit' has no attribute '_accelerate' when running with accelerated numpy #12374

Open
tinaoberoi opened this issue May 9, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@tinaoberoi
Copy link

Environment

  • Qiskit version: 1.0.1
  • Python version: 3.10
  • system: Google colab

What is happening?

I am using cupy and accelerarted numpy to improve performance of some code. When using cupy and numpy alsong with qiskit libraries the installation gives qiskit._accelerate not found error.

----------------------------------
AttributeError                            Traceback (most recent call last)
[<ipython-input-9-50bfb866a323>](https://localhost:8080/#) in <cell line: 6>()
      4 
      5 from lattice import ZigzagSquareLattice, SquareLattice
----> 6 from hamiltonian import SkyrmionHamiltonian
      7 # from ansatz import SkyrmionAnsatz

1 frames
[/content/quantum-skyrmion-simulation/./src/hamiltonian.py](https://localhost:8080/#) in <module>
      4 import subprocess
      5 from lattice import Lattice
----> 6 from qiskit.quantum_info import SparsePauliOp
      7 from qiskit_algorithms import NumPyMinimumEigensolver
      8 

[/usr/local/lib/python3.10/dist-packages/qiskit/__init__.py](https://localhost:8080/#) in <module>
     53 # We manually define them on import so people can directly import qiskit._accelerate.* submodules
     54 # and not have to rely on attribute access.  No action needed for top-level extension packages.
---> 55 sys.modules["qiskit._accelerate.nlayout"] = qiskit._accelerate.nlayout
     56 sys.modules["qiskit._accelerate.stochastic_swap"] = qiskit._accelerate.stochastic_swap
     57 sys.modules["qiskit._accelerate.sabre_swap"] = qiskit._accelerate.sabre_swap

AttributeError: partially initialized module 'qiskit' has no attribute '_accelerate' (most likely due to a circular import)

This issue fixes itself sometimes when I restart the kernel and it is fixed. I also tried to use 0.46 qiskit version but same issue. The code works fine if I dont use accelerated numpy/cupy.

How can we reproduce the issue?

Installations

sudo apt-get install numpy libopenblas-dev
pip install cupy-cuda12x
pip install qiskit==0.46.1
pip install qiskit_algorithms==0.3.0

Use qiskit imports

What should happen?

The imports should happen without error.

Any suggestions?

No response

@tinaoberoi tinaoberoi added the bug Something isn't working label May 9, 2024
@jakelishman
Copy link
Member

Please can you give more detail about what precisely you've run in a clean Colab session, both to install additional packages (both pip and the system package manager) and then try to produce a minimal reproducer of a failure that doesn't involve any of the additional packages you've got?

Fwiw, if the cupy installation is changing anything about what happens when you import numpy or any of the internal objects, then it's quite likely that Qiskit simply isn't compatible with that - we use Numpy's C API, so if anything is messing with Numpy internals, we could very quickly be getting out of sync.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants