-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
[MRG] MNT Cblas to scipy cython blas in liblinear and remove bundled cblas #13203
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
[MRG] MNT Cblas to scipy cython blas in liblinear and remove bundled cblas #13203
Conversation
I think I'm fine with both options. The one that is implemented in this PR has the advantage of being already implemented ;) I would be curious as to what other people think. Anyway I am really glad that we can finally get rid of the embedded cblas source code 🎆 |
BTW, I merged #13084 so you can rebase this on top of master. |
I think I'm fine with both options. The one that is implemented in this
PR has the advantage of being already implemented ;)
I was going to say much the same.
I also think that despite the clunkiness of passing the struct around, the
fact that it's called Blas is nice and explicit!
Well done!
|
|
I also just noticed the following slowdown:
I am pretty sure that those tests were running much faster before. However it was already there in some builds on travis that dates back to more than 24h ago, that is prior to merging #13084. |
BTW could you please run a quick benchmark to check that the new TRON solver code that uses function pointers to call BLAS is not significantly slower than calling the embedded ATLAS cblas routines directly. For instance, you can try with LinearSVC or LogisticRegression on a make_classification problem large enough to last a couple of seconds. |
I don't see how it would be related to cblas, since for those metrics we directly call scipy cdist/pdist.
I just looked at travis on master and it's there since the test was added. |
8443070
to
b014885
Compare
quick question: |
Alright. I thought I had run the full test suite on scikit-learn master locally yesterday and I did not recall those this is why I was misled. This should be ignored for this PR. Those tests should be sped up but this is unrelated. |
I would vote for svm/src/liblinear for now. If we ever need to reuse it somewhere else we will move it to utils/src while making the BLAS covered API exposed in this |
Weird failure in circle ci:
probably unrelated but annoying. I cannot find any other issue that references this failure. |
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.
+1 for after a quick benchmark to check that the new code does not introduce any significant performance regression.
Here are the result of the small benchmark you propose. from sklearn.datasets import make_classification
from sklearn.linear_model import LogisticRegression
X, y = make_classification(n_samples=100000, n_features=100, n_informative=50, n_classes=5)
lr = LogisticRegression(solver='liblinear', random_state=0, multi_class='auto')
%timeit lr.fit(X,y) First, on a machine with no blas installed, forcing the use of bundled cblas, on master: Then, on a machine with mkl installed, on master: |
I switched to [MRG] but there's still the circle ci failure which I don't understand. Does not seem to appear on master... |
green \o/ |
Merged! Thank you very much for this work @jeremiedbb! |
Hum, circle CI has failed with the same error on master: https://circleci.com/gh/scikit-learn/scikit-learn/47352 So this is probably caused by the change in this PR unfortunately. Maybe this is is causing some extra memory usage when running the linear model examples? |
I don't think so. The same failure appeared on master earlier today: |
Alright then. |
Thanks so much for tackling this @jeremiedbb ! 😄 |
…bundled cblas (scikit-learn#13203)" This reverts commit 06a3056.
…bundled cblas (scikit-learn#13203)" This reverts commit 06a3056.
Fixes #11638
This PR includes #13084 which needs to be merged first for easier reviews.
After #13084, the only remaining calls to cblas are from c++ code in liblinear, which is tricky because we want to use cython functions from scipy. There are 2 solutions to that AFIK:
The first one, implemented in this PR, is to pass pointers to the cython blas functions (grouped in a struct) in each function call down to where blas is called (i.e. in
tron.cpp
). It's fine because there aren't too many.The other one would be to have such a struct as a global variable initialized when liblinear is imported, in order to avoid passing it through many functions.
I'd like to have some opinions on which solution would be preferable.
All this finally allows to remove the whole bundled Cblas, resulting in a -12000 diff !!
ping @ogrisel