Skip to content

Investigate incompatible signatures of scipy.linalg.cython_blas.dasum #26290

Closed

Description

@larsoner

Describe your issue.

In MNE-Python we run a pip-pre job with thhe latest scipy-wheels-nightly builds for NumPy/SciPy/sklearn. The latest 1.11.0.dev0+1956.7c74503 SciPy + 1.3.dev0 sklearn pip-pre wheel combination appears to be buggy:

It worked with 1.11.0.dev0+1926.070b2a8 in SciPy:

Probably because SciPy changed their signature to int const * in scipy/scipy#18247.

Some form of this should allow you to reproduce the issue I think:

pip install --pre --extra-index-url "https://pypi.anaconda.org/scipy-wheels-nightly/simple" numpy scipy sklearn

This is the error message we see in CIs:

________ ERROR at setup of test_make_forward_solution_kit[testing_data] ________
mne/forward/tests/test_make_forward.py:381: in small_surf_src
    src = setup_source_space('sample', 'oct2', subjects_dir=subjects_dir,
<decorator-gen-115>:12: in setup_source_space
    ???
mne/source_space.py:1439: in setup_source_space
    s = _create_surf_spacing(surf, hemi, subject, stype, ico_surf,
mne/surface.py:1066: in _create_surf_spacing
    mmap = _compute_nearest(from_surf['rr'], ico_surf['rr'])
mne/surface.py:503: in _compute_nearest
    tree = _DistanceQuery(xhs, method=method)
mne/surface.py:525: in __init__
    from sklearn.neighbors import BallTree
/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/sklearn/neighbors/__init__.py:8: in <module>
    from ._distance_metric import DistanceMetric
/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/sklearn/neighbors/_distance_metric.py:4: in <module>
    from ..metrics import DistanceMetric as _DistanceMetric
/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/sklearn/metrics/__init__.py:42: in <module>
    from . import cluster
/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/sklearn/metrics/cluster/__init__.py:22: in <module>
    from ._unsupervised import silhouette_samples
/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/sklearn/metrics/cluster/_unsupervised.py:23: in <module>
    from ..pairwise import pairwise_distances_chunked
/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/sklearn/metrics/pairwise.py:40: in <module>
    from ._pairwise_distances_reduction import ArgKmin
/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/sklearn/metrics/_pairwise_distances_reduction/__init__.py:89: in <module>
    from ._dispatcher import (
/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/sklearn/metrics/_pairwise_distances_reduction/_dispatcher.py:11: in <module>
    from ._base import _sqeuclidean_row_norms32, _sqeuclidean_row_norms64
sklearn/metrics/_pairwise_distances_reduction/_base.pyx:1: in init sklearn.metrics._pairwise_distances_reduction._base
    ???
sklearn/utils/_cython_blas.pyx:1: in init sklearn.utils._cython_blas
    ???
E   TypeError: C function scipy.linalg.cython_blas.dasum has wrong signature (expected __pyx_t_5scipy_6linalg_11cython_blas_d (int *, __pyx_t_5scipy_6linalg_11cython_blas_d *, int *), got __pyx_t_5scipy_6linalg_11cython_blas_d (int const *, __pyx_t_5scipy_6linalg_11cython_blas_d const *, int const *))
Platform                Linux-5.15.0-1035-azure-x86_64-with-glibc2.35
Python                  3.11.3 (main, Apr  6 2023, 07:55:46) [GCC 11.3.0]
Executable              /opt/hostedtoolcache/Python/3.11.3/x64/bin/python
├☑ numpy                1.25.0.dev0+1207.gafa98ddef (OpenBLAS 0.3.21 with 1 thread)
├☑ scipy                1.11.0.dev0+1926.070b2a8
├☑ sklearn              1.3.dev0

Assuming the SciPy change was good/reasonable, it seems like sklearn should adapt to/permit this new signature type. But I might be wrong...

I've opened scipy/scipy#18377 at the SciPy end in case you want to argue with the SciPy folks that they did something wrong here

Activity

  1. added
    Needs Triage
    on Apr 27, 2023
  2. larsoner commented on Apr 28, 2023

    @larsoner
    ContributorAuthor

    This seems almost certainly due to scipy/scipy#18247 where the signature of the function was changed. So perhaps the scikit-learn wheel needs to tolerate two different signatures somehow (?) since older SciPy wheels will have int * and newer ones will have int const *.

  3. betatim commented on Apr 28, 2023

    @betatim
    Member

    Thanks for opening this and the helpful links and context.

    From a brief look it sounds like scikit-learn would need to add some kind of wrapper/shim/thing so that wheels work with older and new scipy versions because of the change in the PR. (What you said.) @jjerphan or @Micky774 do you know if there is a precedence for this somewhere in the scikit-learn code base?

  4. added and removed
    Needs Triage
    on Apr 28, 2023
  5. jjerphan commented on Apr 28, 2023

    @jjerphan
    Member

    @jjerphan or @Micky774 do you know if there is a precedence for this somewhere in the scikit-learn code base?

    Edit: I do think there is precedence for this case in scikit-learn's code-base.

  6. betatim commented on Apr 28, 2023

    @betatim
    Member

    Do you think it is possible to build a scikit-learn wheel that works with both old and new versions of scipy (from a purely technical/cython point of view)? Otherwise I think we should open an issue with them to discuss how to deal with this.

  7. larsoner commented on Apr 28, 2023

    @larsoner
    ContributorAuthor

    Feel free to use scipy/scipy#18377 if you want to discuss with the SciPy folks

  8. betatim commented on Apr 28, 2023

    @betatim
    Member

    Actually, even if we can fix up scikit-learn so that future releases of scikit-learn can handle both the old and new signature in scipy, for versions of scikit-learn that were already released people will get failures when these scipy changes are released.

  9. changed the title [-]BUG: Wrong signature in latest SciPy[/-] [+]Investigate incompatible signatures of `scipy.linalg.cython_blas.dasum`[/+] on Apr 28, 2023
  10. jjerphan commented on Oct 29, 2023

    @jjerphan
    Member

    Closing as solved by scipy/scipy#18405.

    Anyone should feel free to reopen if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions