Data & Model Versioning
What is MLOps? Why we need it? and what tools are available?
Why do we need Model Versioning?
I wrote a model 6 months back. I don’t know where it is.
I wrote a model 6 months back. I don’t remember what it is. Let me try to find it.
I got 80% accuracy yesterday. I swear.
Why do these problems exist?
Because conventional software engineering process does not work for Machine learning project
Unlike Software Engineering, Machine Learning involves trial and error and experimentation. We need a way to track these experiments.
GitHub is not enough
1. Data is huge and are often not in CSV itself
2. Model is huge. We need to store it better
Why should we care about it?
Businesses need an audit. Anything that doesn’t have an audit or cannot reproduce results is not production-grade.
Toolkit for MLOps
1. MLflow
2. Kubeflow
3. DVC
MLflow
MLFlow has pretty much has everything that an ML engineer looks for
1. A dev environment
2. Place to run and track experiments
3. Build and run pipelines
Disadvantages
1. MLflow is a Python library in itself. Hard-core engineers do not want to work with abstractions. It is impossible for them to `from mlops.sklearn`
Kubeflow
Kubeflow focuses on the pipeline orchestration of the ML process. Whereas in data versioning, we focus on individual components that define the pipelines
DVC - Data version control
1. Create a GitHub repo
2. Create assets directory for `data`, `models`, `raw_data`, `features.`
3. `dvc init`
4. `dvc add file/directory`
5. DVC will create a `.dvc` file and a `.gitignore` to ignore specific files\
Experiment tracking and pipelines
Every time you run the DVC pipeline, the model gets versioned along with the data it is trained on.
Deployment on Kubernetes with DVC
1. Add an NFS volume to the pod and mount it to assets
2. Create a docker image with the DVC repo
3. On the init script, do a `dvc pull`
The DVC remote S3/GCS should be accessible by the Kubernetes cluster
2026 note on DVC: In November 2025 lakeFS acquired DVC from Iterative. The announcement says DVC stays open source under the same license, with no breaking changes to commands or workflows, and its repositories are moving to the Treeverse GitHub organization. If you are following the steps above, nothing changes, but update any old
iterative/dvclinks you have bookmarked.
Data version, model version, model registry: three different things
The first half of this post is about versioning artifacts: data files and model files tracked next to your code. A model registry is a different layer on top, and it is easy to conflate the two.
| What it answers | Typical tool | |
|---|---|---|
| Data versioning | ”Which exact data was this trained on?” | DVC, lakeFS |
| Experiment tracking | ”Which parameters and metrics produced this run?” | MLflow Tracking, DVC experiments |
| Model registry | ”Which model is live, who approved it, and what was it built from?” | MLflow Model Registry |
A registry is a central catalogue of named models with numbered versions. In MLflow’s words, it is a centralized model store with versioning, aliasing, metadata tagging and annotation, and every registered version is linked to the run or logged model that produced it. That link is the point: from a version in production you can walk back to the parameters, metrics and (if you tracked it) the data version behind it.
Git gives you “which commit is on main”. The registry gives you the same idea for models: “which version is champion”.
Stages, aliases and promotion gates
Models do not go from a notebook straight to production. They move through states, and the registry is where you record that.
The older way was stages (None -> Staging -> Production -> Archived). MLflow deprecated stages as of 2.9.0 because they were too inflexible to express real MLOps workflows, and recommends aliases and tags instead:
- An alias is a mutable, named pointer to one version, such as
championorchallenger. Your serving code loadsmodels:/iris-classifier@championand never hard-codes a version number. - A tag is a key-value label on a version, such as
validation_status=passed, which you can use to record what checks a version has cleared.
A promotion gate is just the check that has to pass before an alias moves. It can be as small as “the candidate beats the current champion on the held-out set”, or as heavy as “passed bias checks, load test and a human sign-off”. Here is a minimal version I ran with MLflow 3.18 and scikit-learn on the Iris dataset (two logistic regression runs with different regularization, C=0.01 and C=1.0):
import mlflow, mlflow.sklearn
from mlflow import MlflowClient
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split
mlflow.set_tracking_uri("sqlite:///mlflow.db") # registry needs a database-backed store
mlflow.set_experiment("iris")
NAME = "iris-classifier"
X, y = load_iris(return_X_y=True)
Xtr, Xte, ytr, yte = train_test_split(X, y, random_state=42)
for C in (0.01, 1.0):
with mlflow.start_run():
model = LogisticRegression(C=C, max_iter=200).fit(Xtr, ytr)
mlflow.log_param("C", C)
mlflow.log_metric("accuracy", accuracy_score(yte, model.predict(Xte)))
mlflow.sklearn.log_model(model, name="model", registered_model_name=NAME)
client = MlflowClient()
client.set_registered_model_alias(NAME, "champion", 1) # first model goes live
def accuracy(version: int) -> float:
run_id = client.get_model_version(NAME, str(version)).run_id
return client.get_run(run_id).data.metrics["accuracy"]
# Promotion gate: only move the alias if the candidate is better
if accuracy(2) > accuracy(1):
client.set_registered_model_alias(NAME, "champion", 2)
client.set_model_version_tag(NAME, "2", "validation_status", "passed")
live = mlflow.sklearn.load_model(f"models:/{NAME}@champion") # serving code never changes
Because serving code resolves the alias at load time, a promotion is a metadata change, not a redeploy of code. To promote across environments (say a staging registered model to a production one), MLflow also offers copy_model_version.
Rollback and version comparison
Two benefits that justify the registry on their own.
Rollback is moving the alias back:
client.set_registered_model_alias(NAME, "champion", 1) # version 2 misbehaving? back to 1
No retraining, no hunting for the right pickle on someone’s laptop. This is the “I wrote a model 6 months back, where is it?” problem from the start of this post, solved at the model level. The same idea works at the data level: with DVC, git checkout <tag> followed by dvc checkout restores the data and model files that matched that commit.
Version comparison answers “is the new one actually better?” with evidence instead of memory. In the registry, every version points back to its run, so you can line up parameters and metrics side by side (the MLflow UI does this too). With DVC, dvc metrics diff compares metrics between two Git revisions or tags:
dvc metrics diff v1.0 v2.0
I haven’t run the DVC commands above for this post; they are taken from the linked DVC docs.
A reproducibility checklist
“I got 80% accuracy yesterday. I swear.” goes away when you can rebuild the result. For each model version you plan to keep, record:
- Code: the Git commit of the training and feature code
- Data: the exact dataset version (a DVC
.dvc/dvc.lockhash, a lakeFS commit), including the train/validation/test split - Parameters: hyperparameters and config files, not just the ones you remember changing
- Randomness: random seeds for every library involved (Python, NumPy, your framework)
- Environment: a lockfile or container image, with Python and library versions
- Hardware and framework flags: GPU type, CUDA/driver version, deterministic-mode settings
- Preprocessing and features: the transformation code that ran before the model, versioned like everything else
- Evaluation: the metrics, the evaluation dataset version and the code that computed them
- Lineage: a link from the registered version back to the run that produced it
Even with all of that, exact bit-for-bit results are not always possible. PyTorch’s documentation is upfront that completely reproducible results are not guaranteed across releases, individual commits or different platforms, though you can reduce nondeterminism by seeding and calling torch.use_deterministic_algorithms(True). So aim for reproducible enough to explain and audit, and write down the environment so you know why a rerun differs.
Putting it together
- DVC (or lakeFS) versions the data and model files with the code.
- MLflow Tracking (or DVC experiments) records parameters and metrics per run.
- A model registry names the versions, moves aliases through a promotion gate, and gives you a one-line rollback.
- The checklist makes any of those versions rebuildable.