Skip to main content

How to Stop MLflow Autologging from Saving Models

· 6 min read
Jagdish Kumawat
Founder @ Dewiride

By default, autologging saves the trained model with every fit: its file, its environment files and its input format. That's what you want for the model you'll deploy, but not for every experiment along the way, and a hyperparameter search saves two models per search. mlflow.sklearn.autolog(log_models=False) keeps everything else and leaves the models out. This guide runs the same training with and without it, with real output from MLflow 3.18.0.

Syntax​

Syntax
mlflow.sklearn.autolog(log_models=False)
PartWhat it means
log_models=FalseDon't save trained models. Parameters, metrics, tags, datasets and charts are still recorded

MLflow's reference adds that input examples and model signatures, "which are attributes of MLflow models, are also omitted when log_models is False".

Prerequisites​

Step 1: Train Once With a Model, Once Without​

The example fits a linear regression to scikit-learn's diabetes data twice. First with autologging's defaults, in with_model.py:

with_model.py
import mlflow
from sklearn.datasets import load_diabetes
from sklearn.linear_model import LinearRegression

mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("no-models-demo")
mlflow.sklearn.autolog()

X, y = load_diabetes(return_X_y=True, as_frame=True)

with mlflow.start_run(run_name="with-model"):
LinearRegression().fit(X, y)

Then with log_models=False, in no_models.py:

The no_models.py script in a macOS-style code window: it sets the tracking server and the experiment no-models-demo, calls mlflow.sklearn.autolog with log_models False, loads the diabetes data and fits a LinearRegression inside a run named without-model.

no_models.py
import mlflow
from sklearn.datasets import load_diabetes
from sklearn.linear_model import LinearRegression

mlflow.set_tracking_uri("http://127.0.0.1:8080")
mlflow.set_experiment("no-models-demo")
mlflow.sklearn.autolog(log_models=False)

X, y = load_diabetes(return_X_y=True, as_frame=True)

with mlflow.start_run(run_name="without-model"):
LinearRegression().fit(X, y)
Terminal
uv run python with_model.py
uv run python no_models.py
Output
2026/11/21 11:02:52 INFO mlflow.tracking.fluent: Experiment with name 'no-models-demo' does not exist. Creating a new experiment.
2026/11/21 11:02:53 INFO mlflow.utils.uv_utils: Detected uv project: found uv.lock and pyproject.toml in /Users/you/source/mlflow-demo
2026/11/21 11:02:53 WARNING mlflow.sklearn: Saving scikit-learn models in the pickle or cloudpickle format requires exercising caution because these formats rely on Python's object serialization mechanism, which can execute arbitrary code during deserialization. The recommended safe alternative is the 'skops' format. For more information, see: https://scikit-learn.org/stable/model_persistence.html
2026/11/21 11:02:53 INFO mlflow.utils.uv_utils: Detected uv project: found uv.lock and pyproject.toml in /Users/you/source/mlflow-demo
2026/11/21 11:02:53 INFO mlflow.utils.environment: Detected uv project at /Users/you/source/mlflow-demo. Attempting to export requirements via 'uv export'.
2026/11/21 11:02:53 INFO mlflow.utils.uv_utils: Exported 91 dependencies via uv
2026/11/21 11:02:53 INFO mlflow.utils.environment: Successfully exported 91 requirements from uv project. Skipping package capture based inference.
2026/11/21 11:02:53 WARNING mlflow.utils.environment: Failed to resolve installed pip version. ``pip`` will be added to conda.yaml environment spec without a version specifier.
🏃 View run with-model at: http://127.0.0.1:8080/#/experiments/11/runs/44710287f29f4f288b6d49c43f6a3e9d
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/11
🏃 View run without-model at: http://127.0.0.1:8080/#/experiments/11/runs/fdf146bc11f44d7a9583fa9766fb6786
🧪 View experiment at: http://127.0.0.1:8080/#/experiments/11

Two terminal runs: with_model.py prints the uv export lines, the pickle caution and the pip warning before linking the run with-model; no_models.py only links the run without-model.

Every line between the experiment's creation and with-model's link is about saving the model: finding the project's packages, and two warnings, about the pickle format and pip's version. With log_models=False, none of them appears.

Step 2: Compare the Runs​

The experiment's runs table has a Models column:

The no-models-demo runs table with the columns Run Name, Created, Duration and Models: without-model has a dash in Models, with-model has a link named model.

with-model has its model; without-model has none, and took 67 milliseconds instead of 0.6 seconds. Both runs have the same parameters and training metrics.

Common Mistakes​

MistakeWhat happensDo this instead
Turning models off for the training run you'll deployThere's no model to load, register or serveSave that one: leave log_models on, or save it yourself
Expecting a signature or input example without a modelThey belong to the saved modelLeave log_models on when you need them

Troubleshooting​

SymptomLikely causeFix
A run has no model you expectedlog_models=False somewhere before itCheck every autolog() call in the script

FAQ​

Why would I not want the model?​

Saving it takes time and storage on every fit, and a hyperparameter search saves two: the search object and its best model. When a run is only there to compare settings, the parameters and metrics are what you need.

How do I save just the model I chose?​

Train it once more with log_models on, or save it with mlflow.sklearn.log_model.

Conclusion​

mlflow.sklearn.autolog(log_models=False) recorded the same parameters and metrics as the default, without the model, its environment lines or the two model-saving warnings. Turn models off for runs that only compare settings, and keep them on for the run you'll deploy.

Additional Resources​