Drops the cloud-comparison chip and replaces the data-sheet
energy estimate with a real per-call measurement off the L4 GPU.
inference-vllm/proxy.py
- Background sampler reads nvmlDeviceGetPowerUsage every 100 ms into
a 60 s ring buffer. Each forwarded POST records the upstream
wall-clock window and computes the mean power across the matching
samples; results land on the response as X-GPU-Power-W and
X-GPU-Energy-J (joules).
- New GET /v1/power exposes instantaneous + 1 s avg + 5 s avg for
bracket-sampling clients (used by the LLM path, where LiteLLM
hides response headers).
- pynvml init is best-effort: on failure the proxy still serves
traffic, just without power data.
inference-vllm/Dockerfile
- Adds nvidia-ml-py>=12.560 to the proxy's pip layer.
app/emissions.py
- Tracker.record_{llm,ml} accept optional joules_real / power_w_real.
When present, those values land on the row directly and the row is
flagged measured=True. Otherwise we fall back to the data-sheet
…
feat(emissions): per-call inference energy + token tracker
Adds an additive emissions ledger that records every llm.chat call
and every remote app.inference._post call, surfacing the per-query
total Wh / J + token counts on the briefing.
Backend
- app/emissions.py: thread-local Tracker with hardware power profiles
(MI300X 600 W, T4 50 W, Apple M 20 W, x86 30 W) and a summarize()
rollup with by-kind, by-hardware, and frontier-cloud comparison.
- app/llm.py: chat() times each call, picks hardware via engine
detection, reads prompt/completion tokens from LiteLLM usage for
non-stream calls, estimates from response text for streams.
- app/inference.py: _post() records duration vs the MI300X profile.
- app/fsm.py: captures the parent-thread tracker and re-installs it on
the iter_steps runner thread (mirrors the token_callback pattern);
attaches `emissions` alongside the existing `energy` block in both
run() and the iter_steps final event.
- app/context/eo_chip_cache.py + app/flood_layers/prithvi_live.py:
ThreadPoolExecutor initializ…
Phase 1 — tests/test_compare_shape.py: asserts /api/agent/stream for a
compare query emits exactly one final event with intent="compare", two
targets each carrying an address field, and a merged paragraph that
splits at "---" into PLACE A / PLACE B sections each with citations.
6/6 pass against the live server.
Phase 2 — CompareBriefing.svelte: when plan.intent=="compare" and
finalResult lands, renders a two-column layout (1fr 1px 1fr grid,
collapses below 900 px) with:
- Per-column .address-header showing the resolved address
- Existing Briefing component in each column, no changes to Briefing
- compare-delta-bar above both columns: one row per canonical section
where the first compared number differs (e.g. "TWI: 12.4 vs 8.2")
- Stone provenance / FindingsRegion unchanged (full-width below)
During streaming the merged paragraph renders in the existing single
Briefing path; the two-column view switches in only after finalResult.
FinalResult interface gains optional intent + target…
Telescoped from ~25 spine commits into the three UI generations:
Lit (kept on disk for reference, not loaded):
web/static/components/{briefing,trace,signals,sources-footer}.js
Component-per-tag custom elements with reactive props.
Svelte 5 custom-element bundle (legacy primary, served at /legacy):
web/svelte/src/lib/{Briefing,Trace,SourcesFooter}.svelte + main.js
Shared store for cross-component highlight (citeIndex,
highlightedDocId). Built artifact ships at web/static/dist/riprap.js.
SvelteKit design-system v0.4.2 (the new primary):
web/sveltekit/src/* — adapter-static build, IBM Plex, four-tier
glyphs, MapLibre map with custom basemap, server-side render of
/q/sample + /q/<query>. Built artifact ships at web/sveltekit/build/.
web/main.py wired up the new endpoint surface:
/, /q/sample, /q/<query> → SvelteKit build
/legacy, /single, /compare → Svelte custom-element bundle
/api/agent/stream → SSE pipeline (plan/step/toke…