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

Qiskit-aer-gpu does not work as expected #2194

Open
gzquse opened this issue Jul 15, 2024 · 3 comments
Open

Qiskit-aer-gpu does not work as expected #2194

gzquse opened this issue Jul 15, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@gzquse
Copy link

gzquse commented Jul 15, 2024

Informations

  • Qiskit Aer version:
    Requirement already satisfied: qiskit-aer-gpu in /global/homes/g/gzquse/.conda/envs/qiskit-summer/lib/python3.11/site-packages (0.14.2)
    Requirement already satisfied: qiskit>=0.45.2 in /global/homes/g/gzquse/.conda/envs/qiskit-summer/lib/python3.11/site-packages (from qiskit-aer-gpu) (1.1.1)
    Requirement already satisfied: numpy>=1.16.3 in /global/homes/g/gzquse/.conda/envs/qiskit-summer/lib/python3.11/site-packages (from qiskit-aer-gpu) (2.0.0)
    Requirement already satisfied: scipy>=1.0 in /global/homes/g/gzquse/.conda/envs/qiskit-summer/lib/python3.11/site-packages (from qiskit-aer-gpu) (1.14.0)
    Requirement already satisfied: psutil>=5 in /global/homes/g/gzquse/.conda/envs/qiskit-summer/lib/python3.11/site-packages (from qiskit-aer-gpu) (6.0.0)
    Requirement already satisfied: nvidia-cuda-runtime-cu12>=12.1.105 in /global/homes/g/gzquse/.conda/envs/qiskit-summer/lib/python3.11/site-packages (from qiskit-aer-gpu) (12.5.82)
    Requirement already satisfied: nvidia-nvjitlink-cu12 in /global/homes/g/gzquse/.conda/envs/qiskit-summer/lib/python3.11/site-packages (from qiskit-aer-gpu) (12.5.82)
    Requirement already satisfied: nvidia-cublas-cu12>=12.1.3.1 in /global/homes/g/gzquse/.conda/envs/qiskit-summer/lib/python3.11/site-packages (from qiskit-aer-gpu) (12.5.3.2)
    Requirement already satisfied: nvidia-cusolver-cu12>=11.4.5.107 in /global/homes/g/gzquse/.conda/envs/qiskit-summer/lib/python3.11/site-packages (from qiskit-aer-gpu) (11.6.3.83)
    Requirement already satisfied: nvidia-cusparse-cu12>=12.1.0.106 in /global/homes/g/gzquse/.conda/envs/qiskit-summer/lib/python3.11/site-packages (from qiskit-aer-gpu) (12.5.1.3)
    Requirement already satisfied: cuquantum-cu12>=23.3.0 in /global/homes/g/gzquse/.conda/envs/qiskit-summer/lib/python3.11/site-packages (from qiskit-aer-gpu) (24.3.0.post1)
    Requirement already satisfied: custatevec-cu12==1.6.0.post1 in /global/homes/g/gzquse/.conda/envs/qiskit-summer/lib/python3.11/site-packages (from cuquantum-cu12>=23.3.0->qiskit-aer
  • Python version:
    Python 3.11.9
  • Operating system:
    x86_64 linux
  • cuda version
    +-----------------------------------------------------------------------------+
    | NVIDIA-SMI 525.105.17 Driver Version: 525.105.17 CUDA Version: 12.2 |
    |-------------------------------+----------------------+----------------------+
    | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
    | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
    | | | MIG M. |
    |===============================+======================+======================|
    | 0 NVIDIA A100-SXM... On | 00000000:03:00.0 Off | 0 |
    | N/A 27C P0 61W / 500W | 0MiB / 81920MiB | 0% Default |
    | | | Disabled |
    +-------------------------------+----------------------+----------------------+
    | 1 NVIDIA A100-SXM... On | 00000000:41:00.0 Off | 0 |
    | N/A 27C P0 62W / 500W | 0MiB / 81920MiB | 0% Default |
    | | | Disabled |
    +-------------------------------+----------------------+----------------------+
    | 2 NVIDIA A100-SXM... On | 00000000:82:00.0 Off | 0 |
    | N/A 28C P0 63W / 500W | 0MiB / 81920MiB | 0% Default |
    | | | Disabled |
    +-------------------------------+----------------------+----------------------+
    | 3 NVIDIA A100-SXM... On | 00000000:C1:00.0 Off | 0 |
    | N/A 28C P0 61W / 500W | 0MiB / 81920MiB | 0% Default |
    | | | Disabled |
    +-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+

What is the current behavior?

demo python file:

from qiskit import transpile
from qiskit.circuit.library import RealAmplitudes
from qiskit.quantum_info import SparsePauliOp
from qiskit_aer import AerSimulator

sim = AerSimulator()
# --------------------------
# Simulating using estimator
#---------------------------
from qiskit_aer.primitives import EstimatorV2

psi1 = transpile(RealAmplitudes(num_qubits=2, reps=2), sim, optimization_level=0)
psi2 = transpile(RealAmplitudes(num_qubits=2, reps=3), sim, optimization_level=0)

H1 = SparsePauliOp.from_list([("II", 1), ("IZ", 2), ("XI", 3)])
H2 = SparsePauliOp.from_list([("IZ", 1)])
H3 = SparsePauliOp.from_list([("ZI", 1), ("ZZ", 1)])

theta1 = [0, 1, 1, 2, 3, 5]
theta2 = [0, 1, 1, 2, 3, 5, 8, 13]
theta3 = [1, 2, 3, 4, 5, 6]

estimator = EstimatorV2()

# calculate [ [<psi1(theta1)|H1|psi1(theta1)>,
#              <psi1(theta3)|H3|psi1(theta3)>],
#             [<psi2(theta2)|H2|psi2(theta2)>] ]
job = estimator.run(
    [
        (psi1, [H1, H3], [theta1, theta3]),
        (psi2, H2, theta2)
    ],
    precision=0.01
)
result = job.result()
print(f"expectation values : psi1 = {result[0].data.evs}, psi2 = {result[1].data.evs}")

# --------------------------
# Simulating using sampler
# --------------------------
from qiskit_aer.primitives import SamplerV2
from qiskit import QuantumCircuit

# create a Bell circuit
bell = QuantumCircuit(2)
bell.h(0)
bell.cx(0, 1)
bell.measure_all()

# create two parameterized circuits
pqc = RealAmplitudes(num_qubits=2, reps=2)
pqc.measure_all()
pqc = transpile(pqc, sim, optimization_level=0)
pqc2 = RealAmplitudes(num_qubits=2, reps=3)
pqc2.measure_all()
pqc2 = transpile(pqc2, sim, optimization_level=0)

theta1 = [0, 1, 1, 2, 3, 5]
theta2 = [0, 1, 2, 3, 4, 5, 6, 7]

# initialization of the sampler
sampler = SamplerV2()

# collect 128 shots from the Bell circuit
job = sampler.run([bell], shots=128)
job_result = job.result()
print(f"counts for Bell circuit : {job_result[0].data.meas.get_counts()}")
 
# run a sampler job on the parameterized circuits
job2 = sampler.run([(pqc, theta1), (pqc2, theta2)])
job_result = job2.result()
print(f"counts for parameterized circuit : {job_result[0].data.meas.get_counts()}")

# --------------------------------------------------
# Simulating with noise model from actual hardware
# --------------------------------------------------
from qiskit_ibm_runtime import QiskitRuntimeService
provider = QiskitRuntimeService(channel='ibm_quantum', token="set your own token here")
backend = provider.get_backend("ibm_kyoto")

# create sampler from the actual backend
sampler = SamplerV2.from_backend(backend)

# run a sampler job on the parameterized circuits with noise model of the actual hardware
bell_t = transpile(bell, AerSimulator(basis_gates=["ecr", "id", "rz", "sx"]), optimization_level=0)
job3 = sampler.run([bell_t], shots=128)
job_result = job3.result()
print(f"counts for Bell circuit w/noise: {job_result[0].data.meas.get_counts()}")

When I ran the program I got this error:

ImportError: /global/homes/g/gzquse/.conda/envs/qiskit-summer/lib/python3.11/site-packages/qiskit_aer/backends/../../nvidia/cusparse/lib/libcusparse.so.12: undefined symbol: __nvJitLinkAddData_12_5, version libnvJitLink.so.12

Steps to reproduce the problem

python cuda_test.py

What is the expected behavior?

run as expected

Suggested solutions

@gzquse gzquse added the bug Something isn't working label Jul 15, 2024
@doichanj
Copy link
Collaborator

Please try

pip install nvidia-nvjitlink-cu12

@gzquse
Copy link
Author

gzquse commented Jul 16, 2024

Requirement already satisfied: nvidia-nvjitlink-cu12 in /global/homes/g/gzquse/.conda/envs/qiskit-summer/lib/python3.11/site-packages (12.5.82)

Same results

@enum-class
Copy link
Contributor

maybe this solution can be helpful
pytorch/pytorch#111469 (comment)

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

3 participants