New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Package OpenBLAS and use OpenBLAS in scipy #3331
Conversation
So I have the same error locally as in https://circleci.com/gh/pyodide/pyodide/62097
Note the
And somehow inside the Pyodide docker, the generated I managed to build OpenBLAS on my machine not sure what is different compared to the Pyodide docker image. A mystery that needs to be investigated a bit further ... |
For now I will use a recent commit on the OpenBLAS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! So it looks like OpenBLAS is building OK. Next step could be to remove CLAPACK (also to make sure it's not used) and link to OpenBLAS instead in scipy.
Maybe we should build it with -Os
instead of -O2
as currently, it produces a zip of 2.8MB while CLAPACK was 1.24MB
packages/openblas/meta.yaml
Outdated
mkdir -p dist | ||
cp libopenblas.so dist/ | ||
mkdir -p ${WASM_LIBRARY_DIR}/{lib,include} | ||
# TODO do I need include as in CLAPACK? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have guessed yes, but you can also probably not include it and see if there are any related include errors as done now.
This reverts commit c7dce40.
There are some errors when linking scipy with OpenBLAS:
There are already some similar warning when building OpenBLAS, so maybe this can be fixed in OpenBLAS: OpenMathLib/OpenBLAS#3640 (comment) |
We've been patching all void return value functions to return i32. This has something to do with alternative returns. |
Until it gets fixed upstream, you can try replacing all void return values with int. In suitesparse, the same problem happened, but the patching was not hard because the problematic functions had all same prefixes, not sure about this one though... pyodide/packages/suitesparse/meta.yaml Lines 20 to 22 in 7241496
|
OK I'll try something like this, thanks! Out of curiosity, the convention to always return int rather than void is a Pyodide convention (always returning |
It's because of a fortran feature called alternative returns. |
So scipy builds now but I get errors like this locally for example when doing
They happens in CircleCI as well e.g. this build https://app.circleci.com/pipelines/github/pyodide/pyodide/5095/workflows/d2b521c2-9683-4bc0-a994-ffd7520610e2/jobs/62303:
Suggestions more than welcome! |
You need to add
|
The CI failure seems to be because the HTTPS certificate has expired for https://mpfr.loria.fr/mpfr-4.1.0/mpfr-4.1.0.tar.xz, oh well ... In case this does not get fixed soonish, we can get the source from https://gitlab.inria.fr/mpfr/mpfr/-/archive/4.1.0/mpfr-4.1.0.tar.gz, but we then need to |
I have marked this PR as ready to review. Here are the few things that I am not too sure about:
About the CI failure and the problematic HTTPS certificate, it seems like the mpfr people know so hopefully that should be fixed soon. Another alternative is to use https://ftp.gnu.org/gnu/mpfr/, which is simpler than the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great, thanks a lot @lesteve !
For now I renamed CLAPACK to libf2c, but we still download the full CLAPACK, this was easier to do it this way since we already have the necessary patches.
I think it's fine this way, considering all the other things we download a few extra MB is not going to matter.
Personally this LGTM, I'll let Hood do the final review/approval.
Date: Fri, 10 Mar 2023 14:47:00 +0000 | ||
Subject: [PATCH 11/11] When forward declaring print_soln, give it the correct | ||
signature | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unresolving as I think it still needs the above comment in the patch description.
That was fixed in #3749 |
For completeness, the macOS test-core failure does not seem related to this PR. It seems to happen from time to time on main e.g. https://github.com/pyodide/pyodide/actions/runs/4663743467/jobs/8255711856. |
Yes, macOS CI is a bit flaky |
Thanks for your hard work @lesteve! I haven't been following this conversation closely, so I'll also let Hood approve it. My only concern is that CI-wise this PR adds a library that takes over 10 minutes to build when it's not cached. But we are trying to work on it (#3544, #3341), so hopefully we can find a way around it. |
Okay merging. Thanks again @lesteve! Really valuable to have someone contributing stuff like this. |
Great to see this one merged! Thanks a lot for the comments and the help, in particular the session in Paris helped a lot to see how you debug the kind of issues I was facing! |
@lesteve Were you planning of doing some benchmarks for say matrix multiplication before and after this change? You can take for instance 0.23.0 with CLAPACK and compare it with the dev deployment with OpenBLAS. I would expect for it to be a bit better but not massively better, at least until we optionally allow SIMD. So a next step could be to go and ask OpenBLAS people what could be done to make it better ^ Although to evaluate matrix multiplication we would probably need to use some low level scipy functions, since numpy still currently uses the built-in reference BLAS. |
I have to say that was not on my radar at all 😉. The first thing I wanted to do was to look at all the scipy issues in Pyodide and check again whether they still happen. I am pretty sure some of them should have been fixed by switching to OpenBLAS.
I remember asking you about using OpenBLAS for numpy as well, but I don't remember the answer I have to admit. |
That works. Opened #3763 about it. Maybe I'll have a look later. |
Description
Opening a draft PR on this.
This could potentially get rid of some of the low-level issues like #3203.
Also OpenBLAS is more maintained than CLAPACK.
Related to #227.
Checklists