Skip to content

LogisticRegression GPU fallback ignores allow_sklearn_after_onedal=False #3220

@cakedev0

Description

@cakedev0

Describe the bug

sklearnex.config_context(target_offload="gpu", allow_fallback_to_host=False, allow_sklearn_after_onedal=False) still allows sklearnex.linear_model.LogisticRegression to fall back to stock scikit-learn on host for a GPU-targeted run.

The operation completes successfully and only logs:

fallback to original Scikit-learn. All input data transferred to host for further backend computations.

This looks inconsistent with the config docs:

  • allow_fallback_to_host=False should disallow GPU to host fallback.
  • allow_sklearn_after_onedal=False should disallow fallback to stock scikit-learn when no accelerated version is available.

I also checked main, the dispatch path in sklearnex/_device_offload.py still appears to call the sklearn branch after writing the fallback log without checking allow_sklearn_after_onedal in that path.

To Reproduce

from sklearn.datasets import make_classification
from sklearn.model_selection import train_test_split
from sklearnex import config_context
from sklearnex.linear_model import LogisticRegression

X, y = make_classification(
    n_samples=3000,
    n_features=20,
    n_informative=10,
    n_classes=2,
    random_state=42,
)
X_train, X_test, y_train, y_test = train_test_split(
    X.astype("float32"), y, test_size=0.2, random_state=0
)

with config_context(
    target_offload="gpu",
    allow_fallback_to_host=False,
    allow_sklearn_after_onedal=False,
):
    clf = LogisticRegression()
    clf.fit(X_train, y_train)
    clf.predict(X_test)

Observed behavior

The script completes without an exception. With sklearnex logging displayed, it reports fallback to stock scikit-learn on host:

INFO:sklearnex: sklearn.linear_model.LogisticRegression.fit: fallback to original Scikit-learn. All input data transferred to host for further backend computations.
INFO:sklearnex: sklearn.linear_model.LogisticRegression.predict: fallback to original Scikit-learn. All input data transferred to host for further backend computations.
INFO:sklearnex: sklearn.linear_model.LogisticRegression.decision_function: fallback to original Scikit-learn. All input data transferred to host for further backend computations.

Expected behavior

With both fallback controls set to False, this should fail instead of silently running stock scikit-learn on host.
Environment:

  • OS: Linux
  • Python: 3.12
  • scikit-learn-intelex: distribution metadata reports 2026.0.0; sklearnex.__version__ reports 2199.9.9 (why this discrepancy btw?)
  • scikit-learn: 1.8.0
  • GPU visible through dpctl: Intel(R) Arc(TM) B390 GPU

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions