fix: integrate GPU power when energy counter is absent - #1319
Open
davidberenstein1957 wants to merge 1 commit into
Open
fix: integrate GPU power when energy counter is absent#1319davidberenstein1957 wants to merge 1 commit into
davidberenstein1957 wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1319 +/- ##
==========================================
+ Coverage 91.43% 91.48% +0.04%
==========================================
Files 49 49
Lines 5057 5071 +14
==========================================
+ Hits 4624 4639 +15
+ Misses 433 432 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
GPUs without nvmlDeviceGetTotalEnergyConsumption now integrate instantaneous power instead of reporting zero, re-baselining cleanly when the counter returns. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
davidberenstein1957
force-pushed
the
fix/gpu-without-energy-counter
branch
from
August 19, 2026 15:20
4e36cc8 to
1889fda
Compare
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
GPUDevice.deltanow branches on the backend returningNonefor the cumulative energy counter. When it does, it computesPower.from_watts(self._get_power_usage())andEnergy.from_power_and_time(...)instead of comparing two identical counter readings, and logs a single warning per device so users know which method produced their numbers.The per-sample
logger.warninginNvidiaGPUDevice._get_total_energy_consumptionis demoted todebug, since the once-per-device warning now carries the signal.Why
On GPUs where NVML does not implement
nvmlDeviceGetTotalEnergyConsumption(pre-Volta cards, many virtualised GPUs) the previous code returnedlast_energyunchanged, yieldingenergy_delta = 0andpower = 0for the entire run — a GPU-bound job silently reported only CPU + RAM. The fallback lives in the sharedGPUDevice, so the AMD backend (which returnsNonewhen no energy accumulator is present) is fixed by the same change.Power integration is less accurate than the counter, but it is the same approximation the CPU path already uses and is dramatically better than zero.
How verified
tests/test_gpu_nvidia.py::TestGpu::test_gpu_without_energy_counter_falls_back_to_powerpatches the NVML energy query to raise and asserts 26 W / 29 W and 0.026 / 0.029 kWh over an hour. It fails on master (assert 0.0 == 26) and passes here.tests/test_gpu.py,tests/test_gpu_nvidia.pyandtests/test_gpu_amd.pyall pass (51 tests).Closes #1316
🤖 Generated with Claude Code