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
@@ -1,5 +1,5 @@
1
1
  // What hardware is where and what it runs: versions for inventory records, and `topology` edges
2
- // { t, kind: nvlink|pcie|ib|rack|row|pdu|site, from, to, ...attrs }
2
+ // { t, kind: nvlink|xgmi|pcie|pcie-p2p|ib|rack|row|pdu|site, from, to, ...attrs }
3
3
  // Node names are plain (gpu-a01); devices are node/gpuN or node/mlx5_0; shared components are prefixed
4
4
  // (switch:leaf-01, rack:R12, pdu:P3, row:B, site:dc1).
5
5
  import { normPci } from './logs.mjs';
@@ -73,6 +73,58 @@ export function nvidiaTopo(text, { node, t = Math.floor(Date.now() / 1000) } = {
73
73
  return out;
74
74
  }
75
75
 
76
+ // amd-smi JSON: a list of per-GPU objects, or { "gpu_data": [...] } in newer releases; values may be { value, unit }.
77
+ const amdList = j => { const o = typeof j === 'string' ? JSON.parse(j) : j; const a = Array.isArray(o) ? o : (o && (o.gpu_data || o.gpus)) || []; return a.filter(x => x && typeof x === 'object' && x.gpu != null); };
78
+ const val = v => (v && typeof v === 'object' && 'value' in v ? v.value : v);
79
+ const known = v => { const x = val(v); return x == null || x === 'N/A' || x === '' ? undefined : x; };
80
+ const num = v => { const x = known(v); const n = typeof x === 'number' ? x : parseFloat(String(x ?? '')); return Number.isFinite(n) ? n : undefined; };
81
+ const PCIE_GEN = { 2.5: 1, 5: 2, 8: 3, 16: 4, 32: 5, 64: 6, 128: 7 };
82
+
83
+ // `amd-smi static --json` (or --asic --bus --vbios --driver --limit --json) → { inventory, pciMap }, the AMD
84
+ // counterpart of nvidiaSmiQ: product name, driver, IFWI (VBIOS) per GPU, PCI address → GPU index, power limit, PCIe max.
85
+ export function amdSmiStatic(json, { node, t = Math.floor(Date.now() / 1000), rocm } = {}) {
86
+ if (!node) throw new Error('amd-smi static output has no hostname: pass node');
87
+ const gpus = amdList(json).map(g => {
88
+ const a = g.asic || {}, b = g.bus || {}, fw = typeof g.ifwi === 'object' && g.ifwi ? g.ifwi : typeof g.vbios === 'object' && g.vbios ? g.vbios : {}, lim = g.limit || {}, brd = g.board || {};
89
+ const speed = num(b.max_pcie_speed);
90
+ const r = { gpu: String(g.gpu), pci: b.bdf && known(b.bdf) ? normPci(b.bdf) : undefined, sku: known(a.market_name) || known(brd.product_name), serial: known(a.asic_serial) || known(brd.product_serial),
91
+ vbios: known(fw.version) || known(fw.part_number), oamId: num(a.oam_id), gfx: known(a.target_graphics_version),
92
+ powerLimitW: num((lim.ppt0 || {}).socket_power_limit) ?? num(lim.socket_power) ?? num(lim.max_power),
93
+ pcieWidthMax: num(b.max_pcie_width), pcieGenMax: speed != null ? PCIE_GEN[speed] : undefined, driver: known((g.driver || {}).version) };
94
+ for (const k of Object.keys(r)) if (r[k] === undefined) delete r[k];
95
+ return r;
96
+ });
97
+ if (!gpus.length) throw new Error('no GPUs in the amd-smi output (expected `amd-smi static --json`)');
98
+ const versions = { driver: mostCommon(gpus.map(x => x.driver)), vbios: mostCommon(gpus.map(x => x.vbios)), ...(rocm ? { rocm } : {}) };
99
+ for (const k of Object.keys(versions)) if (!versions[k]) delete versions[k];
100
+ const mixed = ['vbios', 'driver'].filter(k => new Set(gpus.map(x => x[k]).filter(Boolean)).size > 1);
101
+ gpus.forEach(x => delete x.driver);
102
+ const inventory = { t, node, vendor: 'amd', kind: 'gpu', sku: mostCommon(gpus.map(x => x.sku)) || '', devices: gpus.length, versions, gpus, ...(mixed.length ? { mixedVersions: mixed } : {}), source: 'amd-smi' };
103
+ return { inventory, pciMap: Object.fromEntries(gpus.filter(x => x.pci).map(x => [x.pci, x.gpu])) };
104
+ }
105
+
106
+ // `amd-smi topology --json` → GPU↔GPU edges: kind xgmi (Infinity Fabric, the scale-up link) or pcie-p2p, with hops and
107
+ // weight. Reads both layouts amd-smi has shipped: per-GPU `links: [...]`, and the older per-field maps
108
+ // (link_type: { gpu_1: "XGMI" }, hops: { … }, weight: { … }).
109
+ export function amdSmiTopology(json, { node, t = Math.floor(Date.now() / 1000) } = {}) {
110
+ if (!node) throw new Error('amd-smi topology output has no hostname: pass node');
111
+ const out = [], seen = new Set();
112
+ const edge = (a, b, type, hops, weight, bw, status) => {
113
+ const T = String(type || '').toUpperCase();
114
+ if (a === b || T === 'SELF' || !T || T === 'N/A') return;
115
+ const key = [a, b].sort().join('|'); if (seen.has(key)) return; seen.add(key);
116
+ const r = { t, kind: T === 'XGMI' ? 'xgmi' : 'pcie-p2p', from: `${node}/gpu${a}`, to: `${node}/gpu${b}`, hops: num(hops), weight: num(weight), bandwidth: known(bw), enabled: status == null ? undefined : String(status).toUpperCase() === 'ENABLED', node, source: 'amd-smi-topology' };
117
+ for (const k of Object.keys(r)) if (r[k] === undefined) delete r[k];
118
+ out.push(r);
119
+ };
120
+ for (const g of amdList(json)) {
121
+ if (Array.isArray(g.links)) for (const l of g.links) edge(String(g.gpu), String(l.gpu), l.link_type, l.num_hops, l.weight, l.bandwidth, l.link_status);
122
+ else if (g.link_type && typeof g.link_type === 'object')
123
+ for (const [k, type] of Object.entries(g.link_type)) { const b = k.replace(/^gpu_/, ''); edge(String(g.gpu), b, type, (g.hops || {})[k], (g.weight || {})[k], (g.numa_bandwidth || {})[k], (g.link_accessibility || {})[k]); }
124
+ }
125
+ return out;
126
+ }
127
+
76
128
  // `ibnetdiscover` → host↔leaf and leaf↔spine edges. Host names are the first word of the node description
77
129
  // ("gpu-a01 mlx5_0"); switch names are their description ("leaf-01").
78
130
  export function ibnetdiscover(text, { t = Math.floor(Date.now() / 1000) } = {}) {
@@ -3,20 +3,21 @@
3
3
  // Checks (each pass, fail or missing):
4
4
  // burn-in hours under real load (device samples above burnInLoad) with no hard fault, no new uncorrectable ECC,
5
5
  // no pending row remap and temperatures within limits; or a burn-in check from tools/admit-node.sh
6
- // dcgm-diag `dcgmi diag -r 3` passed (check record from admit-node.sh)
6
+ // diag the vendor's GPU diagnostic passed: `dcgmi diag -r 3` on NVIDIA, ROCm Validation Suite on AMD
7
+ // (check record dcgm-diag or rvs-diag from admit-node.sh; `dcgm-diag` in a policy means this check)
7
8
  // sdc-canary tools/sdc-canary.py on every GPU, all agreeing with their peers / the golden values
8
9
  // nccl all-reduce bus bandwidth within ncclFrac of the same SKU's admitted nodes (or a reference)
9
- // topology as many GPUs, NVLink links and the same PCIe link as the same SKU's other nodes
10
- // versions driver, CUDA, firmware, VBIOS, NCCL, kernel equal to the fleet's baseline for the SKU
10
+ // topology as many GPUs, scale-up links (NVLink, XGMI) and the same PCIe link as the same SKU's other nodes
11
+ // versions driver, CUDA or ROCm, firmware, VBIOS/IFWI, NCCL or RCCL, kernel equal to the fleet's baseline for the SKU
11
12
  // Any fail rejects; otherwise anything missing leaves the node waiting (incomplete) with what to run.
13
+ import { medianUpper as median } from './stats.mjs';
12
14
  const H = 3600, DAY = 86400;
13
15
  export const ADMISSION_POLICY = {
14
16
  lookbackS: 3 * DAY, burnInS: 6 * H, burnInLoad: 0.5, maxTempC: 87, maxMemTempC: 95,
15
- require: ['burn-in', 'dcgm-diag', 'sdc-canary', 'nccl', 'topology', 'versions'],
17
+ require: ['burn-in', 'diag', 'sdc-canary', 'nccl', 'topology', 'versions'],
16
18
  ncclFrac: 0.9, ncclRef: {}, // { sku: GB/s } when the fleet has no admitted peers yet
17
- versionFields: ['driver', 'cuda', 'firmware', 'vbios', 'nccl', 'kernel'], golden: {}, // { sku: { driver: '…' } }
19
+ versionFields: ['driver', 'cuda', 'rocm', 'firmware', 'vbios', 'nccl', 'rccl', 'kernel'], golden: {}, // { sku: { driver: '…' } }
18
20
  };
19
- const median = a => { const s = a.filter(Number.isFinite).sort((x, y) => x - y); return s.length ? s[Math.floor(s.length / 2)] : NaN; };
20
21
  const mode = a => { const m = new Map(); for (const v of a) if (v != null) m.set(String(v), (m.get(String(v)) || 0) + 1); let b = null, n = 0; for (const [k, c] of m) if (c > n) { b = k; n = c; } return b; };
21
22
 
22
23
  function latestInventory(store, to) {
@@ -30,8 +31,8 @@ function latestInventory(store, to) {
30
31
  function lastAdmissions(store, to) { const m = new Map(); for (const a of store.query('admission', { to })) m.set(a.node, a); return m; }
31
32
 
32
33
  // Nodes that need the gate: new to the inventory, back from quarantine or repair, or changed by hand since admitted.
33
- export function pending(store, { now = Math.floor(Date.now() / 1000), policy = {} } = {}) {
34
- const P = Object.assign({}, ADMISSION_POLICY, policy), inv = latestInventory(store, now), adm = lastAdmissions(store, now), out = [];
34
+ export function pending(store, { now = Math.floor(Date.now() / 1000) } = {}) {
35
+ const inv = latestInventory(store, now), adm = lastAdmissions(store, now), out = [];
35
36
  const since = n => (adm.get(n) && adm.get(n).verdict === 'admit' ? adm.get(n).t : -Infinity);
36
37
  for (const [node, r] of inv) {
37
38
  const reasons = [];
@@ -43,8 +44,13 @@ export function pending(store, { now = Math.floor(Date.now() / 1000), policy = {
43
44
  return out.sort((a, b) => a.node.localeCompare(b.node));
44
45
  }
45
46
 
47
+ // diagnostics, scale-up links and the tools that produce them, per vendor
48
+ const DIAG = { nvidia: ['dcgm-diag', 'dcgmi diag -r 3'], amd: ['rvs-diag', 'the ROCm Validation Suite (rvs)'] };
49
+ const LINK = { nvidia: 'NVLink', amd: 'XGMI' };
46
50
  export function evaluate(store, node, { now = Math.floor(Date.now() / 1000), policy = {} } = {}) {
47
- const P = Object.assign({}, ADMISSION_POLICY, policy), from = now - P.lookbackS, inv = latestInventory(store, now), me = inv.get(node);
51
+ const P = Object.assign({}, ADMISSION_POLICY, policy);
52
+ P.require = [...new Set((P.require || []).map(r => (r === 'dcgm-diag' ? 'diag' : r)))];
53
+ const from = now - P.lookbackS, inv = latestInventory(store, now), me = inv.get(node);
48
54
  if (!me) throw new Error(`${node} is not in the inventory (import kubectl nodes, nvidia-smi or the admit-node.sh results first)`);
49
55
  const sku = me.sku, peers = [...inv.values()].filter(r => r.node !== node && r.sku === sku), adm = lastAdmissions(store, now);
50
56
  const admittedPeers = peers.filter(r => (adm.get(r.node) || {}).verdict === 'admit');
@@ -71,10 +77,11 @@ export function evaluate(store, node, { now = Math.floor(Date.now() / 1000), pol
71
77
  else if ((b.value || 0) < P.burnInS) add('burn-in', 'missing', `${((b.value || 0) / H).toFixed(1)} h of ${P.burnInS / H} h`, `tools/admit-node.sh --burn-in ${P.burnInS / H}h`);
72
78
  else add('burn-in', 'pass', `${(b.value / H).toFixed(1)} h${b.maxTempC ? `, max ${b.maxTempC}°C` : ''} (admit-node.sh)`);
73
79
  }
74
- // dcgm diag
75
- const d = chk('dcgm-diag').pop();
76
- if (!d) add('dcgm-diag', 'missing', 'no DCGM diagnostic in the window', 'tools/admit-node.sh (runs dcgmi diag -r 3)');
77
- else add('dcgm-diag', d.ok ? 'pass' : 'fail', d.detail || (d.ok ? 'level 3 passed' : 'failed'));
80
+ // the vendor's diagnostic (DCGM on NVIDIA, RVS on AMD; any `diag` check record counts)
81
+ const vendor = me.vendor || 'nvidia', [diagName, diagTool] = DIAG[vendor] || ['diag', "the vendor's GPU diagnostic"];
82
+ const d = ['dcgm-diag', 'rvs-diag', 'diag'].flatMap(chk).sort((a, b) => a.t - b.t).pop();
83
+ if (!d) add('diag', 'missing', `no ${diagName} result in the window`, `tools/admit-node.sh (runs ${diagTool})`);
84
+ else add('diag', d.ok ? 'pass' : 'fail', `${d.check}: ${d.detail || (d.ok ? 'passed' : 'failed')}`);
78
85
  // SDC canary on every GPU
79
86
  const can = store.query('sdc_check', { from, to: now, where: c => c.node === node && c.check === 'canary' });
80
87
  const gpusExpected = me.devices || median(peers.map(p => p.devices)) || null, gpusCovered = new Set(can.map(c => String(c.gpu))).size;
@@ -94,21 +101,22 @@ export function evaluate(store, node, { now = Math.floor(Date.now() / 1000), pol
94
101
  const seenGpus = new Set(dev.map(x => String(x.gpu))).size || (chk('gpu-count').pop() || {}).value || me.devices;
95
102
  const peerGpus = median(peers.map(p => p.devices));
96
103
  if (seenGpus != null && Number.isFinite(peerGpus) && seenGpus < peerGpus) topo.push(`${seenGpus} GPUs, the same SKU has ${peerGpus}`);
97
- const links = n => store.query('topology', { to: now, where: e => e.kind === 'nvlink' && String(e.from).startsWith(`${n}/`) }).length;
104
+ const linkWord = LINK[vendor] || 'scale-up';
105
+ const links = n => store.query('topology', { to: now, where: e => (e.kind === 'nvlink' || e.kind === 'xgmi') && e.enabled !== false && String(e.from).startsWith(`${n}/`) }).length;
98
106
  const myLinks = links(node), peerLinks = median(peers.map(p => links(p.node)).filter(x => x > 0));
99
- if (Number.isFinite(peerLinks) && myLinks < peerLinks) topo.push(`${myLinks} NVLink links, the same SKU has ${peerLinks}`);
107
+ if (Number.isFinite(peerLinks) && myLinks < peerLinks) topo.push(`${myLinks} ${linkWord} links, the same SKU has ${peerLinks}`);
100
108
  const pcie = chk('pcie').pop(), peerPcie = mode(store.query('check', { to: now, where: c => c.check === 'pcie' && peers.some(p => p.node === c.node) }).map(c => c.value));
101
109
  if (pcie && peerPcie && String(pcie.value) !== peerPcie) topo.push(`PCIe ${pcie.value}, the same SKU runs ${peerPcie}`);
102
110
  const anyTopo = seenGpus != null || myLinks > 0 || pcie;
103
111
  if (topo.length) add('topology', 'fail', topo.join('; '));
104
- else if (!anyTopo) add('topology', 'missing', 'no GPU count, NVLink or PCIe data', 'tools/admit-node.sh (nvidia-smi topo, nvlink, PCIe link)');
105
- else add('topology', 'pass', [seenGpus != null && `${seenGpus} GPUs`, myLinks && `${myLinks} NVLink links`, pcie && `PCIe ${pcie.value}`].filter(Boolean).join(', '));
112
+ else if (!anyTopo) add('topology', 'missing', `no GPU count, ${linkWord} or PCIe data`, `tools/admit-node.sh (${vendor === 'amd' ? 'amd-smi topology, PCIe link' : 'nvidia-smi topo, nvlink, PCIe link'})`);
113
+ else add('topology', 'pass', [seenGpus != null && `${seenGpus} GPUs`, myLinks && `${myLinks} ${linkWord} links`, pcie && `PCIe ${pcie.value}`].filter(Boolean).join(', '));
106
114
  // versions against the baseline: the policy's golden set, else what most of the same SKU's admitted (or all) nodes run
107
115
  const base = Object.assign({}, ...P.versionFields.map(f => { const g = (P.golden[sku] || {})[f]; const m = g ?? mode((admittedPeers.length ? admittedPeers : peers).map(p => p.versions[f])); return m != null ? { [f]: m } : {}; }));
108
116
  const mine = me.versions || {}, diff = Object.entries(base).filter(([f, v]) => mine[f] != null && String(mine[f]) !== String(v)), unknown = Object.keys(base).filter(f => mine[f] == null);
109
117
  if (!Object.keys(base).length) add('versions', 'missing', 'no baseline: no golden versions and no peers of the same SKU', `set golden.${sku} in the policy`);
110
118
  else if (diff.length) add('versions', 'fail', diff.map(([f, v]) => `${f} ${mine[f]}, baseline ${v}`).join('; '), 'align the versions (or roll the new one out with fleetops rollout, canary first)');
111
- else if (unknown.length === Object.keys(base).length) add('versions', 'missing', 'the node reports no versions', 'tools/admit-node.sh (records driver, CUDA, VBIOS, NCCL, kernel)');
119
+ else if (unknown.length === Object.keys(base).length) add('versions', 'missing', 'the node reports no versions', `tools/admit-node.sh (records ${vendor === 'amd' ? 'driver, ROCm, IFWI, RCCL' : 'driver, CUDA, VBIOS, NCCL'}, kernel)`);
112
120
  else add('versions', 'pass', Object.entries(base).filter(([f]) => mine[f] != null).map(([f, v]) => `${f} ${v}`).join(', '));
113
121
 
114
122
  const req = checks.filter(c => P.require.includes(c.name));
@@ -16,10 +16,11 @@ import { diagnose } from './rca.mjs';
16
16
  import { goodput } from './goodput.mjs';
17
17
  import { goodputHtml, goodputMarkdown } from './goodput-report.mjs';
18
18
  import { tune, tuneMarkdown } from './tune.mjs';
19
+ import { medianUpper } from './stats.mjs';
19
20
 
20
21
  const num = (v, d) => (v == null || v === '' ? d : Number(v));
21
22
  const time = v => (v == null || v === '' ? undefined : /^\d+(\.\d+)?$/.test(v) ? +v : Date.parse(v) / 1000);
22
- const median = a => { const s = a.slice().sort((x, y) => x - y); return s.length ? s[Math.floor(s.length / 2)] : null; };
23
+ const median = a => medianUpper(a, null);
23
24
  const AGG = { avg: a => a.reduce((t, v) => t + v, 0) / a.length, max: a => Math.max(...a), min: a => Math.min(...a), sum: a => a.reduce((t, v) => t + v, 0), count: a => a.length, p50: median, p99: a => a.slice().sort((x, y) => x - y)[Math.floor(0.99 * (a.length - 1))] };
24
25
 
25
26
  function jobMetaFor(store, recs, to) {
@@ -92,6 +92,9 @@ export function sniff(name, head) {
92
92
  const n = name.toLowerCase(), h = String(head).slice(0, 65536), t = h.trimStart();
93
93
  if (n.endsWith('manifest.json')) return null;
94
94
  if (/^\s*<\?xml[\s\S]{0,200}<nvidia_smi_log|^==============NVSMI LOG==============/m.test(h) || /\bProduct Name\s+:/.test(h) && /\bSerial Number\s+:/.test(h)) return 'nvidia-smi-q';
95
+ if (/"timeSeries"\s*:/.test(h) && /accelerator\/(duty_cycle|tensorcore_utilization|memory_used)/.test(h)) return 'cloud-monitoring';
96
+ if (/"market_name"\s*:/.test(h) && /"asic"\s*:/.test(h)) return 'amd-smi-static';
97
+ if (/"link_type"\s*:/.test(h) && /"(links|hops|num_hops)"\s*:/.test(h)) return 'amd-smi-topology';
95
98
  if (/\bGPU0\b/.test(h) && /Legend:/.test(h)) return 'nvidia-topo';
96
99
  if (/^(Switch|Ca)\s+\d+\s+"/m.test(h) || /vendid=0x/.test(h)) return 'ibnetdiscover';
97
100
  if (/^Errors for\s+0x[0-9a-f]+/im.test(h)) return 'ibqueryerrors';
@@ -9,12 +9,12 @@
9
9
  //
10
10
  // Profiles are plain JSON so FleetScope graphs and the sizer (`--calibration`) can read them without this package.
11
11
  import { createRequire } from 'node:module';
12
+ import { medianUpper as median } from './stats.mjs';
12
13
 
13
14
  const require = createRequire(import.meta.url);
14
15
  const E = require('../../fleetscope/src/engine.js'), Cal = require('../../fleetscope/src/calibrate.js'), TP = require('../../fleetscope/src/templates.js');
15
16
  const SM = require('../../inference-sizer/src/model.js'), SC = require('../../inference-sizer/src/catalog.js');
16
17
 
17
- const median = a => { const s = a.filter(Number.isFinite).sort((x, y) => x - y); return s.length ? s[Math.floor(s.length / 2)] : NaN; };
18
18
  const lookup = (k, s) => E.scaleTrace(E.genTrace(k, 7), s || 1, 7);
19
19
 
20
20
  // Benchmark model names → each tool's closest catalog model (same architecture).
@@ -9,8 +9,8 @@
9
9
  // incident window begins at the change, not at the alarm;
10
10
  // - incidents with overlapping windows and the same symptom (and pool) fold into one; others that overlap are linked.
11
11
 
12
- const median = a => { const s = a.filter(Number.isFinite).sort((x, y) => x - y); return s.length ? s[Math.floor(s.length / 2)] : NaN; };
13
12
  import { findSdc } from './sdc.mjs';
13
+ import { medianUpper as median } from './stats.mjs';
14
14
 
15
15
  const iso = t => new Date(t * 1000).toISOString().replace('.000Z', 'Z');
16
16
 
@@ -2,6 +2,7 @@
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import { toGpuHealthFaults } from './adapters/logs.mjs';
5
+ import { remediating } from './adapters/nvsentinel.mjs';
5
6
  import { findSdc, toGpuHealthResults } from './sdc.mjs';
6
7
 
7
8
  const jsonl = rows => rows.map(r => JSON.stringify(r)).join('\n') + (rows.length ? '\n' : '');
@@ -25,7 +26,10 @@ export function toGpuHealth(store, { from, to } = {}) {
25
26
  return Object.assign({ t: j.t, kind: 'job-end', job: j.job, status: j.status === 'ok' ? 'ok' : 'failed', cause: j.cause || 'unknown' }, d ? { node: d.node, gpu: String(d.gpu) } : {}, j.lostGpuHours != null ? { lostGpuHours: j.lostGpuHours } : {});
26
27
  });
27
28
  // device faults seen only in logs (dmesg XIDs, AER, AMD RAS) reach gpu-health as fault results
28
- results.push(...toGpuHealthFaults(store.query('log', { from, to })));
29
+ const logs = store.query('log', { from, to });
30
+ results.push(...toGpuHealthFaults(logs));
31
+ // nodes NVSentinel is remediating: gpu-health defers to it rather than queue its own repairs
32
+ for (const [k, r] of remediating(logs, { now: to ?? Infinity })) { const [node, gpu] = k.split('/'); results.push(Object.assign({ t: r.t, kind: 'external-remediation', node, by: r.by, action: r.action, check: r.check }, gpu != null ? { gpu } : {})); }
29
33
  // silent data corruption found in the store reaches gpu-health as sdc results (it quarantines with fault class sdc)
30
34
  results.push(...toGpuHealthResults(findSdc(store, { from, to })));
31
35
  return { samples, jobs: jobList, results };
@@ -95,11 +95,9 @@ function splitAttempt(a, steps, ideal, ckpts, now) {
95
95
  const extraCkpt = ckpts.filter(c => c.t > a.start && c.t <= end && !mine.some(s => s.ckpt > 0 && Math.abs(s.t1 - c.t) < 1)).reduce((t, c) => t + (c.saveS || 0), 0);
96
96
  const lastMark = marks.length ? marks[marks.length - 1] : -Infinity;
97
97
  const kept = s => !failed || s.t1 <= lastMark;
98
- let stepWall = 0;
99
98
  for (const s of mine) {
100
99
  const w = s.n * s.dur, ck = Math.min(s.ckpt, w), da = Math.min(s.data, w - ck), work = w - ck - da;
101
100
  const good = Math.min(work, ideal * s.n), slow = work - good;
102
- stepWall += w;
103
101
  out.checkpoint += ck;
104
102
  if (kept(s)) { out.productive += good; out['slow-steps'] += slow; out['data-stall'] += da; }
105
103
  else out['lost-work'] += good + slow + da;
@@ -8,12 +8,11 @@
8
8
  // Paging (PagerDuty Events v2, Opsgenie Alerts, or a JSON webhook) is a dry run unless --live: nothing is sent otherwise.
9
9
 
10
10
  import { checkEgress } from './security.mjs';
11
+ import { medianUpper as median } from './stats.mjs';
11
12
 
12
- export const STATES = ['open', 'acknowledged', 'mitigated', 'resolved'];
13
13
  const NEXT = { open: ['acknowledged', 'mitigated', 'resolved'], acknowledged: ['mitigated', 'resolved'], mitigated: ['resolved', 'acknowledged'], resolved: ['open'] };
14
14
  const EVENT_STATE = { opened: 'open', acknowledged: 'acknowledged', mitigated: 'mitigated', resolved: 'resolved', reopened: 'open' };
15
15
  const iso = t => new Date(t * 1000).toISOString().replace('.000Z', 'Z');
16
- const median = a => { const s = a.filter(Number.isFinite).sort((x, y) => x - y); return s.length ? s[Math.floor(s.length / 2)] : NaN; };
17
16
 
18
17
  // sev1 (worst) … sev4, from the symptom's size.
19
18
  export function severityOf(inc) {
@@ -92,7 +92,7 @@ export function otlpTracesToSpans(body) {
92
92
  for (const rs of body.resourceSpans || []) {
93
93
  const res = attrs((rs.resource || {}).attributes);
94
94
  for (const ss of rs.scopeSpans || []) for (const sp of ss.spans || []) {
95
- const t = nano(sp.startTimeUnixNano), end = nano(sp.endTimeUnixNano);
95
+ const t = nano(sp.startTimeUnixNano);
96
96
  if (t == null || !sp.traceId || !sp.spanId) continue;
97
97
  const a = attrs(sp.attributes);
98
98
  const durS = sp.endTimeUnixNano != null ? Number(BigInt(String(sp.endTimeUnixNano)) - BigInt(String(sp.startTimeUnixNano))) / 1e9 : null; // exact, from integer nanoseconds
@@ -11,7 +11,7 @@
11
11
  import { spawnSync } from 'node:child_process';
12
12
  import fs from 'node:fs';
13
13
 
14
- const NAME = /^[A-Za-z0-9][A-Za-z0-9._:\/@-]{0,252}$/, NUM = /^\d{1,10}$/, PCI = /^[0-9a-fA-F]{4}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}(\.\d)?$/, SET = /^[A-Za-z0-9._\/-]+=[A-Za-z0-9._:\/@,-]*$/;
14
+ const NAME = /^[A-Za-z0-9][A-Za-z0-9._:/@-]{0,252}$/, NUM = /^\d{1,10}$/, PCI = /^[0-9a-fA-F]{4}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}(\.\d)?$/, SET = /^[A-Za-z0-9._/-]+=[A-Za-z0-9._:/@,-]*$/;
15
15
 
16
16
  // fault → what it needs, what it runs, how to undo it, and the rule a correct diagnosis ranks first (null: measured
17
17
  // for detection only until the rule exists). DCGM field IDs: 230 XID, 311 DBE volatile total, 313 DBE aggregate total.
@@ -95,7 +95,7 @@ export function prepare(fault, params, { allow = [] } = {}) {
95
95
  }
96
96
 
97
97
  export const loadAllow = file => (file && fs.existsSync(file) ? fs.readFileSync(file, 'utf8').split(/\r?\n/).map(l => l.replace(/#.*/, '').trim()).filter(Boolean) : []);
98
- const sh = argv => argv.map(a => (/^[\w.\/:@=,-]+$/.test(a) ? a : `'${a.replace(/'/g, `'\\''`)}'`)).join(' ');
98
+ const sh = argv => argv.map(a => (/^[\w./:@=,-]+$/.test(a) ? a : `'${a.replace(/'/g, `'\\''`)}'`)).join(' ');
99
99
 
100
100
  // Run one prepared injection. runner(argv) → { status, stdout, stderr }; sleep(s) waits (both injectable for tests).
101
101
  export async function run(prep, { live = false, forS = 300, store, now = () => Date.now() / 1000, runner, sleep, log = console.log } = {}) {
@@ -17,8 +17,9 @@ import * as Inc from './incidents.mjs';
17
17
  import { goodput } from './goodput.mjs';
18
18
  import { agentState, decisions, paused, setPaused, AGENT_DEFAULTS } from './agent.mjs';
19
19
  import { can } from './security.mjs';
20
+ import { medianUpper } from './stats.mjs';
20
21
 
21
- const median = a => { const s = a.filter(Number.isFinite).sort((x, y) => x - y); return s.length ? s[Math.floor(s.length / 2)] : null; };
22
+ const median = a => medianUpper(a, null);
22
23
  const readJson = f => { try { return JSON.parse(fs.readFileSync(f, 'utf8')); } catch { return null; } };
23
24
  const readJsonl = (f, n = 200) => { try { return fs.readFileSync(f, 'utf8').trim().split('\n').filter(Boolean).slice(-n).map(l => JSON.parse(l)); } catch { return []; } };
24
25
 
@@ -6,11 +6,15 @@
6
6
  // a3ae49a (November 2026): DisaggregatedSet from LeaderWorkerSet ≥ 0.11.1 with enableDisaggregatedSet, the router
7
7
  // chart oci://ghcr.io/llm-d/charts/llm-d-router-standalone, InferencePool CRDs from the Gateway API Inference
8
8
  // Extension, pods selected by the label llm-d.ai/guide = the router's release name.
9
+ import { createRequire } from 'node:module';
10
+ const REG = createRequire(import.meta.url)('../../inference-sizer/src/accelerators.js');
11
+
9
12
  export const LLMD = {
10
13
  ref: 'llm-d/llm-d guides/pd-disaggregation @ a3ae49a',
11
14
  lwsVersion: '1.0.0', routerChart: 'oci://ghcr.io/llm-d/charts/llm-d-router-standalone', routerVersion: 'v0',
12
15
  sidecar: 'ghcr.io/llm-d/llm-d-router-disagg-sidecar:v1.0.0',
13
- vllm: { nvidia: 'docker.io/vllm/vllm-openai:v0.31.0', amd: 'docker.io/vllm/vllm-openai-rocm:v0.31.0' },
16
+ // the vLLM image the guide validates, per vendor (from the accelerator registry)
17
+ vllm: Object.fromEntries(Object.entries(REG.VENDORS).filter(([, v]) => v.images.llmdVllm).map(([k, v]) => [k, v.images.llmdVllm])),
14
18
  crds: { ds: 'disaggregatedsets.disaggregatedset.x-k8s.io', pool: 'inferencepools.inference.networking.k8s.io' },
15
19
  };
16
20
 
@@ -43,9 +47,9 @@ schedulingProfiles:
43
47
  `;
44
48
 
45
49
  // p: { name, namespace, model (served id), repo, vendor, gpuResource, image, hfSecret, hfSecretKey, maxLen, gpuMemoryUtilization,
46
- // kvDtype, prefill: { tp, replicas }, decode: { tp, replicas, maxNumSeqs }, cachePvc }
50
+ // kvBufferDevice, kvDtype, prefill: { tp, replicas }, decode: { tp, replicas, maxNumSeqs }, cachePvc }
47
51
  export function render(p) {
48
- const kv = role => JSON.stringify({ kv_connector: 'NixlConnector', kv_role: role, kv_buffer_device: p.vendor === 'amd' ? 'cpu' : 'cuda', kv_connector_extra_config: { backends: ['UCX'] } });
52
+ const kv = role => JSON.stringify({ kv_connector: 'NixlConnector', kv_role: role, kv_buffer_device: p.kvBufferDevice || (REG.VENDORS[p.vendor] || {}).kvBufferDevice || 'cuda', kv_connector_extra_config: { backends: ['UCX'] } });
49
53
  const labels = role => ({ 'llm-d.ai/inference-serving': 'true', 'llm-d.ai/guide': p.name, 'llm-d.ai/model': p.model, 'llm-d.ai/role': role, 'llm-d.ai/engine-type': 'vllm',
50
54
  app: p.name, 'fleetops.aiinfra/pool': p.name, 'gpu-health.aiinfra/serving': 'true' });
51
55
  const env = [{ name: 'VLLM_NIXL_SIDE_CHANNEL_HOST', valueFrom: { fieldRef: { fieldPath: 'status.podIP' } } }, { name: 'VLLM_HTTP_TIMEOUT_KEEP_ALIVE', value: '120' }, { name: 'HF_HOME', value: '/cache/huggingface' }, { name: 'VLLM_NO_USAGE_STATS', value: '1' }];
@@ -20,11 +20,11 @@ import { Store } from '../../gpu-health/src/actions.mjs';
20
20
  import { run as runAction, fill, SAFE } from '../../gpu-health/src/executors.mjs';
21
21
  import { toGpuHealth } from './export.mjs';
22
22
  import { checkEgress } from './security.mjs';
23
+ import { medianUpper as median } from './stats.mjs';
23
24
 
24
25
  const require = createRequire(import.meta.url);
25
26
  const E = require('../../fleetscope/src/engine.js'), FO = require('../../fleetscope/src/optimize.js');
26
27
  const RISK_W = { low: 1, medium: 0.8, high: 0.5 };
27
- const median = a => { const s = a.filter(Number.isFinite).sort((x, y) => x - y); return s.length ? s[Math.floor(s.length / 2)] : NaN; };
28
28
 
29
29
  // ---------- candidates ----------
30
30
 
@@ -9,12 +9,12 @@
9
9
  import { loadConfig as ghLoad } from '../../gpu-health/src/config.mjs';
10
10
  import { executorFor } from '../../gpu-health/src/vendors.mjs';
11
11
  import { fill } from '../../gpu-health/src/executors.mjs';
12
+ import { createRequire } from 'node:module';
13
+ const REG = createRequire(import.meta.url)('../../inference-sizer/src/accelerators.js');
12
14
 
13
15
  export const POWER_DEFAULTS = { binS: 300, gpuShare: 0.7, alphaCompute: 0.35, alphaMemory: 0.08, busy: 0.3, atLimit: 0.95, levels: [0.9, 0.8, 0.7, 0.6], minCapPct: 0.6, maxSlowdown: 0.05, pue: 1.3 };
14
- // board power (W) by GPU model, approximate spec-sheet figures, when the limit isn't exported
15
- const TDP = [[/GB200/i, 1200], [/B300/i, 1100], [/B200/i, 1000], [/H200/i, 700], [/H100.*PCIe/i, 350], [/H100|H800/i, 700], [/H20\b/i, 400], [/A100.*PCIe/i, 300], [/A100|A800/i, 400],
16
- [/L40S/i, 350], [/L4\b/i, 72], [/A10\b/i, 150], [/T4\b/i, 70], [/MI325X/i, 1000], [/MI300X/i, 750], [/MI250/i, 560], [/V100/i, 300]];
17
- export const tdpOf = sku => { for (const [re, w] of TDP) if (re.test(String(sku || ''))) return w; return null; };
16
+ // board power (W) by chip, from the shared accelerator registry, when the limit isn't exported
17
+ export const tdpOf = sku => REG.tdpOf(sku);
18
18
  const q = (a, p) => { const s = a.filter(Number.isFinite).sort((x, y) => x - y); return s.length ? s[Math.min(s.length - 1, Math.floor(p * (s.length - 1)))] : NaN; };
19
19
  const mean = a => { const x = a.filter(Number.isFinite); return x.length ? x.reduce((s, v) => s + v, 0) / x.length : NaN; };
20
20
 
@@ -101,8 +101,8 @@ export function predict(j, capW, { alphaCompute = POWER_DEFAULTS.alphaCompute, a
101
101
  }
102
102
 
103
103
  // ---------- fit α from clocks under different limits ----------
104
- export function fit(store, { from, to, opts = {} } = {}) {
105
- const O = Object.assign({}, POWER_DEFAULTS, opts), by = new Map();
104
+ export function fit(store, { from, to } = {}) {
105
+ const by = new Map();
106
106
  for (const d of store.query('device', { from, to, where: d => Number.isFinite(d.powerLimitW) && Number.isFinite(d.clockMHz) && (d.sm ?? d.tensor ?? 0) >= 0.5 })) {
107
107
  const k = `${d.node}|${d.gpu}`, L = Math.round(d.powerLimitW / 10) * 10; if (!by.has(k)) by.set(k, new Map()); const m = by.get(k); if (!m.has(L)) m.set(L, []); m.get(L).push(d);
108
108
  }
@@ -153,7 +153,7 @@ export function plan(store, { from, to, budgets = {}, saveKw = null, opts = {},
153
153
  for (const r of results) {
154
154
  const cs = caps.filter(c => c.group === r.group); if (!cs.length) continue;
155
155
  const cmd = (c, watts) => byNode(c).flatMap(([node, gpus]) => {
156
- const whole = gpus.length >= (devicesOf.get(node) || 8), t = executorFor(cfg, c.vendor, whole ? 'power-cap-node' : 'power-cap');
156
+ const whole = gpus.length >= (devicesOf.get(node) || 8), t = executorFor(cfg, c.vendor, whole ? 'power-cap-node' : 'power-cap', node);
157
157
  if (!Array.isArray(t)) return [];
158
158
  return whole ? t.map(a => fill(a, { node, watts })) : gpus.flatMap(gpu => t.map(a => fill(a, { node, gpu, watts })));
159
159
  });
@@ -0,0 +1,67 @@
1
+ // Procurement lookups: a GPU need (type, count, days) → the cloud's own read-only command that lists what can be
2
+ // bought, so a capacity plan ends in something to check rather than a number. Nothing here buys anything: purchases
3
+ // stay with a person, in the cloud's console or CLI.
4
+ //
5
+ // AWS EC2 Capacity Blocks for ML (docs.aws.amazon.com/AWSEC2/latest/UserGuide/capacity-blocks-purchase.html):
6
+ // `aws ec2 describe-capacity-block-offerings` with an instance type and count, a duration in 1-day steps up to
7
+ // 14 days and 7-day steps up to 182 days, and a date range to start in.
8
+ // GCP Dynamic Workload Scheduler calendar mode (future reservations of GPUs or TPUs, up to 90 days):
9
+ // `gcloud compute advice calendar-mode` recommends a start time and zone (docs.cloud.google.com/sdk/gcloud/reference/compute/advice/calendar-mode).
10
+ import { createRequire } from 'node:module';
11
+
12
+ const REG = createRequire(import.meta.url)('../../inference-sizer/src/accelerators.js');
13
+ const DAY = 86400;
14
+ const iso = s => new Date(s * 1000).toISOString().replace(/\.\d{3}Z$/, 'Z');
15
+
16
+ // instance types on a cloud that carry this chip, largest first
17
+ export function instancesFor(chip, cloud) {
18
+ const want = (REG.match(chip) || {}).id || chip;
19
+ return Object.entries(REG.INSTANCES).filter(([, v]) => v.cloud === cloud && ((REG.match(v.chip) || {}).id || v.chip) === want)
20
+ .map(([type, v]) => ({ type, gpus: v.gpus })).sort((a, b) => b.gpus - a.gpus);
21
+ }
22
+
23
+ // AWS Capacity Blocks: the describe command for `gpus` of `chip` (or an --instance-type) for `days`, starting within
24
+ // [from, from + windowDays]
25
+ export function awsCapacityBlocks({ chip, instanceType, gpus, days, from = Math.floor(Date.now() / 1000), windowDays = 14 }) {
26
+ if (!(gpus > 0) || !(days > 0)) throw new Error('need --gpus N and --days N');
27
+ const options = instanceType ? [{ type: instanceType, gpus: (REG.instanceOf(instanceType) || {}).gpus }] : instancesFor(chip, 'aws');
28
+ const pick = options.find(o => o.gpus >= 8) || options[0];
29
+ if (!pick || !pick.gpus) throw new Error(`no AWS instance type known for ${instanceType || chip}; known: ${[...new Set(Object.values(REG.INSTANCES).filter(v => v.cloud === 'aws').map(v => v.chip))].join(', ')}`);
30
+ const notes = [];
31
+ let d = Math.ceil(days);
32
+ if (d > 14) { const r = Math.ceil(d / 7) * 7; if (r !== d) notes.push(`Capacity Blocks longer than 14 days come in 7-day steps: asking for ${r} days instead of ${d}.`); d = r; }
33
+ if (d > 182) { notes.push('Capacity Blocks run at most 182 days: asking for 182.'); d = 182; }
34
+ const instances = Math.ceil(gpus / pick.gpus);
35
+ if (instances * pick.gpus > gpus) notes.push(`${instances} × ${pick.type} is ${instances * pick.gpus} GPUs (asked for ${gpus}).`);
36
+ if (/p6e-gb200/.test(pick.type)) notes.push('P6e-GB200 is sold as UltraServers: use --ultraserver-type u-p6e-gb200x36 or u-p6e-gb200x72 with --ultraserver-count instead.');
37
+ const argv = ['aws', 'ec2', 'describe-capacity-block-offerings', '--instance-type', pick.type, '--instance-count', String(instances),
38
+ '--capacity-duration-hours', String(d * 24), '--start-date-range', iso(from), '--end-date-range', iso(from + windowDays * DAY)];
39
+ notes.push('Read-only: it lists offerings and their upfront fee. Buying one (purchase-capacity-block) cannot be cancelled: a person does that.');
40
+ return { cloud: 'aws', instanceType: pick.type, gpusPerInstance: pick.gpus, instances, days: d, argv, notes };
41
+ }
42
+
43
+ // GCP calendar mode: the read-only `gcloud compute advice calendar-mode` for `gpus` GPUs (machine type and VM count)
44
+ // or TPU chips (TPU version and chip count) for `days`, starting within [from, from + windowDays]
45
+ const TPU_VERSION = { 'TPU-v5e': 'V5E', 'TPU-v5p': 'V5P', 'TPU-v6e': 'V6E' };
46
+ export function gcpCalendarMode({ chip, machineType, gpus, days, region, from = Math.floor(Date.now() / 1000), windowDays = 14, workload = 'BATCH' }) {
47
+ if (!(gpus > 0) || !(days > 0)) throw new Error('need --gpus N and --days N');
48
+ if (!region) throw new Error('need --region (e.g. us-central1)');
49
+ const notes = [], d = Math.min(Math.ceil(days), 90), day = s => iso(s).slice(0, 10);
50
+ if (days > 90) notes.push('Calendar mode reserves at most 90 days: asking for 90.');
51
+ const a = REG.match(chip || '') || {}, common = [`--region=${region}`, `--duration-range=min=${d}d,max=${d}d`, `--start-time-range=from=${day(from)},to=${day(from + windowDays * DAY)}`];
52
+ let argv;
53
+ if (a.kind === 'tpu') {
54
+ const v = TPU_VERSION[a.id];
55
+ if (!v) notes.push(`Check \`gcloud compute advice calendar-mode --help\` for the --tpu-version value of ${a.id}.`);
56
+ argv = ['gcloud', 'compute', 'advice', 'calendar-mode', `--tpu-version=${v || a.id.toUpperCase()}`, `--chip-count=${gpus}`, `--workload-type=${workload}`, ...common];
57
+ return { cloud: 'gcp', chip: a.id, chips: gpus, days: d, argv, notes: notes.concat(['Read-only: it recommends when and where the capacity is available. Creating the future reservation is a separate step a person takes.']) };
58
+ }
59
+ const options = machineType ? [{ type: machineType, gpus: (REG.instanceOf(machineType) || {}).gpus }] : instancesFor(chip, 'gcp');
60
+ const pick = options.find(o => o.gpus >= 8) || options[0];
61
+ if (!pick || !pick.gpus) throw new Error(`no GCP machine type known for ${machineType || chip}`);
62
+ const vms = Math.ceil(gpus / pick.gpus);
63
+ if (vms * pick.gpus > gpus) notes.push(`${vms} × ${pick.type} is ${vms * pick.gpus} GPUs (asked for ${gpus}).`);
64
+ argv = ['gcloud', 'compute', 'advice', 'calendar-mode', `--machine-type=${pick.type}`, `--vm-count=${vms}`, ...common];
65
+ notes.push('Read-only: it recommends when and where the capacity is available. Creating the future reservation is a separate step a person takes.');
66
+ return { cloud: 'gcp', machineType: pick.type, gpusPerVm: pick.gpus, vms, days: d, argv, notes };
67
+ }
@@ -17,9 +17,9 @@ import { groups } from './adapters/topology.mjs';
17
17
  import { growth, ERROR_COUNTERS, CONGESTION_COUNTERS } from './adapters/fabric.mjs';
18
18
  import { findSdc } from './sdc.mjs';
19
19
  import { DEVICE_CLASSES } from './adapters/logs.mjs';
20
+ import { medianUpper as median } from './stats.mjs';
20
21
 
21
22
  const H = 3600;
22
- const median = a => { const s = a.filter(Number.isFinite).sort((x, y) => x - y); return s.length ? s[Math.floor(s.length / 2)] : NaN; };
23
23
  const share = (counts, total) => [...counts.entries()].map(([k, n]) => ({ k, n, share: total ? n / total : 0 })).sort((a, b) => b.n - a.n);
24
24
  const count = (arr, f) => { const m = new Map(); for (const x of arr) for (const k of [].concat(f(x)).filter(v => v != null)) m.set(k, (m.get(k) || 0) + 1); return m; };
25
25
  const clamp01 = v => Math.max(0, Math.min(1, v));
@@ -8,6 +8,7 @@
8
8
  import { loadConfig as ghLoad } from '../../gpu-health/src/config.mjs';
9
9
  import { Store } from '../../gpu-health/src/actions.mjs';
10
10
  import { run as runAction, fill } from '../../gpu-health/src/executors.mjs';
11
+ import { median } from './stats.mjs';
11
12
 
12
13
  const H = 3600, DAY = 86400;
13
14
  export const ROLLOUT_POLICY = {
@@ -16,7 +17,6 @@ export const ROLLOUT_POLICY = {
16
17
  busbwDrop: 0.1, computeSlowdown: 0.05, ttftSlowdown: 0.1, minSamples: 20,
17
18
  appliedShare: 0.8, // share of a wave's nodes that must report the new version before judging it
18
19
  };
19
- const median = a => { const s = a.filter(Number.isFinite).sort((x, y) => x - y); return s.length ? (s.length % 2 ? s[(s.length - 1) / 2] : (s[s.length / 2 - 1] + s[s.length / 2]) / 2) : NaN; };
20
20
  const mode = a => { const m = new Map(); for (const v of a) if (v != null) m.set(String(v), (m.get(String(v)) || 0) + 1); let b = null, n = 0; for (const [k, c] of m) if (c > n) { b = k; n = c; } return b; };
21
21
  // P(X ≥ k) for X ~ Poisson(λ)
22
22
  export function poissonSf(k, lam) { if (k <= 0) return 1; let term = Math.exp(-lam), cdf = term; for (let i = 1; i < k; i++) { term *= lam / i; cdf += term; } return Math.max(0, 1 - cdf); }
@@ -24,10 +24,11 @@
24
24
  // step records may add loss, gradNorm (the rank's local gradient norm) and n (steps covered, for every-N-steps logs)
25
25
  // collective one NCCL operation (NCCL Inspector): { op, job?, node, rank?, gpu?, comm, nranks, sn?, bytes?, msgSize?, execS, busbw, algobw? }
26
26
  // port a switch or NIC port's counters (totals): { switch, port, symbolErrors?, linkRecovery?, linkDowned?, rcvErrors?, xmitDiscards?,
27
- // fecUncorrected?, xmitWait?, pfcPause?, ecnMarked?, cnpSent?, outOfBuffer?, rxBytes?, txBytes? } (src/adapters/fabric.mjs)
27
+ // fecUncorrected?, xmitWait?, pfcPause?, ecnMarked?, cnpSent?, outOfBuffer?, rxBytes?, txBytes?,
28
+ // EFA: rxDrops?, rdmaErrors?, unresponsiveRemote?, retransPkts?, retransTimeouts?, impairedConns?, efa? } (src/adapters/fabric.mjs)
28
29
  // storage I/O against one storage target over a window: { target, op: read|write|meta, node?, job?, ops?, bytes?, latMs?, windowS? }
29
30
  // inventory records may carry versions: { driver, cuda, vbios, inforom, firmware, kernel, os, runtime, kubelet, image }
30
- // check a node check before admission (tools/admit-node.sh): { node, check: dcgm-diag|nccl-allreduce|burn-in|pcie|gpu-count, ok?, value?, unit?, detail? }
31
+ // check a node check before admission (tools/admit-node.sh): { node, check: dcgm-diag|rvs-diag|nccl-allreduce|burn-in|pcie|gpu-count, ok?, value?, unit?, detail? }
31
32
  // admission a node's admission verdict: { node, verdict: admit|reject|incomplete, failed, missing, by? }
32
33
  // rollout a step of a version rollout: { id, event: applied|verified|rolled-back|halted, stage, field, version, nodes }
33
34
  // Later PRs add calibration, drift, incident and optimization records.
@@ -55,7 +55,7 @@ export function visible(tenant, kind, r, ctx = {}) {
55
55
  // Span attributes that carry request content are dropped; secrets in log lines are masked. Counted, never stored.
56
56
  const CONTENT_KEY = /(^|\.)(prompt|prompts|completion|completions|messages|input\.value|output\.value|input_messages|output_messages|content|body)(\.|$)|gen_ai\.(prompt|completion|input|output)|llm\.(prompts|input|output)|http\.(request|response)\.body/i;
57
57
  const SECRETS = [
58
- [/\bBearer\s+[A-Za-z0-9._~+\/=-]{12,}/g, 'Bearer [redacted]'],
58
+ [/\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/g, 'Bearer [redacted]'],
59
59
  [/\b(sk|pk|rk)-[A-Za-z0-9_-]{16,}\b/g, '[redacted-key]'],
60
60
  [/\bAKIA[0-9A-Z]{16}\b/g, '[redacted-aws-key]'],
61
61
  [/\bgh[pousr]_[A-Za-z0-9]{30,}\b/g, '[redacted-token]'],