trackio
Trackio is a lightweight, local-first, and free experiment tracking library built by Hugging Face. It offers an API compatible with Weights & Biases (wandb) for seamless migration, allowing users to log metrics, parameters, and artifacts. Logs are persisted locally in an SQLite database and can be optionally synced with Hugging Face Datasets and visualized on Hugging Face Spaces. It is actively developed with a focus on simplicity, extensibility, and LLM-friendly programmatic access.
Warnings
- breaking Trackio is currently in beta, and its SQLite database schema may change in future releases. This could necessitate migrating or deleting existing database files (located by default at `~/.cache/huggingface/trackio`) to maintain compatibility.
- gotcha The `trackio.init()` function must be called at the beginning of your script or experiment run before any other `trackio` logging functions (`log`, `save`, etc.) are used. Failing to do so will result in errors as the tracking context will not be established.
- gotcha While Trackio provides API compatibility with `wandb`, it is intentionally lightweight and does not yet support all advanced features found in Weights & Biases, such as artifact versioning, comprehensive custom visualizations, or advanced sweeps management.
- gotcha When using `space_id` in `trackio.init()` to sync logs to Hugging Face Spaces, your local `huggingface-cli` must be logged in and configured with a token that has write permissions for the specified Space or to create a new one.
Install
-
pip install trackio -
pip install trackio[gpu] -
pip install trackio[apple-gpu] -
pip install trackio[tensorboard] -
pip install trackio[dev] -
pip install trackio[spaces]
Imports
- trackio
import trackio
- wandb_alias
import trackio as wandb
Quickstart
import trackio
import random
import time
import os
# Initialize a new experiment run
# For Spaces integration, add space_id='your_username/your_space_name'
run = trackio.init(project="my-awesome-project",
name=f"run-{int(time.time())}",
config={
"learning_rate": 0.001,
"epochs": 5,
"batch_size": 32
})
print(f"Starting run: {run.name} in project: {run.project_name}")
# Simulate a training loop
for epoch in range(run.config["epochs"]):
# Simulate metrics
train_loss = 1.0 / (epoch + 1) + random.uniform(-0.1, 0.1)
val_loss = 0.8 / (epoch + 1) + random.uniform(-0.05, 0.05)
accuracy = 0.5 + (epoch / run.config["epochs"]) * 0.4 + random.uniform(-0.03, 0.03)
# Log metrics
trackio.log({"epoch": epoch, "train_loss": train_loss, "val_loss": val_loss, "accuracy": accuracy})
print(f"Epoch {epoch}: Train Loss = {train_loss:.4f}, Val Loss = {val_loss:.4f}, Accuracy = {accuracy:.4f}")
time.sleep(0.5)
# Finish the run
trackio.finish()
print("Run finished. To view the dashboard, run `trackio show` in your terminal.")