QuantumSavory / PyQDecoders.jl

A Julia interface to popular python packages for decoding quantum error correcting codes.
MIT License
3 stars 0 forks source link

ldpc initialization error due to numpy data type #11

Closed royess closed 4 weeks ago

royess commented 4 weeks ago

The dependency ldpc raises an initialization error due to the numpy data type.

This is actually an error of the ldpc package, which I have exactly reproduced in Python.

It seems strange because this is a very new bug to me but the ldpc package does not have a new release recently (https://pypi.org/project/ldpc/#history).

To be mentioned, this error also makes the decoder tests of QuantumClifford.jl fail.

The error reads:

julia> using PyQDecoders
ERROR: InitError: Python: ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
Python stacktrace:
 [1] init ldpc.bp_decoder
   @ src/ldpc/bp_decoder.pyx:1
 [2] <module>
   @ ~/.julia/environments/v1.10/.CondaPkg/env/lib/python3.12/site-packages/ldpc/__init__.py:2
Stacktrace:
  [1] pythrow()
    @ PythonCall.Core ~/.julia/packages/PythonCall/S5MOg/src/Core/err.jl:92
  [2] errcheck
    @ ~/.julia/packages/PythonCall/S5MOg/src/Core/err.jl:10 [inlined]
  [3] pyimport(m::String)
    @ PythonCall.Core ~/.julia/packages/PythonCall/S5MOg/src/Core/builtins.jl:1444
  [4] __init__()
    @ PyQDecoders ~/.julia/packages/PyQDecoders/nk69c/src/PyQDecoders.jl:16
  [5] run_module_init(mod::Module, i::Int64)
    @ Base ./loading.jl:1134
  [6] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1122
  [7] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any})
    @ Base ./loading.jl:1067
  [8] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128)
    @ Base ./loading.jl:1581
  [9] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:1938
 [10] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1812
 [11] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [12] invoke_in_world
    @ ./essentials.jl:923 [inlined]
 [13] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:1803
 [14] macro expansion
    @ ./loading.jl:1790 [inlined]
 [15] macro expansion
    @ ./lock.jl:267 [inlined]
 [16] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1753
 [17] #invoke_in_world#3
    @ ./essentials.jl:926 [inlined]
 [18] invoke_in_world
    @ ./essentials.jl:923 [inlined]`
 [19] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:1746
during initialization of module PyQDecoders
royess commented 4 weeks ago

After some checking, I found this is related to the new changes in numpy 2.0.0 (https://pypi.org/project/numpy/2.0.0/#history).

I have reported this bug to Python ldpc in quantumgizmos/ldpc/issues/40.

To get things temporarily fixed, we may consider degrading numpy version.

Krastanov commented 4 weeks ago

a temporary compat bound on numpy would indeed be helpful, probably to be added here https://github.com/QuantumSavory/PyQDecoders.jl/blob/master/CondaPkg.toml as described here https://github.com/JuliaPy/CondaPkg.jl?tab=readme-ov-file#condapkgtoml