Repository navigation
Fix: Issue #34764 Bug in module:ensemble - #3
Open
Prathamj07 wants to merge 1 commit into
Open
Prathamj07 wants to merge 1 commit into
Prathamj07 wants to merge 1 commit into
Conversation
|
Could you evaluate the impact of this change on a machine running linux with ligomp and a machine running windows with MSVC's OpenMP implementation? Please also repeated the experiments with various I am worried that fast-changing the number of threads in subsequent parallel regions might be detrimental for some loads and environments. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference Issues/PRs
Fixes scikit-learn#34764.
What does this implement/fix? Explain your changes.
HistGradientBoostinglaunches many small OpenMPprangeregions during fit (histogram build and split finding). On machines where OpenMP active wait is off (GOMP_SPINCOUNT=1/KMP_BLOCKTIME=0, typical on hybrid-core laptops and conda-forgelibomp), thread start/join overhead dominates and small-to-medium fits can be several times slower.This PR does not change OpenMP's wait policy (libgomp cannot set that per region anyway). It only caps
num_threadson those inner loops so we never spawn more workers than there is work:histogram.pyx:num_threads=min(n_threads, n_samples)when reordering gradients/hessians, andmin(n_threads, n_allowed_features)when building per-feature histogramssplitting.pyx:min(self.n_threads, n_samples)when partitioning a node, andmin(n_threads, n_allowed_features)when scanning candidate featuresPublic API, tree structure, and numeric results are unchanged: each iteration writes an independent slot, so fewer threads only skip idle workers. KMeans / OpenBLAS interaction from the same issue is left untouched.
On an Apple Silicon
libompbuild with active wait effectively disabled, repeated small HGB fits went from ~1481 ms/fit to ~1060 ms/fit (~28%). Forcing active wait on was unchanged within noise. That is a mitigation, not a full fix of the wait-policy problem.Introduce yourself
I use scikit-learn for model training. I picked this up after seeing the OpenMP active-wait slowdown on HistGradientBoosting in scikit-learn#34764.
AI usage disclosure
I used AI assistance for:
Any other comments?
Verified on a rebuilt editable install with Homebrew
libomp(8 threads): 466 tests in_hist_gradient_boosting+test_gradient_boosting.pypassed. Predictions matched the pre-fix binary bit-for-bit on small and large regressor/classifier cases.