energy_monitor
energy_monitor
¶
EnergyMonitor ABC — multi-vendor energy measurement with hardware counters.
Classes¶
EnergyVendor
¶
Bases: str, Enum
Supported energy measurement vendors.
EnergySample
dataclass
¶
EnergySample(energy_joules: float = 0.0, mean_power_watts: float = 0.0, peak_power_watts: float = 0.0, duration_seconds: float = 0.0, num_snapshots: int = 0, mean_utilization_pct: float = 0.0, peak_utilization_pct: float = 0.0, mean_memory_used_gb: float = 0.0, peak_memory_used_gb: float = 0.0, mean_temperature_c: float = 0.0, peak_temperature_c: float = 0.0, vendor: str = '', device_name: str = '', device_count: int = 0, energy_method: str = '', cpu_energy_joules: float = 0.0, gpu_energy_joules: float = 0.0, dram_energy_joules: float = 0.0, ane_energy_joules: float = 0.0, cpu_power_watts: float = 0.0, gpu_power_watts: float = 0.0, ane_power_watts: float = 0.0, soc_energy_joules: float = 0.0, soc_power_watts: float = 0.0, basis: str = '')
Aggregated energy metrics over an inference bracket.
Superset of GpuSample — adds vendor, device info, energy method,
and per-component breakdown (CPU, GPU, DRAM, ANE).
EnergyMonitor
¶
Bases: ABC
Abstract base class for energy measurement backends.
Each vendor implementation probes for hardware support at init,
exposes an available() class method, and provides a sample()
context manager that measures energy over a code block.
Functions¶
available
abstractmethod
staticmethod
¶
vendor
abstractmethod
¶
vendor() -> EnergyVendor
energy_method
abstractmethod
¶
Return the measurement method.
One of hw_counter, polling, rapl, ioreport, or
tdp_estimate. Everything but the last is a real measurement;
tdp_estimate is modelled and only reachable when the caller
explicitly opts in.
Source code in src/openjarvis/telemetry/energy_monitor.py
sample
abstractmethod
¶
sample() -> Generator[EnergySample, None, None]
Context manager that measures energy during the enclosed block.
Yields an EnergySample that is populated when the block exits.
Source code in src/openjarvis/telemetry/energy_monitor.py
snapshot
¶
snapshot() -> EnergySample
Return an instantaneous energy reading without start/stop bracket.
Subclasses should override to provide actual readings. Default returns an empty sample.
Source code in src/openjarvis/telemetry/energy_monitor.py
Functions¶
create_energy_monitor
¶
create_energy_monitor(poll_interval_ms: int = 50, prefer_vendor: Optional[str] = None, allow_estimates: bool = False) -> Optional[EnergyMonitor]
Factory — auto-detect and return the best available EnergyMonitor.
Detection order: NVIDIA > AMD > Apple > CPU RAPL. If prefer_vendor is set, try that vendor first.
Every monitor returned by the normal path reports measured energy. When
allow_estimates is set and nothing measurable is present, a modelled
estimator may be returned instead — currently only on Apple Silicon, and
only when the IOReport backend is missing. Estimators always report a
distinct energy_method so callers can tell modelled joules from
measured ones. Off by default: a fabricated number that lands in the
telemetry DB is indistinguishable from a real one at query time.
Returns None if no energy monitoring is available.
Source code in src/openjarvis/telemetry/energy_monitor.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |