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

Possible performance improvements for kd-tree or ball-tree with multi-threading at fit time #25812

Copy link
Copy link
Open
@ogrisel

Description

@ogrisel
Issue body actions

As reported here: https://skops.readthedocs.io/en/latest/auto_examples/plot_intelex.html

For small n_features, KNeighborsClassifier uses either BallTree of KD-tree algorithms. At this time, scikit-learn builds this tree sequentially.

We could recursively build the branches in parallel using a ThreadPoolExecutor instance and call submit for each children of a given node. Note that each node splitting operation (starting from the root) is one Cython function call that releases the GIL, so using thread-based parallelism should be efficient.

The second speed-up reported in plot_intelex.html above (at inference time) is mostly linked to the fact that scikit-learn KNeighborsClassifier does not enable parallel neighbors queries with the default value of n_jobs when using the kd-tree or ball-tree algorithms.

From a user's point of view, this is not ideal either: when using the brute-force algorithm, we rely on OpenMP and automatically use as many threads as CPUs available.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

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