GPU energy metering for AI training workloads
Project description
matcha
GPU energy metering for AI training workloads
Measure GPU energy consumption of any training run. One command. Zero overhead. Zero code changes.
Install
pip install matcha-gpu
Requires an NVIDIA GPU with drivers installed.
Quick Start
Prefix your training command with matcha run:
matcha run torchrun --standalone --nproc_per_node=1 train_gpt.py
Your training runs at full speed. Matcha appends one line at the end:
matcha_energy total:364722J (101.31Wh) duration:746.0s avg_power:489W peak_power:700W samples:7449
That's it. No code changes. No config files. Works with any training script.
How It Works
Matcha runs a lightweight background thread that polls GPU power via NVML at 100ms intervals. Your training process runs natively — no stdout interception, no wrapper overhead. When training finishes, Matcha computes total energy using trapezoidal integration of instantaneous power readings.
Commands
matcha run — Zero overhead energy measurement
# Measure total energy for any training command
matcha run python train.py
matcha run torchrun --standalone --nproc_per_node=1 train_gpt.py
matcha run deepspeed --num_gpus=4 train.py --deepspeed ds_config.json
matcha wrap — Per-step energy breakdown
# See energy for each training step (some overhead)
matcha wrap -p python train.py
Parses stdout for step markers (step 10, iter 10, [10/1000], etc.) and reports energy between each step. Useful for diagnosing energy spikes and inefficient training phases.
matcha monitor — Live GPU power monitoring
# Watch GPU power draw in real time
matcha monitor
matcha monitor --gpu 0 --window 2.0
Python SDK
import matcha
m = matcha.init()
for step in range(num_steps):
m.step_start()
# ... your training code, unchanged ...
energy = m.step_end(step)
summary = m.finish()
# summary.total_energy_j, summary.energy_kwh, summary.j_per_step
Example Output
step:1/20000 train_loss:6.9357 train_time:356ms step_avg:356.10ms
step:2/20000 train_loss:16.7414 train_time:725ms step_avg:362.47ms
...
step:1709/20000 val_loss:2.2111 val_bpb:1.3095 train_time:600097ms step_avg:351.14ms
final_int8_zlib_roundtrip_exact val_loss:2.21311047 val_bpb:1.31072868
matcha_energy total:364722J (101.31Wh) duration:746.0s avg_power:489W peak_power:700W samples:7449
Tested On
- NVIDIA H100 80GB HBM3 — training nanoGPT variants at 500-700W
- Works with
torchrun,deepspeed,accelerate, or plainpython - Compatible with PyTorch, JAX, and any framework that runs on NVIDIA GPUs
Why
GPU rental is expensive. Electricity is cheap. But knowing your energy profile tells you whether your GPU is actually working hard or sitting idle — and that directly maps to training efficiency and cost.
10-minute H100 training run:
Energy cost: $0.01 (101 Wh @ $0.12/kWh)
Compute cost: $0.48 (RunPod @ $2.90/hr)
→ Compute is 48x the energy cost
→ Optimizing energy/step = faster training = less rental time
Roadmap
- Multi-GPU support (aggregate across 8xH100)
- Log file tailing for zero-overhead per-step attribution
- JSONL output for downstream analysis
- Go sidecar binary for production deployments
- Carbon footprint estimation by region
Built by
License
Apache 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file matcha_gpu-0.3.0.tar.gz.
File metadata
- Download URL: matcha_gpu-0.3.0.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f096c41a9ca850d37a7be076952256be52e9cb9f2dde1fea1c8a304f5e981d8f
|
|
| MD5 |
86ecf8352668a580e098efee911b67e1
|
|
| BLAKE2b-256 |
7028d279105cbbbcf90f426cb3ab49ef05f0826b02dc843a719f3867eeebfa04
|
File details
Details for the file matcha_gpu-0.3.0-py3-none-any.whl.
File metadata
- Download URL: matcha_gpu-0.3.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
427f8fe18a9fb00db4f98e12b83a9e62be7abcd8367d2cf37d445d14adf01c71
|
|
| MD5 |
652ee3cd568780e6d1b55446faacf491
|
|
| BLAKE2b-256 |
6c5e061f831b3f39b87d25fefc6304ebe8def3b4272592393d76ae59217ce3fa
|