[PR #1876] [CLOSED] Add opt-in cumulative GPU energy monitoring to the Power card #3729

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

📋 Pull Request Information

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

Base: main ← Head: feature/monitor-gpu-energy-optin


📝 Commits (1)

  • 4b8ba58 feat(monitor): add opt-in cumulative GPU energy tracking

📊 Changes

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

View changed files

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

📄 Description

Extended version with electricity pricing: https://github.com/Niko1221/Strata/pull/1925

Summary

This PR adds opt-in cumulative GPU energy monitoring to the existing Power card, based on Strata v0.1.42.

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

This is intentionally a small first step, without request-level energy attribution or token cost calculations.

Screenshot

grafik

Configuration

Enable energy monitoring by adding an electricity block at the top level of the existing Strata JSON configuration:

"electricity": {}

An empty object is sufficient to enable the feature.

Without this block, the existing Power card remains unchanged.

Electricity prices and currency settings are not used in this initial version.

Power Card

The existing Power card continues to display:

  • Current GPU power consumption (W)
  • NVIDIA power limit (W)
  • Power history sparkline

When enabled, it additionally displays cumulative GPU energy consumption since telemetry started.

Example:

Power
70 W
of 440 W limit · 26.0 Wh

Energy values are formatted using the browser's locale:

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

The accumulated value updates automatically through the existing Monitor refresh cycle.

Energy Measurement

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

Unlike integrating periodically sampled power readings, the hardware counter directly reports accumulated energy. This provides more reliable measurements, particularly when GPU power changes between samples.

If the hardware counter is unavailable, energy consumption is estimated by integrating the existing GPU power readings over time.

For multi-GPU configurations, the energy consumption of monitored GPUs is aggregated.

The accumulated energy is kept in memory and resets when Strata restarts.

Scope

The cumulative energy value is exposed through the existing /metrics hardware data.

Measurement covers GPU energy only. CPU, RAM, motherboard, storage, fans, and PSU losses are not included.

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

File Changes
serve/telemetry.py Cumulative GPU energy measurement using NVML with sampled-power fallback
serve/server.py Optional electricity configuration passed to telemetry
serve/web/app.js Wh/kWh display in the existing Power card

🔄 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/1876 **Author:** [@hash13](https://github.com/hash13) **Created:** 10/10/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/monitor-gpu-energy-optin` --- ### 📝 Commits (1) - [`4b8ba58`](https://github.com/Niko1221/Strata/commit/4b8ba58aba3ecbb1db9b7ef2cfef27e339b4b2e7) feat(monitor): add opt-in cumulative GPU energy tracking ### 📊 Changes **3 files changed** (+52 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+3 -1) 📝 `serve/telemetry.py` (+44 -1) 📝 `serve/web/app.js` (+5 -1) </details> ### 📄 Description Extended version with electricity pricing: https://github.com/Niko1221/Strata/pull/1925 ## Summary This PR adds opt-in cumulative GPU energy monitoring to the existing Power card, based on Strata v0.1.42. The implementation reuses Strata's existing GPU telemetry, multi-GPU support, and Monitor refresh infrastructure. No additional services, dependencies, or persistent storage are required. This is intentionally a small first step, without request-level energy attribution or token cost calculations. ## Screenshot <img width="357" height="209" alt="grafik" src="https://github.com/user-attachments/assets/037ae159-4358-4d6d-a12c-7ed3377a9ffd" /> ## Configuration Enable energy monitoring by adding an `electricity` block at the top level of the existing Strata JSON configuration: ```json "electricity": {} ``` An empty object is sufficient to enable the feature. Without this block, the existing Power card remains unchanged. Electricity prices and currency settings are not used in this initial version. ## Power Card The existing Power card continues to display: - Current GPU power consumption (W) - NVIDIA power limit (W) - Power history sparkline When enabled, it additionally displays cumulative GPU energy consumption since telemetry started. Example: ```text Power 70 W of 440 W limit · 26.0 Wh ``` Energy values are formatted using the browser's locale: | Energy consumption | Display | |---|---| | Below 1 kWh | Wh, one decimal place | | From 1 kWh | kWh, three decimal places | The accumulated value updates automatically through the existing Monitor refresh cycle. ## Energy Measurement The implementation prefers NVIDIA's cumulative NVML hardware energy counter (`nvmlDeviceGetTotalEnergyConsumption`). Unlike integrating periodically sampled power readings, the hardware counter directly reports accumulated energy. This provides more reliable measurements, particularly when GPU power changes between samples. If the hardware counter is unavailable, energy consumption is estimated by integrating the existing GPU power readings over time. For multi-GPU configurations, the energy consumption of monitored GPUs is aggregated. The accumulated energy is kept in memory and resets when Strata restarts. ## Scope The cumulative energy value is exposed through the existing `/metrics` hardware data. Measurement covers GPU energy only. CPU, RAM, motherboard, storage, fans, and PSU losses are not included. 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 | File | Changes | |---|---| | `serve/telemetry.py` | Cumulative GPU energy measurement using NVML with sampled-power fallback | | `serve/server.py` | Optional `electricity` configuration passed to telemetry | | `serve/web/app.js` | Wh/kWh display in the existing Power card | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:30:20 +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#3729
No description provided.