pdmlabs.energy.export#
Turn the JSONL spool into a tidy, portable, self-describing table.
The spool is an append-only write format optimised for never losing a record under concurrency. This module turns it into the long-format table the analysis works from: one row per (study, run, phase-or-trial), with the machine fingerprint and idle baseline folded in so the file stands alone – no MLflow, no spool, no environment needed to read it later.
Two things happen here that cannot happen at write time:
Idle subtraction.
dynamic_j = total_j - idle_w * duration_s. It needs the idle baseline, which is measured once per study rather than per record. Negative results are clamped to zero and flagged, because the clamp rate is itself a data-quality signal – silently clamping would hide a bad baseline.The fingerprint gate. Records from machines that differ in ways that affect energy (DRAM rail present or not, RAPL readable or not, different GPUs) are not comparable. Pooling them is refused rather than warned about, because the resulting number looks perfectly reasonable and is wrong.
Functions
|
Enrich raw spool records into export rows. |
|
Refuse to pool records from machines that are not comparable. |
|
Read a study's spool and write |
|
Cross-check the invariants the analysis depends on. |
- pdmlabs.energy.export.build_rows(records, idle=None, fingerprint=None)#
Enrich raw spool records into export rows.
- pdmlabs.energy.export.check_fingerprints(rows, allow_mixed=False)#
Refuse to pool records from machines that are not comparable.
- pdmlabs.energy.export.export_study(spool_dir, out_dir=None, study_id=None, allow_mixed=False, cleanup=False)#
Read a study’s spool and write
records.parquetplusrecords.csv.Returns
(rows, summary). The spool is left in place unless cleanup is explicitly requested – it is the study’s raw data, and deleting it on the strength of an export that might itself be wrong is not a trade worth making.
- pdmlabs.energy.export.reconcile(rows)#
Cross-check the invariants the analysis depends on.
Returns a list of findings, one per SEARCH phase. A list of flat records rather than a dict keyed by tuple: it is JSON-serialisable, and it drops straight into a DataFrame alongside the exported rows.
These are reported, not enforced: a violation means the measurement is untrustworthy, which the analyst must see rather than have silently corrected.