MLflow Model Versioning and Rollbacks: Workflow Guide

Model Versioning and Rollbacks with MLflow: A Practical Workflow

Sooner or later every team ships a model that makes things worse. Conversion dips, support tickets spike, and someone asks the question nobody can answer: which version was live before this one, and can we get it back?

If your models live as pickle files on a shared drive, that question takes an afternoon. If they live in the MLflow Model Registry with aliases, it takes one command. This guide walks through a versioning workflow that makes rollbacks boring: train, log, register, promote with aliases, serve through the alias, and move the alias back when a release goes wrong.

Runs Are History, Registered Models Are Inventory

MLflow tracking records experiments and runs. Each run captures parameters, metrics, and artifacts, and it is immutable. That is your audit trail. The registry is the layer on top of it: a registered model like churn-classifier is a container, and every time you register, you get a new version (v1, v2, v3) whose source points back to the exact run that produced it. Picking the tracking tool itself is a separate decision, and our comparison of MLflow vs Weights & Biases vs Neptune covers the experiment-tracking side in depth.

This separation matters for rollbacks. A run tells you what was tried. A registered version tells you what is addressable in production. One more piece completes the picture: aliases. An alias is a named pointer to a specific version, such as production or challenger. MLflow 2.x introduced aliases as the replacement for the old lifecycle stages (Staging, Production, Archived), which are now deprecated. If your codebase still calls transition_model_version_stage, plan to migrate to aliases.

Register With Annotations, Not Just Artifacts

The most common mistake is registering models with no context. A version number alone does not help you decide whether it is safe to promote. Register from your training script and describe what changed:

import mlflow
from mlflow.tracking import MlflowClient

mlflow.set_tracking_uri("http://mlflow:5000")
mlflow.set_experiment("churn-model")

with mlflow.start_run() as run:
    # ... your training code here
    mlflow.log_param("n_estimators", 200)
    mlflow.log_metric("auc", 0.91)
    mlflow.sklearn.log_model(
        model,
        "model",
        registered_model_name="churn-classifier",
    )

client = MlflowClient()
client.update_model_version(
    name="churn-classifier",
    version="3",
    description="v3: added tenure bucketing, trained on 2026-Q3 cohort; holdout AUC 0.91",
)
client.set_registered_model_alias(
    name="churn-classifier",
    alias="challenger",
    version="3",
)

A short description pays for itself during incident review. When the alias moves back to v2, the person on call can read exactly what v3 changed without opening a notebook. If you log your git commit hash and dataset version as tags, even better.

Promote With Aliases, Never Hardcode Versions in Deployment

Here is the design decision that makes rollbacks cheap: your deployment config should never contain a version number. It should reference the alias:

# promote the challenger after validation
client.set_registered_model_alias(
    name="churn-classifier",
    alias="production",
    version="3",
)

Promotion is just moving a pointer. Nothing in the serving layer changes, which means rollback is also just moving a pointer. Teams that hardcode models:/churn-classifier/3 into a deployment manifest end up editing YAML at 2 a.m. Teams that serve models:/churn-classifier@production move one alias and go back to sleep.

Serve Through the Alias

The alias URI syntax works directly with the MLflow CLI. This is the full serving command:

mlflow models serve 
  -m "models:/churn-classifier@production" 
  --port 5001 
  --no-conda

The server exposes an /invocations endpoint, and because the URI resolves to whatever version the alias currently points at, restarting the server after a rollback loads the restored version with no config diff and no redeploy pipeline. Serving a self-hosted LLM looks different from serving a classifier, though; our guide to serving a Llama model with vLLM and Docker covers that side.

The Rollback, Step by Step

Assume v3 is live under the production alias and your monitoring flags a problem: prediction quality drops, or downstream complaints arrive. This is the procedure:

1. Confirm the regression is the model, not the data. Compare live feature distributions and prediction rates against the last healthy window. Rollback is the wrong move if an upstream feed changed; you would restore v2 and still be broken.

2. Move the alias back to the last good version.

from mlflow.tracking import MlflowClient

client = MlflowClient()
client.set_registered_model_alias(
    name="churn-classifier",
    alias="production",
    version="2",
)

3. Restart the serving process. It points at models:/churn-classifier@production, so it now loads v2. Verify with a live request:

curl -X POST http://localhost:5001/invocations 
  -H "Content-Type: application/json" 
  -d '{"dataframe_split": {"columns": ["tenure", "monthly_charges"], "data": [[12, 45.5]]}}'

4. Quarantine the bad version. Remove the challenger alias from v3 so nobody promotes it again by accident. If your retention policy allows it, delete the version entirely:

client.delete_registered_model_alias(
    name="churn-classifier",
    alias="challenger",
)
client.delete_model_version(
    name="churn-classifier",
    version="3",
)

Move the alias first. MLflow refuses to delete a version an alias still points to, which is the registry protecting you from yourself. Also note that deleted versions cannot be restored, so check your backup policy before deleting instead of just removing the alias.

5. Record what happened on the version you rolled back to. Add a note to v2: “restored to production on 2026-10-21 after v3 regression.” Future you will be grateful.

Guardrails That Keep Rollbacks Uneventful

A rollback is a safety net you want to use rarely. A few habits reduce how often you need it:

  • Tag every version with its lineage. Git commit, dataset version, training seed. When v4 behaves oddly, you can diff its inputs against v3 in seconds.
  • Keep a challenger alias for canaries. Route a fraction of traffic to @challenger, watch it for a defined window, then promote. The rollback path stays identical either way.
  • Write descriptions at registration time. “v5: same features as v4, larger training window” is worth more than any dashboard when you are choosing between versions under pressure.
  • Protect the registry like production. Restrict who can move the production alias. An accidental promotion is the same incident as an accidental rollback.

Frequently Asked Questions

Should I use stages or aliases in MLflow?

Aliases. Stages are deprecated since MLflow 2.x, and aliases express the same idea more flexibly. If you are starting fresh, never use transition_model_version_stage.

Can I un-delete a deleted model version?

No. Deletion is permanent, which is why many teams only remove aliases and keep the versions. Delete versions only under an explicit retention policy.

How many versions should I keep?

Enough to roll back through at least two releases, plus whatever your audit or compliance requirements demand. The registry stores artifacts per version, so old versions also cost storage.

Model versioning with MLflow is not complicated, but it only helps if the workflow is in place before the incident. Register every model you ship, serve through aliases, and a bad release becomes a five-minute alias move instead of a postmortem. Versioning is only half the release story; setting up CI/CD for ML models is what makes promotions and rollbacks automatic instead of manual.

Ditulis oleh

Firdaus Safari Putra

Founder, PT FirKaizen Digital Solutions

Firdaus Safari Putra adalah founder PT FirKaizen Digital Solutions. Ia membangun dan mengoperasikan infrastruktur server di balik panduan ini, dan menulis berdasarkan apa yang benar-benar ia jalankan, uji, dan ukur — bukan teori.