Skip to content

fix: apply PUE to reported power too - #1332

Open
davidberenstein1957 wants to merge 1 commit into
masterfrom
fix/pue-power-energy-consistency
Open

fix: apply PUE to reported power too#1332
davidberenstein1957 wants to merge 1 commit into
masterfrom
fix/pue-power-energy-consistency

Conversation

@davidberenstein1957

@davidberenstein1957 davidberenstein1957 commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

What changed

_do_measurements now scales the measured power by self._pue at the same point where it already scales energy (codecarbon/emissions_tracker.py:1177). Power.__mul__ already exists, so every hardware branch below picks up the scaled value automatically.

Why

PUE was applied to energy (and, through it, to water) but not to the power values reported in the same record. With pue != 1 the CSV row was internally inconsistent: energy_consumed did not match (cpu_power + gpu_power + ram_power) x duration, and nothing in the row explained the gap. PUE is a facility property, so it applies equally to instantaneous power and integrated energy.

Verification

Added tests/test_emissions_tracker_constant.py::TestCarbonTrackerConstant::test_carbon_tracker_offline_constant_pue, which runs the offline tracker with a forced CPU power and pue=2.0, asserts the reported cpu_power includes the PUE, and asserts energy_consumed is reconstructible from the reported power columns and duration. The test fails on master and passes with this change. Full file: uv run pytest tests/test_emissions_tracker_constant.py -q -> 7 passed.

Note on visible numbers

This changes reported power values for users running with pue != 1cpu_power, gpu_power and ram_power (and the per-hardware logger.info lines) are now facility-level. energy_consumed and emissions are unchanged. The default pue=1.0 means the overwhelming majority of runs see no difference, but the change is not silent and warrants a changelog entry. Anyone manually multiplying power by PUE downstream would now double-apply it.

Follow-up, out of scope here: EmissionCreate (codecarbon/core/api_client.py) carries wue but no pue, so the server cannot tell whether an incoming cpu_power is device- or facility-level.

Closes #1320

🤖 Generated with Claude Code

Changelog / release note

CHANGELOG.md is not on master yet (it arrives with docs/traction-batch), so the note lives in the docs instead: docs/reference/output.md now carries a "PUE and the power columns" admonition. When the changelog lands, copy this entry:

Changed — the pue multiplier is now applied to the reported power columns (cpu_power, gpu_power, ram_power) as well as to the energy columns, so energy_consumed stays reconstructible from the reported power. Runs with pue != 1 will see larger power values; energy and emissions are unchanged.

Consequence worth spelling out: pue also scales forced values, so force_cpu_power=100 with pue=1.5 now reports a 150 W CPU. That is consistent with treating the columns as facility-level, but it is surprising for a parameter named "force" — documented in docs/reference/output.md and in both pue docstrings.

Because this changes user-visible numbers, it should ride a minor release (3.4.0), not a patch.

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.43%. Comparing base (3ec31a0) to head (3e233b1).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1332   +/-   ##
=======================================
  Coverage   91.43%   91.43%           
=======================================
  Files          49       49           
  Lines        5057     5058    +1     
=======================================
+ Hits         4624     4625    +1     
  Misses        433      433           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@davidberenstein1957
davidberenstein1957 marked this pull request as ready for review August 12, 2026 19:14
@davidberenstein1957
davidberenstein1957 requested a review from a team as a code owner August 12, 2026 19:14
@davidberenstein1957
davidberenstein1957 force-pushed the fix/pue-power-energy-consistency branch 2 times, most recently from f9781ca to 54beac7 Compare August 19, 2026 14:29
Energy and water were scaled by the datacenter PUE while the reported power
values stayed at device level, so `energy_consumed` could not be derived from
the power columns whenever `pue != 1`.

Scale the reported power by the PUE as well, so the power and energy columns
stay consistent with each other, and document that the power columns include
the PUE.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@davidberenstein1957
davidberenstein1957 force-pushed the fix/pue-power-energy-consistency branch from 54beac7 to 3e233b1 Compare August 20, 2026 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PUE is applied to energy but not to reported power

1 participant