ML Model Versioning: Registries, Aliases and Rollback
How to version ML models in practice: what to track, MLflow registry aliases, DVC for data, Hugging Face revisions, promotion, rollback and reproducibility.
A trained model is more than a weights file. To reproduce it, explain it or undo a bad release, you need to know which code, data, settings and software produced it, and which copy is serving traffic right now. This guide covers what to version, how a model registry with aliases handles promotion and rollback, and where tools like DVC and the Hugging Face Hub fit. Everything below is checked against each project’s official documentation: the MLflow Model Registry docs, DVC’s getting-started guide and the huggingface_hub download guide.
What to version
Treat a model release as a bundle of five things. If any one of them is missing, you can’t rebuild the model or say exactly why it behaves the way it does.
| Item | Why it matters | Where it usually lives |
|---|---|---|
| Weights | The artifact you actually serve | Registry or artifact store |
| Training code | Same data plus different code gives a different model | Git |
| Data | The most common silent cause of changes in behaviour | DVC, artifact store, dataset repo |
| Config and parameters | Hyperparameters, feature lists, thresholds | Logged with the run |
| Environment | Library versions change outputs and loading | Lock files saved next to the model |
MLflow covers several of these out of the box. Its tracking component records parameters, code versions, metrics and output files for each run, and model weights go to an artifact store. When you log a model, MLflow also writes conda.yaml, python_env.yaml and requirements.txt next to it so the environment can be rebuilt later, plus an MLmodel file that can hold the model’s input and output signature.
The model registry: versions, aliases and tags
A registry gives every model a stable name and numbers each version you add under it. In MLflow, the first model registered under a name becomes version 1, and each later registration under that name gets the next number. You refer to an exact version with a URI such as models:/MyModel/1.
The registry also stores lineage. Each MLflow model version links back to the run, logged model or notebook that created it, so you can trace a production model to the parameters and data used to train it.
Three labelling tools sit on top of version numbers:
- Aliases are movable names that point at one version, like
championorcandidate. Production code loadsmodels:/MyModel@championand never hard-codes a number. One version can carry several aliases, which helps with A/B tests and staged rollouts. - Tags are key-value pairs for status, for example
validation_status: pendingchanging toapprovedafter checks pass. - Descriptions are Markdown notes on the model or a single version, a good place for the dataset used and the reasoning behind a change.
If you learned MLflow a few years ago, note one change: the fixed stages (None, Staging, Production, Archived) are deprecated as of MLflow 2.9.0 and are slated for removal in a future major release. MLflow replaced them with aliases and tags, and recommends separate registered models per environment when you need access control.
A working MLflow example
This is the registration example from the MLflow docs, trimmed slightly. Logging with registered_model_name creates the registered model if it doesn’t exist (as version 1) or adds a new version if it does.
from sklearn.datasets import make_regression
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import train_test_split
import mlflow
from mlflow.models import infer_signature
with mlflow.start_run() as run:
X, y = make_regression(n_features=4, n_informative=2, random_state=0, shuffle=False)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
params = {"max_depth": 2, "random_state": 42}
model = RandomForestRegressor(**params).fit(X_train, y_train)
signature = infer_signature(X_test, model.predict(X_test))
mlflow.log_params(params)
mlflow.sklearn.log_model(
sk_model=model,
name="sklearn-model",
signature=signature,
registered_model_name="sk-learn-random-forest-reg-model",
)
Then point an alias at a version and load the model through it:
from mlflow import MlflowClient
import mlflow.pyfunc
client = MlflowClient()
client.set_registered_model_alias("sk-learn-random-forest-reg-model", "champion", 1)
model = mlflow.pyfunc.load_model("models:/sk-learn-random-forest-reg-model@champion")
You can also serve the alias directly with mlflow models serve -m "models:/sk-learn-random-forest-reg-model@champion". If you would rather wrap the model in your own API, our guide to serving ML models with FastAPI shows the loading and endpoint side.
Promotion and rollback
Because serving code follows the alias and not a number, promotion and rollback are the same operation: move the alias.
- Register the new model. It gets the next version number, say 2.
- Set
candidateon version 2 and run your validation againstmodels:/name@candidate. Record the result as a version tag. - When it passes, call
set_registered_model_alias(name, "champion", 2). Anything that loads@championgets version 2 on its next load. - If version 2 misbehaves, set
championback to 1. Version 1 never left the registry, so nothing has to be retrained or re-uploaded.
MLflow documents this decoupling directly: alias assignments can change without touching production code. Note the phrase “next load”. A long-running server that loaded the model at startup keeps the old one in memory until it reloads, so plan a restart or reload hook.
For separate environments, MLflow suggests one registered model per environment, such as dev.ml_team.revenue_forecasting and prod.ml_team.revenue_forecasting, with permissions set through MLflow Authentication. For simple setups, copy_model_version() copies a version (for example the one tagged @candidate in staging) into the production model. For mature setups, MLflow recommends promoting the training and inference code through CI/CD and retraining in each environment, instead of copying model files between them.
Versioning data with DVC
Git handles code well but not multi-gigabyte datasets. DVC solves this by tracking small metadata files in Git while the data itself sits in a cache and a remote such as S3, SSH, Azure Blob Storage or a local directory. The core loop from DVC’s getting-started guide:
dvc init
dvc add data/data.xml
git add data/data.xml.dvc data/.gitignore
git commit -m "Add raw data"
dvc remote add -d storage s3://mybucket/dvcstore
dvc push
Each .dvc file records a content hash of the tracked file. To return to an older dataset, check out the older .dvc file with Git and run dvc checkout. Since the data version is now part of a Git commit, one commit hash identifies both the code and the data used for training. DVC itself points out that it is not a version control system on its own; it relies on Git for history. Its docs also say that for workflows built around data lakes or syncing tens of thousands of files, lakeFS is the better fit.
For metrics and parameters inside a DVC project, DVCLive is the companion logger; its repository describes it as a way to log and track metrics, parameters and models with Git and/or DVC.
Hugging Face Hub: Git revisions for models
Model repositories on the Hugging Face Hub are Git repositories. Each commit is a revision, and large files such as weights are stored through the Git Xet extension. In code, the revision argument of hf_hub_download and snapshot_download pins a branch, tag, pull request ref or commit:
from huggingface_hub import hf_hub_download
hf_hub_download(repo_id="lysandre/arxiv-nlp", filename="config.json", revision="v1.0")
Without revision you get the latest version on main, which can change under you. For reproducible builds, pin a tag or a full commit hash; the library requires the full-length hash, not the 7-character short form.
Other tools in the same space
- Weights & Biases Artifacts version datasets and models as inputs and outputs of runs, and you fetch them by name and alias, such as
training_dataset:latest. W&B’s docs now live on the CoreWeave documentation site. - TorchServe registers models with a version and has a
set-defaultendpoint that makes any registered version the model’s default, a server-side take on the alias idea. Check its status before adopting it: the docs mark the project as in limited maintenance, with no planned updates or security patches. More serving options are in our LLM infrastructure hub.
A checklist for reproducibility
- Every served model maps to one registry version, and that version links to a run.
- The run records parameters, metrics and the Git commit of the training code.
- The training data is pinned by a DVC-tracked
.dvcfile in that commit, or by an artifact version. - The environment files saved with the model match what production installs.
- Production loads by alias; rollback is moving the alias back, and you have tested it once.
- Validation results live on the version as tags, so the reason for each promotion is on record.
Tracking how a promoted model behaves after release is a separate job; see the evaluation and monitoring hub for tools.
Written by AI Agents Directory
Editorial team
Facts in this guide are checked against official documentation and repositories, which are linked in the article.