Skip to content

Commit 52e84c3

Browse files
fix(demo): kWh display precision + correct efficiency comparison metric
- kWh/TFLOP and kWh/1M tokens: use scientific notation (2e format) and None-check instead of truthiness so near-zero values display correctly instead of showing '—' or '0.00000' - Most efficient summary: compare W/TFLOP (work per watt) instead of raw avg watts; show time multiplier and RunPod cost saving % Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 29e8dd9 commit 52e84c3

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

agent/tests/runpod_demo.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,9 @@ def _print_results(
322322
adj_w = max(0.0, r.avg_power_w - idle_w)
323323
tflops_str = f"{r.tflops:.1f}" if r.tflops else "—"
324324
kwh_tflop = r.kwh_per_tflop
325-
kwh_tflop_str = f"{kwh_tflop:.5f}" if kwh_tflop else "—"
325+
kwh_tflop_str = f"{kwh_tflop:.2e}" if kwh_tflop is not None else "—"
326326
kwh_1m = r.kwh_per_1m_tokens
327-
kwh_1m_str = f"{kwh_1m:.5f}" if kwh_1m else "—"
327+
kwh_1m_str = f"{kwh_1m:.2e}" if kwh_1m is not None else "—"
328328
cost_hr = _cost_usd(r.avg_power_w, 3600, rate_per_hr)
329329
cost_mo = cost_hr * MONTHLY_HOURS
330330
table.add_row(
@@ -340,18 +340,21 @@ def _print_results(
340340

341341
console.print(table)
342342

343-
# Highlight the best workload
344-
efficient = min(
345-
(r for r in results if r.tflops),
346-
key=lambda r: (r.avg_power_w / max(r.tflops, 1e-9)),
347-
default=None,
348-
)
349-
if efficient:
350-
saving = results[0].avg_power_w - efficient.avg_power_w
351-
saving_pct = saving / max(results[0].avg_power_w, 1) * 100
343+
# Highlight the best workload by W/TFLOP (lower = more efficient)
344+
tflop_results = [r for r in results if r.tflops and r.tflops > 0]
345+
if tflop_results:
346+
worst = max(tflop_results, key=lambda r: r.avg_power_w / r.tflops)
347+
efficient = min(tflop_results, key=lambda r: r.avg_power_w / r.tflops)
348+
worst_w_per_tflop = worst.avg_power_w / worst.tflops
349+
best_w_per_tflop = efficient.avg_power_w / efficient.tflops
350+
improvement_pct = (worst_w_per_tflop - best_w_per_tflop) / worst_w_per_tflop * 100
351+
time_saving_pct = (1.0 - worst.tflops / efficient.tflops) * 100 # same work, less time
352+
cost_saving_pct = time_saving_pct # RunPod charges by time
352353
console.print(
353-
f"\n[bold green]Most efficient:[/] {efficient.name} — "
354-
f"[green]{saving_pct:.1f}% lower avg power[/] vs {results[0].name}"
354+
f"\n[bold green]Most compute-efficient:[/] [cyan]{efficient.name}[/] "
355+
f"— [green]{improvement_pct:.0f}% less W/TFLOP[/] vs {worst.name}\n"
356+
f" Same job finishes [bold]{efficient.tflops/worst.tflops:.1f}×[/] faster "
357+
f"→ [bold green]{cost_saving_pct:.0f}% lower RunPod cost[/] for that workload"
355358
)
356359
console.print(
357360
f"\n[dim]Baseline idle: {idle_w:.1f} W subtracted from all attributed samples.[/]"

0 commit comments

Comments
 (0)