-
Notifications
You must be signed in to change notification settings - Fork 193
Open
Labels
area/c++Involves the C++ code portions of qsimInvolves the C++ code portions of qsimarea/gpuInvolves CUDA, GPUs, and similarInvolves CUDA, GPUs, and similarpriority/p1High priorityHigh priority
Milestone
Description
Describe the issue
When running gpu version of qsimcirq (installed from source following the tutorial GPU-based quantum simulation on Google Cloud) in a Python virtual environment, I get the following runtime error:
RuntimeError: Unable to cast Python instance of type <class 'qsimcirq.qsim_avx2.Circuit'> to C++ type '?' (#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for details)
This happens when both qsim_avx2 and qsim_cuda backends are present in site-packages. The error occurs while calling compute_amplitudes or simulate on a qsimcirq.QSimSimulator instance.
Removing one of the backend .so files makes the error go away, but then the package fails to import if the missing backend is referenced in init.py.
What version of qsim are you using?
0.23.0.dev0
How can the issue be reproduced?
- In a Python 3.12 venv, install qsimcirq from source (following the tutorial GPU-based quantum simulation on Google Cloud
) - Create a simple circuit in Cirq and try to run it with qsimcirq.QSimSimulator.
- Call
simulateorcompute_amplitudes. The error appears.
Example code:
import cirq, qsimcirq
q = cirq.LineQubit.range(2)
c = cirq.Circuit([cirq.H(q[0]), cirq.CX(q[0], q[1])])
sim = qsimcirq.QSimSimulator()
result = sim.simulate(c)Metadata
Metadata
Assignees
Labels
area/c++Involves the C++ code portions of qsimInvolves the C++ code portions of qsimarea/gpuInvolves CUDA, GPUs, and similarInvolves CUDA, GPUs, and similarpriority/p1High priorityHigh priority
Type
Projects
Status
No status