fix: apply PUE to reported power too - #1332
Open
davidberenstein1957 wants to merge 2 commits into
Open
Conversation
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 when pue != 1. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1332 +/- ##
==========================================
+ Coverage 91.39% 91.43% +0.04%
==========================================
Files 49 49
Lines 5056 5057 +1
==========================================
+ Hits 4621 4624 +3
+ Misses 435 433 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
davidberenstein1957
marked this pull request as ready for review
August 12, 2026 19:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
_do_measurementsnow scales the measuredpowerbyself._pueat the same point where it already scalesenergy(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 != 1the CSV row was internally inconsistent:energy_consumeddid 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 andpue=2.0, asserts the reportedcpu_powerincludes the PUE, and assertsenergy_consumedis 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 != 1—cpu_power,gpu_powerandram_power(and the per-hardwarelogger.infolines) are now facility-level.energy_consumedand emissions are unchanged. The defaultpue=1.0means 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) carrieswuebut nopue, so the server cannot tell whether an incomingcpu_poweris device- or facility-level.Closes #1320
🤖 Generated with Claude Code
Changelog / release note
CHANGELOG.mdis not onmasteryet (it arrives withdocs/traction-batch), so the note lives in the docs instead:docs/reference/output.mdnow carries a "PUE and the power columns" admonition. When the changelog lands, copy this entry:Consequence worth spelling out:
puealso scales forced values, soforce_cpu_power=100withpue=1.5now 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 indocs/reference/output.mdand in bothpuedocstrings.Because this changes user-visible numbers, it should ride a minor release (3.4.0), not a patch.