Skip to content

DOC: Add visible warning about not using LogisticRegression in parallel threads#2860

Open
david-cortes-intel wants to merge 4 commits intouxlfoundation:mainfrom
david-cortes-intel:par_lr_warn
Open

DOC: Add visible warning about not using LogisticRegression in parallel threads#2860
david-cortes-intel wants to merge 4 commits intouxlfoundation:mainfrom
david-cortes-intel:par_lr_warn

Conversation

@david-cortes-intel
Copy link
Contributor

Description

Logistic regression in sklearnex is implemented differently from the rest. Turns out that it does on-the-fly replacements of sklearn module attributes that have effects beyond calls to sklearnex and are not thread-safe:

This PR adds a visible warning not to use logistic regression in parallel python threads.


Checklist:

Completeness and readability

  • I have updated the documentation to reflect the changes or created a separate PR with updates and provided its number in the description, if necessary.
  • Git commit message contains an appropriate signed-off-by string (see CONTRIBUTING.md for details).
  • I have resolved any merge conflicts that might occur with the base branch.

Testing

  • All CI jobs are green or I have provided justification why they aren't.

@codecov
Copy link

codecov bot commented Dec 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
github 81.83% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@david-cortes-intel
Copy link
Contributor Author

CI failure is a rate limiting issue with wikipedia links.

@Vika-F
Copy link
Contributor

Vika-F commented Jan 9, 2026

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@david-cortes-intel
Copy link
Contributor Author

/azp run

If you need to trigger only one pipeline, it'd be 'azp run Docs'. This PR only changes documentation BTW.

@david-cortes-intel
Copy link
Contributor Author

Should also be extended to LogisticRegressionCV after #2871 is merged.

- Sparse data is not supported.
- Solver ``'newton-cg'`` is **only** available in :doc:`preview mode <preview>`.
- Solver ``'newton-cg'`` is **only** available in :doc:`preview mode <preview>`. **Important:** this estimator should not be used
in parallel Python threads - for concurrent fits (e.g. from :obj:`sklearn.model_selection.GridSearchCV`),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use other estimators inside GridSearchCV? Should this warning be common for estimators?

Copy link
Contributor Author

@david-cortes-intel david-cortes-intel Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, other estimators can be used in GridSearchCV with any parallelism backend. We have a whole section about it:
https://github.com/uxlfoundation/scikit-learn-intelex/blob/main/doc/sources/parallelism.rst

:obj:`sklearn.linear_model.LogisticRegressionCV` in particular are not
suitable for parallel calls in Python threads regardless of the ``n_jobs`` parameter.
Attempting to fit multiple logistic regression estimator objects in parallel
might result in crashes and incorrect estimations.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think more likely it will result in bad performance

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LogisticRegression overwrites a global variable during its execution:

Other estimators don't do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants