Fixed: "Encountered unexpected error during sklearn autologging: The saved sklearn model references untrusted types"
I turned on MLflow's scikit-learn autologging with the safer skops format, and a gradient-boosted model's run ended with WARNING mlflow.utils.autologging_utils: Encountered unexpected error during sklearn autologging: The saved sklearn model references untrusted types. The model was marked Failed, and the run had no metrics at all. Autologging has no way to pass skops the types to trust; logging the model myself with log_model(..., skops_trusted_types=[...]), with autologging's models turned off, fixed it.
What I Was Doing
While building the MLflow series, I wanted autologging to save models in the skops format instead of its default, cloudpickle. On MLflow 3.18.0 and scikit-learn 1.9.1, I trained a HistGradientBoostingRegressor on scikit-learn's diabetes data with autologging set to skops:
import mlflow
from sklearn.datasets import load_diabetes
from sklearn.ensemble import HistGradientBoostingRegressor
mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("autolog-skops-demo")
mlflow.sklearn.autolog(serialization_format="skops")
X, y = load_diabetes(return_X_y=True, as_frame=True)
model = HistGradientBoostingRegressor(random_state=0).fit(X, y)
uv run python autolog_skops.py
What I Expected
An autologged run with the model's parameters, training metrics and the model, saved as model.skops.
What I Got
The run was created and closed, and then a warning:
🏃 View run delicate-tern-811 at: http://127.0.0.1:8080/#/experiments/21/runs/44a935ee655640f093fab1cbf6343df3
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/21
2026/11/21 14:27:10 WARNING mlflow.utils.autologging_utils: Encountered unexpected error during sklearn autologging: The saved sklearn model references untrusted types. If you are sure loading these types is safe, set the 'skops_trusted_types' parameter when calling 'log_model' or 'save_model' to the list of trusted types. Root error: Untrusted types found in the file: ['sklearn.ensemble._hist_gradient_boosting.predictor.TreePredictor'].
- sklearn.ensemble._hist_gradient_boosting.predictor.TreePredictor: sklearn.ensemble._hist_gradient_boosting.predictor.TreePredictor (used by HistGradientBoosting* models) stores raw node indices (left, right, feature_idx) in its nodes array that scikit-learn indexes into without bounds checking. A malicious file can set these to out-of-range values: skops loads the object successfully, but calling .predict() on it can then crash the process (segfault) or read out-of-bounds memory. If you created the file yourself or otherwise fully trust its source, you can load it with trusted=["sklearn.ensemble._hist_gradient_boosting.predictor.TreePredictor"].
Only add the specific types you have reviewed and trust to the `trusted` argument; avoid passing everything reported by get_untrusted_types() just to make a file load.

The run itself, delicate-tern-811, has its 21 parameters but no metrics:

What I Checked
The message. It names the fix for direct calls: "set the 'skops_trusted_types' parameter when calling 'log_model' or 'save_model'". TreePredictor is the object each of the model's trees is stored in, and skops explains why it isn't trusted by default.
Autologging's options. The reference for mlflow.sklearn.autolog lists serialization_format, log_models and others, but no skops_trusted_types. There's no way to hand autologging the list.
What was lost. The model's entry on the experiment's Models tab has the status Failed, and the run has no training metrics. The error interrupted autologging after the parameters were logged.
Why It Happens
skops refuses to save a model whose types it couldn't load back safely, unless you list them as trusted. A HistGradientBoosting* model holds TreePredictor objects, which skops doesn't trust by default. log_model and save_model take the list, skops_trusted_types; autologging doesn't, so its save fails, and it stops logging that model's metrics.
The Fix
Keep autologging for the parameters and metrics, turn its models off, and save the model yourself with the reviewed type listed:

import mlflow
from sklearn.datasets import load_diabetes
from sklearn.ensemble import HistGradientBoostingRegressor
mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("autolog-skops-demo")
# Autologging keeps the parameters and metrics; the model is saved below, with its trusted types.
mlflow.sklearn.autolog(log_models=False)
TRUSTED_TYPES = ["sklearn.ensemble._hist_gradient_boosting.predictor.TreePredictor"]
X, y = load_diabetes(return_X_y=True, as_frame=True)
with mlflow.start_run():
model = HistGradientBoostingRegressor(random_state=0).fit(X, y)
mlflow.sklearn.log_model(
model,
name="model",
input_example=X.head(3),
serialization_format="skops",
skops_trusted_types=TRUSTED_TYPES,
)
The list is written out on purpose, after reading skops's explanation: a model I trained myself is a source I trust.
After the Fix
uv run python autolog_skops_fixed.py
2026/11/21 14:27:15 INFO mlflow.utils.uv_utils: Detected uv project: found uv.lock and pyproject.toml in /Users/you/source/mlflow-demo
2026/11/21 14:27:16 INFO mlflow.utils.uv_utils: Detected uv project: found uv.lock and pyproject.toml in /Users/you/source/mlflow-demo
2026/11/21 14:27:16 INFO mlflow.utils.environment: Detected uv project at /Users/you/source/mlflow-demo. Attempting to export requirements via 'uv export'.
2026/11/21 14:27:16 INFO mlflow.utils.uv_utils: Exported 91 dependencies via uv
2026/11/21 14:27:16 INFO mlflow.utils.environment: Successfully exported 91 requirements from uv project. Skipping package capture based inference.
🏃 View run wise-midge-523 at: http://127.0.0.1:8080/#/experiments/21/runs/90bb944ce22f4034876b8ab8eaee95d2
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/21

No warning. The experiment's Models tab shows both attempts:

The new model is Ready, and its run has the training metrics autologging records, such as training_mean_squared_error.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Trusting every type get_untrusted_types reports, unread | The protection skops gives is gone | Review each type and write out the list |
| Going back to cloudpickle to silence it | The model can run code when loaded | Keep skops and list the trusted types |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
MlflowException: The saved sklearn model references untrusted types from log_model | The same check, without the list | Fixed: The saved sklearn model references untrusted types |
| A logged model's status is Failed | Saving it failed during logging | Check the output for the error |
FAQ
Does this happen with every model?
No. Models made only of types skops trusts, such as a linear regression, save in the skops format with autologging. Tree ensembles like HistGradientBoosting* hold a type it doesn't.
Do I lose anything by logging the model myself?
No: autologging still records the parameters and metrics, and log_model saves the model, with an input example if you pass one.
Conclusion
Autologging couldn't save a HistGradientBoostingRegressor in the skops format, because skops needed TreePredictor listed as trusted and autologging has no parameter for it. The model failed and the run lost its metrics. With autolog(log_models=False) and log_model(..., skops_trusted_types=[...]), the run got its metrics and the model saved as Ready.
Additional Resources
- mlflow.sklearn —
autologandlog_model'sskops_trusted_types. - Secure persistence with skops — trusted types.
