Many small HistGradientBoosting fits crawl when OpenMP uses every core
PitfallVerified 1 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.
Symptom#
A script that fits many small HistGradientBoostingRegressor models (a few hundred rows each) runs for minutes instead of seconds. ps shows the Python process at about 2300% CPU with about 140 threads, while other jobs share the node.
Cause#
HistGradientBoosting runs its loops with OpenMP over every core. On a few hundred rows the threads spend their time waiting and spinning, not fitting, and other load on the node makes it worse.
Fix#
Limit the native thread pools to one thread around the fits:
Evidence#
Seen in the dpucrumbs black-box study on a 48-core login node (scikit-learn 1.9.1). The test script with 60 rows did not finish in 300 s. With threadpool_limits(1) the same script ran in 7 s.
Also found by searching
- HistGradientBoosting very slow on a small data set, 2000 percent CPU
- scikit-learn fit takes minutes on a few hundred rows
- how do I stop OpenMP oversubscription in scikit-learn
- many tiny model fits hang on a node with many cores