GeezerVison is showing github.com — BUG: `SeedSequence` backwards/forwards compatibility check · Issue #33244 · numpy/numpy
BUG: SeedSequence backwards/forwards compatibility check #33244DescriptionFor now, this is a query. My question is--was this an intentional decision from the core team? Following gh-32889, in the numpy/random/bit_generator.pxd header file, it looks like the size of the struct that will get allocated for SeedSequence has increased a bit because of the addition of a _lock object there.
Reading through a subset of the review comments in that PR manually, I saw that considerable attention went into pickle compatibility concerns, but from a quick scan, I don't think I saw much discussion about forward/backward compatibility at runtime.
The reason I'm bringing this up is that I've been seeing CI failures for SciPy when building against recent NumPy main and then performing tests after rolling back to our lowest support NumPy version (2.0.0).
I can reproduce the failures locally on ARM Mac with a relatively simple sequence of steps (below).
- Build SciPy
main against NumPy main.
- Downgrade NumPy in this environment to
2.0.0.
- Run
spin test --no-build -t scipy/stats/tests/test_sampling.py
The errors I see locally match those that are showing up in our CI. In short, it is SeedSequence size changed, may indicate binary incompatibility. Expected 72 from C header, got 64 from PyObject. A sample full traceback is below the fold.
Details
______________________________________________ ERROR collecting build-install/usr/lib/python3.12/site-packages/scipy/stats/tests/test_sampling.py _______________________________________________
scipy/stats/tests/test_sampling.py:14: in <module>
from scipy.stats.sampling import (
IS_WASM = False
__builtins__ = <builtins>
__cached__ = '/Users/treddy/github_projects/scipy/build-install/usr/lib/python3.12/site-packages/scipy/stats/tests/__pycache__/test_sampling.cpython-312.pyc'
__doc__ = None
__file__ = '/Users/treddy/github_projects/scipy/build-install/usr/lib/python3.12/site-packages/scipy/stats/tests/test_sampling.py'
__loader__ = <_pytest.assertion.rewrite.AssertionRewritingHook object at 0x100a9f950>
__name__ = 'scipy.stats.tests.test_sampling'
__package__ = 'scipy.stats.tests'
__spec__ = ModuleSpec(name='scipy.stats.tests.test_sampling', loader=<_pytest.assertion.rewrite.AssertionRewritingHook object at .../Users/treddy/github_projects/scipy/build-install/usr/lib/python3.12/site-packages/scipy/stats/tests/test_sampling.py')
assert_allclose = <function assert_allclose at 0x10379eb60>
assert_equal = <function assert_equal at 0x10379dc60>
deepcopy = <function deepcopy at 0x1008f5440>
math = <module 'math' from '/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/lib-dynload/math.cpython-312-darwin.so'>
np = <module 'numpy' from '/Users/treddy/python_venvs/py_312_scipy_dev/lib/python3.12/site-packages/numpy/__init__.py'>
pickle = <module 'pickle' from '/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/pickle.py'>
platform = <module 'platform' from '/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/platform.py'>
pytest = <module 'pytest' from '/Users/treddy/python_venvs/py_312_scipy_dev/lib/python3.12/site-packages/pytest/__init__.py'>
sys = <module 'sys' (built-in)>
threading = <module 'threading' from '/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/threading.py'>
warnings = <module 'warnings' from '/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/warnings.py'>
scipy/stats/sampling.py:59: in <module>
from ._sampling import FastGeneratorInversion, RatioUniforms
__builtins__ = <builtins>
__cached__ = '/Users/treddy/github_projects/scipy/build-install/usr/lib/python3.12/site-packages/scipy/stats/__pycache__/sampling.cpython-312.pyc'
__doc__ = '\n======================================================\nRandom Number Generators (:mod:`scipy.stats.sampling`)\n===...the following functionality can be used:\n\n.. autosummary::\n :toctree: generated/\n\n FastGeneratorInversion\n\n'
__file__ = '/Users/treddy/github_projects/scipy/build-install/usr/lib/python3.12/site-packages/scipy/stats/sampling.py'
__loader__ = <_frozen_importlib_external.SourceFileLoader object at 0x1075097c0>
__name__ = 'scipy.stats.sampling'
__package__ = 'scipy.stats'
__spec__ = ModuleSpec(name='scipy.stats.sampling', loader=<_frozen_importlib_external.SourceFileLoader object at 0x1075097c0>, origin='/Users/treddy/github_projects/scipy/build-install/usr/lib/python3.12/site-packages/scipy/stats/sampling.py')
scipy/stats/_sampling.py:8: in <module>
from ._unuran.unuran_wrapper import NumericalInversePolynomial
Halton = <class 'scipy.stats._qmc.Halton'>
QMCEngine = <class 'scipy.stats._qmc.QMCEngine'>
__builtins__ = <builtins>
__cached__ = '/Users/treddy/github_projects/scipy/build-install/usr/lib/python3.12/site-packages/scipy/stats/__pycache__/_sampling.cpython-312.pyc'
__doc__ = None
__file__ = '/Users/treddy/github_projects/scipy/build-install/usr/lib/python3.12/site-packages/scipy/stats/_sampling.py'
__loader__ = <_frozen_importlib_external.SourceFileLoader object at 0x10750a6f0>
__name__ = 'scipy.stats._sampling'
__package__ = 'scipy.stats'
__spec__ = ModuleSpec(name='scipy.stats._sampling', loader=<_frozen_importlib_external.SourceFileLoader object at 0x10750a6f0>, origin='/Users/treddy/github_projects/scipy/build-install/usr/lib/python3.12/site-packages/scipy/stats/_sampling.py')
check_random_state_qmc = <function check_random_state at 0x106cc60c0>
math = <module 'math' from '/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/lib-dynload/math.cpython-312-darwin.so'>
np = <module 'numpy' from '/Users/treddy/python_venvs/py_312_scipy_dev/lib/python3.12/site-packages/numpy/__init__.py'>
numbers = <module 'numbers' from '/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/numbers.py'>
sc = <module 'scipy.special' from '/Users/treddy/github_projects/scipy/build-install/usr/lib/python3.12/site-packages/scipy/special/__init__.py'>
stats = <module 'scipy.stats' from '/Users/treddy/github_projects/scipy/build-install/usr/lib/python3.12/site-packages/scipy/stats/__init__.py'>
scipy/stats/_unuran/unuran_wrapper.pyx:1: in init scipy.stats._unuran.unuran_wrapper
???
E ValueError: numpy.random.bit_generator.SeedSequence size changed, may indicate binary incompatibility. Expected 72 from C header, got 64 from PyObject
Activitytylerjereddy commented on Nov 7, 2026 ContributorAuthor More actions I believe this would make all versions of NumPy prior to 2.6.0 incompatible with a SciPy built against that NumPy version, so my guess would be that you might not want to do that, but maybe I don't understand. charris commented on Nov 7, 2026 Hmm, agree that is a problem. charris commented on Nov 7, 2026 Note that this change was backported for 2.5.5, so that might need fixing as well. I'll wait on resolution.
EDIT: I might just revert it. changed the title [-]Query: `SeedSequence` backwards/forwards compatibility check[/-] [+]BUG: `SeedSequence` backwards/forwards compatibility check[/+] on Nov 7, 2026charris commented on Nov 9, 2026 ngoldbaum commented on Nov 9, 2026 Ah darn, I think that means we might need to revert that PR and give it another go. Ping @shbhmbnsl1. Reacted by Shubham Bansal ngoldbaum commented on Nov 9, 2026 Sorry, I didn't appreciate SciPy used that struct. shbhmbnsl1 commented on Nov 9, 2026 Apologies, my focus was to test whether saved objects could be restored in backward versions but didn't check Scipy's compatibility. Here is a quick revert PR for this - #33263
We can talk about fixing the original bug with some alternate approach.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|