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…
fix(ui): match school + hospital adapter field names to backend
adaptSchools read sc.school_name and sc.elev_m, but
doe_schools.summary_for_point emits loc_name and elevation_m. Same
mismatch on adaptHospitals. Pre-existing — register cards have been
quietly showing — for elev and falling through to 'name' for schools
since the rename. Add fallbacks so both old and new shapes render.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
step_nycha hung the FSM for 8+ minutes per query because
summary_for_point did 20 polygon×polygon intersections (5 nearest
developments × 4 layers) every time. Refactor to read pre-computed
exposure flags from data/registers/nycha.json — the bake script
already runs that math citywide once. Per-query work is haversine
+ dict lookup, sub-millisecond.
Same pattern for step_doe_schools (reads data/registers/schools.json,
~1ms). Hospitals have no pre-built catalog (~150 entries; would have
required a new build script + LLM-budget bake) so they read the
30 KB hospitals.geojson directly and sample the Cornerstone baked
rasters per hit (~10ms first call, sub-ms after).
Schema change for NYCHA per-query view: drop pct_inside_sandy_2012
and pct_in_dep_extreme_2080 floats (polygon-overlap percentages
weren't in the prebuilt catalog), replace with binary
inside_sandy_2012 + dep_*_class/dep_*_label to match the schools
and hospitals shape. NYCHA developments are now reported with
"centroid is in…
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…
sync: bring HF Space to parity with origin/main (squash, XET-backed)
Squash-merge of all commits on origin/main not present on HF Space:
- fix(riprap-models): port v2 test_transform patch (services container)
- feat(map): wire TerraMind LULC + Ida 2021 HWM map layers
- fix(map): MapLegend booleans, FloodNet tier proxy
- fix(slides): deck visual fixes
- docs: live-system screenshots (now as LFS/XET pointers, not raw blobs)
- chore: repo cleanup, session artifacts to docs/sessions/
- chore: LFS tracking rules for screenshot and slide PNGs/PPTX
Binary files (screenshots + deck.pptx) are stored as git-lfs/git-xet
pointers so HF's pre-receive hook accepts them. git-xet handles
upload to XET object store during the push.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Harden remote-ML routing + add address test suite
Wires up the regressions surfaced by a real PS 188 / Lower East Side
run on the AMD MI300X stack. Five fixes + one new probe:
1. Lift the `RIPRAP_HEAVY_SPECIALISTS` gate when remote ML is
reachable. The heavy specialists' GPU work (TerraMind LULC +
Buildings, Prithvi-live, register joins) runs on the droplet, so
the local wall-clock cost drops from ~60 s to ~5 s — gate the
default to ON so the public demo never silently disables them.
2. TTM specialists never crash with the
`ModuleNotFoundError("Could not import module 'PreTrainedModel'")`
that surfaced on local-fallback paths. Force-import
`PreTrainedModel` + `TinyTimeMixerForPrediction` before
`get_model()` so the transformers lazy-registry resolves the
class strings under FSM worker threads.
3. When remote ML is configured but returns non-ok, surface the
remote error rather than fall through to a brittle local model
load (`ttm_forecast`, `ttm_battery_surge`, `prithvi_live`). Local
fallback is r…
ux v0.4.5: nine polish deltas on the Findings region
Surgical polish on the shipped v0.4.4 Findings region. None of these
are structural; the card grammar, briefing prose, Mellea status strip,
four-tier palette, cold-start, footer, and PDF template all stay.
P1 — Status semantics (V0.4.5_SPEC §1, "actively misrepresenting
system integrity"). Splits the FSM specialist status from the
four-state ok|warn|error|silent into the five-state
fired / silent_by_design / warned / errored / not_invoked.
- lib/types/card.ts gains a documented SpecialistStatus union
- StoneTally / RunHealthStrip / ProvenanceTrace updated to
branch on the new states
- cardAdapter mapStatus() carefully classifies FSM trace-silent
as silent_by_design, not errored — the spec voice
- Top tally now reads "5 Stones · 21 fired · 5 silent · 1
errored · 24.0s · 25 registered" instead of the old "15/18
functions fired · 3 error" lie
P2 — Capstone meta-card field plumbing (§2). Wires the four metrics
to the rec…
ux: stream Findings cards in real time + fade-in instead of typing caret
Two follow-ups from the live Red Hook walkthrough:
1) **Findings stream as specialists fire.** Previously cards only
populated from `finalResult` (one event at end of stream). Now a
`liveResults` map updates on every SSE `step` event and feeds the
adapter; cards pop into each Stone's rail as their specialist
completes.
* lib/client/cardAdapter.ts gains `applyStepEventToLiveState()`,
mapping step names like `sandy_inundation` / `dep_stormwater` /
`mta_entrance_exposure` to the FSM state-keys the card builders
expect (`sandy`, `dep`, `mta_entrances`, ...). The slim `step.result`
summary shapes are translated into the doc-payload shapes the
builders read; one card per fired specialist, partial-data tolerant.
* `adaptFinalToFindings()` accepts `Partial<FinalResult> | null` and
skips the Capstone meta card until at least one of streaming /
finalResult has produced something to summarise.
* src/routes/q/[queryId]/+page.svelte plumbs `…
ux: wire FindingsRegion into both sample + live routes
Replaces the broken EvidenceGrid + RegisterCard + TraceUI bottom
section with the v0.4.4 FindingsRegion in both:
src/routes/q/sample/+page.svelte
Drives off the SAMPLE_FINDINGS fixture (Red Hook). Lifts
linkedKey, density, provenanceMode, showGrammar to the page.
Removes the EvidenceGrid + TraceUI bottom block; FindingsRegion
subsumes both — the Stones own the trace per-stone, and the
Findings cards own the structured-evidence surface.
src/routes/q/[queryId]/+page.svelte
Same swap, plus a $derived findingsData adapter that runs the
new lib/client/cardAdapter.adaptFinalToFindings against the live
FSM final-state + trace tree. Cards re-derive when finalResult
populates; runWallSeconds tracks elapsed time from onMount → onDone.
src/lib/client/cardAdapter.ts (new)
FSM final-state → Findings Card[] mapper. Per-Stone collectors:
Cornerstone: sandy / dep / ida_hwm / prithvi_water / microtopo
Keystone: mta + nycha + doe + doh fo…
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…