clearml
**ClearML** is the **open-source end-to-end MLOps platform that tightly integrates experiment tracking, remote execution, and data management** — providing a self-hosted alternative to W&B and MLflow that combines all MLOps functions (experiment tracking, pipeline orchestration, data versioning, and model serving) into a single platform with automatic experiment logging and a unique ability to clone and re-run any experiment on remote GPU workers.
**What Is ClearML?**
- **Definition**: An open-source MLOps platform (originally "Trains," rebranded ClearML in 2021) providing experiment tracking, hyperparameter optimization, data management, pipeline orchestration, and model serving — deployed as a self-hosted stack (Docker Compose or Kubernetes) or used via ClearML's managed cloud, with an SDK that automatically captures all experiment details with minimal code changes.
- **Auto-Magic Logging**: ClearML's SDK integrates with matplotlib, TensorBoard, PyTorch, TensorFlow, scikit-learn, and Hydra — importing clearml and calling Task.init() is often sufficient to capture all training parameters, metrics, and artifacts without additional log statements.
- **Remote Execution (ClearML Agent)**: The defining feature that separates ClearML from pure trackers — ClearML Agent enables cloning any tracked experiment and re-running it on a different GPU worker with one click, or queueing modified experiments to run on remote infrastructure automatically.
- **Self-Hosting Advantage**: ClearML Server can be self-hosted for free — all experiment data, models, and artifacts remain in the organization's own infrastructure, satisfying data residency requirements impossible with SaaS-only tools like W&B or Comet.
- **Unified Platform**: Instead of combining MLflow (tracking) + Prefect (orchestration) + DVC (data versioning) + Triton (serving), ClearML provides all these capabilities in a single integrated platform.
**Why ClearML Matters for AI**
- **Experiment Cloning**: Right-click any experiment in the ClearML UI → Clone → modify hyperparameters → enqueue to a GPU worker. No code changes, no SSH, no job script rewriting — iterate on experiments from a browser.
- **Zero-Code Integration**: Add two lines to an existing script (from clearml import Task; task = Task.init(...)) and ClearML automatically captures all matplotlib plots, TensorBoard logs, model checkpoints, and hyperparameters from popular ML frameworks.
- **Self-Hosted and Free**: The open-source ClearML Server runs on any Kubernetes cluster or Docker Compose setup — the complete MLOps stack with no per-seat licensing fees, unlimited experiments, and full data ownership.
- **Pipeline Orchestration**: ClearML Pipelines define multi-step ML workflows where each step runs as a separate ClearML task — the pipeline handles dependencies, triggers, and execution across distributed workers.
- **HPO with Controller**: ClearML's HPO controller launches multiple experiment variants in parallel, monitors results, applies optimization strategies (random, grid, Optuna Bayesian), and stops underperforming trials early.
**ClearML Core Components and API**
**Task Initialization (Auto-Logging)**:
from clearml import Task
import torch
from transformers import Trainer, TrainingArguments
task = Task.init(
project_name="LLM Fine-tuning",
task_name="Llama-3-8B-LoRA-v4",
tags=["llama", "lora", "alpaca"]
)
# ClearML auto-captures: matplotlib figures, TensorBoard logs,
# argparse parameters, PyTorch model structure
training_args = TrainingArguments(
output_dir="./output",
learning_rate=2e-4,
num_train_epochs=3,
report_to="tensorboard" # ClearML intercepts TensorBoard
)
trainer = Trainer(model=model, args=training_args)
trainer.train()
task.close()
**Manual Logging**:
logger = task.get_logger()
for epoch in range(epochs):
logger.report_scalar("Loss/train", "train", iteration=epoch, value=train_loss)
logger.report_scalar("Loss/val", "val", iteration=epoch, value=val_loss)
logger.report_histogram("weight_distribution", "weights", iteration=epoch, values=weights)
**ClearML Data (Dataset Versioning)**:
from clearml import Dataset
dataset = Dataset.create(dataset_name="alpaca-clean", project_name="datasets")
dataset.add_files(path="./data/alpaca_clean_52k.json")
dataset.upload()
dataset.finalize()
print(dataset.id) # Pin this ID for reproducibility
# In training script:
dataset = Dataset.get(dataset_id="abc123")
data_path = dataset.get_local_copy()
**ClearML Pipelines**:
from clearml.automation.controller import PipelineDecorator
@PipelineDecorator.component(return_values=["dataset_id"])
def stage_preprocess(raw_path: str) -> str:
# Preprocessing code — runs as separate ClearML task
return create_dataset(raw_path)
@PipelineDecorator.component(return_values=["model_id"])
def stage_train(dataset_id: str, lr: float) -> str:
dataset = Dataset.get(dataset_id=dataset_id)
return train_model(dataset.get_local_copy(), lr)
@PipelineDecorator.pipeline(name="ML Pipeline", project="LLM")
def ml_pipeline(raw_path: str):
dataset_id = stage_preprocess(raw_path)
model_id = stage_train(dataset_id, lr=2e-4)
return model_id
**ClearML Agent (Remote Execution)**:
# Install agent on GPU worker:
clearml-agent daemon --queue gpu-queue
# Enqueue experiment from UI or API:
task.execute_remotely(queue_name="gpu-queue")
**ClearML vs Alternatives**
| Aspect | ClearML | MLflow | W&B |
|--------|---------|--------|-----|
| Open Source | Yes (full stack) | Yes | No |
| Self-Hosting | Free | Free | Paid |
| Remote Execution | Built-in | No | No |
| Data Versioning | Built-in | Via plugins | Artifacts only |
| Auto-Logging Depth | Excellent | Good | Excellent |
| Pipeline Orchestration | Built-in | External | No |
ClearML is **the open-source MLOps platform that delivers experiment tracking, remote execution, and data versioning in one integrated self-hosted system** — by enabling teams to clone, modify, and re-run any experiment on remote GPU workers from a browser while keeping all data on-premises, ClearML provides the full commercial MLOps experience without per-seat licensing costs or data residency compromises.