Skip to content

[WIP] PERF Parallelize W/H updates of NMF with OpenMP - #16439

Closed
jeremiedbb wants to merge 17 commits into
scikit-learn:mainfrom
jeremiedbb:cd-nmf-openmp
Closed

jeremiedbb wants to merge 17 commits into
scikit-learn:mainfrom
jeremiedbb:cd-nmf-openmp

Conversation

@jeremiedbb

Copy link
Copy Markdown
Member

Continuation of #6641

Here's a benchmark of the speedup using 2 threads. When the number of components is large enough the speed-up approaches 2x (maybe a bit better than 2x because I switched to a blas dot instead of a manual loop).
image

Since it now uses a BLAS function inside an OpenMP loop, we first need to prevent oversubscription with threadpoolctl before we can merge this pr.

@NicolasHug

Copy link
Copy Markdown
Member

Please add something in the UG and maybe also in the docstring to link to https://scikit-learn.org/stable/modules/computing.html#openmp-based-parallelism

Comment thread doc/whats_new/v0.23.rst Resolved
Base automatically changed from master to main January 22, 2021 10:52
@jjerphan

Copy link
Copy Markdown
Member

@jeremiedbb: this already looks like a nice improvement! Is there anything left to do here? 🙂

@jeremiedbb

Copy link
Copy Markdown
Member Author

I tried to run the benchmark again and found very weird results. After digging it appears that there's a weird interaction between some builds of OpenBLAS and OpenMP, making it 10x slower in some cases. This is not expected and I opened OpenMathLib/OpenBLAS#3187. Since it occurs with the openblas shipped by default by conda-forge I think we should wait a bit before merging this.

@jjerphan

Copy link
Copy Markdown
Member

Should we try to update and revisit this PR (without using the call to _dot to prevent OpenMathLib/OpenBLAS#3187 from happening)?

@ogrisel ogrisel added the Parallelism and scalability All things related to efficient handling of cores via thread-based or process-based parallelism. label May 27, 2026
@jeremiedbb jeremiedbb closed this Sep 3, 2026
@jeremiedbb
jeremiedbb deleted the cd-nmf-openmp branch September 3, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cython Enhancement module:decomposition Parallelism and scalability All things related to efficient handling of cores via thread-based or process-based parallelism. Performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants