Prompt
How do I set up an experiment tracker for comparing training runs and managing model artifacts?
Latest observation
A good experiment tracker should cover two things:
- Compare training runs — metrics, params, code version, dataset version
- Manage artifacts — checkpoints, plots, logs, exported models, configs
Here’s a practical way to set one up.
1) Pick a tool
Common options:
- Weights & Biases (W&B) — great UI, easy artifact/version tracking
- MLflow — self-hostable, simple tracking server, good for teams
- TensorBoard + custom storage — lightweight, but weaker artifact management
- Neptune / Comet — similar to W&B, polished tracking platforms
If you want the easiest modern setup, W&B.
If you want self-hosted and open-source, MLflow.
2) Decide what to log
For each run, log:
Metadata
- Experiment name
- Run ID
- Git commit hash
- Branch
- Dataset/version identifier
- Hyperparameters
- Environment info (CUDA, torch version, hostname)
Metrics
- Training loss
- Validation loss
- Accuracy/F1/AUROC/etc.
- Learning rate
- Gradient norms
- Epoch time
Artifacts
- Model checkpoints
- Best model
- Training config
- Sample predictions
- Confusion matrix / plots
- Tokenizer / preprocessing files if applicable
3) Organize your run structure
A simple convention:
experiments/
run_001/
config.yaml
metrics.jsonl
checkpoints/
epoch_1.pt
best.pt
plots/
loss_curve.png
Even if you use a tracker, keeping local structure clean makes debugging easier.
4) Example with MLflow
Install
pip install mlflow
Start a tracking server
Local file-based:
mlflow ui
Or run a proper server with backend store/artifact store if needed.
Log a run
import mlflow
import mlflow.pytorch
import torch
mlflow.set_experiment("my_experiment")
with mlflow.start_run():
mlflow.log_params({
"lr": 1e-3,
"batch_size": 32,
"model": "resnet18"
})
for epoch in range(10):
train_loss = 0.42 - 0.01 * epoch
val_acc = 0.81 + 0.01 * epoch
mlflow.log_metric("train_loss", train_loss, step=epoch)
mlflow.log_metric("val_accuracy", val_acc, step=epoch)
# Save artifact
with open("config.yaml", "w") as f:
f.write("lr: 0.001\nbatch_size: 32\n")
mlflow.log_artifact("config.yaml")
# Save model
torch.save({"weights": "dummy"}, "model.pt")
mlflow.log_artifact("model.pt")
If using PyTorch model logging:
mlflow.pytorch.log_model(model, artifact_path="model")
5) Example with Weights & Biases
Install
pip install wandb
Use it in training
import wandb
wandb.init(project="my_project", name="run_001")
wandb.config.update({
"lr": 1e-3,
"batch_size": 32,
"model": "resnet18"
})
for epoch in range(10):
train_loss = 0.42 - 0.01 * epoch
val_acc = 0.81 + 0.01 * epoch
wandb.log({
"train_loss": train_loss,
"val_accuracy": val_acc,
"epoch": epoch
})
wandb.save("model.pt")
wandb.save("config.yaml")
wandb.finish()
For full artifact versioning:
artifact = wandb.Artifact("model", type="model")
artifact.add_file("model.pt")
wandb.log_artifact(artifact)
6) Make runs comparable
Use consistent naming and grouping:
experiment_namerun_namegroupfor related runs- tags like
baseline,ablation,seed=42
Always log:
- same metrics across runs
- same evaluation dataset
- same step/epoch scale
Also set:
- random seeds
- deterministic flags if possible
This avoids apples-to-oranges comparisons.
7) Track model artifacts properly
Best practices:
- Save best checkpoint based on validation metric
- Save last checkpoint for recovery
- Version artifacts by run ID
- Attach metadata to artifacts:
- metric values
- git commit
- dataset version
- parent run
- Keep large binaries out of Git; use object storage or the tracker’s artifact store
For example:
- Model artifact name:
classifier:v12 - Input data version:
dataset:v5 - Code version: commit SHA
8) Recommended workflow
A solid workflow looks like this:
- Start a run in tracker
- Log params and code version
- During training, log metrics per step/epoch
- Save checkpoints locally
- Upload checkpoints/plots as artifacts
- Mark best run
- Compare runs in UI
- Promote selected artifact to “production” or “approved”
9) If you want a minimal custom setup
If you don’t want a full platform yet:
- Log metrics to JSONL
- Save artifacts in run-specific folders
- Keep a central index in SQLite/Postgres
- Build a small dashboard later
Example runs.db schema:
runs(id, name, created_at, git_sha, dataset_version)metrics(run_id, step, key, value)artifacts(run_id, path, type, checksum)
This is enough for a lightweight in-house tracker.
10) My recommendation
- Solo or small team: W&B
- Need self-hosting / open source: MLflow
- Very lightweight: TensorBoard + local artifact folder
If you want, I can give you:
- a minimal MLflow setup,
- a W&B template for PyTorch training, or
- a self-hosted tracker architecture for a team.