Advanced⏱ 28 min⚑ 110 XP🧩 5-question quiz

Experiment Tracking and Reproducibility

Stop losing your best model: track runs with MLflow or Weights & Biases, version data, environments and models, control randomness, and make every result reproducible, including prompts and fine-tunes.


Module 10 (Building AI Applications) ended with LLM applications that are evaluated and guarded. This module is about the engineering discipline that keeps any model, classic or LLM-based, working after the notebook closes: MLOps. It starts where every model starts: with experiments. You try dozens of feature sets, architectures, hyperparameters, prompts, and data versions. Three weeks later, someone asks "which settings produced the model we shipped, and on what data?" Without discipline, the honest answer is "no idea". Experiment tracking and reproducibility turn that answer into a link.

Sculley et al.'s "Hidden Technical Debt in Machine Learning Systems" (2015) famously showed that the model code is a small box in a large diagram of data collection, configuration, serving, and monitoring infrastructure. This module walks through that diagram: tracking (this lesson), serving, monitoring, CI/CD, and finally LLMOps.

What makes a result reproducible?

A model's metrics are a function of five inputs. Change any one and the result can change:

Rendering diagram…

The diagram shows that a run is reproducible only if all five inputs on the left are recorded, and that the run's outputs (artifact, metrics) should be linked back to them so the registry entry carries its full lineage.

Researchers distinguish repeatability (same team, same setup, same result), reproducibility (different team, same artifacts, same result), and replicability (different team, new implementation or data, consistent conclusions). MLOps tooling mostly targets the first two; Module 13 (AI Research) discusses the third.

Tracking runs with MLflow

An experiment tracker records, for every run: parameters, metrics (including curves over training steps), artifacts (models, plots, data samples), tags, the code version, and the environment. MLflow is the most widely used open-source tracker; Weights & Biases is a popular hosted platform with strong visualization and collaboration features; other options include Comet, Aim, and cloud vendors' built-in trackers. The concepts transfer, and that matters: vendors get acquired and services close (the hosted Neptune.ai tracker shut down in early 2026 after its acquisition by OpenAI), so keep your run data exportable.

Here is what one tracked run looks like as a conversation between your script and the tracking stack:

Rendering diagram…

The sequence shows that metadata (parameters, metrics) goes to the tracking server while large files go to an artifact store, and that registering a model creates a version that points back at the run, which is what makes lineage queries possible later.

This runnable example (written against the MLflow 3.x API and tested with a 3.x release; APIs shift between versions, so check the docs for yours) trains two variants, logs everything needed to reproduce them, and queries for the best run:

# pip install mlflow scikit-learn
import hashlib, random
import numpy as np
import mlflow
from sklearn.datasets import load_breast_cancer
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import f1_score, roc_auc_score
from sklearn.model_selection import train_test_split
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler

SEED = 42
random.seed(SEED); np.random.seed(SEED)

X, y = load_breast_cancer(return_X_y=True)
data_hash = hashlib.sha256(X.tobytes() + y.tobytes()).hexdigest()[:12]   # fingerprint the data
X_tr, X_te, y_tr, y_te = train_test_split(X, y, test_size=0.2, random_state=SEED, stratify=y)

mlflow.set_tracking_uri("sqlite:///mlflow.db")      # local store; point at a shared server for teams
mlflow.set_experiment("cancer-classifier")

for C in (0.01, 1.0):
    params = {"model": "logreg", "C": C, "seed": SEED}
    with mlflow.start_run(run_name=f"logreg-C{C}"):
        mlflow.log_params(params)
        mlflow.set_tags({"data_sha": data_hash, "purpose": "baseline sweep"})
        model = make_pipeline(StandardScaler(), LogisticRegression(C=C, max_iter=1000))
        model.fit(X_tr, y_tr)
        proba = model.predict_proba(X_te)[:, 1]
        metrics = {"f1": f1_score(y_te, proba > 0.5), "roc_auc": roc_auc_score(y_te, proba)}
        mlflow.log_metrics(metrics)
        mlflow.log_dict({"features": X.shape[1], "test_size": len(y_te)}, "data_card.json")
        mlflow.sklearn.log_model(model, name="model")
        print(C, {k: round(v, 4) for k, v in metrics.items()})

best = mlflow.search_runs(order_by=["metrics.roc_auc DESC"], max_results=1)
print(best[["run_id", "params.C", "metrics.roc_auc"]].to_string(index=False))

Run mlflow ui --backend-store-uri sqlite:///mlflow.db and open the browser to compare runs side by side. When the script runs inside a Git repository, MLflow also records the commit hash as a tag. Notice what the code captures beyond metrics: the seed, a fingerprint of the data, and a small data card. Older MLflow versions use artifact_path="model" instead of name="model" in log_model; check the docs for your version.

Good tracking habits:

  • Log everything, decide later. Disk is cheap; re-running a three-day job because you did not log the learning-rate schedule is not.
  • Log the config object, not scattered values: load hyperparameters from a YAML or dataclass and log it whole.
  • Log curves, not just final numbers: training and validation loss per step reveal overfitting and instability.
  • Use autologging (mlflow.autolog() or framework integrations) as a baseline, then add domain-specific metrics.
  • Tag runs with intent ("baseline", "ablation: no augmentation") so future you can read the history.

Sweeps and the multiple-comparisons trap

Hyperparameter search tools (Optuna, Ray Tune, W&B Sweeps) run many trials and log each as a run. Bayesian methods such as the tree-structured Parzen estimator usually find good settings in fewer trials than grid search. But the more configurations you try, the more likely the "best" one is lucky on your validation set. A rough rule of thumb: if mm configurations were all truly equal and their validation scores had independent noise with standard deviation Οƒ\sigma, the expected best observed score would still exceed the true value by an amount that grows roughly like Οƒ2ln⁑m\sigma\sqrt{2\ln m}. For m=100m = 100 the exact expected maximum of 100 standard normal draws is about 2.5Οƒ2.5\sigma: a sizable "improvement" made of pure luck. Keep a held-out test set you touch only once at the end, and report variance across seeds for the winner.

Versioning data

Code lives in Git, but datasets are often gigabytes or terabytes, which Git handles poorly. Options:

  • DVC (Data Version Control): stores a small pointer file containing a content hash in Git, with the bytes in object storage (S3, GCS, Azure, or a shared drive). git checkout an old commit, then dvc pull, and you get the matching data.
  • Lakehouse table formats such as Delta Lake and Apache Iceberg, which support time travel: query a table "as of" a version or timestamp. Log that version with the run.
  • lakeFS and similar tools provide Git-like branches and commits over object storage.
  • At minimum: immutable, dated snapshots (s3://bucket/train/2026-11-01/) plus a content hash logged with each run.
# DVC in a nutshell
dvc init
dvc add data/train.parquet          # writes data/train.parquet.dvc (a pointer with an md5 hash)
git add data/train.parquet.dvc .gitignore && git commit -m "Track training data v1"
dvc remote add -d storage s3://my-bucket/dvc-store
dvc push                             # upload the bytes; Git keeps only the pointer

Also version the transformations: the feature pipeline that turns raw data into training data is code, and a changed join or filter is a changed dataset. DVC pipelines, Airflow, Dagster, or similar orchestrators can record which code produced which data.

Versioning models: the registry

A model registry holds named models with numbered versions, each linked to the run (and therefore the code, data, parameters, and metrics) that produced it. Instead of copying files to a server, deployment systems ask the registry for "the version currently aliased champion". Promotion and rollback become metadata changes, and audits ("which data trained the model that denied this loan?") become queries. MLflow, W&B, Hugging Face Hub, and every major cloud ML platform provide registries. The CI/CD lesson shows how registries gate deployments.

Controlling randomness and environment

Randomness enters through weight initialization, data shuffling, dropout, augmentation, and sampling. Set seeds for every library you use (random, numpy, and your deep-learning framework), and pass explicit random_state arguments. On GPUs, even seeded runs can differ, because some kernels use non-deterministic parallel reductions and floating-point addition is not associative. In 64-bit floats,

(1016+1)βˆ’1016=0but(1016βˆ’1016)+1=1,(10^{16} + 1) - 10^{16} = 0 \quad\text{but}\quad (10^{16} - 10^{16}) + 1 = 1,

because 1016+110^{16} + 1 is not representable and rounds back to 101610^{16}. When thousands of threads sum gradients in whatever order they finish, the last bits differ from run to run, and those differences can grow over training. Frameworks provide deterministic modes (for example, PyTorch's torch.use_deterministic_algorithms(True)), often at some speed cost. When bit-exactness is not required, the honest alternative is to run several seeds and report mean and spread. If one configuration's score varies across seeds with standard deviation Οƒ\sigma, the mean of kk seeds has standard error Οƒ/k\sigma/\sqrt{k}, and the difference between two such means has standard error Οƒ2/k\sigma\sqrt{2/k}. With Οƒ=0.4\sigma = 0.4 points and k=5k = 5, that is about 0.25 points, so a 0.3-point "improvement" is barely more than one standard error: not evidence of anything.

Environment drift is the other silent killer: a minor library upgrade can change default hyperparameters or numerical behavior. Pin exact versions with a lockfile (uv lock, poetry.lock, pip-compile, or conda-lock), record the Python, CUDA, and driver versions, and for full fidelity build a container image and log its digest with the run.

Tracking LLM work

The same discipline applies when you are not training anything:

  • Prompt and configuration experiments: a change to a system prompt, a retrieval parameter, or a model ID is an experiment. Log the prompt version, model and settings, and the eval results it produced (lesson 5 of the previous module).
  • Fine-tuning runs: base model ID and revision, dataset version, adapter configuration (for example LoRA rank), training curves, and eval scores.
  • Evaluation runs themselves: eval set version, judge model and prompt version. A score is meaningless without knowing what measured it.

Modern trackers, including MLflow, have added LLM-specific features such as tracing, prompt registries, and evaluation views. The LLMOps lesson at the end of this module builds on them.

Pitfalls

  • Logging only the winner. Failed runs explain why the winner won; keep them.
  • Data leakage across splits, such as random splits of time-series data or duplicates in train and test, produces reproducible but wrong results. Version the split, not just the data.
  • Notebook state. Cells run out of order produce results no script can reproduce. Promote experiments to scripts or pipelines before trusting them.
  • Mutable "latest" paths. s3://data/latest/ today is not s3://data/latest/ next month.

Hands-on exercise

  1. Run the MLflow example, then open the UI and compare the two runs.
  2. Add a third variant with a different model family (for example, gradient boosting) and log a confusion-matrix plot as an artifact (mlflow.log_figure).
  3. Run the best configuration with five different seeds (also varying the split seed) and log each. Is the seed-to-seed spread larger than the gap between your configurations?
  4. Put a CSV version of the dataset under DVC, change one row, commit the new version, and confirm that checking out the old commit and running dvc checkout restores the original file.
  5. Register the best model in the MLflow Model Registry and give it the alias champion.

Expected outcome: a tracking server with comparable runs, evidence of how much of your "improvement" is seed noise, and a data version and registered model you can trace back to an exact commit.

Key takeaways

  • A result depends on code, data, configuration, environment, and randomness; capture all five.
  • Experiment trackers (MLflow, W&B, and others) log parameters, metrics, artifacts, and lineage for every run.
  • Version data with content hashes (DVC, lakehouse time travel, immutable snapshots) and version the transformations too.
  • A model registry links each deployable version to its lineage and makes promotion and rollback metadata changes.
  • Seeds are necessary but not sufficient on GPUs; report variance across seeds.
  • Treat prompt, configuration, and eval changes in LLM apps as tracked experiments.

Next, you will take a tracked, registered model and put it in front of users: model serving.

Further reading

  • Sculley et al., "Hidden Technical Debt in Machine Learning Systems" (NeurIPS 2015).
  • MLflow documentation: https://mlflow.org/docs/latest/
  • DVC documentation: https://dvc.org/doc
  • Pineau et al., "Improving Reproducibility in Machine Learning Research (A Report from the NeurIPS 2019 Reproducibility Program)" (2021).

Save your progress and earn XP

Create a free account to take the quiz, track progress and unlock badges.

Experiment Tracking and Reproducibility Β· AI Everything