Experiment tracking & reproducibility

In one sentence

Log every run's code commit, data version, config, metrics and artifacts automatically, so any result can be compared, explained and rebuilt months later.

Analogy: A lab notebook that writes itself: each experiment records the recipe, the batch number of every ingredient and the result, so anyone can bake the same cake again.

Pin the four inputs of a run, log its outputs, and the best run carries its lineage into the registry.

How it works

  • A tracking server (MLflow, Weights & Biases) stores runs so you can sort, diff and plot hundreds of them.
  • Reproducibility pins the code commit, an immutable data snapshot, the environment digest and the config with seeds.
  • GPU kernels can be nondeterministic, so expect statistically equivalent results, not bit-identical ones.
  • With 100 eval examples at ~80% accuracy, a 2-point 'win' is noise; compare across 3–5 seeds.
  • For LLM apps, log prompt, model, retrieval config, eval set version and per-example outputs; promote winners to the registry.

Check yourself

Answer to mark it learned; your answers aren't scored.

You rerun last quarter's churn training: same git commit, image digest, config, seeds and frozen eval set. AUC is 0.84 instead of 0.87, far beyond seed variance. The run logged its data as s3://bucket/train/. Most likely cause?

Go deeper

Full explanation

Experiment tracking records, for every training or eval run, everything needed to answer what produced this number?:

  • params: hyperparameters, config, model or prompt id;
  • metrics: loss curves, eval scores, per-slice results;
  • artifacts: model files, plots, predictions;
  • provenance: git commit, data version, environment (lockfile or container digest).

A tracking server (MLflow, Weights & Biases) stores runs so you can sort, diff and plot hundreds of them instead of digging through notebooks.

Reproducibility needs three pinned inputs plus seeds: code (commit), data (an immutable snapshot via DVC, lakeFS or table time travel) and environment (image digest). Even then GPU kernels can be nondeterministic, so expect statistically equivalent results, not bit-identical ones.

For LLM apps a run is a prompt + model + retrieval config scored on a fixed eval set. Log the config, the eval set version, per-example outputs and judge scores, so 'the new prompt is better' becomes a measured claim. Winners get promoted to the Model registry & versioning.

Code A tracked, reproducible run with MLflow
pythonA tracked, reproducible run with MLflow
import subprocess
import mlflow

mlflow.set_experiment("churn-model")
mlflow.autolog()  # captures framework params, metrics and the model

with mlflow.start_run():
    commit = subprocess.check_output(["git", "rev-parse", "HEAD"], text=True).strip()
    mlflow.set_tags({
        "git_commit": commit,
        "data_version": "lakefs://ml-data/a1b2c3d/churn/",  # immutable commit, not a branch
        "image": "ghcr.io/acme/train@sha256:9f2c...",
        "eval_set": "churn-eval-v3",                       # frozen eval set
    })
    mlflow.log_params({"seed": 42, "max_depth": 6, "lr": 0.05})

    model = train(seed=42, max_depth=6, lr=0.05)
    scores = evaluate(model, eval_set="churn-eval-v3")
    mlflow.log_metrics({"auc": scores.auc, "auc_new_users": scores.auc_new})

# Later: rank every run by the metric that matters
best = mlflow.search_runs(order_by=["metrics.auc DESC"], max_results=5)
Real example

Two engineers report AUC 0.87 and 0.84 for 'the same' churn model. The tracking server diffs both runs in a minute: same commit and params, different data_version; one trained before a backfill removed duplicated churn labels. Without tracking that is a week of 'works on my machine'. For an LLM support bot, the team logs 14 prompt variants on a 300-example eval set and only ships the winner after checking its 4-point gain exceeds the spread between reruns of the same prompt.

Trade-offs +3 · −3

+ You gain

  • Turns 'I think v3 was better' into a sortable, diffable table.
  • Explains regressions fast: diff commit, data version and params between two runs.
  • Feeds lineage to the model registry and to audits at no extra effort.

− You pay

  • Only as complete as the discipline: untracked notebook runs still leak into decisions.
  • Versioning large datasets costs storage and tooling effort.
  • Bit-exact reproducibility on GPUs is often impossible; you settle for statistical equivalence.

Use it when

From the first model anyone will compare, and for every prompt or model change in an LLM app that is judged by an eval score.

Avoid it when

Quick throwaway exploration in a notebook; but the moment a result feeds a decision or a slide, rerun it tracked.

Numbers to know 3
  • With 100 eval examples at ~80% accuracy, the 95% confidence interval is about ±8 points: a 2-point 'win' is noise.
  • Rule of thumb: compare model changes across 3–5 seeds and report mean ± std.
  • A reproducible run pins 4 things: code commit, data snapshot, environment digest, config with seeds.
Common pitfalls 4
  • Logging data as a path like s3://bucket/train/: paths change; log an immutable version.
  • Picking the best of 200 runs on the test set: the leaderboard overfits. Keep a held-out set you rarely touch.
  • Changing the eval set between runs and then comparing their scores.
  • Tracking prompt experiments with only an aggregate score: log per-example outputs for error analysis.
Interview questions 2

Answer out loud first, then reveal.

A model trained last quarter must be rebuilt for an audit. What must you have kept?Show answer

Four pinned inputs, tied to the outputs by the tracking run. The git commit for code; an immutable data snapshot, meaning a DVC hash, lakeFS commit or table version, not a path; the environment as a container digest; and the config with seeds. Then I rebuild and show the metrics match within seed variance, since bit-identical is unrealistic on GPUs. The trap is retention: if table time travel expires after a week, the training snapshot must be materialized explicitly.

How do you run prompt experiments for an LLM feature?Show answer

With the same discipline as training. Each variant is a run: prompt version, model id, temperature and retrieval config, scored on a frozen, versioned eval set with the same graders. I log aggregate scores and per-example outputs: the aggregate tells me which won, the examples tell me why. I check the gap exceeds rerun noise, because on a few hundred examples a 2-point difference often isn't significant. The winner ships as a prompt-plus-model bundle, never pasted into production by hand.