diff --git a/metrics_snapshot.py b/metrics_snapshot.py index 6c2a9b1..133a168 100644 --- a/metrics_snapshot.py +++ b/metrics_snapshot.py @@ -342,7 +342,19 @@ def impact_for(models: dict[str, int]) -> tuple[float | None, float | None]: break f = f or IMPACT_PROXY wh += toks / 1000.0 * f["wh_per_1k_out"] - co2 += toks / 1000.0 * f["wh_per_1k_out"] / 1e6 * f["gco2e_per_kwh"] + # Wh -> kWh is /1e3, then x gCO2e/kWh. This divided by 1e6 once, which + # understated carbon exactly 1000x: the energy column stayed plausible + # while carbon read ~0.2 g/day for a day using ~1 kWh. + co2 += toks / 1000.0 * f["wh_per_1k_out"] / 1e3 * f["gco2e_per_kwh"] + # Tripwire against unit errors: the blend of the factors above must imply a + # grid intensity inside a sane band (the factors themselves span 24-250). + if wh > 0: + implied = co2 / wh * 1000.0 # gCO2e per kWh + if not (5.0 <= implied <= 500.0): + print( + f"metrics: WARNING implied grid intensity {implied:.1f} gCO2e/kWh is outside " + f"the plausible band — suspect a unit error before trusting these numbers" + ) return round(wh, 6), round(co2, 6)