Repository navigation
FIX Dont assume available CPU core count never changes - #35062
Conversation
done: Blog: [blog#231](scikit-learn/blog#231) (match Substack's font size), merged todo: move [blog#228](scikit-learn/blog#228) from Waiting to Now: address lorentzenchr's review and answer jjerphan on the OpenBLAS threading layers todo: move [sklearn#35181](scikit-learn/scikit-learn#35181) from Now to Waiting, adam2392's and antoinebaker's questions answered add: Maintenance: follow up on [sklearn#35254](scikit-learn/scikit-learn#35254): settle option B with dherrera1911 and betatim (LDA solvers disagree with custom priors) add: Maintenance: follow up on [sklearn#35209](scikit-learn/scikit-learn#35209): newton-cg LogisticRegressionCV test fails on the macOS x86_64 wheels add: Maintenance: re-review [sklearn#34619](scikit-learn/scikit-learn#34619) (faster PCA mle; jberg5 addressed my comments) add: Benchmarks: review [benchmarks#142](probabl-ai/scikit-learn-benchmarks#142) (cuML config) with the results of the AWS L4 run add: Upstream: upstream to OpenBLAS or close [cakedev0/OpenBLAS#3](cakedev0/OpenBLAS#3) and [cakedev0/OpenBLAS#4](cakedev0/OpenBLAS#4) todo: since dates on [sklearn#35062](scikit-learn/scikit-learn#35062) and [sklearn#35053](scikit-learn/scikit-learn#35053), and virchan's question on the latter todo: lorentzenchr's note on [sklearn#35029](scikit-learn/scikit-learn#35029) in the fork#38 line Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
For users that will upgrade only scikit-learn but not joblib, how much this change would cost them (if we merge this before 1.10)? |
It was 6, 11, and 187 usec on Linux, macOS, and Windows respectively per call. And it's called right before an expensive operation (otherwise why use parallelism?) so should be amortized into irrelevance. |
|
Ah ok, I thought we could change that in scikit-learn because of a recent optimization in joblib/loky, but it's actually not recent. Ok, @thomasjpfan feel free to merge. |
|
@itamarst ping me once the conflicts are resolved and I'll merge. |
Head branch was pushed to by a user without write access
|
@ogrisel I merged forward, thank you. |
|
@betatim would be nice to get this into 1.10 since once new joblib is released this will impact performance. |
|
This PR has been added to the backports PR. Lets see how big that PR gets and then decide if we need a rc2 or can directly release. Out of interest: what is joblib's plan for dealing with people who install scikitl-learn 1.9.x and the latest joblib (that will include the changes that make this PR something we want to include in 1.10)? |
Currently
_openmp_effective_n_threads()assumes the number of available cores never changes.This is not a correct assumption even now; the new test in this PR fails without the corresponding code changes. Changing CPU affinity at runtime is to be fair not very likely, even if it possible.
However, once joblib has a new release, this assumption will be a much bigger problem, since thread workers in
joblib.Parallelwill have different result incpu_count()than e.g. the main thread. That is,cpu_count()will start being thread-local and tied to how many workers there are, with cores divided up between workers. See joblib/joblib#1825 for details.This PR therefore removes the caching.