Scientifically rigorous delta-based energy profiling for Linux workloads
Project description
pywattson
Scientifically rigorous, low-overhead, delta-based energy profiling for Linux workloads — video codecs, ML inference, or anything else.
pip install pywattson
Quick Start
Context Manager (primary)
from wattson import EnergyMonitor, BaselineStrategy
with EnergyMonitor(
gpu_device_indices=0,
metadata={"codec": "DCVC-RT", "qp": 42, "gop": 32},
include_dram=True,
baseline=BaselineStrategy.SEPARATE_SESSION,
) as monitor:
run_codec_encode(...)
result = monitor.result
print(result.total_energy_j)
print(result.to_csv_row())
Decorator
from wattson import EnergyMonitor
@EnergyMonitor.profile(metadata={"codec": "x265"})
def encode():
...
N-Repetition Research Driver
from wattson import run_energy, BaselineStrategy
stats = run_energy(
workload=encode, # or command="python encode.py"
n_repeats=15,
n_warmup=2,
gpu_device_indices=0,
baseline=BaselineStrategy.SEPARATE_SESSION,
metadata={"codec": "VVC"},
)
print(stats["stats"]["total_energy_j"]["median"])
print(stats["stats"]["total_energy_j"]["iqr"])
Scientific Methodology
Why Delta Counters, Not Power Sampling
Wattson reads hardware energy counters before and after a workload and
computes the difference. This pure-delta approach avoids the sampling error
and timing jitter inherent in power × time integration.
RAPL Domains
- Package — total socket energy (cores + uncore).
- DRAM — memory energy on its own power plane (not double-counted with package).
- Counters are 32-bit; overflow is corrected automatically:
corrected_delta = (max_uj − start_uj) + end_uj.
NVML Calibration
Some GPU drivers underreport or overreport the firmware energy counter.
Wattson's calibrate() method compares the counter against integrated
nvmlDeviceGetPowerUsage() and warns if they diverge by more than 20%.
Thermal Bias & BaselineStrategy
Measuring idle after a workload gives a thermally elevated baseline.
Wattson defaults to SEPARATE_SESSION — idle is measured once in a cool state
before any workload runs. Duration normalisation corrects for
time.sleep() scheduler overshoot.
Multi-Tenant Caveat
RAPL counters are socket-wide. If other processes share the CPU socket, their energy is included. For accurate measurements, use a dedicated machine or account for background load.
Versioning
This project uses Conventional Commits and Release Please for automated semantic versioning and changelogs.
fix:→ patch bumpfeat:→ minor bumpfeat!:orBREAKING CHANGE:→ major bump
License
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 pywattson-0.4.5.tar.gz.
File metadata
- Download URL: pywattson-0.4.5.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
962c34ffe7daf16411f3dc09ad6262146d8ebcbca236b790ed206d5a9cb7097a
|
|
| MD5 |
3711c1704d993ef84bde7dcf6ec35ea3
|
|
| BLAKE2b-256 |
c3e3eea5338ee350108ad9f503b013b854c21d4e5b5275ce2758a045a48db1dc
|
Provenance
The following attestation bundles were made for pywattson-0.4.5.tar.gz:
Publisher:
release.yml on oelghatidoc/wattson
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pywattson-0.4.5.tar.gz -
Subject digest:
962c34ffe7daf16411f3dc09ad6262146d8ebcbca236b790ed206d5a9cb7097a - Sigstore transparency entry: 1194153035
- Sigstore integration time:
-
Permalink:
oelghatidoc/wattson@626eaf8916a9269878d399f899c1770075f2a3e0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/oelghatidoc
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@626eaf8916a9269878d399f899c1770075f2a3e0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pywattson-0.4.5-py3-none-any.whl.
File metadata
- Download URL: pywattson-0.4.5-py3-none-any.whl
- Upload date:
- Size: 24.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5078fb72aff0a1607ce1acded694919781ee3aa9aaec85f59923167161d56545
|
|
| MD5 |
c6229949f3c7229f77cf20d1013b3af6
|
|
| BLAKE2b-256 |
a7900e4aa2fecfc2fd5b5f1d99feef0a21f74b97f10c3a37b02b88db36a7493e
|
Provenance
The following attestation bundles were made for pywattson-0.4.5-py3-none-any.whl:
Publisher:
release.yml on oelghatidoc/wattson
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pywattson-0.4.5-py3-none-any.whl -
Subject digest:
5078fb72aff0a1607ce1acded694919781ee3aa9aaec85f59923167161d56545 - Sigstore transparency entry: 1194153036
- Sigstore integration time:
-
Permalink:
oelghatidoc/wattson@626eaf8916a9269878d399f899c1770075f2a3e0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/oelghatidoc
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@626eaf8916a9269878d399f899c1770075f2a3e0 -
Trigger Event:
push
-
Statement type: