aiinfra-tools 0.2.0 → 0.4.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 (160) hide show
  1. package/CHANGELOG.md +268 -0
  2. package/README.md +27 -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 +41 -0
  13. package/fleetops/deploy/shadow-live/kit.yaml +123 -0
  14. package/fleetops/deploy/shadow-live/load-canary.yaml +26 -0
  15. package/fleetops/deploy/shadow-live/run.sh +53 -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 +10 -3
  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 +32 -10
  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 +4 -0
  75. package/fleetscope/dist/index.html +1013 -28
  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 +29 -13
  84. package/fleetscope/src/index.src.html +15 -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 +299 -31
  137. package/inference-sizer/docs/ACCELERATORS.md +62 -0
  138. package/inference-sizer/docs/CATALOG.md +71 -0
  139. package/inference-sizer/docs/METHOD.md +1 -1
  140. package/inference-sizer/docs/VALIDATION-INFERENCEX.md +37 -0
  141. package/inference-sizer/package.json +4 -3
  142. package/inference-sizer/src/accelerators.js +194 -0
  143. package/inference-sizer/src/catalog.js +55 -22
  144. package/inference-sizer/src/fit-ui.js +1 -1
  145. package/inference-sizer/src/index.src.html +3 -0
  146. package/inference-sizer/src/model.js +45 -7
  147. package/inference-sizer/src/ui.js +1 -1
  148. package/inference-sizer/tools/validate-agentx.mjs +116 -0
  149. package/inference-sizer/tools/validate-inferencex.mjs +132 -0
  150. package/mcp/README.md +6 -1
  151. package/mcp/server.mjs +34 -0
  152. package/package.json +10 -6
  153. package/schemas/README.md +3 -0
  154. package/schemas/aiinfra.report.schema.json +474 -0
  155. package/schemas/commands.mjs +14 -0
  156. package/schemas/fleetops.shadow.canary.schema.json +96 -0
  157. package/schemas/fleetops.shadow.compare.schema.json +266 -0
  158. package/schemas/fleetops.shadow.prom.schema.json +354 -0
  159. package/schemas/harness-ledger.economics.schema.json +567 -0
  160. package/schemas/sizer.list.schema.json +15 -2
package/CHANGELOG.md CHANGED
@@ -3,6 +3,274 @@
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.4.0 (2026-11-29)
7
+
8
+ The services now deploy anywhere with one command, and the catalog is current. `deploy/cloud/up.sh` puts fleetops,
9
+ Grafana and the FleetScope and Inference Sizer pages on Google Cloud, AWS, Azure, a neocloud's Kubernetes, on-prem or a
10
+ single GPU server, and hybrid fleets send every site's GPU metrics to one hub. The sizer and FleetScope know the 2026
11
+ open-weight models and the attention they use, and Vera Rubin, MI455X and RTX PRO 6000. No `--json` output changed.
12
+
13
+ - **Deploy anywhere:** one Helm chart, `up.sh gcp | aws | azure | k8s | vm` and `down.sh`, Terraform for each cloud and
14
+ for existing clusters, container images for x86 and Arm (#83). See [docs/DEPLOY.md](docs/DEPLOY.md).
15
+ - **Hybrid fleets:** a site joins a hub with `--site NAME --hub URL`; fleetops records which site each record came from.
16
+ - **Models and hardware:** Kimi K3, DeepSeek V4, GLM-5.x, Qwen3.5 and 3.8, MiniMax M3, Gemma 4 and more; linear,
17
+ compressed and sparse attention in the sizer; a weekly task proposes catalog updates (#80).
18
+ - **AgentX validation** reads InferenceX's real model prefixes and GPU names (#81).
19
+ - **Not yet run on a real cloud:** CI installs a hub and a second site on a local kind cluster; the first GKE, EKS and AKS
20
+ runs will be recorded in [docs/RESULTS.md](docs/RESULTS.md).
21
+
22
+ ### New: deploy anywhere — clouds, neoclouds, on-prem and hybrid
23
+
24
+ - **One Helm chart** (`deploy/helm/aiinfratools`) for the service stack: fleetops, Grafana with the dashboard
25
+ provisioned, the FleetScope and Inference Sizer pages, and a collector (Prometheus in agent mode) that finds the GPU
26
+ exporters on the cluster and sends their series to fleetops. Hub mode runs everything; site mode runs only the
27
+ collector.
28
+ - **One command per target:** `deploy/cloud/up.sh gcp | aws | azure | k8s | vm` makes a GKE Autopilot, EKS Auto Mode or
29
+ AKS cluster when missing, or uses the cluster kubectl points at (neocloud, on-prem), or Docker on one machine.
30
+ `down.sh` removes it, the store's disk first so no cloud disk keeps billing. Google Cloud Shell has a button and a
31
+ walkthrough.
32
+ - **Hybrid fleets:** sites join a hub with `up.sh k8s|vm --site NAME --hub URL`; fleetops ingest takes a per-request
33
+ site from the `X-Fleetops-Site` header, so records say where they came from.
34
+ - **Terraform** for Google, AWS, Azure and existing clusters, through one shared module.
35
+ - **Images** for linux/amd64 and arm64 on GitHub's container registry, pushed from main and releases.
36
+ - **GPU model on any cloud:** fleetops' preflight reads it from GPU Feature Discovery, GKE's label or the instance type,
37
+ and the instance table now has Azure's ND H100/H200/MI300X v5, ND GB200 v6 and ND A100 v4 sizes.
38
+ - CI lints and renders the chart for every platform, validates the Terraform, and installs a hub and a second site on
39
+ kind to check that records arrive tagged by site. See [docs/DEPLOY.md](docs/DEPLOY.md).
40
+
41
+ ### New: models and hardware, current as of November 2026
42
+
43
+ - **Models:** Kimi K3 / K3.1 Pro, Kimi K2.6, DeepSeek-V4-Pro and V4-Flash, GLM-5.1 and GLM-5.3, Mistral Large 4,
44
+ Qwen3.5-397B and Qwen3.8 27B, MiniMax M3 and M2.7, Muse Spark Open and Gemma 4 31B join the Inference Sizer's catalog.
45
+ FleetScope's model menus now list the whole catalog, not five models.
46
+ - **Attention the sizer models:** linear-attention layers with a fixed state per sequence (`linFrac`, `linStateMB`),
47
+ compressed KV (`kvKeep`) and sparse attention (`sparseTopK`). Hugging Face configs with Gated DeltaNet layers or an
48
+ index top-k import with them. A model without these fields sizes exactly as before.
49
+ - **Hardware:** NVIDIA Vera Rubin NVL72, AMD Instinct MI455X (Helios) and NVIDIA RTX PRO 6000 Blackwell Server join the
50
+ accelerator registry, so they reach the sizer, FleetScope, fleetops' power model and telemetry matching.
51
+ - **AgentX validation reads InferenceX's own model prefixes** (`dsv4`, `kimik3.1`, `glm5.3`, `minimaxm3`, `musespark`,
52
+ `qwen3.5`, `gptoss`…), plus A100, Vera Rubin, MI455X and cloud-suffixed GPU names (`b200-nscale`). Models the sizer
53
+ can't size yet are counted as skipped, not read as a shorter prefix.
54
+ - **Kept current weekly:** `inference-sizer/docs/CATALOG.md` says where figures come from and how to add a model or a
55
+ chip, and lists what isn't in yet and why (Trainium3, TPU 8, DeepSeek V4.1 Flash). A weekly scheduled task follows it
56
+ and opens a pull request.
57
+
58
+ ### Fixed
59
+
60
+ - **Live test kit (`fleetops/deploy/shadow-live`):** the engines get 40 minutes to start instead of Kubernetes'
61
+ 10-minute default, which a first start on fresh GPU nodes (pulling the vLLM image, fetching the model) can pass. A
62
+ failed run writes `out/diag.txt` (pods, events, GPUs per node, engine logs) before cleaning up (#82).
63
+
64
+ ## 0.3.0 (2026-11-26)
65
+
66
+ The loop now covers what a change costs, not only whether it works. There is a new tool for agent harnesses
67
+ (harness-ledger), shadow tests run inside the rollout tools (Argo Rollouts, llm-d canaries), and `aiinfra report`
68
+ puts plan → verify → account on one page. Coverage reaches AMD, AWS and Cloud TPU through one accelerator registry.
69
+ Some `--json` output changed; see "Changed (`--json`)" below.
70
+
71
+ - **New tool: harness-ledger.** It finds where agent harnesses (Claude Code, Codex, OpenTelemetry, Langfuse) waste
72
+ model resources, and works out the cost per successful task and when self-hosting pays.
73
+ - **Shadow tests in the rollout path:** `fleetops shadow` measures a change against the baseline at matched load.
74
+ `shadow prom` judges a canary from its own vLLM metrics, `shadow serve` acts as an Argo Rollouts analysis, and
75
+ `shadow canary` steps llm-d route weights, with every step up waiting for a person's approval.
76
+ - **Agentic sizing from real traces:** FleetScope profiles agentic workloads from TraceLab, AgentX and Mooncake
77
+ traces. It sizes them by the KV working set, and now by KV offload to host memory and tokens per MW too.
78
+ - **Integrations:** OpenCost prices, NVSentinel health events (gpu-health defers to it), and measured calibration
79
+ that feeds back into the sizer and the economics.
80
+ - **One accelerator registry** covering NVIDIA, AMD and Cloud TPU, read by every tool, with EKS and EFA on AWS and GKE
81
+ on GCP.
82
+ - **For agents and scripts:** 20 MCP tools and 21 JSON Schemas for `--json` output.
83
+ - **Quality:** ESLint on every PR, a weekly check that the supported formats are current, and branch-coverage
84
+ floors of 80% (77% for fleetops).
85
+
86
+ ### Plan → verify → account, and what agents can call
87
+
88
+ - **`aiinfra report`:** one page from what the tools already keep in a fleetops store: the Inference Sizer's GPU count
89
+ before and after the store's calibration, the last shadow verdict with prediction against measurement, the last
90
+ promotion, each canary's share and any step waiting for a person's approval, and agent economics (cost per resolved
91
+ task, self-hosting sized with the calibration, tokens per MW). Text, Markdown or `--json`; `--demo` runs it on demo data.
92
+ It only reads. Shadow verdict records now keep the prediction rows so the report can show them.
93
+ - **KV offload in the sizing:** FleetScope's agentic sizing reports what LMCache-style offload to host memory would do:
94
+ 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
95
+ 8-GPU server), the PCIe reload time for a returning session, and PCIe load at the peak minute. `--kv-offload` (on
96
+ `harness-ledger economics` and `agentic.mjs size`) uses it when a reload fits the TTFT target and PCIe stays under 80%.
97
+ - **Tokens per megawatt** next to every agentic GPU count: peak output tokens/s over provisioned power, from published
98
+ node power, or the GPU's board power when none is published.
99
+ - **New `--json` contracts:** `fleetops.shadow.compare`, `fleetops.shadow.prom`, `fleetops.shadow.canary`,
100
+ `harness-ledger.economics` and `aiinfra.report`. `harness-ledger.economics` gains `offload`, `kvOffloadUsed` and
101
+ `power` under `selfHost`; `sizer.list` GPUs gain `tdpW`. Both changes add fields only.
102
+ - **MCP tools:** `shadow_verdict`, `canary_status`, `agent_economics` and `infra_report` (20 tools). None of them can
103
+ advance or approve a canary.
104
+
105
+ ### Code quality
106
+
107
+ - **fleetops CLI split:** `tools/fleetops.mjs` now only parses and dispatches. Each area's commands live in
108
+ `tools/cmd/<area>.mjs`, unchanged.
109
+ - **Branch coverage floors** go from 70% to 80% in every package except fleetops, which goes to 77%. New tests cover
110
+ the least-covered branches, mostly the command lines and their errors.
111
+ - **Fixed:** gpu-ledger read a time it couldn't parse as NaN instead of no time, so a CSV row with an unreadable start
112
+ was kept. Such a row is now dropped.
113
+
114
+ - **Lint gate:** ESLint recommended rules on every pull request (`eslint.config.mjs`, `.github/workflows/lint.yml`),
115
+ starting from zero findings.
116
+ - **Removed:**
117
+ - four exports nothing used (`STATES`, `slowRequests`, `NUM_FIELDS`, `knownPlatforms`, and the helper behind the last);
118
+ - 20 unused locals and imports;
119
+ - a no-op self-assignment in the sizer UI;
120
+ - nine needless regex escapes;
121
+ - a literal byte-order mark in a regex.
122
+ - **One copy of fleetops' statistics:** `fleetops/src/stats.mjs` replaces 11 copies of median, percentile and the seeded
123
+ generator. Each copy's exact behaviour is kept, so no result moved.
124
+ - **Weekly format check:** `scripts/check-formats.mjs` and `.github/workflows/formats.yml`.
125
+ - Its first run found that the Argo Rollouts schemas had been vendored from v1.9.3 while v1.10.2 is current. They are
126
+ refreshed; the manifests pass both.
127
+
128
+ ### Integrations, and the loop between the tools
129
+
130
+ - **OpenCost:** `harness-ledger economics --opencost FILE|URL` (its `/inferenceCost/total`) or `--opencost-prom URL` (its
131
+ `llm_cost_per_million_tokens` and `llm_cache_savings_fraction` gauges) uses OpenCost's measured self-host cost per token.
132
+ - The price per delivered input token is turned into a price per prefilled token.
133
+ - A deployment whose label join failed (zero cost) is explained, not used.
134
+ - **NVSentinel:** `fleetops data import nvsentinel` reads its health events: event-exporter CloudEvents, datastore
135
+ documents, HealthEventResource objects and bare events, with XIDs classified through gpu-health's table.
136
+ - Root-cause analysis uses them as evidence.
137
+ - gpu-health defers to NVSentinel on nodes it is remediating: one informational `external-remediation` action instead
138
+ of a second repair ladder (`deferToExternal: false` to turn this off).
139
+ - **llm-d canaries:** `fleetops shadow canary start|advance|approve|status` steps two LLMInferenceServices' route weights
140
+ by the judge's verdict.
141
+ - A rollback is written at once with `--live`.
142
+ - A step up is queued for a person and written only after `approve --by NAME`.
143
+ - Manifests and patches are checked against KServe's CRD schema (v1alpha2, vendored).
144
+ - **The loop:**
145
+ - `shadow plan` records its configs.
146
+ - `compare` and `prom` with `--plan` refit the candidate's sizer efficiencies when the prediction was off by more than
147
+ 15%, into `<store>/calibration/sizer.json`. `shadow plan`, `inference-sizer --calibration` and
148
+ `harness-ledger economics --calibration` read it.
149
+ - Promoted changes are recorded in `<store>/shadow/promoted.jsonl`.
150
+ - `shadow prom` takes `--plan` (prediction vs measurement, as `compare` does).
151
+ - **Recovered:** the agent unit economics work (`harness-ledger economics`, `validate-economics`) had been merged into a
152
+ feature branch instead of `main`; it is included here.
153
+
154
+ ### Shadow upgrades inside the rollout tools
155
+
156
+ - **`fleetops shadow prom`** judges a canary from its own per-version vLLM metrics in Prometheus (llm-d controlled
157
+ deployments' `llm_isvc_name`, Argo Rollouts' pod-template hash, Flagger's `app` label, or any label matchers).
158
+ - Each canary window is compared with what the baseline shows at the same load per engine, prompt length and cache
159
+ hit (a local fit on the baseline's own history), with an interval and a verdict. Per-version means are shown beside it.
160
+ - On synthetic canaries at half or a quarter of the baseline's load, the effect lands within 1 point of the truth
161
+ where per-version means say 20–33% faster.
162
+ - `--save` keeps the series; `--file` reruns them; `--demo` shows the trap.
163
+ - **`fleetops shadow serve`** runs the judge as a service for Argo Rollouts (an AnalysisTemplate web metric) and
164
+ Flagger (`rollout` and `confirm-promotion` webhooks): promote, rollback or wait.
165
+ - Manifests in `fleetops/deploy/shadow-gate/`, checked against the real CRD schemas (Argo Rollouts v1.10.2, Flagger
166
+ v1.45.0, Prometheus Operator v0.95.2).
167
+ - Selectors are checked as label matchers before any query is built.
168
+ - **`fleetops/deploy/shadow-live/`**: a kit that runs everything on three 1-GPU L4 nodes against real vLLM engines
169
+ (paired replay, an in-cluster canary, the judge). Not run yet.
170
+ - `shadow replay` takes `--max-isl` / `--max-osl` to fit long agent sessions to a small model's context.
171
+ - `compare`'s decision logic is shared (`decide`); with no latency data at all the decision is now *extend the test*,
172
+ not *promote*.
173
+
174
+ ### Agent unit economics
175
+
176
+ - **`harness-ledger economics`** reports what a successful agent task costs and what changing it is worth.
177
+ - **Cost per resolved task** and the share of spend on failed tasks.
178
+ - **Fixes ranked by what they save per resolved task:** each waste cause, plus a step cap computed exactly from each
179
+ session's calls.
180
+ - **Self-hosting vs the API:** the same workload sized with the Inference Sizer for an open model (FleetScope's agentic
181
+ path: real arrivals, cache reuse, the KV working set; busiest day's peak).
182
+ - The result is a break-even GPU-hour price per resolved task, and with `--gpu-rate` the volume from which
183
+ self-hosting wins.
184
+ - `--self-host-price` uses measured prices (OpenCost) instead.
185
+ - `--self-host-success-rate` and `--token-scale` (calls per task) carry the open model's quality and verbosity.
186
+ - **`validate-economics`** on TraceLab's workload with SWE-bench success rates (`docs/VALIDATION-ECONOMICS.md`; a CI job
187
+ in `validate.yml`).
188
+ - One team's volume (about $5,600 a month of API spend at Sonnet-class prices) favours the API: self-hosting pays only
189
+ below about $0.25–0.50 a GPU-hour.
190
+ - At $3 a GPU-hour on B200, self-hosting wins from about 8–16× that volume.
191
+ - Half the calls exceed the open models' 128k context.
192
+
193
+ ### Shadow upgrades
194
+
195
+ - **`fleetops shadow`** measures an infra change before it ships, against the baseline at matched load.
196
+ - **`plan`:** predicts the effect with the Inference Sizer and sizes the test.
197
+ - **`replay`:** the same recorded sessions to two OpenAI-compatible endpoints at the same moments, paired per
198
+ request, with session prefixes kept for the prefix cache. Dry run unless `--live`.
199
+ - **`answers`:** greedy tokens and log-probs compared on a prompt set.
200
+ - **`compare`:** stratified by calls in flight, prompt length and cache hit (or paired), with bootstrap intervals,
201
+ verdicts against gates, the naive number beside each, errors, tokens/s per GPU, $ per M tokens, infra signals, and
202
+ prediction vs measurement.
203
+ - **`baseline` / `watch`:** drift of a service against its own saved history.
204
+ - Design and architecture: `fleetops/docs/SHADOW.md`. Tested on synthetic arms and mock endpoints; not yet run against
205
+ live engines.
206
+
207
+ ### Agentic workloads from real traces
208
+
209
+ - **FleetScope agentic profiles** (`fleetscope/tools/agentic.mjs`, `aiinfra agentic`):
210
+ - fit a profile of how agent sessions behave from a real trace: TraceLab, AgentX "weka", Mooncake, harness-ledger
211
+ records or your own CSV/JSONL;
212
+ - generate sessions from a profile at any load;
213
+ - measure what a workload asks of a fleet: prefill after cache reuse, and the KV working set idle sessions hold;
214
+ - size GPUs for both compute and KV.
215
+
216
+ On TraceLab, a profile fitted on 70% of sessions matches the held-out 30% within 1–8% on cache hit, call rate, and
217
+ prefill and output rates. The KV working set comes out 28% low. Flat ISL/OSL sizing of the same calls asks for 440
218
+ GPUs where 40 do. Ingest reads AgentX, Mooncake and TraceLab traces, with prefix reuse computed from block hashes.
219
+ - **harness-ledger on real data:**
220
+ - TraceLab importer, streamed;
221
+ - `--prices relative`;
222
+ - a report on 8,058 real sessions: 22% of spend avoidable, mostly caches expiring in pauses.
223
+ - **harness-ledger outcomes:** cost per successful task, spend on failures, and what call caps would save. On SWE-bench
224
+ Verified across 11 models, 39% of spend goes to unresolved tasks, and caps save about 1% at no more than one point
225
+ of success lost.
226
+ - **Sizer against AgentX** (`inference-sizer/tools/validate-agentx.mjs`): scores and calibrates the sizer on AgentX
227
+ agentic results. It needs the results downloaded from InferenceX.
228
+ - Fix: price prefixes match only at a version boundary (`gpt-5` no longer prices `gpt-5.5`).
229
+
230
+ ### New tool: harness-ledger
231
+
232
+ - **Where agent harnesses waste model resources, across harnesses.** Importers for Claude Code transcripts, Codex
233
+ rollouts, OpenTelemetry GenAI and OpenInference spans, and Langfuse exports write one `llm_call` record per model
234
+ call, with token meanings normalized (cached tokens are part of input). Checks: prompt-cache misses and expiries,
235
+ unread cache writes, oversized tool output carried forward, repeated tool calls, retry loops, failed calls, unused
236
+ tool definitions, and routing calls on a large model (as candidates). Costs come from a price file, the harness's
237
+ recorded cost, or, for self-hosted models, GPU time joined from vLLM's request spans through gpu-ledger's rate card.
238
+ Cost per successful task with `--outcomes`. Records keep counts, names and hashes only.
239
+ `harness-ledger scan | report | import | demo`, HTML report, skill. Token accounting matches ccusage on its Codex
240
+ fixtures.
241
+
242
+ Vendor-neutral: the tools no longer assume NVIDIA.
243
+
244
+ ### New
245
+
246
+ - **One accelerator registry** (`inference-sizer/src/accelerators.js`), read by the sizer, FleetScope, the power model,
247
+ serving manifests and Kubernetes inventory; vendor adapters replace the NVIDIA-or-AMD branches. MI325X, MI355X and
248
+ GB300 NVL72 added. InferenceX validation covers 198 runs (#66).
249
+ - **GCP and Cloud TPU:**
250
+ - TPU v6e, v5p and TPU7x in the sizer.
251
+ - Serving on GKE TPUs: `vllm/vllm-tpu`, `google.com/tpu`, slice selected by accelerator and topology labels.
252
+ - GKE nodes give project, zone and instance, and scheduled host maintenance is a planned event.
253
+ - gpu-health `gke` and `gcp` platforms: GKE's `fault-behavior` label, `report-host-as-faulty` on Compute Engine.
254
+ - Cloud Monitoring accelerator metrics as telemetry.
255
+ - `gpu-ledger import gcp-billing`.
256
+ - `fleetops procure gcp-calendar`.
257
+ - **AWS:**
258
+ - EFA `hw_counters` read as fabric counters. Retransmits, timeouts and impaired connections count as congestion; RDMA errors as errors.
259
+ - EKS nodes give their instance, zone and GPU (from the instance type); the node monitoring agent's `AcceleratedHardwareReady` conditions become faults.
260
+ - gpu-health platforms: reboot and replace act on the EC2 instance; reseat is never proposed. `autoRepair` leaves both to EKS.
261
+ - `gpu-ledger import aws-cur`: GPU-hours priced at what the CUR says was billed.
262
+ - Capacity Blocks and spot in FleetScope's buy-vs-rent plan. `fleetops procure aws-blocks` prints the read-only lookup.
263
+ - **AMD at parity:**
264
+ - `amd-smi-static` and `amd-smi-topology` importers (inventory, IFWI, PCI → GPU map; XGMI links);
265
+ - `collect.sh` and `admit-node.sh` on AMD nodes (amd-smi, ROCm Validation Suite, rccl-tests);
266
+ - RCCL version and HIP error lines in job logs.
267
+
268
+ ### Changed (`--json`)
269
+
270
+ - `sizer list`: `nodeKW` is optional; `kind` and `vendorKey` added.
271
+ - `admit check`: the diagnostic check is named `diag` (was `dcgm-diag`). Its evidence names the record (`dcgm-diag` or
272
+ `rvs-diag`). A policy that still lists `dcgm-diag` in `require` keeps working.
273
+
6
274
  ## 0.2.0 (2026-11)
7
275
 
8
276
  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,9 +34,22 @@ 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
 
40
+ ## Deploy the services
41
+
42
+ fleetops, Grafana and the FleetScope and Inference Sizer pages, on Google Cloud, AWS, Azure, a neocloud's Kubernetes,
43
+ on-prem or a single GPU server, in one command; hybrid fleets send every site's GPU metrics to one hub. Terraform too.
44
+ See [docs/DEPLOY.md](docs/DEPLOY.md).
45
+
46
+ ```bash
47
+ deploy/cloud/up.sh gcp | aws | azure | k8s | vm # a hub
48
+ deploy/cloud/up.sh k8s --site onprem-sd --hub https://fleetops.example.com # a site joining it
49
+ ```
50
+
51
+ [![Open in Cloud Shell](https://gstatic.com/cloudssh/images/open-btn.svg)](https://shell.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fhardikashah-eng%2FAIInfraTools&cloudshell_tutorial=deploy%2Fcloud%2FTUTORIAL-gcp.md&shellonly=true)
52
+
39
53
  ## The loop in one command
40
54
 
41
55
  `aiinfra demo` runs Observe → Diagnose → Simulate → Approve → Optimize → Verify on one real week of the Microsoft
@@ -45,6 +59,15 @@ you to approve it. Then `aiinfra demo --continue DIR` rolls it out (dry run) and
45
59
  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
60
  your own data.
47
61
 
62
+ ## One page: plan → verify → account
63
+
64
+ `aiinfra report --store DIR --model M --gpu G --harness PATH` puts the loop on one page, from what the tools already
65
+ keep: the Inference Sizer's GPU count before and after the store's measured calibration, the last shadow verdict with
66
+ prediction against measurement, each canary's share and any step waiting for a person's approval, and what an agent
67
+ workload costs per resolved task at the API and self-hosted (with tokens per megawatt). `--format md` writes Markdown,
68
+ `--json` the [schema'd](schemas/aiinfra.report.schema.json) record; `aiinfra report --demo` runs it on demo data. It
69
+ only reads.
70
+
48
71
  ## Use with LLMs (skills)
49
72
 
50
73
  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 +79,7 @@ Each tool is also packaged as an [Agent Skill](https://agentskills.io/specificat
56
79
  | [hybrid-tracing](skills/hybrid-tracing/SKILL.md) | Clock-skew correction for traces, clock checks, and collector, chrony and PTP configs |
57
80
  | [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
81
  | [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 |
82
+ | [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
83
  | [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
84
 
61
85
  **MCP.** Every tool is also an MCP tool, for Claude Desktop, Cursor and any other MCP client:
@@ -74,7 +98,7 @@ On Claude Code 2.1.275 or later, this one step does both: `/plugin install aiinf
74
98
 
75
99
  **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
100
 
77
- All skills need Node.js 20+ and nothing else.
101
+ All skills need Node.js 22+ and nothing else.
78
102
 
79
103
  **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
104
 
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