Expand description
2026-09-26: Energy attribution: the NVML counter’s deltas, paired with the tokens produced over the same interval.
Two cumulative totals are kept, GPU-rail millijoules and tokens, and
sampled together into EnergyRing. Every ratio is formed from
differences of those totals: J/token over the last
crate::hub::LIVE_WINDOW samples, J/token since the first sample, and a
request’s energy (its token share of its lifetime window). No ratio is
accumulated.
The sampler thread reads the counter at the device cadence, not per
scheduler step, so a window’s ΔE/Δtokens is exact up to one sample period
at each edge. A backwards step is a wrap or a reset;
CounterTracker::advance tells them apart.
Owner: telemetry. Invariants: none beyond the types.
Structs§
- Counter
Tracker - 2026-09-26: Turns raw counter readings into non-negative deltas.
- Energy
Point - 2026-09-26: One ring point: cumulative energy and tokens at one sample instant.
- Energy
Ring - 2026-09-26: The sampled (time, energy, tokens) series.
pushassumes one writer (the sampler thread); any number of readers read without a lock.
Enums§
- Advance
- 2026-09-26: What one counter reading did to the running total.
Constants§
- RING_
SLOTS - 2026-09-26: Ring capacity: 8192 samples, ~13.6 minutes at the 10 Hz serving cadence. A request older than the ring is attributed from the oldest point it still holds.
Functions§
- joules_
per_ token - 2026-09-26: GPU-rail joules per token for a (ΔmJ, Δtokens) pair.
Nonewhen either is 0, so the result is never 0 or ∞. - request_
millijoules - 2026-09-26: Millijoules attributed to a request that emitted
tokensover[start_ns, end_ns]: its share, by tokens, of the energy counted over that window.Nonewhen the ring is empty or the window saw no tokens.