[PR #3628] [CLOSED] [GUI] Add opt-in GPU energy and electricity cost monitoring to the Power card #4723

Closed
opened 2026-11-07 15:38:35 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3628
Author: @hash13
Created: 10/21/2026
Status: ❌ Closed

Base: main ← Head: feature/monitor-gpu-electricity-cost


📝 Commits (6)

  • 4b8ba58 feat(monitor): add opt-in cumulative GPU energy tracking
  • 51134b6 feat(monitor): show GPU electricity costs in Power card
  • 3dbfe9a Merge branch 'main' into feature/monitor-gpu-electricity-cost
  • ac3f2a2 Merge branch 'main' into feature/monitor-gpu-electricity-cost
  • 9729bf6 Merge branch 'Niko1221:main' into feature/monitor-gpu-electricity-cost
  • fdb7e6d Merge branch 'Niko1221:main' into feature/monitor-gpu-electricity-cost

📊 Changes

3 files changed (+104 additions, -3 deletions)

View changed files

📝 serve/server.py (+3 -1)
📝 serve/telemetry.py (+54 -1)
📝 serve/web/app.js (+47 -1)

📄 Description

[GUI] Add opt-in GPU energy and electricity cost monitoring to the Power card

Summary

This PR adds optional GPU energy monitoring and electricity cost calculations to Strata's existing Monitor Power card.

The feature reuses Strata's existing GPU telemetry, multi-GPU support, and Monitor refresh infrastructure. No additional services, dependencies, or persistent storage are required.

Energy monitoring is strictly opt-in. Without an electricity configuration block, the existing Power card behavior remains unchanged.

The implementation focuses on cumulative GPU energy consumption and total electricity costs. Request-level energy attribution and token cost calculations are intentionally out of scope.

Screenshot

GPU energy and electricity cost monitoring

Configuration

Add an electricity block to the top level of the active Strata JSON configuration.

Energy monitoring only:

"electricity": {}

Energy monitoring with electricity costs:

"electricity": {
  "price_per_kwh": 0.32,
  "currency": "EUR"
}
  • price_per_kwh: Optional non-negative electricity price per kWh.
  • currency: Optional ISO currency code, defaulting to EUR.
  • Without a valid price, cumulative energy consumption is displayed without costs.
  • Without an electricity block, the feature is disabled.

Configuration changes take effect after restarting the server.

Power Card

The existing Power card retains its current GPU power reading, power limit, and power history sparkline.

When electricity costs are enabled, the card uses a compact two-column layout:

Power Electricity cost
278 W 0.155 €
of 520 W limit 483.0 Wh

The layout reuses the existing Speed card styling without additional CSS or increased card height.

When only energy monitoring is enabled, cumulative energy consumption appears alongside the existing power limit.

All values update through the existing Monitor refresh cycle.

Value Formatting

Energy consumption:

Consumption Display
Below 1 kWh Wh, one decimal place
From 1 kWh kWh, three decimal places

Electricity costs:

Cost Display
Positive values below 0.001 < 0.001 €
Below 10 Three decimal places
From 10 Two decimal places

Currency symbols use the existing smaller unit styling. Number formatting follows the browser's locale.

Energy Measurement

The implementation prefers NVIDIA's cumulative NVML hardware energy counter (nvmlDeviceGetTotalEnergyConsumption) when supported.

This provides accumulated energy directly in millijoules and avoids estimating consumption solely from periodically sampled power values.

If cumulative counter readings are unavailable during initialization, energy is estimated by integrating the existing GPU power samples over time using the trapezoidal rule.

For multi-GPU configurations:

  • Supported hardware counters are aggregated across monitored GPUs.
  • If cumulative counters are unavailable for one or more GPUs, the fallback uses aggregated GPU power measurements.

Energy accumulation begins when the telemetry sampler starts and resets when the sampler is recreated.

Electricity costs are calculated as:

Cost = accumulated GPU energy (kWh) × configured price per kWh

The cost calculation uses the accumulated energy value without requiring additional NVML reads beyond energy monitoring itself.

Measurements cover GPU energy only. CPU, RAM, motherboard, storage, fans, and PSU conversion losses are excluded.

Estimated energy depends on the availability and accuracy of GPU power readings.

Operating Modes

Configuration Power Card Display
No electricity block Current GPU power (W) and power limit only
"electricity": {} GPU power, power limit, and cumulative energy consumption (Wh/kWh)
electricity with price_per_kwh Two-column layout: GPU power and power limit on the left; total electricity cost and cumulative energy consumption on the right

Scope and Compatibility

  • Feature disabled by default
  • No changes to inference behavior
  • No request-level accounting or token cost estimation
  • No additional dependencies or persistent storage
  • Existing /metrics endpoint extended with hardware.gpu_energy_kwh when enabled
  • Optional electricity price and currency exposed through hardware_static
  • Existing Power card retained when disabled

Request-level energy attribution is deferred to a later PR, initially limited to serial requests to avoid double counting energy during overlapping requests.

Changed Files

The complete implementation affects three files:

File Changes
serve/telemetry.py NVML cumulative energy readings, sampled-power fallback, multi-GPU aggregation, and electricity price metadata
serve/server.py Pass optional electricity configuration to telemetry
serve/web/app.js Display cumulative energy consumption and optional electricity costs in the existing Power card

Failed: None observed.

Not run: Automated tests, AMD GPUs.

Validation

Revision: Strata v0.2.2 with PR changes
Environment: Intel i9-14900K, 2× RTX 5060 Ti, CUDA 13.0, Podman

Commands / steps:

  • Started Strata with the modified configuration.
  • Opened Monitor → Power in the browser.

Passed:

  • Manual testing on Strata v0.2.2
  • GPU energy and electricity cost display

Failed: None observed.

Not run: Automated tests, AMD GPUs.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/3628 **Author:** [@hash13](https://github.com/hash13) **Created:** 10/21/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/monitor-gpu-electricity-cost` --- ### 📝 Commits (6) - [`4b8ba58`](https://github.com/Niko1221/Strata/commit/4b8ba58aba3ecbb1db9b7ef2cfef27e339b4b2e7) feat(monitor): add opt-in cumulative GPU energy tracking - [`51134b6`](https://github.com/Niko1221/Strata/commit/51134b6cad6789d36df98ce2fd2aa10d44f3c02c) feat(monitor): show GPU electricity costs in Power card - [`3dbfe9a`](https://github.com/Niko1221/Strata/commit/3dbfe9ae65e6d87cd17e619e601a22eecb2baca9) Merge branch 'main' into feature/monitor-gpu-electricity-cost - [`ac3f2a2`](https://github.com/Niko1221/Strata/commit/ac3f2a2e8f2acd6ad84baa8476cc709d573a195f) Merge branch 'main' into feature/monitor-gpu-electricity-cost - [`9729bf6`](https://github.com/Niko1221/Strata/commit/9729bf64bcce2e59a7246a412de49938baa3f50b) Merge branch 'Niko1221:main' into feature/monitor-gpu-electricity-cost - [`fdb7e6d`](https://github.com/Niko1221/Strata/commit/fdb7e6d152e9a0db4eeaa0ed6a7dd47f330cb0c9) Merge branch 'Niko1221:main' into feature/monitor-gpu-electricity-cost ### 📊 Changes **3 files changed** (+104 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+3 -1) 📝 `serve/telemetry.py` (+54 -1) 📝 `serve/web/app.js` (+47 -1) </details> ### 📄 Description # [GUI] Add opt-in GPU energy and electricity cost monitoring to the Power card ## Summary This PR adds optional GPU energy monitoring and electricity cost calculations to Strata's existing Monitor Power card. The feature reuses Strata's existing GPU telemetry, multi-GPU support, and Monitor refresh infrastructure. No additional services, dependencies, or persistent storage are required. Energy monitoring is strictly opt-in. Without an `electricity` configuration block, the existing Power card behavior remains unchanged. The implementation focuses on cumulative GPU energy consumption and total electricity costs. Request-level energy attribution and token cost calculations are intentionally out of scope. ## Screenshot <img width="353" height="212" alt="GPU energy and electricity cost monitoring" src="https://github.com/user-attachments/assets/efc6d451-e2b2-47f9-ad10-faaec18ab68f" /> ## Configuration Add an `electricity` block to the top level of the active Strata JSON configuration. **Energy monitoring only:** ```json "electricity": {} ``` **Energy monitoring with electricity costs:** ```json "electricity": { "price_per_kwh": 0.32, "currency": "EUR" } ``` - `price_per_kwh`: Optional non-negative electricity price per kWh. - `currency`: Optional ISO currency code, defaulting to `EUR`. - Without a valid price, cumulative energy consumption is displayed without costs. - Without an `electricity` block, the feature is disabled. Configuration changes take effect after restarting the server. ## Power Card The existing Power card retains its current GPU power reading, power limit, and power history sparkline. When electricity costs are enabled, the card uses a compact two-column layout: | Power | Electricity cost | |---|---| | **278 W** | **0.155 €** | | of 520 W limit | 483.0 Wh | The layout reuses the existing Speed card styling without additional CSS or increased card height. When only energy monitoring is enabled, cumulative energy consumption appears alongside the existing power limit. All values update through the existing Monitor refresh cycle. ### Value Formatting **Energy consumption:** | Consumption | Display | |---|---| | Below 1 kWh | Wh, one decimal place | | From 1 kWh | kWh, three decimal places | **Electricity costs:** | Cost | Display | |---|---| | Positive values below 0.001 | `< 0.001 €` | | Below 10 | Three decimal places | | From 10 | Two decimal places | Currency symbols use the existing smaller unit styling. Number formatting follows the browser's locale. ## Energy Measurement The implementation prefers NVIDIA's cumulative NVML hardware energy counter (`nvmlDeviceGetTotalEnergyConsumption`) when supported. This provides accumulated energy directly in millijoules and avoids estimating consumption solely from periodically sampled power values. If cumulative counter readings are unavailable during initialization, energy is estimated by integrating the existing GPU power samples over time using the trapezoidal rule. For multi-GPU configurations: - Supported hardware counters are aggregated across monitored GPUs. - If cumulative counters are unavailable for one or more GPUs, the fallback uses aggregated GPU power measurements. Energy accumulation begins when the telemetry sampler starts and resets when the sampler is recreated. Electricity costs are calculated as: **Cost = accumulated GPU energy (kWh) × configured price per kWh** The cost calculation uses the accumulated energy value without requiring additional NVML reads beyond energy monitoring itself. Measurements cover GPU energy only. CPU, RAM, motherboard, storage, fans, and PSU conversion losses are excluded. Estimated energy depends on the availability and accuracy of GPU power readings. ## Operating Modes | Configuration | Power Card Display | |---|---| | No `electricity` block | Current GPU power (W) and power limit only | | `"electricity": {}` | GPU power, power limit, and cumulative energy consumption (Wh/kWh) | | `electricity` with `price_per_kwh` | Two-column layout: GPU power and power limit on the left; total electricity cost and cumulative energy consumption on the right | ## Scope and Compatibility - Feature disabled by default - No changes to inference behavior - No request-level accounting or token cost estimation - No additional dependencies or persistent storage - Existing `/metrics` endpoint extended with `hardware.gpu_energy_kwh` when enabled - Optional electricity price and currency exposed through `hardware_static` - Existing Power card retained when disabled Request-level energy attribution is deferred to a later PR, initially limited to serial requests to avoid double counting energy during overlapping requests. ## Changed Files The complete implementation affects three files: | File | Changes | |---|---| | `serve/telemetry.py` | NVML cumulative energy readings, sampled-power fallback, multi-GPU aggregation, and electricity price metadata | | `serve/server.py` | Pass optional electricity configuration to telemetry | | `serve/web/app.js` | Display cumulative energy consumption and optional electricity costs in the existing Power card | **Failed:** None observed. **Not run:** Automated tests, AMD GPUs. ## Validation **Revision:** Strata v0.2.2 with PR changes **Environment:** Intel i9-14900K, 2× RTX 5060 Ti, CUDA 13.0, Podman **Commands / steps:** - Started Strata with the modified configuration. - Opened Monitor → Power in the browser. **Passed:** - Manual testing on Strata v0.2.2 - GPU energy and electricity cost display **Failed:** None observed. **Not run:** Automated tests, AMD GPUs. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:38:35 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4723
No description provided.