-
Notifications
You must be signed in to change notification settings - Fork 217
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
feature: knn kd tree fix for parallel #3007
base: main
Are you sure you want to change the base?
feature: knn kd tree fix for parallel #3007
Conversation
/intelci: run |
/intelci: run |
...daal/src/algorithms/k_nearest_neighbors/kdtree_knn_classification_train_dense_default_impl.i
Outdated
Show resolved
Hide resolved
...daal/src/algorithms/k_nearest_neighbors/kdtree_knn_classification_train_dense_default_impl.i
Show resolved
Hide resolved
/intelci: run |
...daal/src/algorithms/k_nearest_neighbors/kdtree_knn_classification_train_dense_default_impl.i
Outdated
Show resolved
Hide resolved
...daal/src/algorithms/k_nearest_neighbors/kdtree_knn_classification_train_dense_default_impl.i
Show resolved
Hide resolved
...daal/src/algorithms/k_nearest_neighbors/kdtree_knn_classification_train_dense_default_impl.i
Show resolved
Hide resolved
/intelci: run |
...daal/src/algorithms/k_nearest_neighbors/kdtree_knn_classification_train_dense_default_impl.i
Outdated
Show resolved
Hide resolved
{ | ||
isNeedToReindex = true; | ||
actualNodeCount += ptr->nodeIndex - firstNodeIndex[ptr->threadIndex]; |
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.
Would be interesting to see how this change impacts the performance.
But anyway, the change is justified as it fixes the crashes.
/intelci: run |
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.
Next example gives seg. fault with this PR:
from sklearnex.neighbors import KNeighborsClassifier
from sklearn.datasets import make_classification
import logging as lg
lg.getLogger().setLevel("DEBUG")
x, y = make_classification(
n_samples=200000,
n_features=8,
random_state=42,
)
knn = KNeighborsClassifier(algorithm="kd_tree")
knn.fit(x, y)
print("Score:", knn.score(x, y))
Backtrace:
daal::algorithms::kdtree_knn_classification::prediction::internal::KNNClassificationPredictKernel<double, (daal::algorithms::kdtree_knn_classification::prediction::Method)0, (daal::CpuType)6>::findNearestNeighbors(double const*, daal::internal::Heap<daal::internal::GlobalNeighbors<double, (daal::CpuType)6>, (daal::CpuType)6>&, daal::algorithms::kdtree_knn_classification::internal::Stack<daal::algorithms::kdtree_knn_classification::prediction::internal::SearchNode, (daal::CpuType)6>&, unsigned long, double, daal::algorithms::kdtree_knn_classification::interface1::KDTreeTable const&, unsigned long, daal::data_management::interface1::NumericTable const&, bool, daal::services::internal::DynamicArray<double*, daal::services::internal::ScalableMalloc<double*, (daal::CpuType)6>, daal::services::internal::DefaultConstructionPolicy<double*, (daal::CpuType)6, true>, (daal::CpuType)6>&)
Description
PR introduces memory optimizations in Knn KD-tree algorithm. Correct reindexing in parallel mode has been added. Queue helper has been updated.
PR completeness and readability
Testing
Performance