ScQ-Cloud / pyquafu

PyQuafu is designed for users to construct, compile, and execute quantum circuits on quantum devices on Quafu using Python.
Apache License 2.0
65 stars 23 forks source link

simulator cannot be used on Windows with python 3.11 #174

Closed Zhaoyilunnn closed 3 months ago

Zhaoyilunnn commented 3 months ago

System Info

OS: Windows 11 Python: 3.11.9 PyQuafu version: 0.4.0

How to reproduce

run following script fails

from quafu import QuantumCircuit, simulate

qc = QuantumCircuit(2)
qc.h(0)
qc.cnot(0, 1)

res = simulate(qc)

报错如下

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Lenovo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\quafu\simulators\__init__.py", line 41, in simulate
    from .simulator import SVSimulator
  File "C:\Users\Lenovo\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\quafu\simulators\simulator.py", line 19, in <module>
    from .qfvm import simulate_circuit, applyop_statevec, expect_statevec, sampling_statevec,simulate_circuit_clifford
ImportError: DLL load failed while importing qfvm: 找不到指定的模块。
Zhaoyilunnn commented 3 months ago

Debug Log

20240618

Successfully build from source on Windows 11 and simulate works well. Seems to be issue with CI environment.

20240620

Check the dependents of .pyd

0.4.0

Dump of file qfvm.cp311-win_amd64.pyd

File Type: DLL

  Image has the following dependencies:

    python311.dll
    MSVCP140.dll
    VCRUNTIME140_1.dll
    VCRUNTIME140.dll
    api-ms-win-crt-heap-l1-1-0.dll
    api-ms-win-crt-convert-l1-1-0.dll
    api-ms-win-crt-math-l1-1-0.dll
    api-ms-win-crt-string-l1-1-0.dll
    api-ms-win-crt-runtime-l1-1-0.dll
    KERNEL32.dll
    VCOMP140.DLL

  Summary

        2000 .data
        3000 .pdata
        D000 .rdata
        1000 .reloc
        1000 .rsrc
       2D000 .text
       12000 _RDATA

0.3.6

Dump of file .\qfvm.cp311-win_amd64.pyd

File Type: DLL

  Image has the following dependencies:

    python311.dll
    MSVCP140.dll
    VCRUNTIME140_1.dll
    VCRUNTIME140.dll
    api-ms-win-crt-heap-l1-1-0.dll
    api-ms-win-crt-convert-l1-1-0.dll
    api-ms-win-crt-math-l1-1-0.dll
    api-ms-win-crt-string-l1-1-0.dll
    api-ms-win-crt-runtime-l1-1-0.dll
    KERNEL32.dll
    VCOMP140.DLL

  Summary

        2000 .data
        3000 .pdata
        D000 .rdata
        1000 .reloc
        1000 .rsrc
       2D000 .text
       12000 _RDATA

20240624

find that this issue can be resolved after installing visual studio community 2022

Zhaoyilunnn commented 3 months ago

https://github.com/ScQ-Cloud/pyquafu/pull/176

The root cause is the debug flag