pdmlabs.energy.machine#
Machine fingerprint and idle-power baseline.
Two jobs, both about making energy records comparable:
Fingerprint. Captures everything that changes how much energy a given
computation costs – CPU model and topology, frequency governor and turbo
state, BLAS thread limits, which GPUs are visible, and crucially the
measurement provenance (is RAPL readable, is there a DRAM rail). Records
carrying different fingerprints must never be pooled: a run on a box without a
dram domain reports systematically lower total energy than one with, for
reasons that have nothing to do with the code being measured.
Idle baseline. Energy backends report what the machine drew, which includes everything drawing power while doing nothing useful. On a two-GPU workstation idle is around 84 W (about 22 W CPU package plus about 62 W of idle GPU), so a ten-hour CPU-only study accrues roughly 3 MJ attributable to nothing at all. Reporting only total energy would let idle draw dominate the comparison between optimizers that differ mainly in how long they run.
Both total_j and idle-subtracted dynamic_j are always kept. Neither
replaces the other: total is what the wall socket saw, dynamic is what the work
cost.
Functions
Describe this machine and its measurement capability. |
|
|
Stable short hash over only the fields that affect comparability. |
|
Measure idle power with the same backend that will measure the study. |
|
Measure idle twice and report the drift between them. |
|
Write |
|
Flag configuration that will confound a cross-optimizer comparison. |
- pdmlabs.energy.machine.fingerprint()#
Describe this machine and its measurement capability.
- pdmlabs.energy.machine.fingerprint_id(fp)#
Stable short hash over only the fields that affect comparability.
Deliberately excludes volatile context (SLURM job id, package versions of things unrelated to measurement) so that two runs on the same node in the same state share an id.
- pdmlabs.energy.machine.measure_idle(backend='codecarbon', duration_s=60.0, settle_s=10.0, backend_kwargs=None)#
Measure idle power with the same backend that will measure the study.
settle_s is discarded before measuring: GPU clocks and package temperature take tens of seconds to reach steady state, and including that ramp biases the baseline. Using the study’s own backend matters too – an idle figure from one backend subtracted from another’s totals would mix two different measurement models.
- pdmlabs.energy.machine.measure_idle_bracketed(backend='codecarbon', duration_s=60.0, settle_s=10.0, backend_kwargs=None, drift_tolerance=0.1)#
Measure idle twice and report the drift between them.
A baseline is only meaningful if the machine’s idle state was stable across the run. Drift beyond drift_tolerance means ambient temperature or a background process moved, and every
dynamic_jderived from it is suspect – so the drift is returned rather than averaged away.
- pdmlabs.energy.machine.save_machine_context(out_dir, backend='codecarbon', idle=True, idle_duration_s=60.0, backend_kwargs=None)#
Write
machine.json(andidle_baseline.json) for a study.
- pdmlabs.energy.machine.warn_if_unpinned(fp)#
Flag configuration that will confound a cross-optimizer comparison.