energy_monitor
diapason.telemetry.energy_monitor
¶
EnergyMonitor ABC — multi-vendor energy measurement with hardware counters.
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.
available()
abstractmethod
staticmethod
¶
Return True if this monitor can run on the current hardware.
close()
abstractmethod
¶
Release any resources (handles, threads, etc.).
energy_method()
abstractmethod
¶
Return the measurement method: 'hw_counter', 'polling', 'rapl', or 'zeus'.
sample()
abstractmethod
¶
Context manager that measures energy during the enclosed block.
Yields an EnergySample that is populated when the block exits.
snapshot()
¶
Return an instantaneous energy reading without start/stop bracket.
Subclasses should override to provide actual readings. Default returns an empty sample.
vendor()
abstractmethod
¶
Return the vendor enum for this monitor.
EnergySample
dataclass
¶
Aggregated energy metrics over an inference bracket.
Superset of GpuSample — adds vendor, device info, energy method,
and per-component breakdown (CPU, GPU, DRAM, ANE).
EnergyVendor
¶
Bases: str, Enum
Supported energy measurement vendors.
create_energy_monitor(poll_interval_ms=50, prefer_vendor=None)
¶
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.
Returns None if no energy monitoring is available.