Sub topic 1
Why Experiment Tracking Matters
Training a model is rarely a single event. You change a learning rate, retrain, change the features, retrain, and repeat. After a few weeks you have dozens of results and no reliable record of which change produced which number. This chapter explains why that happens, what it costs, and what an experiment tracker does about it. Later chapters compare specific tools. Here you build the case for needing one at all.
Prerequisites
This chapter assumes you can do the following:
- Read and write basic Python and use a command line.
- Train and evaluate a machine learning model, including a train/validation split.
- Explain hyperparameters (settings you choose before training, such as learning rate) and metrics (numbers that score a model, such as AUC).
- Describe a client-server application, where a program sends requests, often over REST, to a service that stores data.
You do not need to have used MLflow, Weights & Biases, or any tracker.
The problem: results you cannot reproduce
Suppose you train a churn model on Monday and get a validation AUC of 0.91. On Thursday a colleague asks, "Which settings gave you 0.91?" You search your terminal history and find three scripts with similar names, two notebooks, and a spreadsheet you stopped updating on Tuesday.
This is a reproducibility problem. A result is reproducible when you can rerun the same procedure and get the same outcome, within expected random variation. To rerun a procedure you need to know everything that influenced it. For a typical training run, that includes:
- Code. The exact commit, plus any uncommitted edits.
- Hyperparameters. Every setting, including defaults you never typed, because library defaults change between versions.
- Data. Which snapshot or query, which filters, which train/validation split, and the random seed that produced the split.
- Environment. Python and library versions, hardware, and CUDA or driver versions when GPUs are involved.
- Outputs. Metrics over time, final scores, plots, and the trained model file.
If any one item is missing, you may be unable to explain a difference between two runs. You may also be unable to tell whether an apparent improvement is real.
What goes wrong without tracking
Teams without a tracking habit tend to hit the same failures. Each one has a mechanism, not just an inconvenience.
Lost best results
You get your best score on run 14 and overwrite the model file on run 15. The score is in a screenshot, but the model and its settings are gone. You now retrain and hope to land near 0.91 again.
Unfair comparisons
You compare a run with AUC 0.91 to a run with AUC 0.89 and conclude that the first configuration is better. Between those runs you also refreshed the dataset and changed the validation split. The difference may come from the data, not the model. Without a record of what changed, you cannot tell.
Noise mistaken for signal
Many training procedures are stochastic, which means results vary from run to run because of random seeds, data shuffling, and nondeterministic GPU operations. A gap of 0.01 AUC may be within that variation. You can only judge this if you have several runs of the same configuration to compare. People rarely keep those without a system.
Hidden dependence on one person
The knowledge of how the model was built lives in one engineer's memory and notebooks. When that person is on leave or leaves the company, the team cannot retrain the production model with confidence.
Slow debugging of regressions
A model in production performs worse than expected. You need to know which training run produced it, what data it saw, and how its offline metrics compared to the previous model. Without a link from the deployed file back to a run record, you are guessing.
Compliance and audit gaps
In regulated settings such as credit, health, and insurance, you may be asked to show how a model was trained and evaluated. "We believe it was the January dataset" is not an acceptable answer.
A manual baseline
Before choosing a tool, it helps to see what you would build by hand. The following script appends one JSON record per run to a file, then reads the file back to find the best run. It uses only the standard library.
import json
import platform
import subprocess
import sys
import time
import uuid
def git_commit():
try:
return subprocess.check_output(
["git", "rev-parse", "HEAD"],
text=True,
stderr=subprocess.DEVNULL,
).strip()
except (subprocess.CalledProcessError, FileNotFoundError):
return "unknown"
def log_run(params, metrics, tags=None, path="runs.jsonl"):
record = {
"run_id": uuid.uuid4().hex,
"timestamp": time.time(),
"git_commit": git_commit(),
"python": sys.version.split()[0],
"platform": platform.platform(),
"params": params,
"metrics": metrics,
"tags": tags or {},
}
with open(path, "a", encoding="utf-8") as f:
f.write(json.dumps(record) + "\n")
return record["run_id"]
def best_run(metric, path="runs.jsonl"):
with open(path, encoding="utf-8") as f:
runs = [json.loads(line) for line in f if line.strip()]
runs = [r for r in runs if metric in r["metrics"]]
return max(runs, key=lambda r: r["metrics"][metric])
if __name__ == "__main__":
log_run(
params={"max_depth": 6, "learning_rate": 0.1},
metrics={"val_auc": 0.91},
tags={"data_version": "2026-11-01"},
)
log_run(
params={"max_depth": 8, "learning_rate": 0.05},
metrics={"val_auc": 0.89},
tags={"data_version": "2026-11-01"},
)
winner = best_run("val_auc")
print(winner["run_id"], winner["params"], winner["metrics"])This already captures the code version, the environment, the settings, and the result. It also shows where a hand-built approach starts to strain:
- Concurrent writes. Two training jobs appending to the same file can interleave lines, and on network file systems that risk is higher.
- Metric series. A single number per run hides the training curve. Storing a value per step makes records large and awkward to query.
- Large files. Models, plots, and sample predictions do not belong in a JSON line. You need somewhere to store them and a way to link them to the run.
- Comparison. Sorting by one metric is easy. Overlaying learning curves, filtering by a parameter, or grouping by data version means writing more code.
- Sharing. A file on your laptop is not visible to teammates, and a shared file has no access control or history.
- Uncommitted changes. The commit hash is misleading if your working tree had edits. The script above does not detect that.
Each of these gaps is a feature that a tracker supplies.
What a tracker adds
An experiment tracker is software that records the inputs, outputs, and context of each training run in a central, queryable place. Tools differ in architecture and cost, which later chapters cover. The core capabilities are common to all of them.
- Structured recording. Parameters, metrics, tags, and files are stored under a run, with consistent names and types.
- Time series. Metrics can be logged repeatedly with a step number, so you can see a training curve and not only a final value.
- Automatic context. Many trackers capture the git commit, command line, host, and system metrics without extra code.
- Artifact storage. Models, plots, and data samples are stored and linked to the run that produced them.
- Search and comparison. You can filter runs by parameter, sort by metric, and plot runs side by side.
- Sharing. A teammate opens a link and sees the same run you saw.
- A path to deployment. Many trackers include or connect to a model registry, which tracks which model version is staged or in production and which run produced it.
The following diagram shows where tracking sits in the loop of training work.
The loop on the right of the diagram is the point. Comparison informs the next choice of parameters, and that decision is only as good as the record behind it.
What a tracker does not do
Expect less than the marketing suggests.
- It does not make runs reproducible by itself. It records what you tell it, or what it can detect automatically. If your code reads a mutable table and you do not log a version, the tracker cannot recover it.
- It does not fix a bad evaluation. Tracking a metric computed on leaked data produces a well-documented wrong answer.
- It does not replace data and pipeline versioning. A tracker may store dataset references, but tools built for data versioning or orchestration handle that job in more depth. The chapter on artifacts returns to this.
- It adds operating cost. Someone must run the server, pay the bill, manage access, and keep the logging code working.
Common mistakes when starting
Teams that adopt tracking often repeat the same errors. Knowing them early saves a migration later.
- Logging too little. Only the final metric is recorded, so you cannot see overfitting in the curve or explain a plateau.
- Logging inconsistent names. One person logs
val_auc, another logsvalidation_auc. Comparison tables then have empty cells. Agree on names and units before the team grows. - Logging every run, including debug runs. Smoke tests and crashed runs crowd the results. Use tags or a separate experiment for scratch work.
- Not logging failures. A run that diverged or ran out of memory is information. Make sure the run is closed with a failed status, not left open.
- Skipping the seed. Without it you cannot distinguish a real change from variation.
- Treating tracker choice as permanent. Training code that calls a tracker's API in hundreds of places is expensive to change. Chapter 10 covers a thin interface that limits this.
Why the choice matters
Almost any tracker is better than none, so the first decision is to track. The second decision, which tool, has real consequences:
- Where data lives. Parameters and metrics can reveal business information, and artifacts can contain customer data. Self-hosting and hosted services differ in who can access it.
- Who maintains it. A self-hosted server needs an owner, backups, and upgrades. A hosted service moves that work to a vendor in exchange for a subscription.
- How the team works. A solo researcher on one machine, a ten-person team sharing GPU clusters, and a regulated enterprise have different needs for access control and dashboards.
- How hard it is to leave. Run history is valuable. If it is locked into a proprietary format, switching later means losing it or writing an export.
The remaining chapters build a vocabulary for these questions. You will first learn the shared data model, then examine MLflow and Weights & Biases, then other options, and finally criteria and a trial process for deciding.
Summary of the argument
Model development produces many runs that differ in code, data, settings, and environment. Memory, notebooks, and ad hoc files cannot reliably keep that context, and the failures are lost results, unfair comparisons, noise mistaken for signal, and untraceable production models. A tracker supplies structured records, metric series, artifact storage, search, and sharing. It does not replace good evaluation or data versioning, and it carries an operating cost.
Exercise
A teammate reports that run A (validation AUC 0.92) beat run B (0.90) and recommends shipping A's configuration. Name three pieces of information you would want recorded for both runs before accepting that conclusion, and say what each could reveal.
Show answer
Any three of the following. (1) The data version and train/validation split for each run. If A used a different snapshot or split, the gap may come from the data, not the model. (2) The random seed, and results from repeated runs of each configuration. A 0.02 gap may be within normal run-to-run variation. (3) The code commit and any uncommitted changes. A may include a feature or preprocessing change that B lacks. (4) The full hyperparameter set including defaults. A library default may differ between versions. (5) The library and environment versions. A different version may change training behavior. The common point is that a comparison is fair only when everything except the variable under test is known and held constant.
Exercise
Using the manual script in this chapter, name two concrete limitations that would appear when ten people run hundreds of GPU training jobs, and name the tracker capability that addresses each.
Show answer
First, concurrent appends to one JSONL file can interleave or corrupt lines, and the file is not visible to teammates. A tracker with a central server or database handles concurrent writers and sharing. Second, the script stores one number per metric and cannot hold training curves or model files. A tracker's step-indexed metric logging and artifact storage address that. Other valid answers: no run comparison or plotting (search and comparison UI), no access control (hosted or server-based permissions), and no detection of uncommitted code changes (automatic context capture).