Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Parallelize init_bound_dense in Elkan algorithm #19052

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

Merged
merged 5 commits into from
Dec 22, 2020

Conversation

YusukeNagasaka
Copy link
Contributor

What does this implement/fix?

Parallelize init_bound_dense function. This is an initialization part in Elkan algorithm.

Any other comments?

This fix does not affect the quality of the clustering itself. This parallelization only reduces execution time of KMeans.fit on multi-core CPUs, even more beneficial on many-core CPUs.
For instance, I tested on a machine with 2 sockets of Intel Xeon CPUs (totally 40 cores). The table below is the time spent during KMeans.fit and init_bound_dense (the time in seconds). The data is generated uniformly at random with n_samples=1M, n_features=100. The parameters of KMeans are n_clusters=1000, init='random', algorithm='elkan', max_iter=1000.

master PR
total time 751 692
init_bound_dense 66 2

@jeremiedbb
Copy link
Member

Thanks @YusukeNagasaka. looks good. It would make sense to also do the change in init_bound_sparse if you're willing to.

Copy link
Member

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the improvement.

@kobaski
Copy link
Contributor

kobaski commented Dec 21, 2020

This makes huge performance improvement on A64FX CPU, even not much improvement on Intel CPU. @YusukeNagasaka will change init_bound_sparse too.

@YusukeNagasaka
Copy link
Contributor Author

The same parallelization is applied to init_bounds_sparse. Of course, this change does not affect the quality of clustering itself :)

The schedule in prange I adopted is static. The dynamic scheduling might show better performance on the skewed sparse dataset, but the dynamic scheduling brings some overhead of distributing work to each thread. I think the static scheduling works well enough on sparse datasets, too.

Copy link
Member

@jeremiedbb jeremiedbb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ogrisel ogrisel merged commit 3cdfb56 into scikit-learn:master Dec 22, 2020
@ogrisel
Copy link
Member

ogrisel commented Dec 22, 2020

Merged! Thank you very much @YusukeNagasaka!

@glemaitre glemaitre mentioned this pull request Apr 22, 2021
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.