quantumgizmos / ldpc

A belief propagation decoder for low density parity check (LDPC) codes
MIT License
69 stars 25 forks source link

Incompatibility problem with numpy 2.0.0 #40

Open royess opened 3 months ago

royess commented 3 months ago

Incompatible problem with the newly released numpy 2.0.0 (https://pypi.org/project/numpy/2.0.0/#history).

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/yuxuan/anaconda3/envs/ldpc/lib/python3.12/site-packages/ldpc/__init__.py", line 2, in <module>
    from .bp_decoder import bp_decoder
  File "src/ldpc/bp_decoder.pyx", line 1, in init ldpc.bp_decoder
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

Versions: python==3.12, ldpc==0.1.51, numpy=2.0.0, scipy==1.13.1

quantumgizmos commented 3 months ago

Hi. Thanks for pointing this out. I think the problem is that that numpy 2.0.0 doesn't support the np.int_t type for some reason. I've changed the default output type to np.uint8_t and it seems to work for me locally. Could you test the fix in branch issue40?

royess commented 3 months ago

The new branch seems to work well. It no longer triggers errors. I also tested decoding a small repetition code, which returned an expected result. Thanks for this fixing!

burgholzer commented 1 month ago

Any chance of getting this fix merged and released as a new version (before the v2 release)? That will also directly fix #43.

Potentially, besides the fix for numpy 2.0 compatibility, wheels for Python 3.12 would be great and should be easy to do.

quantumgizmos commented 1 month ago

@burgholzer I've made pull request #44 to ship this? Could you confirm it works in your environment? Then it can be shipped 🚢

burgholzer commented 4 weeks ago
uv venv --python 3.12 .venv312
source .venv312/bin/activate
uv pip install git+https://github.com/quantumgizmos/ldpc@issue40

succeeds without issues om my Linux machine as well as my Windows and my Apple arm64 machine. Also briefly tested the new version over in our QECC repo and everything builds fine and also runs fine. So definitely "go" from my side.

quantumgizmos commented 4 weeks ago

Thanks @burgholzer pr #44 is now integrated and uploaded to PyPi!

burgholzer commented 4 weeks ago

Many thanks 🙏🏼 Already integrated the new version in mqt-qecc and it works like a charm ✨