Repository navigation
Closed
Labels
Build / CIfree-threadingPRs and issues related to support for free-threaded CPython (a.k.a. nogil or no-GIL, PEP 703)
Description
Also seen in #32303 (comment) as well in a different test and on Linux (this one is on macOS).
This is very likely related to warnings being thread-unsafe in cp313t. Not sure this is worth doing something about it since it doesn't seem to happen that often.
______________________ test_no_user_warning_with_scoring _______________________
joblib.externals.loky.process_executor._RemoteTraceback:
"""
Traceback (most recent call last):
File "/private/var/folders/q1/lmdr88vx1k90l53fxl9p8lwc0000gn/T/cibw-run-kd2mu_4k/cp313t-macosx_arm64/venv-test-arm64/lib/python3.13t/site-packages/joblib/_utils.py", line 72, in __call__
return self.func(**kwargs)
~~~~~~~~~^^^^^^^^^^
File "/private/var/folders/q1/lmdr88vx1k90l53fxl9p8lwc0000gn/T/cibw-run-kd2mu_4k/cp313t-macosx_arm64/venv-test-arm64/lib/python3.13t/site-packages/joblib/parallel.py", line 607, in __call__
return [func(*args, **kwargs) for func, args, kwargs in self.items]
~~~~^^^^^^^^^^^^^^^^^
File "/private/var/folders/q1/lmdr88vx1k90l53fxl9p8lwc0000gn/T/cibw-run-kd2mu_4k/cp313t-macosx_arm64/venv-test-arm64/lib/python3.13t/site-packages/sklearn/utils/parallel.py", line 144, in __call__
warnings.warn(
~~~~~~~~~~~~~^
(
^
...<5 lines>...
UserWarning,
^^^^^^^^^^^^
)
^
UserWarning: `sklearn.utils.parallel.delayed` should be used with `sklearn.utils.parallel.Parallel` to make it possible to propagate the scikit-learn configuration of the current thread to the joblib workers.
"""
The above exception was the direct cause of the following exception:
def test_no_user_warning_with_scoring():
"""Check that no UserWarning is raised when scoring is set.
Non-regression test for #22907.
"""
pd = pytest.importorskip("pandas")
X, y = make_regression(n_samples=50, random_state=0)
X_df = pd.DataFrame(X, columns=[f"col{i}" for i in range(X.shape[1])])
est = HistGradientBoostingRegressor(
random_state=0, scoring="neg_mean_absolute_error", early_stopping=True
)
with warnings.catch_warnings():
warnings.simplefilter("error", UserWarning)
> est.fit(X_df, y)
../venv-test-arm64/lib/python3.13t/site-packages/sklearn/ensemble/_hist_gradient_boosting/tests/test_gradient_boosting.py:1370:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../venv-test-arm64/lib/python3.13t/site-packages/sklearn/base.py:1336: in wrapper
return fit_method(estimator, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../venv-test-arm64/lib/python3.13t/site-packages/sklearn/ensemble/_hist_gradient_boosting/gradient_boosting.py:722: in fit
X_binned_train = self._bin_data(X_train, is_training_data=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../venv-test-arm64/lib/python3.13t/site-packages/sklearn/ensemble/_hist_gradient_boosting/gradient_boosting.py:1237: in _bin_data
X_binned = self._bin_mapper.fit_transform(X) # F-aligned array
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../venv-test-arm64/lib/python3.13t/site-packages/sklearn/utils/_set_output.py:316: in wrapped
data_to_wrap = f(self, X, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
../venv-test-arm64/lib/python3.13t/site-packages/sklearn/base.py:907: in fit_transform
return self.fit(X, **fit_params).transform(X)
^^^^^^^^^^^^^^^^^^^^^^^^^
../venv-test-arm64/lib/python3.13t/site-packages/sklearn/ensemble/_hist_gradient_boosting/binning.py:240: in fit
non_cat_thresholds = Parallel(n_jobs=self.n_threads, backend="threading")(
../venv-test-arm64/lib/python3.13t/site-packages/sklearn/utils/parallel.py:91: in __call__
return super().__call__(iterable_with_config_and_warning_filters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../venv-test-arm64/lib/python3.13t/site-packages/joblib/parallel.py:2072: in __call__
return output if self.return_generator else list(output)
^^^^^^^^^^^^
../venv-test-arm64/lib/python3.13t/site-packages/joblib/parallel.py:1682: in _get_outputs
yield from self._retrieve()
../venv-test-arm64/lib/python3.13t/site-packages/joblib/parallel.py:1784: in _retrieve
self._raise_error_fast()
../venv-test-arm64/lib/python3.13t/site-packages/joblib/parallel.py:1859: in _raise_error_fast
error_job.get_result(self.timeout)
../venv-test-arm64/lib/python3.13t/site-packages/joblib/parallel.py:758: in get_result
return self._return_or_raise()
^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <joblib.parallel.BatchCompletionCallBack object at 0x5d4061e5010>
def _return_or_raise(self):
try:
if self.status == TASK_ERROR:
> raise self._result
E UserWarning: `sklearn.utils.parallel.delayed` should be used with `sklearn.utils.parallel.Parallel` to make it possible to propagate the scikit-learn configuration of the current thread to the joblib workers.
../venv-test-arm64/lib/python3.13t/site-packages/joblib/parallel.py:773: UserWarning
Reacted by Jeff Keller, Matej yangwao and Gabrielle Rafanan Cabebe
Metadata
Metadata
Assignees
Labels
Build / CIfree-threadingPRs and issues related to support for free-threaded CPython (a.k.a. nogil or no-GIL, PEP 703)
Activity
[-]cp313t intermittent failure `UserWarning: `sklearn.utils.parallel.delayed` should be used with `sklearn.utils.parallel.Parallel``[/-][+]cp313t intermittent failure `UserWarning: `sklearn.utils.parallel.delayed` should be used with `sklearn.utils.parallel.Parallel`[/+][-]cp313t intermittent failure `UserWarning: `sklearn.utils.parallel.delayed` should be used with `sklearn.utils.parallel.Parallel`[/-][+]cp313t intermittent failure `UserWarning: sklearn.utils.parallel.delayed should be used with sklearn.utils.parallel.Parallel`[/+][-]cp313t intermittent failure `UserWarning: sklearn.utils.parallel.delayed should be used with sklearn.utils.parallel.Parallel`[/-][+]CI cp313t intermittent failure `UserWarning: sklearn.utils.parallel.delayed should be used with sklearn.utils.parallel.Parallel`[/+]modify: sklearn/utils/parallel.py - Issue scikit-learn#32631
lesteve commentedon Feb 19, 2026
I am not able to reproduce locally but since it adds some noise in the Wheels tracking issue #32393, I opened #33320 to xfail this test on Python 3.13 free-threaded.
yangwao commentedon Mar 5, 2026
Hey is this resolved? I came along had probably similar related error on p314 free threaded
Here what Claude Opus 4.6 thinks
pyrysepp commentedon Sep 1, 2026
Hi! it appears to me that this hasn't been resolved so far. I can report the warning being annoying to deal with in a setup where a randomforestclassifier is used at scale. I managed to surpress the warnings by modifying the showwarning like so:
` original_showwarning = warnings.showwarning
lesteve commentedon Sep 2, 2026
This was an issue specific to Python 3.13t so please don't comment in this old closed issue.
It is well possible that you get a similar warning for a different reason, if that's the case please open a separate issue with a reproducer 🙏. Without a reproducer there is not much we can do really.
TST Remove the xfail of test_no_user_warning_with_scoring on Python 3…