conda-forge / scipy-feedstock

A conda-smithy repository for scipy.
BSD 3-Clause "New" or "Revised" License
6 stars 36 forks source link

Win: Alternative to MKL #257

Open ax3l opened 1 year ago

ax3l commented 1 year ago

Solution to issue cannot be found in the documentation.

Issue

Currently, the CF scipy build on Windows unconditionally builds against MKL (for blas & lapack). mkl has a hard dependency on intel-openmp, which means downstream projects that use scipy cannot use llvm-openmp with clang-cl anymore if they pull in scipy (even if only at runtime).

https://conda-forge.org/docs/maintainer/knowledge_base.html#blas https://github.com/conda-forge/intel_repack-feedstock/issues/59

Is it possible to provide an alternative to depending on MKL for windows builds?

Installed packages

intel-openmp
mkl
scipy
...

Environment info

See link
h-vetinari commented 1 year ago

Currently, the CF scipy build on Windows unconditionally builds against MKL (for blas & lapack)

That is not true. We build against reference LAPACK, and you can switch it out in your environment as you please. I just tried[^1]

mamba create -n test scipy python=3.12 libblas=*=*blis
mamba create -n test scipy python=3.12 libblas=*=*mkl
mamba create -n test scipy python=3.12 libblas=*=*netlib
mamba create -n test scipy python=3.12 libblas=*=*openblas

and they all resolve without issue.

If you're trying to combine specifically openblas with llvm-openmp, you're going to run into the fact that we have no llvm-openmp builds of openblas on windows, but are stuck with an old libflang that's incompatible:

mamba create -n test scipy python=3.12 libblas=*=*openblas clang llvm-openmp

Looking for: ['scipy', 'python=3.12', 'libblas=[build=*openblas]', 'clang', 'llvm-openmp']

conda-forge/win-64                                          Using cache
conda-forge/noarch                                          Using cache
Could not solve for environment specs
The following packages are incompatible
├─ libblas * *openblas is installable with the potential options
│  ├─ libblas 3.8.0 would require
│  │  └─ openblas 0.3.6 h828a276_2, which does not exist (perhaps a missing channel);
│  ├─ libblas [3.8.0|3.9.0] would require
│  │  ├─ libopenblas [0.3.10 hc8a65f3_0|0.3.12 pthreads_h1662909_0|...|0.3.9 hcfe7411_0], which requires
│  │  │  └─ libflang [<6.0.0.a0 |>=5.0.0,<6.0.0.a0 ] with the potential options
│  │  │     ├─ libflang 5.0.0 would require
│  │  │     │  └─ openmp 5.0.0 , which can be installed;
│  │  │     └─ libflang 5.0.0 would require
│  │  │        └─ vc 14 , which does not exist (perhaps a missing channel);
│  │  └─ openblas >=0.3.6,<0.3.7.0a0 , which requires
│  │     └─ libflang <6.0.0.a0  with the potential options
│  │        ├─ libflang 5.0.0, which can be installed (as previously explained);
│  │        └─ libflang 5.0.0, which cannot be installed (as previously explained);

That work (openblas+llvm-openmp) was waiting for a very long time on https://github.com/conda-forge/conda-forge-pinning-feedstock/pull/1359, which itself needed a stable flang (that we've all been waiting for for even longer).

We now have flang 17, but that's still pretty experimental (and only used here out of necessity). I'm hoping that by flang 18 at the beginning of next year, we'll be able to roll it out as our fortran compiler on windows more generally.

CC @isuruf

[^1]: python=3.12 is not necessary, but just to force the solver to definitely pick the builds post-#255

ax3l commented 1 year ago

Thank you for the guidance!

Do you know what blas/lapack to pick on Windows to avoid incompatibility with llvm-openmp?

h-vetinari commented 1 year ago

Do you know what blas/lapack to pick on Windows to avoid incompatibility with llvm-openmp?

Neither blis nor netlib conflict

mamba create -n test scipy python=3.12 llvm-openmp libblas=*=*blis      ✅ 
mamba create -n test scipy python=3.12 llvm-openmp libblas=*=*mkl       ❌  # resolves but has both {intel,llvm}-openmp
mamba create -n test scipy python=3.12 llvm-openmp libblas=*=*netlib    ✅ 
mamba create -n test scipy python=3.12 llvm-openmp libblas=*=*openblas  ❌
ax3l commented 1 year ago

Thank you! I'll give that a try in https://github.com/conda-forge/impactx-feedstock/pull/23 :)

lucascolley commented 1 month ago

can this be closed @ax3l ?