Skip to main content

TraceML

Diagnose slow PyTorch training. Compare runs and catch performance regressions.

Works automatically with: Hugging Face Trainer · PyTorch Lightning · RF-DETR

PyPI version CI Python 3.10+ License GitHub stars

Quickstart · Integrations · Distributed training · Monitoring · Compare runs · Documentation

⭐ If TraceML helps you find a bottleneck, please star the repository.

TraceML breaks down training-step time, identifies likely bottlenecks, and saves reports for comparison or CI.

  • Trainer integrations: automatic setup for supported trainers; explicit step instrumentation for custom PyTorch loops.
  • Distributed diagnosis: compare rank timings and identify stragglers across GPUs and nodes.
  • Continuous monitoring: collect timing and resource metrics throughout training.

Quickstart

1. Install

If your training framework is already installed:

pip install traceml-ai

2. Run your existing script

- python train.py
+ traceml run train.py

For the standard trainer APIs listed above, no script changes are needed. TraceML prints a diagnosis when training finishes and writes final_summary.json and final_summary.txt under logs/<run-name>/.

No training script ready? Try the interactive demo, the Colab example, or the RF-DETR sample-data demo, which needs no dataset download.

What you get

The terminal report identifies the likely bottleneck, shows the timing and resource evidence behind it, and suggests the next investigation.

+----------------------------------------------------------------------------------------------------------------------------------------------------------+
|  TraceML Run Summary                                                                                                                                     |
|  bert_finetune · 1 rank · 1 GPU observed · 256 common steps · 52.4s                                                                                      |
+----------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                                                                                                                          |
|  Verdict: INPUT-BOUND  (CRITICAL)                                                                                                                        |
|  Why: Input Wait took 64% of Step Time.                                                                                                                  |
|  Next: Increase workers, prefetch, or storage throughput.                                                                                                |
|                                                                                                                                                          |
|  STEP TIMING (Window Average), GPU Clock                      ||  STEP MEMORY: BALANCED                                                                  |
|  Step Time           200.4 ms  100%                           ||                                                                                         |
|  ├─ Input Wait       128.0 ms   64%  ◀  cause                 ||                                                                                         |
|  ├─ Compute           68.0 ms   34%                           ||  avg per-step peak           avg                                                        |
|  │  ├─ Forward        24.0 ms   12%                           ||  Allocated                   2.7 GiB                                                    |
|  │  ├─ Backward       38.0 ms   19%                           ||  Reserved                    3.0 GiB                                                    |
|  │  └─ Optimizer       6.0 ms    3%                           ||                                                                                         |
|  ├─ H2D                0.4 ms   <1%                           ||                                                                                         |
|  └─ Residual           3.6 ms    2%                           ||                                                                                         |
|  DataLoader fetch: 120.0 ms (CPU, supplemental)               ||                                                                                         |
|                                                                                                                                                          |
|  SYSTEM METRICS: LOW GPU UTIL                                 ||  PROCESS METRICS: NORMAL                                                                |
|  Evidence: GPU utilization averaged 24%.                      ||                                                                                         |
|                                                               ||                                                                                         |
|                         avg                                   ||                       avg                                                               |
|  CPU                    18%                                   ||  CPU capacity         14%                                                               |
|  RAM used               5.8 GiB (19%)                         ||  RSS used             2.9 GiB (10%)                                                     |
|  GPU util               24%                                   ||  CUDA allocated       2.7 GiB                                                           |
|  GPU memory/device      3.1 GiB (21%)                         ||  CUDA reserved        3.0 GiB (20%)                                                     |
|  GPU temperature        42C                                   ||                                                                                         |
|  GPU power              58W                                   ||                                                                                         |
|                                                                                                                                                          |
|                                                                                                                                                          |
|  Full evidence: logs/bert_finetune/final_summary.json  (--html-report)                                                                                   |
+----------------------------------------------------------------------------------------------------------------------------------------------------------+

What TraceML diagnoses

Diagnosis Where to investigate
Input-bound DataLoader workers, transforms, tokenization, collation, or storage
H2D-bound Pinned memory, non-blocking copies, batch size, or transfer overlap
Compute-bound Model compute, mixed precision, batch size, or deeper profiling
Residual-heavy Logging, checkpointing, validation, CPU stalls, or unobserved work
Rank straggler Rank-local input, data imbalance, node variance, or networking
Memory creep Retained tensors, logging references, or cached activations

Read How to Read TraceML Output for definitions, diagnosis rules, and evidence limits.

Integrations

For these standard trainer APIs, traceml run needs no changes to your script:

Framework Training API
Hugging Face Trainer trainer.train()
PyTorch Lightning trainer.fit(...)
RF-DETR model.train(...)

Custom loops and other frameworks

Use the following setup for custom loops and other frameworks:

Training path Setup
Plain PyTorch or a custom loop traceml.init() and trace_step(...)
Hugging Face Accelerate Explicit step instrumentation
Ray Train and Ray Data TraceML Trainer/config wrappers
DeepSpeed Explicit step instrumentation
MONAI TraceML handler setup
Plain PyTorch example
import traceml_ai as traceml

traceml.init(mode="auto")

for batch in dataloader:
    with traceml.trace_step(model):
        optimizer.zero_grad(set_to_none=True)
        outputs = model(batch["x"])
        loss = criterion(outputs, batch["y"])
        loss.backward()
        optimizer.step()

Run it with traceml run train.py.

See the Public API and integration support matrix.

Distributed training and straggler detection

For scripts already configured for distributed training, replace torchrun with traceml run:

- torchrun --nproc-per-node=4 train.py
+ traceml run train.py --nproc-per-node=4

Across machines, run the same command on every node and change only --node-rank. On node 0:

traceml run train.py \
  --nnodes=2 \
  --node-rank=0 \
  --nproc-per-node=4 \
  --master-addr=node0 \
  --run-name=my-run \
  --logs-dir=/shared/traceml/logs

Node 0 starts the TraceML aggregator; other nodes join the same run. All nodes require a shared logs directory. Multi-node DDP uses summary mode; multi-node GPU support is experimental.

When training finishes, TraceML aligns common steps across all ranks and nodes and points to the rank most likely holding up the run:

+----------------------------------------------------------------------------------------------------------------------------------------------------------+
|  TraceML Run Summary                                                                                                                                     |
|  ddp_pretrain · 4/4 ranks · 4 GPUs observed · 2/2 nodes · 250 common steps · 40.1s                                                                       |
+----------------------------------------------------------------------------------------------------------------------------------------------------------+
|                                                                                                                                                          |
|  Verdict: INPUT STRAGGLER  (CRITICAL)                                                                                                                    |
|  Why: R0/N0 waited 254.5 ms for input; R1/N0 waited 3.8 ms for input.                                                                                    |
|  Next: Inspect input wait on the slow rank.                                                                                                              |
|  Scope: N = node · R = global rank · G = GPU index                                                                                                       |
|                                                                                                                                                          |
|  STEP TIMING (Median R1/N0), GPU Clock                        ||  STEP MEMORY: BALANCED · 4/4 ranks                                                      |
|  Step Time           303.7 ms  100%                           ||                                                                                         |
|  ├─ Input Wait         3.8 ms    1%                           ||                                                                                         |
|  ├─ Compute          259.5 ms   85%                           ||  avg per-step peak           median rank avg     worst rank avg                         |
|  │  ├─ Forward        80.0 ms   26%                           ||  Allocated                   7.9 GiB             8.8 GiB, R2/N1                         |
|  │  ├─ Backward      169.5 ms   56%                           ||  Reserved                    8.3 GiB             9.1 GiB, R2/N1                         |
|  │  └─ Optimizer      10.0 ms    3%                           ||                                                                                         |
|  ├─ H2D                1.1 ms   <1%                           ||                                                                                         |
|  └─ Residual          39.3 ms   13%                           ||                                                                                         |
|  DataLoader fetch: 3.7 ms (CPU, supplemental)                 ||                                                                                         |
|                                                                                                                                                          |
|  SYSTEM METRICS: LOW GPU UTIL · 2/2 nodes                     ||  PROCESS METRICS: NORMAL · 4/4 ranks                                                    |
|  Evidence: GPU utilization averaged 14%.                      ||                                                                                         |
|                                                               ||                                                                                         |
|                         median node avg   worst node avg      ||                       median rank avg   worst rank avg                                  |
|  CPU                    18%               26%, N1             ||  CPU capacity         12%               81%, R2/N1                                      |
|  RAM used               14.9 GiB (27%)    19.4 GiB (35%), N1  ||  RSS used             2.9 GiB (10%)     5.0 GiB (17%), R1/N0                            |
|  GPU util               9%                9%, N1              ||  CUDA allocated       2.7 GiB           4.3 GiB, R3/N1                                  |
|  GPU memory/device      4.7 GiB (31%)     6.5 GiB (44%), N1   ||  CUDA reserved        3.0 GiB (20%)     6.3 GiB (43%), R3/N1                            |
|  GPU temperature        58C               70C, N1             ||                                                                                         |
|  GPU power              220W              280W, N1            ||                                                                                         |
|                                                                                                                                                          |
|                                                                                                                                                          |
|  Full evidence: logs/ddp_pretrain/final_summary.json  (--html-report)                                                                                    |
+----------------------------------------------------------------------------------------------------------------------------------------------------------+

Distributed GPU comparisons assume homogeneous hardware across ranks. See Distributed Training for ports and shared storage, DDP rank stragglers, Slurm, and the integration support matrix for framework-specific details, including FSDP.

Continuous monitoring

TraceML records GPU phase timings with CUDA events and resolves them asynchronously. Telemetry is batched and processed by a separate aggregator.

Use a kernel profiler when the diagnosis points inside GPU compute.

Compare runs

After changing the DataLoader, batch size, model, or infrastructure, compare two completed runs:

traceml compare before/final_summary.json after/final_summary.json
+--------------------------------------------------------------------------------------+
|  TraceML Compare                                                                     |
+--------------------------------------------------------------------------------------+
|  A: before_dataloader_fix                                                            |
|  B: after_dataloader_fix                                                             |
|  Primary diagnosis: INPUT-BOUND -> COMPUTE-BOUND (changed)                           |
|                                                                                      |
|  Verdict: IMPROVEMENT                                                                |
|  Why: GPU Step Time decreased by 59.9%.                                              |
+--------------------------------------------------------------------------------------+

TraceML keeps the comparison evidence in JSON and text so the result is easy to review, archive, or use in automation. See Compare Runs.

Performance regression checks

Use the same comparison as a local or CI gate for compatible runs:

traceml compare \
  logs/reference/final_summary.json \
  logs/candidate/final_summary.json \
  --max-step-time-regression-pct 5 \
  --output compare/reference-vs-candidate

TraceML writes JSON and text reports before returning the CI exit code. See Regression Guard for comparability requirements and supported environments.

Investigation Result
LeRobot v3 image-loading regression Reproduce a known input-pipeline regression and see TraceML change from input-bound to compute-bound after the upstream fix.
ResNet-18 input pipeline See an input-bound run become compute-bound after changing only DataLoader settings.
RF-DETR Nano training Examine single-GPU phase timing and four-GPU DDP scaling on real COCO batches.
RF-DETR release regression Attribute a release-to-release slowdown to input waiting and verify the fixed release.

Browse all case studies →

Reports and experiment trackers

Summary mode is the default. For live diagnostics in the terminal, use:

traceml run train.py --mode=cli

For the browser dashboard, install the optional dashboard dependencies:

pip install "traceml-ai[dashboard]"
traceml run train.py --mode=dashboard

TraceML can also export a self-contained HTML report and send its compact summary to an existing W&B or MLflow run. See W&B and MLflow and the complete quickstart.

Learn more

Community

Questions, contributions, and real-world slowdown reports are welcome:

License

Apache 2.0. See LICENSE.

Metadata

Release files for traceml-ai 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for traceml-ai 0.5.1
File Size Uploaded Provenance Actions
traceml_ai-0.5.1.tar.gz 4.3 MB With provenance Details for traceml_ai-0.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for traceml-ai 0.5.1
File Interpreter ABI Platform Actions
traceml_ai-0.5.1-py3-none-any.whl Python 3 none any Details for traceml_ai-0.5.1-py3-none-any.whl

Total release size: 5.1 MB

Release files / traceml_ai-0.5.1.tar.gz

Download URL traceml_ai-0.5.1.tar.gz
Size 4.3 MB
Tags Source
SHA-256 checksum
How to use checksums
f09133b1760d7e916447efc5dc2b1a91f1ae95c28cd7aacc87dce67668ed43f2
BLAKE2b-256 checksum
How to use checksums
09d5491a79436802e0c356f2cab168baf7ebd0c6c4130328648f70038034f0ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / traceml_ai-0.5.1-py3-none-any.whl

Download URL traceml_ai-0.5.1-py3-none-any.whl
Size 747.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
098a4e8cdb8858872dc1ad7d884b5871210b954797a3c8d8b671532d43ba7bf5
BLAKE2b-256 checksum
How to use checksums
4c63231b38010cd403263bd3154a86fbcf897284f37b223cd2bf91fcfd14050e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Security for traceml-ai 0.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for traceml_ai-0.5.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page