Skip to content

Conversation

ilayn
Copy link
Member

@ilayn ilayn commented Aug 31, 2025

Reference issue

Towards #18566

What does this implement/fix?

  • Randomization is changed from LAPACK's ?larnv to an xoshiro256+ implementation whose seeds can be controlled by NumPy PRNGs.
  • Extracted cdotc and zdotc and rewrote as standalone functions to avoid the occasional segfaults.
  • The common function copies are eliminated and combined into common.c
  • Rewrote bunch of goto based code pieces to flattened C code.
  • Some tests were not testing np.complex64 and had strange dtype selection that are now fixed.

Additional information

Since this was previously a submodule, if merged, this code will create some annoyance in your local fork due to remaining Fortran77 files from earlier cloning. After using git clean -xdf in the repo root should clean up the remaining fortran pieces and scipy can be rebuilt.

ilayn added 30 commits August 20, 2025 18:41
@ilayn ilayn added this to the 1.17.0 milestone Aug 31, 2025
@ilayn ilayn requested a review from perimosocordiae as a code owner August 31, 2025 03:38
@ilayn ilayn added enhancement A new feature or improvement scipy.sparse.linalg maintenance Items related to regular maintenance tasks C/C++ Items related to the internal C/C++ code base Fortran Items related to the internal Fortran code base Meson Items related to the introduction of Meson as the new build system for SciPy labels Aug 31, 2025
@ilayn ilayn mentioned this pull request Aug 10, 2025
37 tasks
@ilayn
Copy link
Member Author

ilayn commented Aug 31, 2025

@Mugundanmcw Could you help me with a detail here about the WoA job failures I'm trying to troubleshoot? I don't understand what this error is trying to tell me
 [122/1292] Compiling C object scipy/sparse/linalg/_propack/libpropack_lib.a.p/PROPACK_src_gemm_overwrite.c.obj
FAILED: [code=1] scipy/sparse/linalg/_propack/libpropack_lib.a.p/PROPACK_src_gemm_overwrite.c.obj 
"clang-cl" "-Iscipy\sparse\linalg\_propack\libpropack_lib.a.p" "-Iscipy\sparse\linalg\_propack" "-I..\scipy\sparse\linalg\_propack" "-I..\scipy\sparse\linalg\_propack\PROPACK\include" "-I..\scipy\sparse\linalg\_propack\PROPACK\src\include" "-IC:/hostedtoolcache/windows/Python/3.11.9/arm64/Lib/site-packages/scipy_openblas32/include" "-DNDEBUG" "/MD" "/nologo" "/showIncludes" "/utf-8" "/W2" "/clang:-std=c17" "/O2" "/Gw" "-Wno-unused-but-set-variable" "-Wno-unused-function" "-Wno-conversion" "-Wno-misleading-indentation" "-Qunused-arguments" "-D_CRT_SECURE_NO_WARNINGS" "-DBLAS_SYMBOL_PREFIX=scipy_" "/Fdscipy\sparse\linalg\_propack\libpropack_lib.a.p\PROPACK_src_gemm_overwrite.c.pdb" /Foscipy/sparse/linalg/_propack/libpropack_lib.a.p/PROPACK_src_gemm_overwrite.c.obj "/c" ../scipy/sparse/linalg/_propack/PROPACK/src/gemm_overwrite.c
../scipy/sparse/linalg/_propack/PROPACK/src/gemm_overwrite.c(305,43): error: call to undeclared function '_FCMulcr'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  305 |                 PROPACK_CPLXF_TYPE tmp1 = _FCMulcr(A[i + l * lda], b_val);
      |                                           ^
../scipy/sparse/linalg/_propack/PROPACK/src/gemm_overwrite.c(305,43): note: did you mean '_FCmulcr'?
C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\ucrt\complex.h(153,28): note: '_FCmulcr' declared here
  153 | _ACRTIMP _Fcomplex __cdecl _FCmulcr(_In_ _Fcomplex _X, _In_ float _Y);
      |                            ^
../scipy/sparse/linalg/_propack/PROPACK/src/gemm_overwrite.c(305,36): error: initializing 'PROPACK_CPLXF_TYPE' (aka 'struct _C_float_complex') with an expression of incompatible type 'int'
  305 |                 PROPACK_CPLXF_TYPE tmp1 = _FCMulcr(A[i + l * lda], b_val);
      |                                    ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.

It finds half of the complex.h but cannot figure out the other half. Then tells exactly what is missing, is located in complex.h. In the meantime it is not tripping over _CMulcr which is the double precision version of the same thing. I might be blinded by looking at it for so long now, so I would appreciate any pointers.

Tangentially by the way, why is clang defining _MSC_VER on windows? I would have expected it to go through the C99 compliant route.

Yep, I am blind that's a typo and I was staring at it for hours.

Copy link
Contributor

@tylerjereddy tylerjereddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I seem to remember some propack-specific issues in tests, but the one skip I tried to purge out has the same behavior here I think:

--- a/scipy/sparse/linalg/_eigen/tests/test_svds.py
+++ b/scipy/sparse/linalg/_eigen/tests/test_svds.py
@@ -738,9 +738,6 @@ class SVDSCommonTests:
                 and k == min(A.shape) - 1):
             pytest.skip("#16725")
 
-        if self.solver == 'propack':
-            pytest.skip("PROPACK failures unrelated to PR #16712")

There was, at one time, a mass of propack problems on Windows + conda-forge IIRC, that even blocked a release for a month or so? It might be worth touching base with @h-vetinari to see if there's a desire to take this branch for a spin over there? Or maybe those problems are all long gone anyway..

@ilayn
Copy link
Member Author

ilayn commented Sep 1, 2025

If someone knows how to tame conda to use MKL instead of openblas in scipy builds, I can check these remaining 3 failing jobs. The instructions are a bit outdated and not geared towards spin usage. If I fix these three jobs, then all segfaults/hangups can be analyzed in a debugger of anyone's choice.

The sparse.linalg test suite apparently grew a bit organically over time and has lots of conditional skips that I can't always read the intention behind it. Some might be actual shortcomings of PROPACK.

@lucascolley
Copy link
Member

With https://github.com/rgommers/pixi-dev-scipystack you can pixi shell --environment=mkl, then a fresh build with spin should use mkl.

Just avoid pixi run build for now, that still uses openblas.

@ev-br
Copy link
Member

ev-br commented Sep 1, 2025

tame conda to use MKL instead of openblas in scipy builds

From https://github.com/scipy/scipy/blob/main/.github/workflows/linux_blas.yml#L60

$ pip install git+https://github.com/numpy/meson.git@main-numpymeson
$ pip install mkl mkl-devel
$ spin build -S-Dblas=mkl

Note 1) need the numpy fork of meson, and 2) need to git clean -xdf or otherwise ensure a clean rebuild.

@ilayn
Copy link
Member Author

ilayn commented Sep 1, 2025

With https://github.com/rgommers/pixi-dev-scipystack you can pixi shell --environment=mkl, then a fresh build with spin should use mkl.

No luck unfortunately.

(scipy:mkl) (base) ➜  scipy git:(rewrite_propack) spin build
$ meson setup build --prefix=/usr
The Meson build system
Version: 1.8.2
Source dir: /home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/scipy
Build dir: /home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/scipy/build
Build type: native build
Project name: scipy
Project version: 1.17.0.dev0+git20250831.61d5373
C compiler for the host machine: /home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/bin/x86_64-conda-linux-gnu-cc (gcc 13.3.0 "x86_64-conda-linux-gnu-cc (conda-forge gcc 13.3.0-2) 13.3.0")
C linker for the host machine: /home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/bin/x86_64-conda-linux-gnu-cc ld.bfd 2.44
C++ compiler for the host machine: /home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/bin/x86_64-conda-linux-gnu-c++ (gcc 13.3.0 "x86_64-conda-linux-gnu-c++ (conda-forge gcc 13.3.0-2) 13.3.0")
C++ linker for the host machine: /home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/bin/x86_64-conda-linux-gnu-c++ ld.bfd 2.44
Cython compiler for the host machine: cython (cython 3.1.2)
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program python3 found: YES (/home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/bin/python3.12)
Found pkg-config: YES (/home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/bin/pkg-config) 0.29.2
Run-time dependency python found: YES 3.12
Program cython found: YES (/home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/bin/cython)
Compiler for C supports arguments -Wno-unused-but-set-variable: YES 
Compiler for C supports arguments -Wno-unused-function: YES 
Compiler for C supports arguments -Wno-conversion: YES 
Compiler for C supports arguments -Wno-misleading-indentation: YES 
Library m found: YES
Fortran compiler for the host machine: /home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/bin/x86_64-conda-linux-gnu-gfortran (gcc 13.3.0 "GNU Fortran (conda-forge gcc 13.3.0-2) 13.3.0")
Fortran linker for the host machine: /home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/bin/x86_64-conda-linux-gnu-gfortran ld.bfd 2.44
meson.build:94: WARNING: Consider using the built-in option for language standard version instead of using "-std=legacy".
Compiler for Fortran supports arguments -Wno-conversion: YES 
Checking if "-Wl,--version-script" links: YES 
Program tools/generate_f2pymod.py found: YES (/home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/bin/python3.12 /home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/scipy/tools/generate_f2pymod.py)
Program scipy/_build_utils/tempita.py found: YES (/home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/bin/python3.12 /home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/scipy/scipy/_build_utils/tempita.py)
Program pythran found: YES 0.18.0 0.18.0 (/home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/bin/pythran)
Did not find CMake 'cmake'
Found CMake: NO
Run-time dependency xsimd found: NO (tried pkgconfig and cmake)

Executing subproject xsf 

xsf| Project name: xsf
xsf| Project version: 0.1.0
xsf| C++ compiler for the host machine: /home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/bin/x86_64-conda-linux-gnu-c++ (gcc 13.3.0 "x86_64-conda-linux-gnu-c++ (conda-forge gcc 13.3.0-2) 13.3.0")
xsf| C++ linker for the host machine: /home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/bin/x86_64-conda-linux-gnu-c++ ld.bfd 2.44
xsf| Build targets in project: 0
xsf| Subproject xsf finished.


Executing subproject boost_math 

boost_math| Project name: boost-math
boost_math| Project version: 1.88.0
boost_math| Build targets in project: 0
boost_math| Subproject boost_math finished.


Executing subproject qhull_r 

qhull_r| Project name: qhull_r
qhull_r| Project version: 8.0.2
qhull_r| C compiler for the host machine: /home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/bin/x86_64-conda-linux-gnu-cc (gcc 13.3.0 "x86_64-conda-linux-gnu-cc (conda-forge gcc 13.3.0-2) 13.3.0")
qhull_r| C linker for the host machine: /home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/bin/x86_64-conda-linux-gnu-cc ld.bfd 2.44
qhull_r| Compiler for C supports arguments -Wno-unused-but-set-variable: YES (cached)
qhull_r| Build targets in project: 1
qhull_r| Subproject qhull_r finished.

Run-time dependency threads found: YES
numpy-config found: YES (/home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/bin/numpy-config) 2.3.1
Run-time dependency numpy found: YES 2.3.1
Message: f2py free-threading enabled
Library npymath found: YES
Run-time dependency pybind11 found: YES 3.0.0
Checking if "thread_local" compiles: NO 
Checking if "_Thread_local" compiles: YES 
Checking if "__thread" compiles: YES 
Configuring scipy_config.h using configuration
Program f2py found: YES (/home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/bin/f2py)
Run-time dependency scipy-openblas found: NO (tried pkgconfig)
Run-time dependency openblas found: NO (tried pkgconfig and cmake)
Run-time dependency openblas found: NO (tried pkgconfig)

scipy/meson.build:285:9: ERROR: Dependency "OpenBLAS" not found, tried pkgconfig

A full log can be found at /home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/scipy/build/meson-logs/meson-log.txt

RuntimeError: Meson configuration failed; please try `spin build` again with the `--clean` flag.

This exception was raised from:

  /home/ilayn/Documents/GitHub/pixi-dev-scipystack/scipy/.pixi/envs/mkl/lib/python3.12/site-packages/spin/cmds/meson.py

If you suspect this is a bug in `spin`, please file a report at:

  https://github.com/scientific-python/spin

including the above traceback and the following information:

  spin: 0.14, package: scipy

Aborting.

Note 1) need the numpy fork of meson, and 2) need to git clean -xdf or otherwise ensure a clean rebuild.

This worked after adding ninja,

(scipy-numpy-mkl) ➜  scipy git:(rewrite_propack) spin build -S-Dblas=mkl
$ meson setup build --prefix=/usr -Dblas=mkl
The Meson build system
Version: 1.8.3
Source dir: /home/ilayn/Documents/GitHub/scipy
Build dir: /home/ilayn/Documents/GitHub/scipy/build
Build type: native build
Project name: scipy
Project version: 1.17.0.dev0+git20250831.61d5373
C compiler for the host machine: /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/x86_64-conda-linux-gnu-cc (gcc 14.3.0 "x86_64-conda-linux-gnu-cc (conda-forge gcc 14.3.0-4) 14.3.0")
C linker for the host machine: /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/x86_64-conda-linux-gnu-cc ld.bfd 2.44
C++ compiler for the host machine: /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/x86_64-conda-linux-gnu-c++ (gcc 14.3.0 "x86_64-conda-linux-gnu-c++ (conda-forge gcc 14.3.0-4) 14.3.0")
C++ linker for the host machine: /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/x86_64-conda-linux-gnu-c++ ld.bfd 2.44
Cython compiler for the host machine: cython (cython 3.1.3)
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program python3 found: YES (/home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/python3.13)
Found pkg-config: YES (/usr/bin/pkg-config) 2.3.0
Run-time dependency python found: YES 3.13
Program cython found: YES (/home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/cython)
Compiler for C supports arguments -Wno-unused-but-set-variable: YES 
Compiler for C supports arguments -Wno-unused-function: YES 
Compiler for C supports arguments -Wno-conversion: YES 
Compiler for C supports arguments -Wno-misleading-indentation: YES 
Library m found: YES
Fortran compiler for the host machine: /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/x86_64-conda-linux-gnu-gfortran (gcc 14.3.0 "GNU Fortran (conda-forge gcc 14.3.0-4) 14.3.0")
Fortran linker for the host machine: /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/x86_64-conda-linux-gnu-gfortran ld.bfd 2.44
meson.build:94: WARNING: Consider using the built-in option for language standard version instead of using "-std=legacy".
Compiler for Fortran supports arguments -Wno-conversion: YES 
Checking if "-Wl,--version-script" links: YES 
Program tools/generate_f2pymod.py found: YES (/home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/python3.13 /home/ilayn/Documents/GitHub/scipy/tools/generate_f2pymod.py)
Program scipy/_build_utils/tempita.py found: YES (/home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/python3.13 /home/ilayn/Documents/GitHub/scipy/scipy/_build_utils/tempita.py)
Program pythran found: YES 0.18.0 0.18.0 (/home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/pythran)
Found CMake: /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/cmake (4.1.1)
Run-time dependency xsimd found: NO (tried pkgconfig and cmake)

Executing subproject xsf 

xsf| Project name: xsf
xsf| Project version: 0.1.0
xsf| C++ compiler for the host machine: /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/x86_64-conda-linux-gnu-c++ (gcc 14.3.0 "x86_64-conda-linux-gnu-c++ (conda-forge gcc 14.3.0-4) 14.3.0")
xsf| C++ linker for the host machine: /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/x86_64-conda-linux-gnu-c++ ld.bfd 2.44
xsf| Build targets in project: 0
xsf| Subproject xsf finished.


Executing subproject boost_math 

boost_math| Project name: boost-math
boost_math| Project version: 1.88.0
boost_math| Build targets in project: 0
boost_math| Subproject boost_math finished.


Executing subproject qhull_r 

qhull_r| Project name: qhull_r
qhull_r| Project version: 8.0.2
qhull_r| C compiler for the host machine: /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/x86_64-conda-linux-gnu-cc (gcc 14.3.0 "x86_64-conda-linux-gnu-cc (conda-forge gcc 14.3.0-4) 14.3.0")
qhull_r| C linker for the host machine: /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/x86_64-conda-linux-gnu-cc ld.bfd 2.44
qhull_r| Compiler for C supports arguments -Wno-unused-but-set-variable: YES (cached)
qhull_r| Build targets in project: 1
qhull_r| Subproject qhull_r finished.

Run-time dependency threads found: YES
numpy-config found: YES (/home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/numpy-config) 2.3.2
Run-time dependency numpy found: YES 2.3.2
Message: f2py free-threading enabled
Library npymath found: YES
pybind11-config found: YES (/home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/pybind11-config) 3.0.1
Run-time dependency pybind11 found: YES 3.0.1
Checking if "thread_local" compiles: NO 
Checking if "_Thread_local" compiles: YES 
Checking if "__thread" compiles: YES 
Configuring scipy_config.h using configuration
Program f2py found: YES (/home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/f2py)
Run-time dependency mkl found: YES 2024.2.0
Run-time dependency mkl found: YES 2024.2.0
Compiler for C supports arguments -Wno-maybe-uninitialized: YES 
Compiler for C supports arguments -Wno-discarded-qualifiers: YES 
Compiler for C supports arguments -Wno-empty-body: YES 
Compiler for C supports arguments -Wno-implicit-function-declaration: YES 
Compiler for C supports arguments -Wno-parentheses: YES 
Compiler for C supports arguments -Wno-switch: YES 
Compiler for C supports arguments -Wno-unused-label: YES 
Compiler for C supports arguments -Wno-unused-result: YES 
Compiler for C supports arguments -Wno-unused-variable: YES 
Compiler for C supports arguments -Wno-unused-but-set-variable: YES (cached)
Compiler for C++ supports arguments -Wno-bitwise-instead-of-logical: NO 
Compiler for C++ supports arguments -Wno-cpp: YES 
Compiler for C++ supports arguments -Wno-class-memaccess: YES 
Compiler for C++ supports arguments -Wno-deprecated-declarations: YES 
Compiler for C++ supports arguments -Wno-deprecated-builtins: NO 
Compiler for C++ supports arguments -Wno-format-truncation: YES 
Compiler for C++ supports arguments -Wno-non-virtual-dtor: YES 
Compiler for C++ supports arguments -Wno-sign-compare: YES 
Compiler for C++ supports arguments -Wno-switch: YES 
Compiler for C++ supports arguments -Wno-terminate: YES 
Compiler for C++ supports arguments -Wno-unused-but-set-variable: YES 
Compiler for C++ supports arguments -Wno-unused-function: YES 
Compiler for C++ supports arguments -Wno-unused-local-typedefs: YES 
Compiler for C++ supports arguments -Wno-unused-variable: YES 
Compiler for C++ supports arguments -Wno-int-in-bool-context: YES 
Compiler for Fortran supports arguments -Wno-argument-mismatch: YES 
Compiler for Fortran supports arguments -Wno-conversion: YES (cached)
Compiler for Fortran supports arguments -Wno-intrinsic-shadow: YES 
Compiler for Fortran supports arguments -Wno-maybe-uninitialized: YES 
Compiler for Fortran supports arguments -Wno-surprising: YES 
Compiler for Fortran supports arguments -Wno-uninitialized: YES 
Compiler for Fortran supports arguments -Wno-unused-dummy-argument: YES 
Compiler for Fortran supports arguments -Wno-unused-label: YES 
Compiler for Fortran supports arguments -Wno-unused-variable: YES 
Compiler for Fortran supports arguments -Wno-tabs: YES 
Compiler for Fortran supports arguments -Wno-argument-mismatch: YES (cached)
Compiler for Fortran supports arguments -Wno-conversion: YES (cached)
Compiler for Fortran supports arguments -Wno-maybe-uninitialized: YES (cached)
Compiler for Fortran supports arguments -Wno-unused-dummy-argument: YES (cached)
Compiler for Fortran supports arguments -Wno-unused-label: YES (cached)
Compiler for Fortran supports arguments -Wno-unused-variable: YES (cached)
Compiler for Fortran supports arguments -Wno-tabs: YES (cached)
Compiler for Fortran supports arguments -cpp -ffree-line-length-none -ffixed-line-length-none: YES 
Checking if "Check atomic builtins without -latomic" links: YES 
Configuring __config__.py using configuration
Checking for function "open_memstream" : YES 
Configuring messagestream_config.h using configuration
Program _generate_pyx.py found: YES (/home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/python3.13 /home/ilayn/Documents/GitHub/scipy/scipy/special/_generate_pyx.py)
Program _generate_pyx.py found: YES (/home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/python3.13 /home/ilayn/Documents/GitHub/scipy/scipy/linalg/_generate_pyx.py)
Program ../_generate_sparsetools.py found: YES (/home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/python3.13 /home/ilayn/Documents/GitHub/scipy/scipy/sparse/sparsetools/../_generate_sparsetools.py)
Checking for size of "void*" : 8 

Executing subproject highs 

highs| Project name: highs
highs| Project version: 1.8.0
highs| C compiler for the host machine: /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/x86_64-conda-linux-gnu-cc (gcc 14.3.0 "x86_64-conda-linux-gnu-cc (conda-forge gcc 14.3.0-4) 14.3.0")
highs| C linker for the host machine: /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/x86_64-conda-linux-gnu-cc ld.bfd 2.44
highs| C++ compiler for the host machine: /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/x86_64-conda-linux-gnu-c++ (gcc 14.3.0 "x86_64-conda-linux-gnu-c++ (conda-forge gcc 14.3.0-4) 14.3.0")
highs| C++ linker for the host machine: /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/x86_64-conda-linux-gnu-c++ ld.bfd 2.44
highs| Compiler for C++ supports arguments -Wno-invalid-offsetof: YES
highs| Compiler for C++ supports arguments -Wno-maybe-uninitialized: YES
highs| Compiler for C++ supports arguments -Wno-reorder: YES
highs| Compiler for C++ supports arguments -Wno-reorder-ctor: NO
highs| Compiler for C++ supports arguments -Wno-sometimes-uninitialized: NO
highs| Compiler for C++ supports arguments -Wno-unused-but-set-variable: YES (cached)
highs| Compiler for C++ supports arguments -Wno-unused-variable: YES (cached)
highs| Compiler for C++ supports arguments -Wno-use-after-free: YES
highs| Compiler for C++ supports arguments -Wno-comment: YES
highs| Compiler for C supports arguments -Wno-comment: YES
highs| Compiler for C supports arguments -Wno-invalid-offsetof: NO
highs| Compiler for C supports arguments -Wno-maybe-uninitialized: YES (cached)
highs| Compiler for C supports arguments -Wno-sometimes-uninitialized: NO
highs| Compiler for C supports arguments -Wno-unused-label: YES (cached)
highs| Compiler for C supports arguments -Wno-use-after-free: YES
highs| Compiler for C supports arguments -Wno-unused-but-set-variable: YES (cached)
highs| Compiler for C supports arguments -Wno-unused-variable: YES (cached)
highs| Compiler for C supports arguments -Wno-use-after-free: YES (cached)
highs| Compiler for C++ supports arguments -mpopcnt: YES
highs| Dependency threads found: YES unknown (cached)
highs| Checking if "Check atomic builtins without -latomic" links: YES (cached)
highs| Dependency zlib skipped: feature use_zlib disabled
highs| Checking if "mm_pause check" compiles: YES
highs| Checking if "builtin_clz check" compiles: YES
highs| Configuring HConfig.h.meson.interim using configuration
highs| Found git repository at /home/ilayn/Documents/GitHub/scipy
highs| Build targets in project: 138
highs| Subproject highs finished.

Build targets in project: 188

scipy 1.17.0.dev0+git20250831.61d5373

  Subprojects
    boost_math: YES
    highs     : YES
    qhull_r   : YES
    xsf       : YES

  User defined options
    blas      : mkl
    prefix    : /usr

Found ninja-1.13.1 at /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/ninja
$ meson compile -j 16 -C build
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/ninja -C /home/ilayn/Documents/GitHub/scipy/build -j 16

But now the test does not fail, it might not be a code issue

(scipy-numpy-mkl) ➜  scipy git:(rewrite_propack) spin test -t scipy.sparse.linalg.tests.test_propack::test_svdp\[LM-False-float64-array\] -v -v -v -- --capture=sys
Invoking `build` prior to running tests:
$ meson compile -j 16 -C build
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/ninja -C /home/ilayn/Documents/GitHub/scipy/build -j 16
ninja: Entering directory `/home/ilayn/Documents/GitHub/scipy/build'
[2/338] Generating subprojects/highs/src/HConfig.h with a custom command
$ meson install --only-changed -C build --destdir ../build-install --tags=runtime,python-runtime,tests,devel
$ export PYTHONPATH="/home/ilayn/Documents/GitHub/scipy/build-install/usr/lib/python3.13/site-packages"
$ /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/python3.13 -P -c 'import scipy'
$ cd /home/ilayn/Documents/GitHub/scipy/build-install/usr/lib/python3.13/site-packages
$ /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/python3.13 -P -m pytest -v -m 'not slow' --capture=sys --pyargs 'scipy.sparse.linalg.tests.test_propack::test_svdp[LM-False-float64-array]'
===================================================================================================================================================== test session starts =====================================================================================================================================================
platform linux -- Python 3.13.5, pytest-8.4.1, pluggy-1.6.0 -- /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/python3.13
cachedir: .pytest_cache
hypothesis profile 'default'
rootdir: /home/ilayn/Documents/GitHub/scipy
configfile: pytest.ini
plugins: hypothesis-6.138.11, xdist-3.8.0
collected 1 item                                                                                                                                                                                                                                                                                                              

scipy/sparse/linalg/tests/test_propack.py::test_svdp[LM-False-float64-array] PASSED                                                                                                                                                                                                                                     [100%]

================================================== 1 passed in 0.33s ==================================================

@lucascolley
Copy link
Member

With rgommers/pixi-dev-scipystack you can pixi shell --environment=mkl, then a fresh build with spin should use mkl.

No luck unfortunately.

Note 1) need the numpy fork of meson

Thanks both! I just checked and pointing to NumPy's fork of meson and passing --setup-args=-Dblas=mkl makes this work with the Pixi setup.

I will make a PR to fix this in the Pixi workspace this week.

@rgommers
Copy link
Member

rgommers commented Sep 2, 2025

Great to see this!

But now the test does not fail, it might not be a code issue

MKL version issue perhaps? CI pulls 2025.2.0 from PyPI, and that isn't yet available in conda-forge. Probably easiest to check by downgrading versions in .github/workflows/linux_blas.yml and see if older versions fail. If they do, it should also be reproducible with the MKL packages in conda-forge, since they're the exact same binaries, just repackaged differently.

@h-vetinari
Copy link
Member

It might be worth touching base with @h-vetinari to see if there's a desire to take this branch for a spin over there?

I can test this PR in our CI if it helps. Unfortunately, the BLAS+openmp situation is in pretty bad shape in conda-forge ATM. MKL 2025 has been blocked for about a year, which caused us to globally cap to <2024 in our blas infrastructure. That can lead the solver astray when it tries to pull in mkl 2025 for some reason.

Furthermore, we switched from intel-openmp to llvm-openmp (after the last hold-out, pytorch, finally became buildable in conda-forge on windows), but this has not gone well. The pytorch feedstock is currently broken, and to add insult to injury, the just-released llvm-openmp v21 breaks numpy.

I've pushed pretty hard on unblocking MKL myself, and asked for help in various places, but there's no cavalry on the horizon. Due to all of this (mostly MKL, and how long they take to update their compatibility with reference lapack), we're also still stuck on LAPACK 3.9, which is by now getting quite long in the tooth.

@ilayn
Copy link
Member Author

ilayn commented Sep 2, 2025

In the meantime I mishmashed a conda-forge environment to have pip installed MKL2025.2. The test still passes

(scipy-numpy-mkl) ➜  scipy git:(rewrite_propack) spin test -t scipy.sparse.linalg.tests.test_propack::test_svdp\[LM-True-float64-array\] -v -v -v -- --capture=sys
Invoking `build` prior to running tests:
$ meson compile -j 16 -C build
INFO: autodetecting backend as ninja
INFO: calculating backend command to run: /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/ninja -C /home/ilayn/Documents/mkl-venv/scipy/build -j 16
ninja: Entering directory `/home/ilayn/Documents/mkl-venv/scipy/build'
[2/338] Generating subprojects/highs/src/HConfig.h with a custom command
$ meson install --only-changed -C build --destdir ../build-install --tags=runtime,python-runtime,tests,devel
$ export PYTHONPATH="/home/ilayn/Documents/mkl-venv/scipy/build-install/usr/lib/python3.13/site-packages"
$ /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/python3.13 -P -c 'import scipy'
$ cd /home/ilayn/Documents/mkl-venv/scipy/build-install/usr/lib/python3.13/site-packages
$ /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/python3.13 -P -m pytest -v -m 'not slow' --capture=sys --pyargs 'scipy.sparse.linalg.tests.test_propack::test_svdp[LM-True-float64-array]'
===================================================================================================================================================== test session starts =====================================================================================================================================================
platform linux -- Python 3.13.5, pytest-8.4.1, pluggy-1.6.0 -- /home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/python3.13
cachedir: .pytest_cache
hypothesis profile 'default'
rootdir: /home/ilayn/Documents/mkl-venv/scipy
configfile: pytest.ini
plugins: hypothesis-6.138.11, xdist-3.8.0
collected 1 item                                                                                                                                                                                                                                                                                                              

scipy/sparse/linalg/tests/test_propack.py::test_svdp[LM-True-float64-array] PASSED                                                                                                                                                                                                                                      [100%]

====================================================================================================================================================== 1 passed in 0.16s ======================================================================================================================================================




(scipy-numpy-mkl) ➜  scipy git:(rewrite_propack) cd build-install/usr/lib/python3.13/site-packages 
(scipy-numpy-mkl) ➜  site-packages git:(rewrite_propack) python
Python 3.13.5 | packaged by conda-forge | (main, Jun 16 2025, 08:27:50) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy 
>>> scipy.show_config()
/home/ilayn/Documents/mkl-venv/scipy/build-install/usr/lib/python3.13/site-packages/scipy/__config__.py:164: UserWarning: Install `pyyaml` for better output
  warnings.warn("Install `pyyaml` for better output", stacklevel=1)
{
  "Compilers": {
    "c": {
      "name": "gcc",
      "linker": "ld.bfd",
      "version": "14.3.0",
      "commands": "/home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/x86_64-conda-linux-gnu-cc",
      "args": "-march=nocona, -mtune=haswell, -ftree-vectorize, -fPIC, -fstack-protector-strong, -fno-plt, -O2, -ffunction-sections, -pipe, -isystem, /home/ilayn/miniforge3/envs/scipy-numpy-mkl/include, -DNDEBUG, -D_FORTIFY_SOURCE=2, -O2, -isystem, /home/ilayn/miniforge3/envs/scipy-numpy-mkl/include",
      "linker args": "-Wl,-O2, -Wl,--sort-common, -Wl,--as-needed, -Wl,-z,relro, -Wl,-z,now, -Wl,--disable-new-dtags, -Wl,--gc-sections, -Wl,--allow-shlib-undefined, -Wl,-rpath,/home/ilayn/miniforge3/envs/scipy-numpy-mkl/lib, -Wl,-rpath-link,/home/ilayn/miniforge3/envs/scipy-numpy-mkl/lib, -L/home/ilayn/miniforge3/envs/scipy-numpy-mkl/lib, -march=nocona, -mtune=haswell, -ftree-vectorize, -fPIC, -fstack-protector-strong, -fno-plt, -O2, -ffunction-sections, -pipe, -isystem, /home/ilayn/miniforge3/envs/scipy-numpy-mkl/include, -DNDEBUG, -D_FORTIFY_SOURCE=2, -O2, -isystem, /home/ilayn/miniforge3/envs/scipy-numpy-mkl/include"
    },
    "cython": {
      "name": "cython",
      "linker": "cython",
      "version": "3.1.3",
      "commands": "cython"
    },
    "c++": {
      "name": "gcc",
      "linker": "ld.bfd",
      "version": "14.3.0",
      "commands": "/home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/x86_64-conda-linux-gnu-c++",
      "args": "-fvisibility-inlines-hidden, -fmessage-length=0, -march=nocona, -mtune=haswell, -ftree-vectorize, -fPIC, -fstack-protector-strong, -fno-plt, -O2, -ffunction-sections, -pipe, -isystem, /home/ilayn/miniforge3/envs/scipy-numpy-mkl/include, -DNDEBUG, -D_FORTIFY_SOURCE=2, -O2, -isystem, /home/ilayn/miniforge3/envs/scipy-numpy-mkl/include",
      "linker args": "-Wl,-O2, -Wl,--sort-common, -Wl,--as-needed, -Wl,-z,relro, -Wl,-z,now, -Wl,--disable-new-dtags, -Wl,--gc-sections, -Wl,--allow-shlib-undefined, -Wl,-rpath,/home/ilayn/miniforge3/envs/scipy-numpy-mkl/lib, -Wl,-rpath-link,/home/ilayn/miniforge3/envs/scipy-numpy-mkl/lib, -L/home/ilayn/miniforge3/envs/scipy-numpy-mkl/lib, -fvisibility-inlines-hidden, -fmessage-length=0, -march=nocona, -mtune=haswell, -ftree-vectorize, -fPIC, -fstack-protector-strong, -fno-plt, -O2, -ffunction-sections, -pipe, -isystem, /home/ilayn/miniforge3/envs/scipy-numpy-mkl/include, -DNDEBUG, -D_FORTIFY_SOURCE=2, -O2, -isystem, /home/ilayn/miniforge3/envs/scipy-numpy-mkl/include"
    },
    "fortran": {
      "name": "gcc",
      "linker": "ld.bfd",
      "version": "14.3.0",
      "commands": "/home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/x86_64-conda-linux-gnu-gfortran",
      "args": "-march=nocona, -mtune=haswell, -ftree-vectorize, -fPIC, -fstack-protector-strong, -fno-plt, -O2, -ffunction-sections, -pipe, -isystem, /home/ilayn/miniforge3/envs/scipy-numpy-mkl/include, -I/home/ilayn/miniforge3/envs/scipy-numpy-mkl/include",
      "linker args": "-Wl,-O2, -Wl,--sort-common, -Wl,--as-needed, -Wl,-z,relro, -Wl,-z,now, -Wl,--disable-new-dtags, -Wl,--gc-sections, -Wl,--allow-shlib-undefined, -Wl,-rpath,/home/ilayn/miniforge3/envs/scipy-numpy-mkl/lib, -Wl,-rpath-link,/home/ilayn/miniforge3/envs/scipy-numpy-mkl/lib, -L/home/ilayn/miniforge3/envs/scipy-numpy-mkl/lib, -march=nocona, -mtune=haswell, -ftree-vectorize, -fPIC, -fstack-protector-strong, -fno-plt, -O2, -ffunction-sections, -pipe, -isystem, /home/ilayn/miniforge3/envs/scipy-numpy-mkl/include, -I/home/ilayn/miniforge3/envs/scipy-numpy-mkl/include"
    },
    "pythran": {
      "version": "0.18.0",
      "include directory": "../../../../miniforge3/envs/scipy-numpy-mkl/lib/python3.13/site-packages/pythran"
    }
  },
  "Machine Information": {
    "host": {
      "cpu": "x86_64",
      "family": "x86_64",
      "endian": "little",
      "system": "linux"
    },
    "build": {
      "cpu": "x86_64",
      "family": "x86_64",
      "endian": "little",
      "system": "linux"
    },
    "cross-compiled": false
  },
  "Build Dependencies": {
    "blas": {
      "name": "mkl-dynamic-lp64-seq",
      "found": true,
      "version": "2025.2",
      "detection method": "pkgconfig",
      "include directory": "/home/ilayn/miniforge3/envs/scipy-numpy-mkl/lib/pkgconfig/../../include",
      "lib directory": "/home/ilayn/miniforge3/envs/scipy-numpy-mkl/lib/pkgconfig/../../lib",
      "openblas configuration": "unknown",
      "pc file directory": "/home/ilayn/miniforge3/envs/scipy-numpy-mkl/lib/pkgconfig"
    },
    "lapack": {
      "name": "mkl-dynamic-lp64-seq",
      "found": true,
      "version": "2025.2",
      "detection method": "pkgconfig",
      "include directory": "/home/ilayn/miniforge3/envs/scipy-numpy-mkl/lib/pkgconfig/../../include",
      "lib directory": "/home/ilayn/miniforge3/envs/scipy-numpy-mkl/lib/pkgconfig/../../lib",
      "openblas configuration": "unknown",
      "pc file directory": "/home/ilayn/miniforge3/envs/scipy-numpy-mkl/lib/pkgconfig"
    },
    "pybind11": {
      "name": "pybind11",
      "version": "3.0.1",
      "detection method": "config-tool",
      "include directory": "unknown"
    }
  },
  "Python Information": {
    "path": "/home/ilayn/miniforge3/envs/scipy-numpy-mkl/bin/python3.13",
    "version": "3.13"
  }
}
>>> 

All versions seem to be similar to BLAS job including the numpy-meson. I am starting to fear that this is another Ubuntu problem similar to that in #23161 that I still could not figure out why.

@ev-br
Copy link
Member

ev-br commented Sep 2, 2025

$ spin build -S-Dblas=mkl
$ spin test scipy/sparse/linalg/tests/test_propack.py -v

passes locally in an environment with

$ mamba list |grep mkl
# packages in environment at /home/ev-br/.conda/envs/scipy-dev-mkl:
libblas                   3.9.0           31_hfdb39a5_mkl    conda-forge
libcblas                  3.9.0           31_h372d94f_mkl    conda-forge
liblapack                 3.9.0           31_hc41d3b0_mkl    conda-forge
mkl                       2024.2.2            ha957f24_16    conda-forge
mkl-devel                 2024.2.2            ha770c72_16    conda-forge
mkl-include               2024.2.2            ha957f24_16    conda-forge

and

$ ldd build/scipy/sparse/linalg/_propack/_propack.cpython-312-x86_64-linux-gnu.so
	linux-vdso.so.1 (0x00007ffe2e1bc000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007cdba4778000)
	libmkl_intel_lp64.so.2 => /home/ev-br/.conda/envs/scipy-dev-mkl/lib/libmkl_intel_lp64.so.2 (0x00007cdba3600000)
	libmkl_sequential.so.2 => /home/ev-br/.conda/envs/scipy-dev-mkl/lib/libmkl_sequential.so.2 (0x00007cdba2000000)
	libmkl_core.so.2 => /home/ev-br/.conda/envs/scipy-dev-mkl/lib/libmkl_core.so.2 (0x00007cdb9de00000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007cdb9da00000)
	/lib64/ld-linux-x86-64.so.2 (0x00007cdba489a000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007cdba4771000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007cdba476c000)

One other difference from #23531 (comment) is the python version. My local environment is for python 3.12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C/C++ Items related to the internal C/C++ code base enhancement A new feature or improvement Fortran Items related to the internal Fortran code base maintenance Items related to regular maintenance tasks Meson Items related to the introduction of Meson as the new build system for SciPy scipy.sparse.linalg
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants