aiinfra-tools 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/CHANGELOG.md +210 -0
  2. package/README.md +14 -3
  3. package/bin/aiinfra.mjs +5 -2
  4. package/bin/report.mjs +177 -0
  5. package/fleetops/README.md +33 -1
  6. package/fleetops/deploy/shadow-gate/argo-analysistemplate.yaml +34 -0
  7. package/fleetops/deploy/shadow-gate/argo-rollout-example.yaml +38 -0
  8. package/fleetops/deploy/shadow-gate/flagger-canary.yaml +34 -0
  9. package/fleetops/deploy/shadow-gate/judge.yaml +51 -0
  10. package/fleetops/deploy/shadow-gate/llmd-canary-example.yaml +35 -0
  11. package/fleetops/deploy/shadow-gate/podmonitor-vllm.yaml +20 -0
  12. package/fleetops/deploy/shadow-live/README.md +33 -0
  13. package/fleetops/deploy/shadow-live/kit.yaml +121 -0
  14. package/fleetops/deploy/shadow-live/load-canary.yaml +26 -0
  15. package/fleetops/deploy/shadow-live/run.sh +48 -0
  16. package/fleetops/docs/ADMISSION.md +9 -9
  17. package/fleetops/docs/FABRIC-STORAGE.md +1 -1
  18. package/fleetops/docs/SERVING.md +11 -1
  19. package/fleetops/docs/SHADOW.md +250 -0
  20. package/fleetops/docs/SIGNALS.md +5 -2
  21. package/fleetops/docs/WORKLOADS.md +1 -1
  22. package/fleetops/package.json +7 -4
  23. package/fleetops/src/adapters/fabric.mjs +19 -7
  24. package/fleetops/src/adapters/live.mjs +38 -5
  25. package/fleetops/src/adapters/logs.mjs +10 -7
  26. package/fleetops/src/adapters/nvsentinel.mjs +95 -0
  27. package/fleetops/src/adapters/topology.mjs +53 -1
  28. package/fleetops/src/admission.mjs +26 -18
  29. package/fleetops/src/api.mjs +2 -1
  30. package/fleetops/src/bundle.mjs +3 -0
  31. package/fleetops/src/calibrate.mjs +1 -1
  32. package/fleetops/src/detect.mjs +1 -1
  33. package/fleetops/src/export.mjs +5 -1
  34. package/fleetops/src/goodput.mjs +0 -2
  35. package/fleetops/src/incidents.mjs +1 -2
  36. package/fleetops/src/ingest.mjs +1 -1
  37. package/fleetops/src/inject.mjs +2 -2
  38. package/fleetops/src/live.mjs +2 -1
  39. package/fleetops/src/llmd.mjs +7 -3
  40. package/fleetops/src/optimize.mjs +1 -1
  41. package/fleetops/src/power.mjs +7 -7
  42. package/fleetops/src/procure.mjs +67 -0
  43. package/fleetops/src/rca.mjs +1 -1
  44. package/fleetops/src/rollout.mjs +1 -1
  45. package/fleetops/src/schema.mjs +3 -2
  46. package/fleetops/src/security.mjs +1 -1
  47. package/fleetops/src/serving.mjs +21 -9
  48. package/fleetops/src/shadow-canary.mjs +74 -0
  49. package/fleetops/src/shadow-gate.mjs +49 -0
  50. package/fleetops/src/shadow-prom.mjs +205 -0
  51. package/fleetops/src/shadow-replay.mjs +147 -0
  52. package/fleetops/src/shadow.mjs +291 -0
  53. package/fleetops/src/stats.mjs +14 -0
  54. package/fleetops/src/traces.mjs +0 -5
  55. package/fleetops/tests/fixtures/real/README.md +5 -0
  56. package/fleetops/tools/admit-node.sh +51 -16
  57. package/fleetops/tools/amd-admit.py +111 -0
  58. package/fleetops/tools/cmd/calibrate.mjs +61 -0
  59. package/fleetops/tools/cmd/capacity.mjs +116 -0
  60. package/fleetops/tools/cmd/common.mjs +32 -0
  61. package/fleetops/tools/cmd/data.mjs +343 -0
  62. package/fleetops/tools/cmd/help.mjs +243 -0
  63. package/fleetops/tools/cmd/incidents.mjs +216 -0
  64. package/fleetops/tools/cmd/rollout.mjs +122 -0
  65. package/fleetops/tools/cmd/server.mjs +122 -0
  66. package/fleetops/tools/cmd/serving.mjs +95 -0
  67. package/fleetops/tools/cmd/shadow.mjs +204 -0
  68. package/fleetops/tools/cmd/training.mjs +79 -0
  69. package/fleetops/tools/collect.sh +6 -1
  70. package/fleetops/tools/fleetops.mjs +18 -1308
  71. package/fleetops/tools/loop-demo.mjs +1 -1
  72. package/fleetops/tools/workload-profile.mjs +0 -1
  73. package/fleetscope/README.md +5 -1
  74. package/fleetscope/build.mjs +1 -0
  75. package/fleetscope/dist/index.html +295 -26
  76. package/fleetscope/docs/AGENTIC.md +89 -0
  77. package/fleetscope/docs/PLANNING.md +4 -2
  78. package/fleetscope/docs/VALIDATION-AGENTIC.md +37 -0
  79. package/fleetscope/package.json +4 -3
  80. package/fleetscope/src/agentic.js +288 -0
  81. package/fleetscope/src/ask.js +0 -1
  82. package/fleetscope/src/cluster-ui.js +1 -0
  83. package/fleetscope/src/engine.js +10 -11
  84. package/fleetscope/src/index.src.html +9 -5
  85. package/fleetscope/src/inference-ui.js +1 -0
  86. package/fleetscope/src/ingest.js +89 -3
  87. package/fleetscope/src/optimize.js +11 -5
  88. package/fleetscope/src/plan.js +1 -1
  89. package/fleetscope/src/training-ui.js +1 -0
  90. package/fleetscope/tools/agentic.mjs +148 -0
  91. package/fleetscope/tools/tracelab-data.mjs +27 -0
  92. package/gpu-health/README.md +13 -2
  93. package/gpu-health/docs/CONFIG.md +29 -1
  94. package/gpu-health/package.json +7 -4
  95. package/gpu-health/src/actions.mjs +16 -3
  96. package/gpu-health/src/analyze.mjs +3 -0
  97. package/gpu-health/src/config.mjs +3 -0
  98. package/gpu-health/src/executors.mjs +9 -4
  99. package/gpu-health/src/health.mjs +1 -1
  100. package/gpu-health/src/ingest.mjs +27 -3
  101. package/gpu-health/src/platforms.mjs +109 -0
  102. package/gpu-health/src/vendors.mjs +12 -5
  103. package/gpu-health/tools/gpu-health.mjs +6 -4
  104. package/gpu-ledger/README.md +3 -1
  105. package/gpu-ledger/package.json +12 -4
  106. package/gpu-ledger/src/adapters.mjs +3 -2
  107. package/gpu-ledger/src/cloud.mjs +104 -0
  108. package/gpu-ledger/src/core.mjs +12 -10
  109. package/gpu-ledger/tools/ledger.mjs +8 -2
  110. package/harness-ledger/README.md +152 -0
  111. package/harness-ledger/docs/FORMATS.md +114 -0
  112. package/harness-ledger/docs/METHOD.md +133 -0
  113. package/harness-ledger/docs/VALIDATION-ECONOMICS.md +59 -0
  114. package/harness-ledger/docs/VALIDATION-SWEBENCH.md +26 -0
  115. package/harness-ledger/docs/VALIDATION-TRACELAB.md +56 -0
  116. package/harness-ledger/package.json +19 -0
  117. package/harness-ledger/src/demo.mjs +115 -0
  118. package/harness-ledger/src/economics.mjs +184 -0
  119. package/harness-ledger/src/gpu.mjs +80 -0
  120. package/harness-ledger/src/html.mjs +63 -0
  121. package/harness-ledger/src/importers.mjs +247 -0
  122. package/harness-ledger/src/ledger.mjs +128 -0
  123. package/harness-ledger/src/opencost.mjs +55 -0
  124. package/harness-ledger/src/outcomes.mjs +67 -0
  125. package/harness-ledger/src/prices.mjs +75 -0
  126. package/harness-ledger/src/record.mjs +52 -0
  127. package/harness-ledger/src/waste.mjs +136 -0
  128. package/harness-ledger/tools/harness-ledger.mjs +199 -0
  129. package/harness-ledger/tools/validate-economics.mjs +69 -0
  130. package/harness-ledger/tools/validate-swebench.mjs +57 -0
  131. package/harness-ledger/tools/validate-tracelab.mjs +74 -0
  132. package/hybrid-tracing/package.json +4 -3
  133. package/hybrid-tracing/tools/fix-skew.mjs +1 -1
  134. package/inference-sizer/README.md +5 -1
  135. package/inference-sizer/build.mjs +1 -0
  136. package/inference-sizer/dist/index.html +205 -22
  137. package/inference-sizer/docs/ACCELERATORS.md +62 -0
  138. package/inference-sizer/docs/VALIDATION-INFERENCEX.md +37 -0
  139. package/inference-sizer/package.json +4 -3
  140. package/inference-sizer/src/accelerators.js +172 -0
  141. package/inference-sizer/src/catalog.js +7 -20
  142. package/inference-sizer/src/fit-ui.js +1 -1
  143. package/inference-sizer/src/index.src.html +3 -0
  144. package/inference-sizer/src/model.js +22 -1
  145. package/inference-sizer/tools/validate-agentx.mjs +110 -0
  146. package/inference-sizer/tools/validate-inferencex.mjs +132 -0
  147. package/mcp/README.md +6 -1
  148. package/mcp/server.mjs +34 -0
  149. package/package.json +9 -4
  150. package/schemas/README.md +3 -0
  151. package/schemas/aiinfra.report.schema.json +474 -0
  152. package/schemas/commands.mjs +14 -0
  153. package/schemas/fleetops.shadow.canary.schema.json +96 -0
  154. package/schemas/fleetops.shadow.compare.schema.json +266 -0
  155. package/schemas/fleetops.shadow.prom.schema.json +354 -0
  156. package/schemas/harness-ledger.economics.schema.json +567 -0
  157. package/schemas/sizer.list.schema.json +15 -2
package/CHANGELOG.md CHANGED
@@ -3,6 +3,216 @@
3
3
  All notable changes. Versions follow [Semantic Versioning](https://semver.org/); before 1.0, a minor version may
4
4
  change the `--json` output, and when it does the change is listed here (see [schemas/](schemas/README.md)).
5
5
 
6
+ ## 0.3.0 (2026-11-26)
7
+
8
+ The loop now covers what a change costs, not only whether it works. There is a new tool for agent harnesses
9
+ (harness-ledger), shadow tests run inside the rollout tools (Argo Rollouts, llm-d canaries), and `aiinfra report`
10
+ puts plan → verify → account on one page. Coverage reaches AMD, AWS and Cloud TPU through one accelerator registry.
11
+ Some `--json` output changed; see "Changed (`--json`)" below.
12
+
13
+ - **New tool: harness-ledger.** It finds where agent harnesses (Claude Code, Codex, OpenTelemetry, Langfuse) waste
14
+ model resources, and works out the cost per successful task and when self-hosting pays.
15
+ - **Shadow tests in the rollout path:** `fleetops shadow` measures a change against the baseline at matched load.
16
+ `shadow prom` judges a canary from its own vLLM metrics, `shadow serve` acts as an Argo Rollouts analysis, and
17
+ `shadow canary` steps llm-d route weights, with every step up waiting for a person's approval.
18
+ - **Agentic sizing from real traces:** FleetScope profiles agentic workloads from TraceLab, AgentX and Mooncake
19
+ traces. It sizes them by the KV working set, and now by KV offload to host memory and tokens per MW too.
20
+ - **Integrations:** OpenCost prices, NVSentinel health events (gpu-health defers to it), and measured calibration
21
+ that feeds back into the sizer and the economics.
22
+ - **One accelerator registry** covering NVIDIA, AMD and Cloud TPU, read by every tool, with EKS and EFA on AWS and GKE
23
+ on GCP.
24
+ - **For agents and scripts:** 20 MCP tools and 21 JSON Schemas for `--json` output.
25
+ - **Quality:** ESLint on every PR, a weekly check that the supported formats are current, and branch-coverage
26
+ floors of 80% (77% for fleetops).
27
+
28
+ ### Plan → verify → account, and what agents can call
29
+
30
+ - **`aiinfra report`:** one page from what the tools already keep in a fleetops store: the Inference Sizer's GPU count
31
+ before and after the store's calibration, the last shadow verdict with prediction against measurement, the last
32
+ promotion, each canary's share and any step waiting for a person's approval, and agent economics (cost per resolved
33
+ task, self-hosting sized with the calibration, tokens per MW). Text, Markdown or `--json`; `--demo` runs it on demo data.
34
+ It only reads. Shadow verdict records now keep the prediction rows so the report can show them.
35
+ - **KV offload in the sizing:** FleetScope's agentic sizing reports what LMCache-style offload to host memory would do:
36
+ the GPU count with the cold part of the KV working set in host memory (375 GB per GPU by default, AgentX's 3 TB per
37
+ 8-GPU server), the PCIe reload time for a returning session, and PCIe load at the peak minute. `--kv-offload` (on
38
+ `harness-ledger economics` and `agentic.mjs size`) uses it when a reload fits the TTFT target and PCIe stays under 80%.
39
+ - **Tokens per megawatt** next to every agentic GPU count: peak output tokens/s over provisioned power, from published
40
+ node power, or the GPU's board power when none is published.
41
+ - **New `--json` contracts:** `fleetops.shadow.compare`, `fleetops.shadow.prom`, `fleetops.shadow.canary`,
42
+ `harness-ledger.economics` and `aiinfra.report`. `harness-ledger.economics` gains `offload`, `kvOffloadUsed` and
43
+ `power` under `selfHost`; `sizer.list` GPUs gain `tdpW`. Both changes add fields only.
44
+ - **MCP tools:** `shadow_verdict`, `canary_status`, `agent_economics` and `infra_report` (20 tools). None of them can
45
+ advance or approve a canary.
46
+
47
+ ### Code quality
48
+
49
+ - **fleetops CLI split:** `tools/fleetops.mjs` now only parses and dispatches. Each area's commands live in
50
+ `tools/cmd/<area>.mjs`, unchanged.
51
+ - **Branch coverage floors** go from 70% to 80% in every package except fleetops, which goes to 77%. New tests cover
52
+ the least-covered branches, mostly the command lines and their errors.
53
+ - **Fixed:** gpu-ledger read a time it couldn't parse as NaN instead of no time, so a CSV row with an unreadable start
54
+ was kept. Such a row is now dropped.
55
+
56
+ - **Lint gate:** ESLint recommended rules on every pull request (`eslint.config.mjs`, `.github/workflows/lint.yml`),
57
+ starting from zero findings.
58
+ - **Removed:**
59
+ - four exports nothing used (`STATES`, `slowRequests`, `NUM_FIELDS`, `knownPlatforms`, and the helper behind the last);
60
+ - 20 unused locals and imports;
61
+ - a no-op self-assignment in the sizer UI;
62
+ - nine needless regex escapes;
63
+ - a literal byte-order mark in a regex.
64
+ - **One copy of fleetops' statistics:** `fleetops/src/stats.mjs` replaces 11 copies of median, percentile and the seeded
65
+ generator. Each copy's exact behaviour is kept, so no result moved.
66
+ - **Weekly format check:** `scripts/check-formats.mjs` and `.github/workflows/formats.yml`.
67
+ - Its first run found that the Argo Rollouts schemas had been vendored from v1.9.3 while v1.10.2 is current. They are
68
+ refreshed; the manifests pass both.
69
+
70
+ ### Integrations, and the loop between the tools
71
+
72
+ - **OpenCost:** `harness-ledger economics --opencost FILE|URL` (its `/inferenceCost/total`) or `--opencost-prom URL` (its
73
+ `llm_cost_per_million_tokens` and `llm_cache_savings_fraction` gauges) uses OpenCost's measured self-host cost per token.
74
+ - The price per delivered input token is turned into a price per prefilled token.
75
+ - A deployment whose label join failed (zero cost) is explained, not used.
76
+ - **NVSentinel:** `fleetops data import nvsentinel` reads its health events: event-exporter CloudEvents, datastore
77
+ documents, HealthEventResource objects and bare events, with XIDs classified through gpu-health's table.
78
+ - Root-cause analysis uses them as evidence.
79
+ - gpu-health defers to NVSentinel on nodes it is remediating: one informational `external-remediation` action instead
80
+ of a second repair ladder (`deferToExternal: false` to turn this off).
81
+ - **llm-d canaries:** `fleetops shadow canary start|advance|approve|status` steps two LLMInferenceServices' route weights
82
+ by the judge's verdict.
83
+ - A rollback is written at once with `--live`.
84
+ - A step up is queued for a person and written only after `approve --by NAME`.
85
+ - Manifests and patches are checked against KServe's CRD schema (v1alpha2, vendored).
86
+ - **The loop:**
87
+ - `shadow plan` records its configs.
88
+ - `compare` and `prom` with `--plan` refit the candidate's sizer efficiencies when the prediction was off by more than
89
+ 15%, into `<store>/calibration/sizer.json`. `shadow plan`, `inference-sizer --calibration` and
90
+ `harness-ledger economics --calibration` read it.
91
+ - Promoted changes are recorded in `<store>/shadow/promoted.jsonl`.
92
+ - `shadow prom` takes `--plan` (prediction vs measurement, as `compare` does).
93
+ - **Recovered:** the agent unit economics work (`harness-ledger economics`, `validate-economics`) had been merged into a
94
+ feature branch instead of `main`; it is included here.
95
+
96
+ ### Shadow upgrades inside the rollout tools
97
+
98
+ - **`fleetops shadow prom`** judges a canary from its own per-version vLLM metrics in Prometheus (llm-d controlled
99
+ deployments' `llm_isvc_name`, Argo Rollouts' pod-template hash, Flagger's `app` label, or any label matchers).
100
+ - Each canary window is compared with what the baseline shows at the same load per engine, prompt length and cache
101
+ hit (a local fit on the baseline's own history), with an interval and a verdict. Per-version means are shown beside it.
102
+ - On synthetic canaries at half or a quarter of the baseline's load, the effect lands within 1 point of the truth
103
+ where per-version means say 20–33% faster.
104
+ - `--save` keeps the series; `--file` reruns them; `--demo` shows the trap.
105
+ - **`fleetops shadow serve`** runs the judge as a service for Argo Rollouts (an AnalysisTemplate web metric) and
106
+ Flagger (`rollout` and `confirm-promotion` webhooks): promote, rollback or wait.
107
+ - Manifests in `fleetops/deploy/shadow-gate/`, checked against the real CRD schemas (Argo Rollouts v1.10.2, Flagger
108
+ v1.45.0, Prometheus Operator v0.95.2).
109
+ - Selectors are checked as label matchers before any query is built.
110
+ - **`fleetops/deploy/shadow-live/`**: a kit that runs everything on three 1-GPU L4 nodes against real vLLM engines
111
+ (paired replay, an in-cluster canary, the judge). Not run yet.
112
+ - `shadow replay` takes `--max-isl` / `--max-osl` to fit long agent sessions to a small model's context.
113
+ - `compare`'s decision logic is shared (`decide`); with no latency data at all the decision is now *extend the test*,
114
+ not *promote*.
115
+
116
+ ### Agent unit economics
117
+
118
+ - **`harness-ledger economics`** reports what a successful agent task costs and what changing it is worth.
119
+ - **Cost per resolved task** and the share of spend on failed tasks.
120
+ - **Fixes ranked by what they save per resolved task:** each waste cause, plus a step cap computed exactly from each
121
+ session's calls.
122
+ - **Self-hosting vs the API:** the same workload sized with the Inference Sizer for an open model (FleetScope's agentic
123
+ path: real arrivals, cache reuse, the KV working set; busiest day's peak).
124
+ - The result is a break-even GPU-hour price per resolved task, and with `--gpu-rate` the volume from which
125
+ self-hosting wins.
126
+ - `--self-host-price` uses measured prices (OpenCost) instead.
127
+ - `--self-host-success-rate` and `--token-scale` (calls per task) carry the open model's quality and verbosity.
128
+ - **`validate-economics`** on TraceLab's workload with SWE-bench success rates (`docs/VALIDATION-ECONOMICS.md`; a CI job
129
+ in `validate.yml`).
130
+ - One team's volume (about $5,600 a month of API spend at Sonnet-class prices) favours the API: self-hosting pays only
131
+ below about $0.25–0.50 a GPU-hour.
132
+ - At $3 a GPU-hour on B200, self-hosting wins from about 8–16× that volume.
133
+ - Half the calls exceed the open models' 128k context.
134
+
135
+ ### Shadow upgrades
136
+
137
+ - **`fleetops shadow`** measures an infra change before it ships, against the baseline at matched load.
138
+ - **`plan`:** predicts the effect with the Inference Sizer and sizes the test.
139
+ - **`replay`:** the same recorded sessions to two OpenAI-compatible endpoints at the same moments, paired per
140
+ request, with session prefixes kept for the prefix cache. Dry run unless `--live`.
141
+ - **`answers`:** greedy tokens and log-probs compared on a prompt set.
142
+ - **`compare`:** stratified by calls in flight, prompt length and cache hit (or paired), with bootstrap intervals,
143
+ verdicts against gates, the naive number beside each, errors, tokens/s per GPU, $ per M tokens, infra signals, and
144
+ prediction vs measurement.
145
+ - **`baseline` / `watch`:** drift of a service against its own saved history.
146
+ - Design and architecture: `fleetops/docs/SHADOW.md`. Tested on synthetic arms and mock endpoints; not yet run against
147
+ live engines.
148
+
149
+ ### Agentic workloads from real traces
150
+
151
+ - **FleetScope agentic profiles** (`fleetscope/tools/agentic.mjs`, `aiinfra agentic`):
152
+ - fit a profile of how agent sessions behave from a real trace: TraceLab, AgentX "weka", Mooncake, harness-ledger
153
+ records or your own CSV/JSONL;
154
+ - generate sessions from a profile at any load;
155
+ - measure what a workload asks of a fleet: prefill after cache reuse, and the KV working set idle sessions hold;
156
+ - size GPUs for both compute and KV.
157
+
158
+ On TraceLab, a profile fitted on 70% of sessions matches the held-out 30% within 1–8% on cache hit, call rate, and
159
+ prefill and output rates. The KV working set comes out 28% low. Flat ISL/OSL sizing of the same calls asks for 440
160
+ GPUs where 40 do. Ingest reads AgentX, Mooncake and TraceLab traces, with prefix reuse computed from block hashes.
161
+ - **harness-ledger on real data:**
162
+ - TraceLab importer, streamed;
163
+ - `--prices relative`;
164
+ - a report on 8,058 real sessions: 22% of spend avoidable, mostly caches expiring in pauses.
165
+ - **harness-ledger outcomes:** cost per successful task, spend on failures, and what call caps would save. On SWE-bench
166
+ Verified across 11 models, 39% of spend goes to unresolved tasks, and caps save about 1% at no more than one point
167
+ of success lost.
168
+ - **Sizer against AgentX** (`inference-sizer/tools/validate-agentx.mjs`): scores and calibrates the sizer on AgentX
169
+ agentic results. It needs the results downloaded from InferenceX.
170
+ - Fix: price prefixes match only at a version boundary (`gpt-5` no longer prices `gpt-5.5`).
171
+
172
+ ### New tool: harness-ledger
173
+
174
+ - **Where agent harnesses waste model resources, across harnesses.** Importers for Claude Code transcripts, Codex
175
+ rollouts, OpenTelemetry GenAI and OpenInference spans, and Langfuse exports write one `llm_call` record per model
176
+ call, with token meanings normalized (cached tokens are part of input). Checks: prompt-cache misses and expiries,
177
+ unread cache writes, oversized tool output carried forward, repeated tool calls, retry loops, failed calls, unused
178
+ tool definitions, and routing calls on a large model (as candidates). Costs come from a price file, the harness's
179
+ recorded cost, or, for self-hosted models, GPU time joined from vLLM's request spans through gpu-ledger's rate card.
180
+ Cost per successful task with `--outcomes`. Records keep counts, names and hashes only.
181
+ `harness-ledger scan | report | import | demo`, HTML report, skill. Token accounting matches ccusage on its Codex
182
+ fixtures.
183
+
184
+ Vendor-neutral: the tools no longer assume NVIDIA.
185
+
186
+ ### New
187
+
188
+ - **One accelerator registry** (`inference-sizer/src/accelerators.js`), read by the sizer, FleetScope, the power model,
189
+ serving manifests and Kubernetes inventory; vendor adapters replace the NVIDIA-or-AMD branches. MI325X, MI355X and
190
+ GB300 NVL72 added. InferenceX validation covers 198 runs (#66).
191
+ - **GCP and Cloud TPU:**
192
+ - TPU v6e, v5p and TPU7x in the sizer.
193
+ - Serving on GKE TPUs: `vllm/vllm-tpu`, `google.com/tpu`, slice selected by accelerator and topology labels.
194
+ - GKE nodes give project, zone and instance, and scheduled host maintenance is a planned event.
195
+ - gpu-health `gke` and `gcp` platforms: GKE's `fault-behavior` label, `report-host-as-faulty` on Compute Engine.
196
+ - Cloud Monitoring accelerator metrics as telemetry.
197
+ - `gpu-ledger import gcp-billing`.
198
+ - `fleetops procure gcp-calendar`.
199
+ - **AWS:**
200
+ - EFA `hw_counters` read as fabric counters. Retransmits, timeouts and impaired connections count as congestion; RDMA errors as errors.
201
+ - EKS nodes give their instance, zone and GPU (from the instance type); the node monitoring agent's `AcceleratedHardwareReady` conditions become faults.
202
+ - gpu-health platforms: reboot and replace act on the EC2 instance; reseat is never proposed. `autoRepair` leaves both to EKS.
203
+ - `gpu-ledger import aws-cur`: GPU-hours priced at what the CUR says was billed.
204
+ - Capacity Blocks and spot in FleetScope's buy-vs-rent plan. `fleetops procure aws-blocks` prints the read-only lookup.
205
+ - **AMD at parity:**
206
+ - `amd-smi-static` and `amd-smi-topology` importers (inventory, IFWI, PCI → GPU map; XGMI links);
207
+ - `collect.sh` and `admit-node.sh` on AMD nodes (amd-smi, ROCm Validation Suite, rccl-tests);
208
+ - RCCL version and HIP error lines in job logs.
209
+
210
+ ### Changed (`--json`)
211
+
212
+ - `sizer list`: `nodeKW` is optional; `kind` and `vendorKey` added.
213
+ - `admit check`: the diagnostic check is named `diag` (was `dcgm-diag`). Its evidence names the record (`dcgm-diag` or
214
+ `rvs-diag`). A policy that still lists `dcgm-diag` in `require` keeps working.
215
+
6
216
  ## 0.2.0 (2026-11)
7
217
 
8
218
  From four utilities to one loop: Observe → Diagnose → Simulate → Approve → Optimize → Verify. First release as an npm
package/README.md CHANGED
@@ -19,13 +19,14 @@ Each tool lives in its own folder with its own README. What has been checked aga
19
19
  | [gpu-health](gpu-health/) | Health checks, utilization and savings for GPU fleets, with suggested fixes that run once approved |
20
20
  | [hybrid-tracing](hybrid-tracing/) | One trace view across on-prem and neocloud: shared clock reference (PTP/chrony), collector tiers, and clock-skew correction for traces |
21
21
  | [gpu-ledger](gpu-ledger/) | GPU billing and waste for any cluster: GPU-hours and cost by org, team, person and use case, split into useful, idle and lost; where to save, with an owner; serving cost per token; FOCUS export. Runs on its own against Kubernetes, DCGM, vLLM, Slurm, OpenCost or CSV |
22
+ | [harness-ledger](harness-ledger/) | Where agent harnesses waste model resources, across harnesses: reads Claude Code and Codex logs, OpenTelemetry GenAI and OpenInference spans and Langfuse exports into one record per model call, then finds cache misses, bloated and repeated tool output, retry loops and unused tools, in tokens, dollars and (with vLLM traces) GPU time; cost per resolved task, fixes ranked by what they save per resolved task, and where self-hosting an open model beats the API. Keeps counts only, never prompt or tool text |
22
23
  | [fleetops](fleetops/) | The shared data layer under the tools: one store of device telemetry, inventory, jobs, serving metrics and changes, with adapters for exporters, Kubernetes, Slurm, change feeds and public traces. On top of it: root-cause analysis, incidents, and a live agent and dashboard that mitigate training and inference issues in real time within approval guardrails |
23
24
 
24
25
  Where this is going, from four utilities to one Observe → Diagnose → Simulate → Approve → Optimize → Verify loop: [ROADMAP.md](ROADMAP.md).
25
26
 
26
27
  ## Install
27
28
 
28
- Node.js 20+ and nothing else:
29
+ Node.js 22+ and nothing else:
29
30
 
30
31
  ```bash
31
32
  npx aiinfra-tools demo # the whole loop on a real week of a GPU cluster
@@ -33,7 +34,7 @@ npx aiinfra-tools --help # every tool, one entr
33
34
  npx aiinfra-tools sizer --model llama33-70b --gpu H100 # or: npm i -g aiinfra-tools, then `aiinfra sizer …`
34
35
  ```
35
36
 
36
- Every command takes `--json`; the output of the ones agents rely on is described by [JSON Schemas](schemas/README.md). Or open the repository in a Codespace ([.devcontainer](.devcontainer/devcontainer.json)): `aiinfra` is ready on the path. The package also installs each tool's own command (`fleetops`, `gpu-health`, `gpu-ledger`, `inference-sizer`,
37
+ Every command takes `--json`; the output of the ones agents rely on is described by [JSON Schemas](schemas/README.md). Or open the repository in a Codespace ([.devcontainer](.devcontainer/devcontainer.json)): `aiinfra` is ready on the path. The package also installs each tool's own command (`fleetops`, `gpu-health`, `gpu-ledger`, `harness-ledger`, `inference-sizer`,
37
38
  `fleetscope`, `fix-skew`). Or clone the repository and run any tool from its folder.
38
39
 
39
40
  ## The loop in one command
@@ -45,6 +46,15 @@ you to approve it. Then `aiinfra demo --continue DIR` rolls it out (dry run) and
45
46
  half of the week, which they fail at 3.3× the expected rate. It prints every command, so you can repeat each step on
46
47
  your own data.
47
48
 
49
+ ## One page: plan → verify → account
50
+
51
+ `aiinfra report --store DIR --model M --gpu G --harness PATH` puts the loop on one page, from what the tools already
52
+ keep: the Inference Sizer's GPU count before and after the store's measured calibration, the last shadow verdict with
53
+ prediction against measurement, each canary's share and any step waiting for a person's approval, and what an agent
54
+ workload costs per resolved task at the API and self-hosted (with tokens per megawatt). `--format md` writes Markdown,
55
+ `--json` the [schema'd](schemas/aiinfra.report.schema.json) record; `aiinfra report --demo` runs it on demo data. It
56
+ only reads.
57
+
48
58
  ## Use with LLMs (skills)
49
59
 
50
60
  Each tool is also packaged as an [Agent Skill](https://agentskills.io/specification) in [skills/](skills/). A skill tells a model when to use the tool, what to ask the user, which command to run and how to read the JSON it returns. A model can then answer questions like "how many H200s for Llama 70B at 25 ms TPOT?", "what if the cloud link drops to 25 Gbps?", "why do our cross-site traces look out of order?" "which GPUs should we pull before they fail?" or "why did half the training jobs fail last night?" by running the tools itself.
@@ -56,6 +66,7 @@ Each tool is also packaged as an [Agent Skill](https://agentskills.io/specificat
56
66
  | [hybrid-tracing](skills/hybrid-tracing/SKILL.md) | Clock-skew correction for traces, clock checks, and collector, chrony and PTP configs |
57
67
  | [gpu-health](skills/gpu-health/SKILL.md) | Health, efficiency and savings analysis, with an approval queue the model may not approve on its own |
58
68
  | [gpu-ledger](skills/gpu-ledger/SKILL.md) | Chargeback and showback, useful vs idle vs lost GPU-hours per team and person, ranked savings, cost per million tokens, FOCUS export |
69
+ | [harness-ledger](skills/harness-ledger/SKILL.md) | Where Claude Code, Codex and OTel- or Langfuse-traced agents waste tokens and money, by cause, harness, tool and session, with fixes; GPU time for self-hosted models |
59
70
  | [fleetops](skills/fleetops/SKILL.md) | Root-cause analysis of job failures, latency and training slowdowns; a live agent that mitigates within approval guardrails, with a live dashboard; incidents, postmortems, accuracy backtests and game days; installers |
60
71
 
61
72
  **MCP.** Every tool is also an MCP tool, for Claude Desktop, Cursor and any other MCP client:
@@ -74,7 +85,7 @@ On Claude Code 2.1.275 or later, this one step does both: `/plugin install aiinf
74
85
 
75
86
  **Other agents.** Any agent that reads Agent Skills can use the skill folders as they are: copy them into its skills directory. For an agent without skill support, every command the skills use takes `--json` and returns one JSON object, so you can wrap each one as a function tool.
76
87
 
77
- All skills need Node.js 20+ and nothing else.
88
+ All skills need Node.js 22+ and nothing else.
78
89
 
79
90
  **Changing a tool.** The skill folders carry copies of the tools' code (`scripts/`), docs (`references/`) and examples (`assets/`), so each folder works on its own. After editing a tool, run `node scripts/build-skills.mjs`. CI fails while the copies are out of date. `node --test scripts/test-skills.mjs` runs each skill's documented commands from an isolated copy.
80
91
 
package/bin/aiinfra.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  // aiinfra: one entry point for every AIInfraTools command. `aiinfra <tool> [args…]` runs that tool's CLI with the
3
- // same Node.js, so `npx aiinfra-tools sizer --help` works with nothing installed but Node 20+.
3
+ // same Node.js, so `npx aiinfra-tools sizer --help` works with nothing installed but Node 22+.
4
4
  import { spawnSync } from 'node:child_process';
5
5
  import fs from 'node:fs';
6
6
  import path from 'node:path';
@@ -12,17 +12,20 @@ export const TOOLS = {
12
12
  fleetscope: { file: 'fleetscope/tools/fleetscope.mjs', what: 'replay LLM traffic on a modelled hybrid GPU fleet; what-ifs and stress suites' },
13
13
  'fleetscope-plan': { file: 'fleetscope/tools/fleetscope-plan.mjs', what: 'capacity plans from FleetScope scenarios' },
14
14
  'live-twin': { file: 'fleetscope/tools/live-twin.mjs', what: 'forecast traffic from Prometheus and predict SLO breaches' },
15
+ agentic: { file: 'fleetscope/tools/agentic.mjs', what: 'agentic workload profiles from real agent traces: synthesize sessions, size GPUs (compute and KV working set)' },
15
16
  'convert-trace': { file: 'fleetscope/tools/convert-trace.mjs', what: 'convert public traces to FleetScope workloads' },
16
17
  'gpu-health': { file: 'gpu-health/tools/gpu-health.mjs', what: 'health checks, utilization and savings, fixes behind an approval queue' },
17
18
  ledger: { file: 'gpu-ledger/tools/ledger.mjs', what: 'GPU-hours and cost by org, team and person: useful, idle, lost; FOCUS export' },
19
+ 'harness-ledger': { file: 'harness-ledger/tools/harness-ledger.mjs', what: 'where agent harnesses (Claude Code, Codex, OTel, Langfuse) waste tokens, dollars and GPU time' },
18
20
  fleetops: { file: 'fleetops/tools/fleetops.mjs', what: 'shared data layer, root-cause analysis, incidents, tuning, power, admission, serving' },
19
21
  'workload-profile': { file: 'fleetops/tools/workload-profile.mjs', what: 'profile and synthesize application workloads (agents, chat, RAG…)' },
20
22
  'fix-skew': { file: 'hybrid-tracing/tools/fix-skew.mjs', what: 'estimate and remove clock skew from OTLP traces' },
21
23
  'skew-corrector': { file: 'hybrid-tracing/tools/skew-corrector.mjs', what: 'run the skew-corrector service' },
22
24
  mcp: { file: 'mcp/server.mjs', what: 'run every tool as an MCP server over stdio (for Claude, Cursor and other MCP clients)' },
23
25
  };
26
+ TOOLS.report = { file: 'bin/report.mjs', what: 'plan → verify → account on one page: sizer prediction, last shadow verdict, calibration, agent economics' };
24
27
  TOOLS.demo = { file: 'fleetops/tools/loop-demo.mjs', what: 'the whole loop on a real week of a GPU cluster: observe → diagnose → simulate → approve → optimize → verify' };
25
- const ALIASES = { 'inference-sizer': 'sizer', 'gpu-ledger': 'ledger', tracing: 'fix-skew', 'hybrid-tracing': 'fix-skew' };
28
+ const ALIASES = { 'inference-sizer': 'sizer', 'gpu-ledger': 'ledger', harness: 'harness-ledger', tracing: 'fix-skew', 'hybrid-tracing': 'fix-skew' };
26
29
  const version = () => JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8')).version;
27
30
 
28
31
  function help() {
package/bin/report.mjs ADDED
@@ -0,0 +1,177 @@
1
+ #!/usr/bin/env node
2
+ // aiinfra report: plan → verify → account on one page, from what the tools already keep.
3
+ //
4
+ // aiinfra report --store DIR --model M --gpu G [--harness PATH|demo] [--gpu-rate 3] [--days 30] [--outcomes F]
5
+ // [--tasks-per-day N] [--set k=v]… [--format text|md] [--json]
6
+ // aiinfra report --demo [--format md] the loop on demo data: a shadow test that corrects the sizer, then economics
7
+ //
8
+ // Plan the Inference Sizer's GPU count for the model on the GPU, before and after the store's calibration
9
+ // Verify the last shadow verdict (decision, metric effects, prediction vs measurement), the last promotion,
10
+ // and each canary's share and anything waiting for a person's approval
11
+ // Calibrate the efficiencies measured so far (<store>/calibration/sizer.json), and how far the sizer was off
12
+ // Account harness-ledger economics on an agent trace: cost per resolved task, self-hosting GPUs (calibrated),
13
+ // the break-even GPU-hour price, tokens per MW
14
+ //
15
+ // The report only reads. It runs each tool's --json command and the files fleetops writes under the store.
16
+ import { spawnSync } from 'node:child_process';
17
+ import fs from 'node:fs';
18
+ import os from 'node:os';
19
+ import path from 'node:path';
20
+ import { fileURLToPath } from 'node:url';
21
+
22
+ const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
23
+ const BIN = { sizer: 'inference-sizer/tools/size.mjs', fleetops: 'fleetops/tools/fleetops.mjs', 'harness-ledger': 'harness-ledger/tools/harness-ledger.mjs' };
24
+
25
+ function args(argv) {
26
+ const o = { set: [] };
27
+ for (let i = 0; i < argv.length; i++) {
28
+ const a = argv[i]; if (!a.startsWith('--')) continue;
29
+ const k = a.slice(2), n = argv[i + 1], v = n === undefined || n.startsWith('--') ? true : (i++, n);
30
+ if (k === 'set') o.set.push(v); else o[k] = v;
31
+ }
32
+ return o;
33
+ }
34
+ function run(tool, a) {
35
+ const r = spawnSync(process.execPath, [path.join(ROOT, BIN[tool]), ...a], { encoding: 'utf8', maxBuffer: 64 << 20 });
36
+ let j = null; try { j = JSON.parse(r.stdout); } catch { /* not JSON: reported below */ }
37
+ if (j && j.error) return { error: j.error };
38
+ if (!j) return { error: (r.stderr || r.stdout || `exit ${r.status}`).trim().split('\n').pop() };
39
+ return j;
40
+ }
41
+ const readJson = f => (fs.existsSync(f) ? JSON.parse(fs.readFileSync(f, 'utf8')) : null);
42
+ const readJsonl = f => (fs.existsSync(f) ? fs.readFileSync(f, 'utf8').split('\n').filter(l => l.trim()).map(l => JSON.parse(l)) : []);
43
+
44
+ // ---- gather ---------------------------------------------------------------------------------------------------------
45
+ export function gather(o) {
46
+ const store = path.resolve(o.store && o.store !== true ? o.store : 'fleet-data');
47
+ const calFile = path.join(store, 'calibration', 'sizer.json'), cal = readJson(calFile);
48
+ const keys = cal && cal.sizer ? Object.keys(cal.sizer) : [];
49
+ // the model and GPU: given, or the only one the store has calibrated
50
+ let model = o.model && o.model !== true ? o.model : null, gpu = o.gpu && o.gpu !== true ? o.gpu : null;
51
+ if ((!model || !gpu) && keys.length === 1) { const [g, m] = keys[0].split('|'); gpu = gpu || g; model = model || m; }
52
+ const out = { store, model, gpu, plan: null, verify: null, calibration: null, account: null, next: [] };
53
+
54
+ // Plan
55
+ if (model && gpu) {
56
+ const base = ['--model', model, '--gpu', gpu, ...o.set.flatMap(s => ['--set', s]), '--json'];
57
+ const sz = run('sizer', base), key = `${gpu}|${model}`, calibrated = cal && cal.sizer && cal.sizer[key] ? run('sizer', [...base, '--calibration', calFile]) : null;
58
+ const pick = r => (r && !r.error ? { found: r.found, mode: r.mode || null, gpus: r.gpus ?? null, provisionedGpus: r.provisionedGpus ?? null, nodes: r.nodes ?? null, costPerMOutputTokens: r.costPerMOutputTokens ?? null, targets: r.targets || null } : r ? { error: r.error } : null);
59
+ out.plan = { sizer: pick(sz), calibrated: pick(calibrated) };
60
+ } else out.next.push('give --model M --gpu G (Inference Sizer ids) to size the model');
61
+
62
+ // Verify
63
+ const sdir = path.join(store, 'shadow'), verdicts = readJsonl(path.join(sdir, 'verdicts.jsonl')), promoted = readJsonl(path.join(sdir, 'promoted.jsonl'));
64
+ const cdir = path.join(sdir, 'canaries');
65
+ const canaries = fs.existsSync(cdir) ? fs.readdirSync(cdir).filter(f => /\.json$/.test(f)).sort().map(f => readJson(path.join(cdir, f))).filter(s => s && s.kind === 'fleetops.llmd-canary')
66
+ .map(s => ({ name: s.name, status: s.status, share: s.status === 'rolled back' ? 0 : s.steps[s.step], steps: s.steps, baseline: s.baseline, candidate: s.candidate, awaitingApproval: s.pending && !s.pending.approvedBy ? { id: s.pending.id, toShare: s.steps[s.pending.toStep] } : null })) : [];
67
+ const last = verdicts.at(-1) || null;
68
+ out.verify = {
69
+ verdicts: verdicts.length,
70
+ last: last && { t: last.t, source: last.source || 'requests', baseline: last.baseline, candidate: last.candidate, decision: last.decision, why: last.why,
71
+ metrics: Object.fromEntries(Object.entries(last.metrics || {}).filter(([, m]) => m && m.verdict).map(([k, m]) => [k, { verdict: m.verdict, effect: Number.isFinite(m.effect) ? m.effect : null }])),
72
+ ...(last.prediction ? { prediction: last.prediction } : {}) },
73
+ ...(promoted.length ? { promoted: promoted.at(-1) } : {}), canaries };
74
+ if (!last) out.next.push(`no shadow verdict yet: fleetops shadow compare … --plan plan.json --store ${store} (or shadow prom)`);
75
+ for (const c of canaries) if (c.awaitingApproval) out.next.push(`canary ${c.name}: the step to ${c.awaitingApproval.toShare}% waits for a person: fleetops shadow canary approve --name ${c.name} --by NAME`);
76
+
77
+ // Calibration
78
+ out.calibration = { file: fs.existsSync(calFile) ? calFile : null,
79
+ entries: keys.map(k => { const e = cal.sizer[k]; return { key: k, effPrefill: e.effPrefill ?? null, effDecodeBW: e.effDecodeBW ?? null, effDecodeComp: e.effDecodeComp ?? null, source: e.source || null, fitOn: e.fitOn || null, t: e.t ?? null }; }) };
80
+ if (!keys.length) out.next.push('no calibration yet: a shadow test whose prediction is off by more than 15% writes one');
81
+
82
+ // Account
83
+ const h = o.harness && o.harness !== true ? o.harness : null;
84
+ if (h) {
85
+ const ea = [...(h === 'demo' ? ['--demo'] : [h]), '--days', String(o.days && o.days !== true ? o.days : 30), '--json'];
86
+ if (model && gpu) ea.push('--self-host-model', model, '--gpu', gpu);
87
+ if (cal && model && gpu && cal.sizer[`${gpu}|${model}`]) ea.push('--calibration', calFile);
88
+ for (const k of ['gpu-rate', 'outcomes', 'tasks-per-day']) if (o[k] && o[k] !== true) ea.push('--' + k, String(o[k]));
89
+ const e = run('harness-ledger', ['economics', ...ea]);
90
+ if (e.error) out.account = { error: e.error };
91
+ else {
92
+ const S = e.selfHost || null;
93
+ out.account = { harness: h, perResolvedTask: e.perResolved ? e.perResolved.costPerResolved ?? null : null, successRate: e.perResolved ? e.perResolved.successRate ?? null : null, monthly: e.volume ? e.volume.apiMonthly ?? null : null,
94
+ selfHost: S && { model: S.model, gpu: S.gpu, gpus: S.gpus ?? null, bound: S.bound || null, calibrated: S.calibrated || null, breakEvenGpuRate: S.breakEvenGpuRate ?? null, cheaper: S.cheaper || null,
95
+ kvOffload: S.offload ? { usable: !!S.offload.usable, gpus: S.offload.gpus ?? null, reloadMs: S.offload.reloadMs } : null,
96
+ tokensPerSecPerMW: S.power ? S.power.tokensPerSecPerMW ?? null : null, powerKW: S.power ? S.power.kw : null } };
97
+ }
98
+ } else out.next.push('add --harness PATH (an agent trace harness-ledger reads) for cost per resolved task and self-hosting');
99
+ return out;
100
+ }
101
+
102
+ // ---- render ---------------------------------------------------------------------------------------------------------
103
+ const pct = x => (x == null || !Number.isFinite(x) ? '–' : `${x >= 0 ? '+' : ''}${(100 * x).toFixed(1)}%`);
104
+ const money = x => (x == null || !Number.isFinite(x) ? '–' : x > 0 && x < 0.005 ? 'under $0.01' : x >= 100 ? '$' + Math.round(x).toLocaleString('en-US') : '$' + x.toFixed(2));
105
+ const when = t => (Number.isFinite(t) ? new Date(t * 1000).toISOString().slice(0, 16).replace('T', ' ') + ' UTC' : '');
106
+
107
+ export function render(r, { md = false } = {}) {
108
+ const L = [], H = s => L.push(md ? `\n## ${s}\n` : `\n${s.toUpperCase()}`), li = s => L.push(md ? `- ${s}` : ` ${s}`);
109
+ L.push(md ? `# AI infrastructure report${r.model ? `: ${r.model} on ${r.gpu}` : ''}` : `AI infrastructure report${r.model ? `: ${r.model} on ${r.gpu}` : ''}`);
110
+ L.push(md ? `\nStore \`${r.store}\`` : `store ${r.store}`);
111
+ H('Plan');
112
+ const P = r.plan;
113
+ if (!P) li('not sized (no model and GPU)');
114
+ else {
115
+ const s = P.sizer, c = P.calibrated;
116
+ if (s && s.error) li(`sizer: ${s.error}`);
117
+ else if (s) li(s.found ? `Inference Sizer: ${s.gpus} GPUs serving (${s.mode}), ${s.provisionedGpus} provisioned in ${s.nodes} nodes; ${money(s.costPerMOutputTokens)} per M output tokens at TTFT ${s.targets.ttftMs} ms / TPOT ${s.targets.tpotMs} ms` : 'Inference Sizer: no layout meets the targets');
118
+ if (c && !c.error) li(c.found ? `with measured efficiencies: ${c.gpus} GPUs serving, ${c.provisionedGpus} provisioned (${c.provisionedGpus === s.provisionedGpus ? 'no change' : `${c.provisionedGpus > s.provisionedGpus ? '+' : ''}${c.provisionedGpus - s.provisionedGpus}`}); ${money(c.costPerMOutputTokens)} per M output tokens` : 'with measured efficiencies: no layout meets the targets');
119
+ else if (c && c.error) li(`calibrated sizing: ${c.error}`);
120
+ else li('no calibration for this model and GPU yet: uncalibrated estimate');
121
+ }
122
+ H('Verify');
123
+ const V = r.verify;
124
+ if (!V.last) li('no shadow verdict yet');
125
+ else {
126
+ const v = V.last;
127
+ li(`last of ${V.verdicts} shadow verdict${V.verdicts > 1 ? 's' : ''} (${when(v.t)}, ${v.source}): **${v.decision}**: ${v.why}`.replace(/\*\*/g, md ? '**' : ''));
128
+ li(`${v.baseline} → ${v.candidate}: ` + (Object.entries(v.metrics).map(([k, m]) => `${k} ${pct(m.effect)} ${m.verdict}`).join(', ') || 'no metric judged'));
129
+ if (v.prediction) li(`prediction ${v.prediction.holds ? 'held' : 'was off'}: ` + v.prediction.rows.map(x => `${x.metric} predicted ${pct(x.predicted)}, measured ${pct(x.measured)}`).join('; '));
130
+ }
131
+ if (V.promoted) li(`last promotion ${when(V.promoted.t)}: ${V.promoted.label}${V.promoted.calibration ? ` (recalibrated ${V.promoted.calibration})` : ''}`);
132
+ for (const c of V.canaries) li(`canary ${c.name} (${c.baseline} → ${c.candidate}): ${c.status}, candidate at ${c.share}%${c.awaitingApproval ? `; step to ${c.awaitingApproval.toShare}% awaiting a person's approval` : ''}`);
133
+ H('Calibration');
134
+ const C = r.calibration;
135
+ if (!C.entries.length) li('none yet');
136
+ for (const e of C.entries) li(`${e.key}: prefill ${e.effPrefill}, decode bandwidth ${e.effDecodeBW}, decode compute ${e.effDecodeComp}${e.fitOn ? ` (${e.fitOn}${e.t ? ', ' + when(e.t) : ''})` : ''}`);
137
+ H('Account');
138
+ const A = r.account;
139
+ if (!A) li('no agent trace given (--harness)');
140
+ else if (A.error) li(`economics: ${A.error}`);
141
+ else {
142
+ li(`${money(A.perResolvedTask)} per resolved task at the API${A.successRate != null ? ` (${(100 * A.successRate).toFixed(0)}% resolved)` : ''}${A.monthly != null ? `, ${money(A.monthly)} a month` : ''}`);
143
+ const S = A.selfHost;
144
+ if (S) {
145
+ li(`self-hosting ${S.model} on ${S.gpu}: ${S.gpus ?? '–'} GPUs (bound by ${S.bound})${S.calibrated ? ', sized with the measured efficiencies' : ''}; cheaper per resolved task below ${money(S.breakEvenGpuRate)} a GPU-hour${S.cheaper ? ` (at the given rate: ${S.cheaper})` : ''}`);
146
+ if (S.kvOffload && S.kvOffload.usable && S.kvOffload.gpus != null && S.gpus != null && S.kvOffload.gpus < S.gpus) li(`KV offload to host memory would bring it to ${S.kvOffload.gpus} GPUs (reload ${S.kvOffload.reloadMs.toFixed(0)} ms)`);
147
+ if (S.tokensPerSecPerMW != null) li(`${Math.round(S.tokensPerSecPerMW).toLocaleString('en-US')} output tokens/s per MW at the peak minute (${S.powerKW.toFixed(0)} kW)`);
148
+ }
149
+ }
150
+ if (r.next.length) { H('Next'); for (const n of r.next) li(n); }
151
+ return L.join('\n').replace(/^\n/, '') + '\n';
152
+ }
153
+
154
+ // the loop on demo data, in a temporary store: shadow demo → plan (H100 → H200) → compare --plan (writes the calibration)
155
+ function demoStore() {
156
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'aiinfra-report-')), store = path.join(dir, 'store'), f = n => path.join(dir, n);
157
+ fs.writeFileSync(f('b.json'), JSON.stringify({ model: 'llama33-70b', gpu: 'H100', tp: 4 })); fs.writeFileSync(f('c.json'), JSON.stringify({ model: 'llama33-70b', gpu: 'H200', tp: 4 }));
158
+ for (const a of [['shadow', 'demo'], ['shadow', 'plan', '--baseline-config', f('b.json'), '--candidate-config', f('c.json'), '--baseline', 'variant=baseline', '--out', f('plan.json')],
159
+ ['shadow', 'compare', '--baseline', 'variant=baseline', '--candidate', 'variant=candidate', '--plan', f('plan.json')]]) {
160
+ const r = run('fleetops', [...a, '--store', store, '--json']); if (r.error) throw new Error(`demo: fleetops ${a.slice(0, 2).join(' ')}: ${r.error}`);
161
+ }
162
+ return store;
163
+ }
164
+
165
+ export function main(argv) {
166
+ const o = args(argv);
167
+ if (o.help) { process.stdout.write(fs.readFileSync(fileURLToPath(import.meta.url), 'utf8').split('\n').slice(1).filter(l => l.startsWith('//')).map(l => l.slice(3)).join('\n').split('\n\nThe report')[0] + '\n'); return 0; }
168
+ if (o.demo) { o.store = demoStore(); if (!o.harness) o.harness = 'demo'; if (!o['gpu-rate']) o['gpu-rate'] = '3'; }
169
+ const r = gather(o);
170
+ if (o.demo) { fs.rmSync(path.dirname(o.store), { recursive: true, force: true }); r.store = '(demo, removed)'; }
171
+ process.stdout.write(o.json ? JSON.stringify(r, null, 1) + '\n' : render(r, { md: o.format === 'md' }));
172
+ return 0;
173
+ }
174
+
175
+ if (process.argv[1] && fs.realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) {
176
+ try { process.exit(main(process.argv.slice(2))); } catch (e) { process.stderr.write('aiinfra report: ' + e.message + '\n'); process.exit(1); }
177
+ }
@@ -2,7 +2,7 @@
2
2
 
3
3
  The shared layer under the AIInfraTools utilities. It is one store of everything the fleet emits, which the other tools read and later steps build on. See [ROADMAP.md](../ROADMAP.md) for the plan: calibration, root-cause analysis and optimization are built on top of it.
4
4
 
5
- Plain JSON lines, no database, no dependencies beyond Node 20+.
5
+ Plain JSON lines, no database, no dependencies beyond Node 22+.
6
6
 
7
7
  ## The data layer
8
8
 
@@ -11,6 +11,7 @@ cd fleetops
11
11
  node tools/fleetops.mjs data import exporter dcgm-scrape.prom --store /var/lib/fleet-data # DCGM / AMD / SambaNova exporters
12
12
  node tools/fleetops.mjs data import vllm metrics.prom --before metrics-1h-ago.prom --pool chat-h200
13
13
  node tools/fleetops.mjs data import k8s-nodes nodes.json; node tools/fleetops.mjs data import k8s-pods pods.json
14
+ node tools/fleetops.mjs data import nvsentinel events.jsonl # NVSentinel health events (gpu-health defers to it)
14
15
  node tools/fleetops.mjs data import sacct sacct.txt # Slurm job outcomes
15
16
  node tools/fleetops.mjs data import git-log infra-git.log --repo infra # change feed from a GitOps repo
16
17
  node tools/fleetops.mjs data summary
@@ -96,6 +97,31 @@ On Philly's real job traces, the 10 flaky nodes found in the first half of a wee
96
97
 
97
98
  See [docs/ADMISSION.md](docs/ADMISSION.md).
98
99
 
100
+ ## Shadow upgrades: measure an infra change before it ships
101
+
102
+ `fleetops shadow` checks a change of GPUs, engine, config, networking, topology or serving layout against the baseline.
103
+ 1. `plan` predicts the effect with the Inference Sizer and sizes the test.
104
+ 2. `replay` sends the same recorded sessions to both endpoints at the same moments, and `answers` checks greedy outputs
105
+ match.
106
+ 3. `compare` judges TTFT, TPOT, end-to-end time, errors, cost per token and infra signals **at matched load**, each with
107
+ a confidence interval. The result is promote, roll back, extend the test, or recalibrate.
108
+
109
+ `baseline` and `watch` catch a service drifting from its own history. In the demo, a candidate 8% slower got lighter
110
+ traffic and looks 7.5% faster on a dashboard; the matched-load comparison finds +7.8% and rolls it back. See
111
+ [docs/SHADOW.md](docs/SHADOW.md).
112
+
113
+ It also works from a canary's own metrics and inside the rollout tools people already run:
114
+ - **`shadow prom`** reads vLLM's per-version metrics from Prometheus (llm-d controlled deployments, Argo Rollouts,
115
+ Flagger) and compares each canary window with the baseline at the same load per engine.
116
+ - **`shadow serve`** is that judge as a service: an Argo Rollouts analysis step (`POST /verdict`) or Flagger webhooks.
117
+ The manifests are in [deploy/shadow-gate/](deploy/shadow-gate/).
118
+ - [deploy/shadow-live/](deploy/shadow-live/) runs it all on three L4 nodes against real vLLM engines (not run yet).
119
+ - **`shadow canary`** steps an llm-d canary (two LLMInferenceServices in one routing group) by the judge's verdict:
120
+ - roll back at once;
121
+ - queue each step up for a person's approval.
122
+ - **With `--plan`**, a verdict whose prediction was off by more than 15% recalibrates the sizer. Planning, the Inference
123
+ Sizer and `harness-ledger economics` all read the result.
124
+
99
125
  ## Serving: what fits, what it carries, deploy it
100
126
 
101
127
  - **What fits:** `fleetops serving fit --gpu H100 --nodes 2 [--rate 5]` lists every catalog model with the load it carries on that hardware within the TTFT and TPOT targets (production and flat out), output tokens/s, $ per million tokens and the layout. With `--rate`, the models that carry it come first, largest first.
@@ -210,6 +236,12 @@ src/security.mjs tokens, roles, tenant scopes, redaction, egress allowli
210
236
  src/incidents.mjs lifecycle, paging, timeline page, postmortem draft, labels from confirmed causes
211
237
  src/traces.mjs spans → requests with stages; Kineto traces and step logs → per-rank steps
212
238
  tools/bench-scale.mjs ingest and 24 h root-cause benchmark
239
+ src/shadow.mjs shadow upgrades: plan, matched-load compare, verdicts, baselines and drift
240
+ src/shadow-replay.mjs paired replay to two OpenAI-compatible endpoints; greedy same-answers check
241
+ src/shadow-prom.mjs a canary's per-version vLLM metrics from Prometheus, judged at matched load
242
+ src/shadow-gate.mjs the judge for Argo Rollouts (web metric) and Flagger (webhooks)
243
+ src/shadow-canary.mjs an llm-d canary (LLMInferenceService route weights) stepped by the judge, steps up approved by a person
244
+ src/adapters/nvsentinel.mjs NVSentinel health events → log records; the nodes it is remediating
213
245
  src/optimize.mjs candidates, selection, staged rollout through gpu-health's queue, guards, rollback, verify
214
246
  tools/fleetops.mjs CLI
215
247
  tools/fetch-public-data.sh
@@ -0,0 +1,34 @@
1
+ # Argo Rollouts: the judge as an analysis step. Every 2 minutes the AnalysisRun asks the judge to compare the canary
2
+ # ReplicaSet with the stable one at matched load. "promote" passes, "rollback" fails the run (Argo aborts the rollout),
3
+ # "wait" (not settled yet) is inconclusive. Ten waits in a row leave the run Inconclusive and the rollout paused for a person.
4
+ apiVersion: argoproj.io/v1alpha1
5
+ kind: AnalysisTemplate
6
+ metadata: { name: fleetops-shadow-gate, namespace: llm }
7
+ spec:
8
+ args:
9
+ - name: stable-hash
10
+ - name: canary-hash
11
+ - name: select # what both versions share, as Prometheus label matchers
12
+ value: 'namespace="llm",app="chat"'
13
+ - name: lookback # seconds of canary traffic to judge
14
+ value: "900"
15
+ metrics:
16
+ - name: shadow-gate
17
+ interval: 2m
18
+ count: 10
19
+ successCondition: result == "promote"
20
+ failureCondition: result == "rollback"
21
+ failureLimit: 0
22
+ inconclusiveLimit: 9
23
+ consecutiveErrorLimit: 3 # the judge or Prometheus unreachable three times in a row fails the run
24
+ provider:
25
+ web:
26
+ method: POST
27
+ url: http://fleetops-shadow-gate.fleetops.svc:9410/verdict
28
+ timeoutSeconds: 60
29
+ jsonBody:
30
+ select: "{{args.select}}"
31
+ baseline: 'rollouts_pod_template_hash="{{args.stable-hash}}"'
32
+ candidate: 'rollouts_pod_template_hash="{{args.canary-hash}}"'
33
+ lookback: "{{args.lookback}}"
34
+ jsonPath: "{$.verdict}"
@@ -0,0 +1,38 @@
1
+ # A vLLM Rollout whose canary steps wait on the judge. Swap the image or args for the change you are testing (engine
2
+ # version, --max-num-seqs, quantization…). Traffic split here is by replica count (1 of 4 pods); with a traffic router
3
+ # (Gateway API, Istio…) use setWeight as usual.
4
+ apiVersion: argoproj.io/v1alpha1
5
+ kind: Rollout
6
+ metadata: { name: chat, namespace: llm }
7
+ spec:
8
+ replicas: 4
9
+ selector: { matchLabels: { app: chat } }
10
+ template:
11
+ metadata: { labels: { app: chat } }
12
+ spec:
13
+ containers:
14
+ - name: vllm
15
+ image: vllm/vllm-openai:v0.32.0
16
+ args: [--model, Qwen/Qwen2.5-1.5B-Instruct, --port, "8000"]
17
+ ports: [{ name: http, containerPort: 8000 }]
18
+ resources: { limits: { nvidia.com/gpu: 1 } }
19
+ strategy:
20
+ canary:
21
+ steps:
22
+ - setWeight: 25
23
+ - pause: { duration: 5m } # let the canary see traffic before judging
24
+ - analysis:
25
+ templates: [{ templateName: fleetops-shadow-gate }]
26
+ args:
27
+ - name: stable-hash
28
+ valueFrom: { podTemplateHashValue: Stable }
29
+ - name: canary-hash
30
+ valueFrom: { podTemplateHashValue: Latest }
31
+ - setWeight: 50
32
+ - analysis:
33
+ templates: [{ templateName: fleetops-shadow-gate }]
34
+ args:
35
+ - name: stable-hash
36
+ valueFrom: { podTemplateHashValue: Stable }
37
+ - name: canary-hash
38
+ valueFrom: { podTemplateHashValue: Latest }