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
@@ -0,0 +1,71 @@
1
+ # Keeping the model and hardware lists current
2
+
3
+ The Inference Sizer's catalog (`src/catalog.js`, `MODELS`) and the accelerator registry (`src/accelerators.js`) are
4
+ the lists behind every model and GPU menu in the repo:
5
+ - the Inference Sizer page and CLI;
6
+ - FleetScope's model menus, which take every catalog model FleetScope doesn't already have;
7
+ - harness-ledger's self-hosting economics;
8
+ - fleetops' power model and serving manifests.
9
+
10
+ They are refreshed weekly: a scheduled task looks for new open-weight models and inference chips and opens a pull
11
+ request against `main`. Anyone can do the same by hand with this checklist.
12
+
13
+ ## Where figures come from
14
+
15
+ Use these sources, most trusted first:
16
+
17
+ 1. The model's Hugging Face `config.json` and model card, or the vendor's spec page or datasheet.
18
+ 2. The model's technical report.
19
+ 3. Pages that reproduce the config with a link to it, such as SemiAnalysis InferenceX's model pages
20
+ (`inferencex.semianalysis.com/model/...`), Sebastian Raschka's LLM Architecture Gallery, or cloud model libraries.
21
+
22
+ Rules:
23
+
24
+ - **Name the source.** Put it in `source`, and say in the comment above the entry where any figure that isn't in the
25
+ config comes from.
26
+ - **Don't guess a missing figure.** Either leave the model out, or use the closest published figure and say so in the
27
+ comment. For example, GLM-5.3's active parameters aren't published, so the GLM-5 lineage's 40B is used, and the
28
+ comment says that.
29
+ - **Use dense chip figures.** Halve "with sparsity" numbers, and divide rack totals by the chip count. When a vendor
30
+ publishes no board power, give the reported figure and say it is reported, not a spec-sheet value.
31
+ - **Prices are placeholders,** not quotes.
32
+
33
+ ## Model fields beyond plain attention
34
+
35
+ | Field | Use it for | How to fill it |
36
+ | --- | --- | --- |
37
+ | `swaFrac`, `swaWindow` | Sliding-window layers (gpt-oss, Gemma, Muse Spark) | Share of layers that use a window, and the window in tokens |
38
+ | `linFrac`, `linStateMB` | Linear-attention layers (Kimi Delta Attention, Gated DeltaNet) | Share of such layers; state per layer per sequence = value heads × key dim × value dim × 4 bytes |
39
+ | `kvKeep` | Compressed attention (DeepSeek V4's CSA/HCA) | Average share of tokens whose KV is kept (V4: 1/4 and 1/128 on alternating layers ≈ 0.129) |
40
+ | `sparseTopK` | Sparse attention (DSA, GLM's IndexShare, MiniMax MSA, Mistral Large 4) | Tokens each query attends (the index top-k) |
41
+
42
+ A linear-attention layer holds a fixed state per sequence rather than KV per token. Its compute per token doesn't grow
43
+ with context. When a model mixes kinds that one entry can't hold exactly, size it on the kind that dominates at long
44
+ context and say what was approximated. For example, Gemma 4's sliding-window layers have more KV heads than its global
45
+ layers, but their KV is capped at the window, so the entry uses the global layers' heads.
46
+
47
+ `fromHFConfig` reads these from a config: `layer_types` with sliding or linear layers, `full_attention_interval`,
48
+ `linear_num_value_heads` and the linear head dims, and `index_topk`.
49
+
50
+ ## Checklist for an update
51
+
52
+ 1. **Models:** find open-weight releases since the last update (Hugging Face trending, the labs' release notes,
53
+ open-weight leaderboards) and their config values. Add each to `MODELS` with a stable `id`, and never rename an
54
+ existing id: saved inputs and FleetScope graphs refer to them.
55
+ 2. **Chips:** find announced or shipping accelerators with published memory, bandwidth and dense FLOPS. Add each to
56
+ `ACCELERATORS` (see [ACCELERATORS.md](ACCELERATORS.md)), with a `match` that doesn't catch other SKUs.
57
+ 3. **Tests:** add the new SKU names to `tests/accelerators.test.mjs`. Check any published KV-per-token figure in
58
+ `inference-sizer/tests/attention.test.mjs`.
59
+ 4. **Build and check:** run `npm run build` in `inference-sizer/` and `fleetscope/`. Then run `npm test` at the root,
60
+ in `inference-sizer/` and in `fleetscope/`. Run `node scripts/schemas.mjs --update` if `sizer list` output changed.
61
+ 5. **Changelog:** add a line under "Unreleased".
62
+
63
+ ## Not in the lists yet, and why
64
+
65
+ | Item | Why it isn't in yet |
66
+ | --- | --- |
67
+ | AWS Trainium3 | Needs a Neuron vendor adapter: Kubernetes resource, exporter, vLLM image and a gpu-health profile |
68
+ | Google TPU 8i / 8t | FP8, BF16 and ICI figures are unpublished, as is the GKE accelerator name |
69
+ | DeepSeek V4.1 Flash | Encoder-decoder with a separate Engram memory: not a shape the sizer models |
70
+ | Qwen3.8 2.4T-A95B, LongCat-2.5, Hunyuan Hy3, Inkling | Config values not found in a citable source yet |
71
+ | NVIDIA Rubin CPX | A prefill-only part: the sizer sizes one GPU type per deployment |
@@ -46,7 +46,7 @@ Engine assumptions, all editable on the page:
46
46
  - MoE models: TP attention with EP experts inside a domain, and wide EP with data-parallel attention across domains.
47
47
  - MLA models: data-parallel attention, because TP would replicate the latent KV cache.
48
48
  - Prefill: TP inside a domain, context parallel across domains.
49
- 3. **Memory.** Weights per GPU follow the layout. With DP attention, the dense weights are replicated. KV per token is `2 × layers × kvHeads × headDim × bytes`, or `(latent + rope) × layers × bytes` for MLA; sliding-window layers store only the window. KV is replicated when TP exceeds the KV-head count.
49
+ 3. **Memory.** Weights per GPU follow the layout. With DP attention, the dense weights are replicated. KV per token is `2 × layers × kvHeads × headDim × bytes`, or `(latent + rope) × layers × bytes` for MLA; sliding-window layers store only the window. Linear-attention layers (Kimi Delta Attention, Gated DeltaNet) store a fixed state per sequence instead. Compressed attention keeps a share of the tokens (`kvKeep`). Sparse attention attends at most `sparseTopK` tokens per query, which caps attention compute but not KV (see [CATALOG.md](CATALOG.md)). KV is replicated when TP exceeds the KV-head count.
50
50
  4. **Decode step.** `max(HBM read time, compute time) + collectives + overhead`. The HBM read covers the weights, but only the experts the batch actually routes to, which is `1 − (1 − topk/experts)^B` of them, plus every stream's KV at the average context. Compute covers the linear layers at the weight precision's tensor rate and attention at BF16. Collectives are TP all-reduce or EP all-to-all over NVLink inside a domain, and over the NIC across domains. The largest batch whose step fits the TPOT target, less the margin, sets streams per instance.
51
51
  5. **Prefill.** `2 × active params × prompt tokens` plus causal attention (sliding-window aware), at the prefill MFU and floored by one read of the weights. Short prompts batch up to 8,192 tokens. Queueing is M/D/1: utilisation is capped so that the average prompt's service time plus its wait meets TTFT. The peak prompt must meet TTFT on an idle instance. In disaggregated mode, the KV transfer to decode (over RDMA) counts against TTFT.
52
52
  6. **Aggregated mode.** Each step carries the decode batch plus a prefill chunk sized so the step stays within TPOT. Prompts drain at that chunk rate, which sets TTFT.
@@ -0,0 +1,37 @@
1
+ # Inference Sizer against InferenceX
2
+
3
+ Generated by `node inference-sizer/tools/validate-inferencex.mjs --markdown`. Data: 198 measured runs (aggregated, one node) of DeepSeek-R1 on MI355X, B200, MI325X, H200, MI300X, B300, from a snapshot of the [InferenceX](https://github.com/SemiAnalysisAI/InferenceX) public API (runs dated 2025-11-02 to 2026-06-11; [snapshot](https://github.com/SemiAnalysisAI/InferenceX-app/blob/187628924b6ec899b1f3f771617655dd4cd61d8c/packages/app/cypress/fixtures/api/benchmarks.json), SHA-256 `f46823a76cb63248…`). For each run the sizer predicts the same layout (TP, DP-attention) at the same concurrency, input and output lengths and precision.
4
+
5
+ Error is how far off the prediction is either way, as a ratio: 40% means 1.4× too high or 1.4× too low. "Predicted ÷ measured" says which way: for TPOT, below 1 means the sizer predicts faster tokens than were measured; for throughput, above 1 means it predicts more than was measured. Both are the optimistic direction.
6
+
7
+ ## Overall
8
+
9
+ | | Runs | TPOT: median error | p90 | median predicted ÷ measured | Output tok/s per GPU: median error | p90 | median predicted ÷ measured |
10
+ | --- | --- | --- | --- | --- | --- | --- | --- |
11
+ | Datasheet roofline (100% of spec, no overhead) | 198 | 141% | 263% | 0.41× | 148% | 279% | 2.48× |
12
+ | Sizer defaults | 198 | 46% | 116% | 0.70× | 47% | 128% | 1.47× |
13
+ | Sizer defaults, held-out runs only | 128 | 51% | 122% | 0.68× | 53% | 133% | 1.53× |
14
+ | **Calibrated per GPU on 1k/1k, scored on 8k/1k and 1k/8k** | 128 | 17% | 79% | 1.04× | 18% | 75% | 0.95× |
15
+ | Calibrated, on the runs it was fitted to | 70 | 9% | 32% | 1.02× | 8% | 33% | 1.03× |
16
+
17
+ ## By GPU (sizer defaults; calibrated on held-out runs)
18
+
19
+ | GPU | Runs | Defaults: TPOT error | Defaults: tok/s error | Defaults: tok/s predicted ÷ measured | Calibrated (held out): TPOT error | Calibrated: tok/s error | Fitted efficiencies (decode BW, decode compute, step ms, prefill) |
20
+ | --- | --- | --- | --- | --- | --- | --- | --- |
21
+ | MI355X | 58 | 35% | 45% | 1.44× | 38% | 35% | 0.9, 0.02, 6, 0.03 |
22
+ | B200 | 60 | 39% | 43% | 1.41× | 14% | 16% | 0.6, 0.08, 4.5, 0.05 |
23
+ | MI325X | 15 | 89% | 97% | 1.97× | 25% | 20% | 0.8, 0.02, 10, 0.08 |
24
+ | H200 | 30 | 22% | 19% | 1.16× | 12% | 14% | 0.8, 0.15, 6, 0.05 |
25
+ | MI300X | 15 | 90% | 99% | 1.99× | 14% | 11% | 0.7, 0.02, 10, 0.03 |
26
+ | B300 | 20 | 37% | 42% | 1.42× | 6% | 7% | 0.7, 0.06, 4.5, 0.08 |
27
+
28
+ ## By framework and concurrency (sizer defaults)
29
+
30
+ | | Runs | TPOT error | tok/s error | tok/s predicted ÷ measured |
31
+ | --- | --- | --- | --- | --- |
32
+ | sglang | 123 | 50% | 54% | 1.54× |
33
+ | trt | 45 | 37% | 39% | 1.36× |
34
+ | atom | 30 | 39% | 45% | 1.32× |
35
+ | concurrency 1–8 | 77 | 70% | 75% | 1.75× |
36
+ | concurrency 16–32 | 58 | 22% | 29% | 1.28× |
37
+ | concurrency 64– | 63 | 33% | 43% | 1.40× |
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "inference-sizer",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "license": "Apache-2.0",
5
5
  "private": true,
6
6
  "description": "Size a GPU fleet for LLM serving: GPUs, layout and cost to meet TTFT/TPOT targets. Exports to FleetScope.",
7
7
  "scripts": {
8
8
  "build": "node build.mjs",
9
9
  "test": "node --test tests/*.test.mjs",
10
- "size": "node tools/size.mjs"
10
+ "size": "node tools/size.mjs",
11
+ "test:coverage": "node --test --experimental-test-coverage --test-coverage-exclude='tests/**' --test-coverage-exclude='../**' --test-coverage-lines=88 --test-coverage-branches=80 tests/*.test.mjs"
11
12
  },
12
13
  "engines": {
13
- "node": ">=20"
14
+ "node": ">=22"
14
15
  }
15
16
  }
@@ -0,0 +1,194 @@
1
+ /* The accelerator registry: every chip the tools know, in one place, and what each vendor's stack needs.
2
+ The Inference Sizer's catalog, FleetScope's GPU table, fleetops' power model and serving manifests all read it, so a
3
+ new chip or vendor is one edit here (plus a gpu-health vendor profile if its exporter is new).
4
+
5
+ ACCELERATORS chips with full spec-sheet figures, usable for sizing and simulation
6
+ id, label, vendor (display), vendorKey (key into VENDORS and gpu-health's vendor profiles), kind (gpu | tpu | …)
7
+ hbmGB, hbmTBs, tfBf16, tfFp8, tfFp4 per chip, dense (sparsity figures halved; rack or system totals divided)
8
+ scaleUpGBs chip-to-chip link, per direction (NVLink, Infinity Fabric, ICI); domain: chips per scale-up domain
9
+ nicGbps scale-out network per chip; nodeKW: max power per domain where the vendor publishes it
10
+ tdpW board power on the spec sheet (TBP/TDP; none for cloud-only chips that don't publish it); match: regex
11
+ for the SKU names telemetry, Kubernetes labels and bills report
12
+ gkeAccelerator GKE's cloud.google.com/gke-tpu-accelerator value, for TPU node selectors
13
+ price, onprem placeholder $/chip-hour (rent, and amortized on-prem cost for FleetScope), not quotes
14
+ short FleetScope's key and short label, where it differs from id; source: spec sheet URL
15
+ OTHER_SKUS chips seen in telemetry but not sized (only power and vendor): id, vendorKey, kind, tdpW, match
16
+ VENDORS per vendor: Kubernetes resource and labels, telemetry tools, collective library, serving images
17
+ INSTANCES cloud instance types → { cloud, chip (registry id or SKU), gpus }, for bills and node labels
18
+
19
+ Order matters for match: more specific names first (GB200 before B200, H100 PCIe before H100). */
20
+ (function (root) {
21
+ 'use strict';
22
+
23
+ const VENDORS = {
24
+ nvidia: {
25
+ name: 'NVIDIA', kind: 'gpu', k8sResource: 'nvidia.com/gpu', productLabels: ['nvidia.com/gpu.product', 'cloud.google.com/gke-accelerator'],
26
+ smi: 'nvidia-smi', exporter: 'dcgm-exporter', collectives: 'NCCL', kvBufferDevice: 'cuda',
27
+ images: { vllm: 'vllm/vllm-openai', llmdVllm: 'docker.io/vllm/vllm-openai:v0.31.0' },
28
+ },
29
+ amd: {
30
+ name: 'AMD', kind: 'gpu', k8sResource: 'amd.com/gpu', productLabels: ['amd.com/gpu.product-name'],
31
+ smi: 'amd-smi', exporter: 'device-metrics-exporter', collectives: 'RCCL',
32
+ // NIXL's UCX path on ROCm stages the KV cache through host memory in llm-d's P/D guide
33
+ kvBufferDevice: 'cpu',
34
+ images: { vllm: 'rocm/vllm', llmdVllm: 'docker.io/vllm/vllm-openai-rocm:v0.31.0' },
35
+ },
36
+ // Cloud TPU on GKE: chips requested as google.com/tpu, the slice chosen by accelerator and topology node labels.
37
+ // vLLM on TPU: the vllm/vllm-tpu image (GKE's Trillium tutorial). No llm-d P/D image validated for TPU here.
38
+ tpu: {
39
+ name: 'Google Cloud TPU', kind: 'tpu', k8sResource: 'google.com/tpu', productLabels: ['cloud.google.com/gke-tpu-accelerator'],
40
+ topologyLabel: 'cloud.google.com/gke-tpu-topology', smi: 'tpu-info', exporter: 'Cloud Monitoring (accelerator metrics) or libtpu', collectives: 'XLA collectives over ICI',
41
+ images: { vllm: 'vllm/vllm-tpu' },
42
+ },
43
+ };
44
+
45
+ const A = (o) => Object.assign({ kind: 'gpu', tfFp4: 0 }, o);
46
+ const ACCELERATORS = [
47
+ // Vera Rubin NVL72 (VR200; first called NVL144 for its 144 dies): per Rubin package, 288 GB HBM4 at 22 TB/s; dense
48
+ // NVFP4 35 PF (the 50 PF inference figure uses adaptive compression), FP8 17.5 PF, BF16 4 PF; NVLink 6 3.6 TB/s
49
+ // bidirectional; ConnectX-9 1.6 Tb/s. NVIDIA publishes no board power: 2.3 kW is the reported Max-P TGP.
50
+ A({ id: 'VR200-NVL72', short: 'VR200', label: 'NVIDIA Vera Rubin NVL72 (72-GPU rack)', vendor: 'NVIDIA', vendorKey: 'nvidia', hbmGB: 288, hbmTBs: 22, tfBf16: 4000, tfFp8: 17500, tfFp4: 35000, scaleUpGBs: 1800, domain: 72, nicGbps: 1600, tdpW: 2300, price: 11.0, onprem: 6.5, match: 'Rubin(?!.*CPX)|VR200|\\bR200\\b',
51
+ source: 'https://developer.nvidia.com/blog/inside-the-NVIDIA-rubin-platform-six-new-chips-one-ai-supercomputer' }),
52
+ A({ id: 'GB300-NVL72', short: 'GB300', label: 'NVIDIA GB300 NVL72 (72-GPU rack)', vendor: 'NVIDIA', vendorKey: 'nvidia', hbmGB: 278, hbmTBs: 8, tfBf16: 2500, tfFp8: 5000, tfFp4: 15000, scaleUpGBs: 900, domain: 72, nicGbps: 800, tdpW: 1400, price: 7.5, onprem: 4.4, match: 'GB300',
53
+ // rack figures ÷ 72: 20 TB HBM, 576 TB/s, 360/720/1080 PFLOPS BF16 (sparse)/FP8 (sparse)/FP4 (dense); board power from InferenceX's chip page
54
+ source: 'https://www.nvidia.com/en-us/data-center/gb300-nvl72/' }),
55
+ A({ id: 'GB200-NVL72', short: 'GB200', label: 'NVIDIA GB200 NVL72 (72-GPU rack)', vendor: 'NVIDIA', vendorKey: 'nvidia', hbmGB: 186, hbmTBs: 8, tfBf16: 2500, tfFp8: 5000, tfFp4: 10000, scaleUpGBs: 900, domain: 72, nicGbps: 400, nodeKW: 120, tdpW: 1200, price: 6.0, onprem: 3.6, match: 'GB200',
56
+ source: 'https://www.nvidia.com/en-us/data-center/gb200-nvl72/' }),
57
+ A({ id: 'B300', label: 'NVIDIA B300 (HGX, 8-GPU)', vendor: 'NVIDIA', vendorKey: 'nvidia', hbmGB: 262, hbmTBs: 8, tfBf16: 2250, tfFp8: 4500, tfFp4: 13500, scaleUpGBs: 900, domain: 8, nicGbps: 800, nodeKW: 14.5, tdpW: 1100, price: 7.0, onprem: 4.0, match: 'B300',
58
+ source: 'https://www.nvidia.com/en-us/data-center/hgx/' }),
59
+ A({ id: 'B200', label: 'NVIDIA B200 (HGX, 8-GPU)', vendor: 'NVIDIA', vendorKey: 'nvidia', hbmGB: 180, hbmTBs: 8, tfBf16: 2250, tfFp8: 4500, tfFp4: 9000, scaleUpGBs: 900, domain: 8, nicGbps: 400, nodeKW: 14.3, tdpW: 1000, price: 5.5, onprem: 3.2, match: 'B200',
60
+ source: 'https://www.nvidia.com/en-us/data-center/dgx-b200/' }),
61
+ A({ id: 'H200', label: 'NVIDIA H200 SXM (8-GPU)', vendor: 'NVIDIA', vendorKey: 'nvidia', hbmGB: 141, hbmTBs: 4.8, tfBf16: 989, tfFp8: 1979, scaleUpGBs: 450, domain: 8, nicGbps: 400, nodeKW: 10.2, tdpW: 700, price: 3.5, onprem: 2.0, match: 'H200',
62
+ source: 'https://www.nvidia.com/en-us/data-center/h200/' }),
63
+ A({ id: 'H100', label: 'NVIDIA H100 SXM (8-GPU)', vendor: 'NVIDIA', vendorKey: 'nvidia', hbmGB: 80, hbmTBs: 3.35, tfBf16: 989, tfFp8: 1979, scaleUpGBs: 450, domain: 8, nicGbps: 400, nodeKW: 10.2, tdpW: 700, price: 2.4, onprem: 1.4, match: 'H100(?!.*PCIe)|H800',
64
+ source: 'https://www.nvidia.com/en-us/data-center/h100/' }),
65
+ A({ id: 'A100', label: 'NVIDIA A100 80GB SXM (8-GPU)', vendor: 'NVIDIA', vendorKey: 'nvidia', hbmGB: 80, hbmTBs: 2.0, tfBf16: 312, tfFp8: 0, scaleUpGBs: 300, domain: 8, nicGbps: 200, nodeKW: 6.5, tdpW: 400, price: 1.6, onprem: 0.9, match: 'A100(?!.*PCIe)|A800',
66
+ source: 'https://www.nvidia.com/en-us/data-center/a100/' }),
67
+ // RTX PRO 6000 Blackwell Server Edition: 96 GB GDDR7 at 1.6 TB/s; 4 / 2 / 1 PF FP4 / FP8 / BF16 with sparsity
68
+ // (halved here); PCIe 5.0 x16 between cards; up to 600 W
69
+ A({ id: 'RTX-PRO-6000', short: 'RTXPRO6000', label: 'NVIDIA RTX PRO 6000 Blackwell Server (PCIe, 8 per server)', vendor: 'NVIDIA', vendorKey: 'nvidia', hbmGB: 96, hbmTBs: 1.6, tfBf16: 500, tfFp8: 1000, tfFp4: 2000, scaleUpGBs: 64, domain: 8, nicGbps: 400, tdpW: 600, price: 1.8, onprem: 1.0, match: 'RTX ?PRO ?6000|RTX-PRO-6000',
70
+ source: 'https://www.nvidia.com/en-us/data-center/rtx-pro-6000-blackwell-server-edition/' }),
71
+ A({ id: 'L40S', label: 'NVIDIA L40S (PCIe, 8 per server)', vendor: 'NVIDIA', vendorKey: 'nvidia', hbmGB: 48, hbmTBs: 0.864, tfBf16: 362, tfFp8: 733, scaleUpGBs: 32, domain: 8, nicGbps: 200, nodeKW: 5, tdpW: 350, price: 1.1, onprem: 0.7, match: 'L40S',
72
+ source: 'https://www.nvidia.com/en-us/data-center/l40s/' }),
73
+ // Helios rack: 72 MI455X, 432 GB HBM4 at 23.3 TB/s, 40 / 20 / 5 PF MXFP4 / MXFP8 / BF16, 3.6 TB/s scale-up
74
+ // (UALink over Ethernet, bidirectional), 43 TB/s scale-out per rack (2.4 Tb/s per GPU per direction), 246 kW per
75
+ // rack (AMD's validated reference design). AMD publishes no board power: ~1.7 kW is the reported projection.
76
+ A({ id: 'MI455X-Helios', short: 'MI455X', label: 'AMD Instinct MI455X Helios (72-GPU rack)', vendor: 'AMD', vendorKey: 'amd', hbmGB: 432, hbmTBs: 23.3, tfBf16: 5000, tfFp8: 20000, tfFp4: 40000, scaleUpGBs: 1800, domain: 72, nicGbps: 2400, nodeKW: 246, tdpW: 1700, price: 8.0, onprem: 4.8, match: 'MI455',
77
+ source: 'https://www.amd.com/en/products/accelerators/instinct/mi400.html' }),
78
+ A({ id: 'MI355X', label: 'AMD Instinct MI355X (8-GPU)', vendor: 'AMD', vendorKey: 'amd', hbmGB: 288, hbmTBs: 8, tfBf16: 2516.6, tfFp8: 5033.2, tfFp4: 10066.3, scaleUpGBs: 504, domain: 8, nicGbps: 400, tdpW: 1400, price: 4.5, onprem: 2.6, match: 'MI355',
79
+ // Infinity Fabric: 7 links × 144 GB/s (bidirectional) = 504 GB/s per direction
80
+ source: 'https://www.amd.com/en/products/accelerators/instinct/mi350/mi355x.html' }),
81
+ A({ id: 'MI325X', label: 'AMD Instinct MI325X (8-GPU)', vendor: 'AMD', vendorKey: 'amd', hbmGB: 256, hbmTBs: 6, tfBf16: 1307.4, tfFp8: 2614.9, scaleUpGBs: 448, domain: 8, nicGbps: 400, tdpW: 1000, price: 2.9, onprem: 1.7, match: 'MI325',
82
+ // platform peer-to-peer I/O 896 GB/s bidirectional = 448 GB/s per direction
83
+ source: 'https://www.amd.com/en/products/accelerators/instinct/mi300/mi325x.html' }),
84
+ // Cloud TPU: per chip, from cloud.google.com/tpu/docs (v6e, tpu7x pages). ICI figures are bidirectional there, halved
85
+ // here. domain = chips per TPU VM host; ICI across hosts in a slice is modelled as the data-center network, so
86
+ // tensor parallelism beyond one host is costed pessimistically. Prices: on-demand $/chip-hour, us-east1/us-central1.
87
+ A({ id: 'TPU7x', label: 'Google TPU7x (Ironwood), 4 per host', vendor: 'Google', vendorKey: 'tpu', kind: 'tpu', hbmGB: 192, hbmTBs: 7.37, tfBf16: 2307, tfFp8: 4614, scaleUpGBs: 600, domain: 4, nicGbps: 100, price: 12.0, gkeAccelerator: 'tpu7x', match: 'tpu7x|ironwood|TpuV7',
88
+ source: 'https://docs.cloud.google.com/tpu/docs/tpu7x' }),
89
+ A({ id: 'TPU-v6e', short: 'v6e', label: 'Google TPU v6e (Trillium), 8 per host', vendor: 'Google', vendorKey: 'tpu', kind: 'tpu', hbmGB: 32, hbmTBs: 1.64, tfBf16: 918, tfFp8: 918, scaleUpGBs: 400, domain: 8, nicGbps: 100, price: 2.7, gkeAccelerator: 'tpu-v6e-slice', match: 'v6e|trillium',
90
+ source: 'https://docs.cloud.google.com/tpu/docs/v6e' }),
91
+ A({ id: 'TPU-v5p', short: 'v5p', label: 'Google TPU v5p, 4 per host', vendor: 'Google', vendorKey: 'tpu', kind: 'tpu', hbmGB: 102, hbmTBs: 2.765, tfBf16: 459, tfFp8: 459, scaleUpGBs: 600, domain: 4, nicGbps: 50, price: 4.2, gkeAccelerator: 'tpu-v5p-slice', match: 'v5p',
92
+ // 95 GiB HBM per chip
93
+ source: 'https://docs.cloud.google.com/tpu/docs/tpu7x' }),
94
+ A({ id: 'MI300X', label: 'AMD Instinct MI300X (8-GPU)', vendor: 'AMD', vendorKey: 'amd', hbmGB: 192, hbmTBs: 5.3, tfBf16: 1307, tfFp8: 2615, scaleUpGBs: 448, domain: 8, nicGbps: 400, nodeKW: 10, tdpW: 750, price: 2.6, onprem: 1.5, match: 'MI300X',
95
+ source: 'https://www.amd.com/en/products/accelerators/instinct/mi300/mi300x.html' }),
96
+ ];
97
+
98
+ const OTHER_SKUS = [
99
+ { id: 'H100-PCIe', vendorKey: 'nvidia', kind: 'gpu', tdpW: 350, match: 'H100.*PCIe' },
100
+ { id: 'H20', vendorKey: 'nvidia', kind: 'gpu', tdpW: 400, match: 'H20\\b' },
101
+ { id: 'A100-PCIe', vendorKey: 'nvidia', kind: 'gpu', tdpW: 300, match: 'A100.*PCIe' },
102
+ { id: 'A100-40GB', vendorKey: 'nvidia', kind: 'gpu', tdpW: 400, match: 'A100.*40\\s?GB' },
103
+ { id: 'A10G', vendorKey: 'nvidia', kind: 'gpu', tdpW: 300, match: 'A10G' },
104
+ { id: 'L4', vendorKey: 'nvidia', kind: 'gpu', tdpW: 72, match: 'L4\\b' },
105
+ { id: 'A10', vendorKey: 'nvidia', kind: 'gpu', tdpW: 150, match: 'A10\\b' },
106
+ { id: 'T4', vendorKey: 'nvidia', kind: 'gpu', tdpW: 70, match: 'T4\\b' },
107
+ { id: 'V100', vendorKey: 'nvidia', kind: 'gpu', tdpW: 300, match: 'V100' },
108
+ { id: 'MI350X', vendorKey: 'amd', kind: 'gpu', tdpW: 1000, match: 'MI350' },
109
+ { id: 'MI250', vendorKey: 'amd', kind: 'gpu', tdpW: 560, match: 'MI250' },
110
+ { id: 'TPU-v5e', vendorKey: 'tpu', kind: 'tpu', match: 'v5e|v5-?lite' },
111
+ ];
112
+
113
+ // ---------- cloud instance types ----------
114
+ // AWS: docs.aws.amazon.com/AWSEC2/latest/UserGuide/accelerated-computing-instances.html and aws.amazon.com/ec2/instance-types/p6/
115
+ const INSTANCES = {};
116
+ const add = (cloud, chip, list) => { for (const [type, gpus] of list) INSTANCES[type.toLowerCase()] = { cloud, chip, gpus }; };
117
+ const sizes = (fam, one, more) => one.map(s => [`${fam}.${s}`, 1]).concat(more.map(([s, n]) => [`${fam}.${s}`, n]));
118
+ add('aws', 'A100-40GB', [['p4d.24xlarge', 8]]);
119
+ add('aws', 'A100', [['p4de.24xlarge', 8]]);
120
+ add('aws', 'H100', [['p5.4xlarge', 1], ['p5.48xlarge', 8]]);
121
+ add('aws', 'H200', [['p5e.48xlarge', 8], ['p5en.48xlarge', 8]]);
122
+ add('aws', 'B200', [['p6-b200.48xlarge', 8]]);
123
+ add('aws', 'B300', [['p6-b300.48xlarge', 8]]);
124
+ add('aws', 'GB200-NVL72', [['p6e-gb200.36xlarge', 4]]); // sold as UltraServers of 36 or 72 GPUs (u-p6e-gb200x36, x72)
125
+ add('aws', 'L40S', sizes('g6e', ['xlarge', '2xlarge', '4xlarge', '8xlarge', '16xlarge'], [['12xlarge', 4], ['24xlarge', 4], ['48xlarge', 8]]));
126
+ add('aws', 'L4', sizes('g6', ['xlarge', '2xlarge', '4xlarge', '8xlarge', '16xlarge'], [['12xlarge', 4], ['24xlarge', 4], ['48xlarge', 8]]));
127
+ add('aws', 'A10G', sizes('g5', ['xlarge', '2xlarge', '4xlarge', '8xlarge', '16xlarge'], [['12xlarge', 4], ['24xlarge', 4], ['48xlarge', 8]]));
128
+ add('aws', 'T4', sizes('g4dn', ['xlarge', '2xlarge', '4xlarge', '8xlarge', '16xlarge'], [['12xlarge', 4], ['metal', 8]]));
129
+ // GCP: docs.cloud.google.com/compute/docs/gpus and /compute/docs/tpus/tpu-machines; GKE TPU machine types
130
+ const gpuN = (fam, chip, ns) => add('gcp', chip, ns.map(n => [`${fam}-${n}g`, n]));
131
+ gpuN('a2-highgpu', 'A100-40GB', [1, 2, 4, 8]); add('gcp', 'A100-40GB', [['a2-megagpu-16g', 16]]);
132
+ gpuN('a2-ultragpu', 'A100', [1, 2, 4, 8]);
133
+ gpuN('a3-highgpu', 'H100', [1, 2, 4, 8]); add('gcp', 'H100', [['a3-megagpu-8g', 8], ['a3-edgegpu-8g', 8]]);
134
+ add('gcp', 'H200', [['a3-ultragpu-8g', 8]]);
135
+ add('gcp', 'B200', [['a4-highgpu-8g', 8]]);
136
+ add('gcp', 'GB200-NVL72', [['a4x-highgpu-4g', 4]]);
137
+ add('gcp', 'L4', [4, 8, 12, 16, 32].map(n => [`g2-standard-${n}`, 1]).concat([['g2-standard-24', 2], ['g2-standard-48', 4], ['g2-standard-96', 8]]));
138
+ add('gcp', 'TPU-v6e', [['ct6e-standard-1t', 1], ['ct6e-standard-4t', 4], ['ct6e-standard-8t', 8]]);
139
+ add('gcp', 'TPU-v5p', [['ct5p-hightpu-4t', 4]]);
140
+ add('gcp', 'TPU7x', [['tpu7x-standard-4t', 4]]);
141
+ add('gcp', 'TPU-v5e', [['ct5lp-hightpu-1t', 1], ['ct5lp-hightpu-4t', 4], ['ct5lp-hightpu-8t', 8]]);
142
+ // Azure: learn.microsoft.com/azure/virtual-machines/sizes/gpu-accelerated (ND H100/H200/MI300X v5, ND GB200 v6, ND A100 v4);
143
+ // AKS puts the size in node.kubernetes.io/instance-type with this capitalisation (matched case-insensitively)
144
+ add('azure', 'H100', [['Standard_ND96isr_H100_v5', 8]]);
145
+ add('azure', 'H200', [['Standard_ND96isr_H200_v5', 8]]);
146
+ add('azure', 'MI300X', [['Standard_ND96isr_MI300X_v5', 8]]);
147
+ add('azure', 'GB200-NVL72', [['Standard_ND128isr_NDR_GB200_v6', 4]]); // 18 VMs per NVL72 rack
148
+ add('azure', 'A100-40GB', [['Standard_ND96asr_v4', 8]]);
149
+ add('azure', 'A100', [['Standard_ND96amsr_A100_v4', 8]]);
150
+ const instanceOf = type => INSTANCES[String(type || '').toLowerCase()] || null;
151
+ // TPU slice topology for a chip count: 2D (v5e, v6e) or 3D torus (v4, v5p, 7x), as GKE's node selector wants it
152
+ const TOPO2 = { 1: '1x1', 4: '2x2', 8: '2x4', 16: '4x4', 32: '4x8', 64: '8x8', 128: '8x16', 256: '16x16' };
153
+ const TOPO3 = { 4: '2x2x1', 8: '2x2x2', 16: '2x2x4', 32: '2x4x4', 64: '4x4x4' };
154
+ function tpuTopology(chip, chips) { const a = byId(chip) || match(chip); if (!a) return null; return (/v6e|v5e/i.test(a.id) ? TOPO2 : TOPO3)[chips] || null; }
155
+
156
+ // telemetry SKU string ("NVIDIA H100 80GB HBM3", "AMD Instinct MI300X", …) → registry entry, most specific first
157
+ const ORDER = (() => {
158
+ const all = ACCELERATORS.concat(OTHER_SKUS).map(x => ({ x, re: new RegExp(x.match, 'i') }));
159
+ // a PCIe or 40 GB variant before its sibling; otherwise registry order (which lists GB* before B*)
160
+ const first = a => /PCIe|40GB/.test(a.x.id);
161
+ return all.filter(first).concat(all.filter(a => !first(a)));
162
+ })();
163
+ function match(sku) {
164
+ const s = String(sku || '');
165
+ if (!s) return null;
166
+ const exact = ACCELERATORS.concat(OTHER_SKUS).find(x => x.id.toLowerCase() === s.toLowerCase() || (x.short && x.short.toLowerCase() === s.toLowerCase()));
167
+ if (exact) return exact;
168
+ const hit = ORDER.find(a => a.re.test(s));
169
+ return hit ? hit.x : null;
170
+ }
171
+ const byId = id => ACCELERATORS.find(x => x.id === id || x.short === id) || null;
172
+ const tdpOf = sku => { const m = match(sku); return m ? m.tdpW : null; };
173
+ // vendor key for an entry, a SKU string or a display vendor ("AMD"); null when unknown
174
+ function vendorKeyOf(x) {
175
+ if (!x) return null;
176
+ if (typeof x === 'object') return x.vendorKey || vendorKeyOf(x.vendor) || vendorKeyOf(x.id);
177
+ const s = String(x).toLowerCase();
178
+ if (VENDORS[s]) return s;
179
+ const v = Object.keys(VENDORS).find(k => VENDORS[k].name.toLowerCase() === s);
180
+ if (v) return v;
181
+ const m = match(x);
182
+ return m ? m.vendorKey : null;
183
+ }
184
+ // the vendor's deployment adapter; throws with the known vendors when there is none
185
+ function vendor(x) {
186
+ const k = vendorKeyOf(x);
187
+ if (!k || !VENDORS[k]) throw new Error(`no vendor adapter for ${typeof x === 'object' ? (x.id || x.vendor) : x}; known: ${Object.keys(VENDORS).join(', ')}`);
188
+ return Object.assign({ key: k }, VENDORS[k]);
189
+ }
190
+
191
+ const api = { VENDORS, ACCELERATORS, OTHER_SKUS, INSTANCES, instanceOf, tpuTopology, match, byId, tdpOf, vendorKeyOf, vendor };
192
+ if (typeof module !== 'undefined' && module.exports) module.exports = api;
193
+ else root.AIInfraAccelerators = api;
194
+ })(typeof globalThis !== 'undefined' ? globalThis : this);
@@ -39,32 +39,23 @@
39
39
  { k: 'topk', label: 'Experts per token', min: 0, max: 1e4, int: true },
40
40
  { k: 'swaFrac', label: 'Share of sliding-window layers', min: 0, max: 1 },
41
41
  { k: 'swaWindow', label: 'Sliding window', unit: 'tokens', min: 0, max: 1e8, int: true },
42
+ { k: 'linFrac', label: 'Share of linear-attention layers', min: 0, max: 1, hint: 'Kimi Delta Attention, Gated DeltaNet: a fixed state per sequence instead of KV per token.' },
43
+ { k: 'linStateMB', label: 'Linear-attention state per layer', unit: 'MB', min: 0, max: 1e4, hint: 'Per sequence: value heads × key dim × value dim × 4 bytes (fp32).' },
44
+ { k: 'kvKeep', label: 'Share of tokens whose KV is kept', min: 0.0001, max: 1, hint: 'Compressed attention (DeepSeek V4): average over layers. 1 for ordinary attention.' },
45
+ { k: 'sparseTopK', label: 'Tokens attended per query (sparse attention)', unit: 'tokens', min: 0, max: 1e8, int: true, hint: 'DSA / CSA / MSA index top-k. 0 = attends every kept token.' },
42
46
  { k: 'maxCtx', label: 'Max context', unit: 'tokens', min: 256, max: 1e8, int: true, required: true },
43
47
  { k: 'wprec', type: 'enum', opts: ['bf16', 'fp8', 'fp4'], label: 'Default weight precision' },
44
48
  { k: 'source', type: 'text', label: 'Model card URL' },
45
49
  ];
46
50
 
47
51
  // ---------- built-in GPUs ----------
48
- // Per-GPU dense figures. HGX/DGX system totals divided by 8 (or 72 for NVL72); "with sparsity" figures halved.
49
- // Prices are placeholder on-demand rents (matching FleetScope's table where it has the GPU), not quotes.
50
- const GPUS = [
51
- { id: 'B200', label: 'NVIDIA B200 (HGX, 8-GPU)', vendor: 'NVIDIA', hbmGB: 180, hbmTBs: 8, tfBf16: 2250, tfFp8: 4500, tfFp4: 9000, scaleUpGBs: 900, domain: 8, nicGbps: 400, nodeKW: 14.3, price: 5.5,
52
- source: 'https://www.nvidia.com/en-us/data-center/dgx-b200/' },
53
- { id: 'B300', label: 'NVIDIA B300 (HGX, 8-GPU)', vendor: 'NVIDIA', hbmGB: 262, hbmTBs: 8, tfBf16: 2250, tfFp8: 4500, tfFp4: 13500, scaleUpGBs: 900, domain: 8, nicGbps: 800, nodeKW: 14.5, price: 7.0,
54
- source: 'https://www.nvidia.com/en-us/data-center/hgx/' },
55
- { id: 'GB200-NVL72', label: 'NVIDIA GB200 NVL72 (72-GPU rack)', vendor: 'NVIDIA', hbmGB: 186, hbmTBs: 8, tfBf16: 2500, tfFp8: 5000, tfFp4: 10000, scaleUpGBs: 900, domain: 72, nicGbps: 400, nodeKW: 120, price: 6.0,
56
- source: 'https://www.nvidia.com/en-us/data-center/gb200-nvl72/' },
57
- { id: 'H200', label: 'NVIDIA H200 SXM (8-GPU)', vendor: 'NVIDIA', hbmGB: 141, hbmTBs: 4.8, tfBf16: 989, tfFp8: 1979, tfFp4: 0, scaleUpGBs: 450, domain: 8, nicGbps: 400, nodeKW: 10.2, price: 3.5,
58
- source: 'https://www.nvidia.com/en-us/data-center/h200/' },
59
- { id: 'H100', label: 'NVIDIA H100 SXM (8-GPU)', vendor: 'NVIDIA', hbmGB: 80, hbmTBs: 3.35, tfBf16: 989, tfFp8: 1979, tfFp4: 0, scaleUpGBs: 450, domain: 8, nicGbps: 400, nodeKW: 10.2, price: 2.4,
60
- source: 'https://www.nvidia.com/en-us/data-center/h100/' },
61
- { id: 'A100', label: 'NVIDIA A100 80GB SXM (8-GPU)', vendor: 'NVIDIA', hbmGB: 80, hbmTBs: 2.0, tfBf16: 312, tfFp8: 0, tfFp4: 0, scaleUpGBs: 300, domain: 8, nicGbps: 200, nodeKW: 6.5, price: 1.6,
62
- source: 'https://www.nvidia.com/en-us/data-center/a100/' },
63
- { id: 'L40S', label: 'NVIDIA L40S (PCIe, 8 per server)', vendor: 'NVIDIA', hbmGB: 48, hbmTBs: 0.864, tfBf16: 362, tfFp8: 733, tfFp4: 0, scaleUpGBs: 32, domain: 8, nicGbps: 200, nodeKW: 5, price: 1.1,
64
- source: 'https://www.nvidia.com/en-us/data-center/l40s/' },
65
- { id: 'MI300X', label: 'AMD Instinct MI300X (8-GPU)', vendor: 'AMD', hbmGB: 192, hbmTBs: 5.3, tfBf16: 1307, tfFp8: 2615, tfFp4: 0, scaleUpGBs: 448, domain: 8, nicGbps: 400, nodeKW: 10, price: 2.6,
66
- source: 'https://www.amd.com/en/products/accelerators/instinct/mi300/mi300x.html' },
67
- ];
52
+ // From the shared accelerator registry (accelerators.js): per-GPU dense figures, HGX/DGX system totals divided by 8
53
+ // (or 72 for NVL72), "with sparsity" figures halved. Prices are placeholder on-demand rents, not quotes.
54
+ const REG = (typeof module !== 'undefined' && module.exports) ? require('./accelerators.js') : root.AIInfraAccelerators;
55
+ const ORDER = ['B200', 'B300', 'GB200-NVL72', 'GB300-NVL72', 'VR200-NVL72', 'H200', 'H100', 'A100', 'L40S', 'RTX-PRO-6000', 'MI300X', 'MI325X', 'MI355X', 'MI455X-Helios', 'TPU7x', 'TPU-v6e', 'TPU-v5p'];
56
+ const KEEP = ['id', 'kind', 'vendorKey', 'gkeAccelerator', 'tdpW'].concat(GPU_FIELDS.map(f => f.k)); // tdpW: board power, for tokens per MW
57
+ const GPUS = REG.ACCELERATORS.slice().sort((a, b) => (ORDER.indexOf(a.id) + 1 || 99) - (ORDER.indexOf(b.id) + 1 || 99))
58
+ .map(g => Object.fromEntries(KEEP.filter(k => g[k] !== undefined).map(k => [k, g[k]])));
68
59
 
69
60
  // ---------- built-in models ----------
70
61
  const MLA = { attn: 'mla', kvHeads: 1, headDim: 128, mlaLatent: 512, mlaRope: 64, mlaNope: 128, mlaV: 128 };
@@ -82,8 +73,36 @@
82
73
  Object.assign({}, G, { id: 'qwen3-coder-480b', name: 'Qwen3-Coder 480B-A35B (MoE)', total: 480, active: 35, layers: 62, hidden: 6144, qHeads: 96, kvHeads: 8, headDim: 128, experts: 160, topk: 8, maxCtx: 262144, wprec: 'fp8', source: 'https://huggingface.co/Qwen/Qwen3-Coder-480B-A35B-Instruct' }),
83
74
  Object.assign({}, G, MLA, { id: 'deepseek-v3', name: 'DeepSeek-V3 / R1 671B (MoE, MLA)', total: 671, active: 37, layers: 61, hidden: 7168, qHeads: 128, experts: 256, topk: 8, maxCtx: 131072, wprec: 'fp8', source: 'https://huggingface.co/deepseek-ai/DeepSeek-V3' }),
84
75
  Object.assign({}, G, MLA, { id: 'kimi-k2', name: 'Kimi K2 1T (MoE, MLA)', total: 1040, active: 32, layers: 61, hidden: 7168, qHeads: 64, experts: 384, topk: 8, maxCtx: 131072, wprec: 'fp8', source: 'https://huggingface.co/moonshotai/Kimi-K2-Instruct' }),
76
+ // ---- 2026 open-weight models (config.json values; see docs/CATALOG.md for where each figure comes from) ----
77
+ // Kimi K3 (K3.1 Pro shares the architecture): 69 Kimi Delta Attention layers (96 heads × 128 × 128 fp32 state) and
78
+ // 24 gated MLA layers; MXFP4 weights from quantization-aware training.
79
+ Object.assign({}, G, MLA, { id: 'kimi-k3', name: 'Kimi K3 / K3.1 Pro 2.8T-A104B (MoE, KDA + MLA)', total: 2800, active: 104, layers: 93, hidden: 7168, qHeads: 96, experts: 896, topk: 16, linFrac: 69 / 93, linStateMB: 6.29, maxCtx: 1048576, wprec: 'fp4', source: 'https://huggingface.co/moonshotai/Kimi-K3' }),
80
+ // Kimi K2.5 / K2.6: K2's shape with 256K context and native INT4 weights (sized as 4-bit)
81
+ Object.assign({}, G, MLA, { id: 'kimi-k26', name: 'Kimi K2.6 1T-A32B (MoE, MLA, INT4)', total: 1000, active: 32, layers: 61, hidden: 7168, qHeads: 64, experts: 384, topk: 8, maxCtx: 262144, wprec: 'fp4', source: 'https://huggingface.co/moonshotai/Kimi-K2.6' }),
82
+ // DeepSeek V4: one 512-wide latent per token, kept at 1/4 (CSA) or 1/128 (HCA) on alternating layers (≈ 0.129 on
83
+ // average); CSA attends its index top-1024, HCA all compressed blocks: modelled as 2048 attended tokens per query.
84
+ // Experts in FP4, the rest FP8.
85
+ Object.assign({}, G, MLA, { id: 'deepseek-v4-pro', name: 'DeepSeek-V4-Pro 1.6T-A49B (MoE, compressed sparse attention)', total: 1600, active: 49, layers: 61, hidden: 7168, qHeads: 128, mlaLatent: 448, mlaRope: 64, mlaNope: 448, mlaV: 512, kvKeep: 0.129, sparseTopK: 2048, experts: 384, topk: 6, maxCtx: 1048576, wprec: 'fp4', source: 'https://huggingface.co/deepseek-ai/DeepSeek-V4-Pro' }),
86
+ Object.assign({}, G, MLA, { id: 'deepseek-v4-flash', name: 'DeepSeek-V4-Flash 284B-A13B (MoE, compressed sparse attention)', total: 284, active: 13, layers: 43, hidden: 4096, qHeads: 64, mlaLatent: 448, mlaRope: 64, mlaNope: 448, mlaV: 512, kvKeep: 0.129, sparseTopK: 2048, experts: 256, topk: 6, maxCtx: 1048576, wprec: 'fp8', source: 'https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash' }),
87
+ // GLM-5.1 and GLM-5.3: MLA with DeepSeek-style sparse attention (index top-2048); GLM-5.3 extends the context to 1M.
88
+ // GLM-5.3's active parameters are not published: the GLM-5 lineage's 40B is assumed.
89
+ Object.assign({}, G, MLA, { id: 'glm-5.1', name: 'GLM-5.1 744B-A40B (MoE, MLA, sparse)', total: 744, active: 40, layers: 78, hidden: 6144, qHeads: 64, mlaNope: 192, mlaV: 256, sparseTopK: 2048, experts: 256, topk: 8, maxCtx: 202752, wprec: 'fp8', source: 'https://huggingface.co/zai-org/GLM-5.1' }),
90
+ Object.assign({}, G, MLA, { id: 'glm-5.3', name: 'GLM-5.3 753B (MoE, MLA, sparse, 1M)', total: 753, active: 40, layers: 78, hidden: 6144, qHeads: 64, mlaNope: 192, mlaV: 256, sparseTopK: 2048, experts: 256, topk: 8, maxCtx: 1048576, wprec: 'fp8', source: 'https://huggingface.co/zai-org/GLM-5.3' }),
91
+ // Mistral Large 4: MLA with sparse token selection (top-2048); nope/v head dims not published (DeepSeek's 128 assumed)
92
+ Object.assign({}, G, MLA, { id: 'mistral-large-4', name: 'Mistral Large 4 1.05T-A52B (MoE, MLA, sparse)', total: 1050, active: 52, layers: 72, hidden: 6144, qHeads: 64, sparseTopK: 2048, experts: 128, topk: 4, maxCtx: 1048576, wprec: 'fp8', source: 'https://huggingface.co/mistralai/Mistral-Large-4-1T-A52B' }),
93
+ // Qwen3.5-397B and Qwen3.8 27B: three Gated DeltaNet layers per gated-attention layer (64 / 48 value heads × 128 × 128 fp32 state)
94
+ Object.assign({}, G, { id: 'qwen35-397b', name: 'Qwen3.5 397B-A17B (MoE, Gated DeltaNet hybrid)', total: 397, active: 17, layers: 60, hidden: 4096, qHeads: 32, kvHeads: 2, headDim: 256, linFrac: 0.75, linStateMB: 4.19, experts: 512, topk: 10, maxCtx: 262144, wprec: 'fp8', source: 'https://huggingface.co/Qwen/Qwen3.5-397B-A17B' }),
95
+ Object.assign({}, G, { id: 'qwen38-27b', name: 'Qwen3.8 27B (Gated DeltaNet hybrid)', total: 27, active: 27, layers: 64, hidden: 5120, qHeads: 24, kvHeads: 4, headDim: 256, linFrac: 0.75, linStateMB: 3.15, maxCtx: 262144, wprec: 'fp8', source: 'https://huggingface.co/Qwen/Qwen3.8-27B' }),
96
+ // MiniMax M3: sparse attention (16 blocks of 128 tokens) in 57 of 60 layers, modelled on all of them
97
+ Object.assign({}, G, { id: 'minimax-m3', name: 'MiniMax M3 428B-A23B (MoE, sparse)', total: 428, active: 23, layers: 60, hidden: 6144, qHeads: 64, kvHeads: 4, headDim: 128, sparseTopK: 2048, experts: 128, topk: 4, maxCtx: 1048576, wprec: 'fp8', source: 'https://huggingface.co/MiniMaxAI/MiniMax-M3' }),
98
+ Object.assign({}, G, { id: 'minimax-m27', name: 'MiniMax M2.7 229B-A10B (MoE)', total: 229, active: 10, layers: 62, hidden: 3072, qHeads: 48, kvHeads: 8, headDim: 128, experts: 256, topk: 8, maxCtx: 204800, wprec: 'fp8', source: 'https://huggingface.co/MiniMaxAI/MiniMax-M2.7' }),
99
+ // Muse Spark Open: 46 sliding-window layers (2048 tokens) and 16 full-attention layers
100
+ Object.assign({}, G, { id: 'muse-spark-open', name: 'Muse Spark Open 816B-A42B (MoE)', total: 816, active: 42, layers: 62, hidden: 8192, qHeads: 128, kvHeads: 16, headDim: 64, swaFrac: 46 / 62, swaWindow: 2048, experts: 256, topk: 8, maxCtx: 1048576, wprec: 'fp4', source: 'https://huggingface.co/meta-models/Muse-Spark-Open-816B-A42B' }),
101
+ // Gemma 4 31B: 50 sliding-window layers (1024 tokens) and 10 global layers with 4 KV heads of 512 and keys reused as
102
+ // values (the KV of 4 × 256 K+V pairs). The sliding layers' 16 heads are sized as 4: their KV is capped at 1024 tokens.
103
+ Object.assign({}, G, { id: 'gemma4-31b', name: 'Gemma 4 31B', total: 30.7, active: 30.7, layers: 60, hidden: 5376, qHeads: 32, kvHeads: 4, headDim: 256, swaFrac: 50 / 60, swaWindow: 1024, maxCtx: 262144, wprec: 'fp8', source: 'https://huggingface.co/google/gemma-4-31B' }),
85
104
  ];
86
- const MODEL_DEFAULTS = { attn: 'gqa', experts: 0, topk: 0, swaFrac: 0, swaWindow: 0, mlaLatent: 512, mlaRope: 64, mlaNope: 128, mlaV: 128, wprec: 'fp8' };
105
+ const MODEL_DEFAULTS = { attn: 'gqa', experts: 0, topk: 0, swaFrac: 0, swaWindow: 0, linFrac: 0, linStateMB: 0, kvKeep: 1, sparseTopK: 0, mlaLatent: 512, mlaRope: 64, mlaNope: 128, mlaV: 128, wprec: 'fp8' };
87
106
  const GPU_DEFAULTS = { tfFp8: 0, tfFp4: 0, nodeKW: 0, price: 0, vendor: '' };
88
107
 
89
108
  // ---------- validation ----------
@@ -113,6 +132,7 @@
113
132
  out[f.k] = v;
114
133
  }
115
134
  if (kind === 'Model' && out.active > out.total) errors.push(`Model "${out.name}": active params (${out.active}B) exceed total (${out.total}B).`);
135
+ if (kind === 'Model' && (out.swaFrac || 0) + (out.linFrac || 0) > 1) errors.push(`Model "${out.name}": sliding-window and linear-attention shares add up to more than all layers.`);
116
136
  if (kind === 'Model' && out.experts > 0 && !(out.topk > 0 && out.topk < out.experts)) errors.push(`Model "${out.name}": experts per token must be between 1 and ${out.experts - 1}.`);
117
137
  if (kind === 'Model' && out.experts > 0 && out.active >= out.total) errors.push(`Model "${out.name}": an MoE model needs active params below total params.`);
118
138
  return { ok: errors.length === 0, errors, value: out };
@@ -195,6 +215,19 @@
195
215
  notes.push('Chunked-attention layers modelled as sliding-window layers.');
196
216
  }
197
217
  if (c.sliding_window && !swaFrac) notes.push('sliding_window is set but not enabled for these layers; KV is sized for full attention.');
218
+ // linear-attention layers (Qwen3-Next / Qwen3.5 Gated DeltaNet: layer_types "linear_attention" or full_attention_interval)
219
+ let linFrac = 0, linStateMB = 0;
220
+ const linN = Array.isArray(c.layer_types) ? c.layer_types.filter(t => /linear/i.test(String(t))).length
221
+ : c.full_attention_interval > 1 ? layers - Math.floor(layers / c.full_attention_interval) : 0;
222
+ if (linN) {
223
+ linFrac = +(linN / layers).toFixed(4);
224
+ const vh = +first(c, ['linear_num_value_heads'], qHeads), kd = +first(c, ['linear_key_head_dim'], 128), vd = +first(c, ['linear_value_head_dim'], 128);
225
+ linStateMB = +(vh * kd * vd * 4 / 1e6).toFixed(3);
226
+ notes.push(`${linN} linear-attention layers: a ${linStateMB} MB state per layer per sequence (fp32), no KV per token.`);
227
+ }
228
+ // sparse attention: an index picks the tokens each query attends (DeepSeek Sparse Attention and its descendants)
229
+ const sparseTopK = c.index_topk ? +c.index_topk : 0;
230
+ if (sparseTopK) notes.push(`Sparse attention: each query attends ${sparseTopK} selected tokens.`);
198
231
  // context
199
232
  let maxCtx = +first(c, ['max_position_embeddings', 'n_positions', 'seq_length', 'max_sequence_length'], 4096);
200
233
  const rs = c.rope_scaling;
@@ -229,7 +262,7 @@
229
262
  const name = String(first(j, ['_name_or_path', 'name_or_path'], '') || '').split('/').pop() || (c.model_type ? c.model_type + ' ' + (total / 1e9).toFixed(0) + 'B' : 'Imported model');
230
263
  const model = {
231
264
  name, total: +(total / 1e9).toFixed(2), active: +(active / 1e9).toFixed(2), layers, hidden, qHeads, kvHeads, headDim,
232
- attn: mla ? 'mla' : 'gqa', mlaLatent, mlaRope, mlaNope, mlaV, experts, topk, swaFrac, swaWindow, maxCtx,
265
+ attn: mla ? 'mla' : 'gqa', mlaLatent, mlaRope, mlaNope, mlaV, experts, topk, swaFrac, swaWindow, linFrac, linStateMB, sparseTopK, maxCtx,
233
266
  wprec: /fp8|float8/i.test(JSON.stringify(j.quantization_config || '')) ? 'fp8' : /mxfp4|nvfp4|fp4/i.test(JSON.stringify(j.quantization_config || '')) ? 'fp4' : 'fp8',
234
267
  };
235
268
  return { model, notes };
@@ -83,7 +83,7 @@ function detailHTML() {
83
83
  }
84
84
 
85
85
  function schedule() { clearTimeout(timer); timer = setTimeout(() => { save(st); run(); }, 120); }
86
- function onInput(e) { const k = e.target.dataset.k; if (!k) return; st[k] = e.target.type === 'number' ? (e.target.value === '' ? '' : +e.target.value) : e.target.value; if (k === 'gpu' || k === 'nodes') st.pick = st.pick; schedule(); }
86
+ function onInput(e) { const k = e.target.dataset.k; if (!k) return; st[k] = e.target.type === 'number' ? (e.target.value === '' ? '' : +e.target.value) : e.target.value; schedule(); }
87
87
  function pick(m) { st.pick = st.pick === m ? null : m; save(st); render(); const d = document.getElementById('fit-detail'); if (st.pick && d) d.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); }
88
88
 
89
89
  function show(view) {
@@ -226,6 +226,9 @@ nav.views .chip { font-size: 12.5px; padding: 4px 12px; }
226
226
  </div>
227
227
  <div class="overlay" id="dialog" hidden></div>
228
228
  <script>
229
+ /*ACCELERATORS*/
230
+ </script>
231
+ <script>
229
232
  /*CATALOG*/
230
233
  </script>
231
234
  <script>
@@ -25,6 +25,12 @@
25
25
  const mla = s.attn === 'mla';
26
26
  const lat = s.mlaLatent || 512, rope = s.mlaRope == null ? 64 : s.mlaRope, nope = s.mlaNope == null ? 128 : s.mlaNope, vh = s.mlaV || 128;
27
27
  const swaLayers = s.swaWindow > 0 ? Math.round(s.layers * (s.swaFrac || 0)) : 0;
28
+ // linear-attention layers (Kimi Delta Attention, Gated DeltaNet): a fixed recurrent state per sequence, no KV per token
29
+ const linLayers = s.linFrac > 0 ? Math.min(s.layers - swaLayers, Math.round(s.layers * s.linFrac)) : 0;
30
+ const linState = linLayers * (s.linStateMB || 0) * 1e6;
31
+ // compressed attention keeps the KV of a share of the tokens (DeepSeek V4: 1/4 or 1/128 per layer); sparse attention
32
+ // (DSA, CSA, MSA) attends a fixed number of selected tokens per query instead of all of them
33
+ const keep = s.kvKeep > 0 && s.kvKeep < 1 ? s.kvKeep : 1, topK = s.sparseTopK > 0 ? s.sparseTopK : 0;
28
34
  // tensor-core rate for the weight precision; fall back when the GPU lacks that precision
29
35
  const tf = { bf16: s.tfBf16, fp8: s.tfFp8 || s.tfBf16, fp4: s.tfFp4 || s.tfFp8 || s.tfBf16 }[s.wprec] || s.tfBf16;
30
36
  const computeFallback = (s.wprec === 'fp4' && !s.tfFp4) ? (s.tfFp8 ? 'fp8' : 'bf16') : (s.wprec === 'fp8' && !s.tfFp8) ? 'bf16' : null;
@@ -33,7 +39,9 @@
33
39
  Wd: dense * 1e9 * bpp, We: Eall * 1e9 * bpp,
34
40
  denseP: dense * 1e9, activeP: (isMoE ? s.active : s.total) * 1e9,
35
41
  kvTokLayer: mla ? (lat + rope) * kvb : 2 * s.kvHeads * s.headDim * kvb,
36
- swaLayers, fullLayers: s.layers - swaLayers, win: s.swaWindow || 0,
42
+ swaLayers, linLayers, fullLayers: s.layers - swaLayers - linLayers, win: s.swaWindow || 0, keep, topK, linState,
43
+ // FLOPs per token per linear-attention layer: read and update the state (fp32, 4 bytes an element), ~4 FLOPs an element
44
+ Alin: (s.linStateMB || 0) * 1e6,
37
45
  // attention FLOPs per (query token, context token) per layer
38
46
  Apre: mla ? s.qHeads * (2 * (nope + rope) + 2 * vh) : 4 * s.qHeads * s.headDim,
39
47
  Adec: mla ? s.qHeads * (2 * (lat + rope) + 2 * lat) : 4 * s.qHeads * s.headDim,
@@ -44,17 +52,26 @@
44
52
  };
45
53
  }
46
54
 
55
+ // KV bytes one sequence of L tokens holds: full-attention layers keep (a share of) every token, sliding-window layers
56
+ // the last W, linear-attention layers a fixed state
47
57
  function kvBytes(md, L) {
48
- const w = md.win || L;
49
- return md.kvTokLayer * (md.fullLayers * L + md.swaLayers * Math.min(L, w));
58
+ const w = md.win || L, keep = md.keep || 1;
59
+ return md.kvTokLayer * (md.fullLayers * L * keep + md.swaLayers * Math.min(L, w)) + (md.linState || 0);
60
+ }
61
+ // context tokens one query attends in a full-attention layer, and its integral over query positions 0..x
62
+ const attended = (md, L) => { const n = L * (md.keep || 1); return md.topK ? Math.min(n, md.topK) : n; };
63
+ function attendedSum(md, x) {
64
+ const k = md.keep || 1;
65
+ if (!md.topK) return k * x * x / 2;
66
+ const t = md.topK / k;
67
+ return x <= t ? k * x * x / 2 : k * t * t / 2 + md.topK * (x - t);
50
68
  }
51
69
  function attnPre(md, Lc, L) {
52
70
  const W = md.win;
53
- const f = x => x * x / 2;
54
71
  const g = x => x <= W ? x * x / 2 : W * W / 2 + W * (x - W);
55
- return md.Apre * (md.fullLayers * (f(L) - f(Lc)) + md.swaLayers * (g(L) - g(Lc)));
72
+ return md.Apre * (md.fullLayers * (attendedSum(md, L) - attendedSum(md, Lc)) + md.swaLayers * (g(L) - g(Lc))) + (md.linLayers || 0) * (md.Alin || 0) * (L - Lc);
56
73
  }
57
- function attnDec(md, L) { return md.Adec * (md.fullLayers * L + md.swaLayers * Math.min(L, md.win || L)); }
74
+ function attnDec(md, L) { return md.Adec * (md.fullLayers * attended(md, L) + md.swaLayers * Math.min(L, md.win || L)) + (md.linLayers || 0) * (md.Alin || 0); }
58
75
 
59
76
  // ---------- parallel layouts ----------
60
77
  // Instances of g GPUs. Inside one scale-up domain (D GPUs): TP, or TP+EP for MoE, or DP-attention+EP for MLA.
@@ -291,6 +308,27 @@
291
308
  return { rows, best };
292
309
  }
293
310
 
311
+ // The operating point of one fixed layout at a fixed concurrency: what an engine running config c with B sequences
312
+ // in flight delivers, by the same physics sizeAgg uses (each step carries the decode batch plus prefill chunks; the
313
+ // prefill share fp slows the compute part). For checking the model against measured runs (e.g. InferenceX):
314
+ // returns TPOT, TTFT, and output tokens/s per GPU.
315
+ function operatingPoint(s, md, c, B) {
316
+ const st = decodeStep(s, md, c, B), ps = prefillStats(s, md, c), osl = s.avgOut, isl = Math.min(s.avgIn, s.ctx);
317
+ let tpot = st.t, ttft = ps.Sbatch, fp = 0;
318
+ for (let i = 0; i < 50; i++) {
319
+ const lam = B / (osl * tpot + ttft); // requests/s through this instance
320
+ fp = Math.min(0.95, lam * isl / ps.cap); // share of compute spent on prefill
321
+ const t = Math.max(st.tm, st.tc / (1 - fp)) * 1.1 + st.comm + st.ovh;
322
+ // a new prompt is prefilled in chunks between decode steps: its share of each step is what decode leaves
323
+ const free = Math.max(0.05, 1 - Math.max(st.tm, st.tc) / t);
324
+ const tt = prefillTime(s, md, c, isl, 0, 1) / free + mdWait(Math.min(0.85, fp), isl / ps.cap) + t;
325
+ if (Math.abs(t - tpot) < 1e-7 && Math.abs(tt - ttft) < 1e-6) { tpot = t; ttft = tt; break; }
326
+ tpot = t; ttft = tt;
327
+ }
328
+ const outPerGpu = B * osl / (osl * tpot + ttft) / c.g;
329
+ return { tpot, ttft, outPerGpu, prefillShare: fp, bound: st.bound, step: st };
330
+ }
331
+
294
332
  // Nodes (scale-up domains) needed: instances that span domains take whole domains; smaller ones pack first-fit-decreasing.
295
333
  function packNodes(pools, D) {
296
334
  const items = [];
@@ -355,6 +393,6 @@
355
393
  return res;
356
394
  }
357
395
 
358
- const api = { SETTINGS, plan, derive, kvBytes, decodeStep, memInfo, prefillStats, configs, computeLoad, decodeLabel, prefillLabel, decodeCap, packNodes };
396
+ const api = { SETTINGS, plan, derive, kvBytes, attnPre, attnDec, decodeStep, memInfo, prefillStats, prefillTime, configs, computeLoad, decodeLabel, prefillLabel, decodeCap, packNodes, operatingPoint };
359
397
  if (typeof module !== 'undefined' && module.exports) module.exports = api; else root.SizerModel = api;
360
398
  })(this);
@@ -467,7 +467,7 @@ function memoryHTML(r) {
467
467
  <div class="membar">${parts.map(p => `<div style="width:${Math.max(0, 100 * p[1] / hbm).toFixed(2)}%;background:${p[2]}" title="${p[0]}"></div>`).join('')}</div>
468
468
  <div class="memlegend">${parts.map(p => `<i style="background:${p[2]}"></i><span>${p[0]}</span><span class="mono">${fGB(p[1])}</span>`).join('')}</div>
469
469
  <dl class="kv" style="margin-top:14px">
470
- <dt>KV per token (all layers)</dt><dd>${fGB(md.kvTokLayer * s.layers)}</dd>
470
+ <dt>KV per token (all layers, averaged over a full context)</dt><dd>${fGB(M.kvBytes(md, s.ctx) / s.ctx)}</dd>
471
471
  <dt>KV for one ${fCtx(s.ctx)} full-context request</dt><dd>${fGB(mi.ctxBytes)}</dd>
472
472
  <dt>KV for an average request (${fInt(s.avgIn + s.avgOut)} tokens)</dt><dd>${fGB(M.kvBytes(md, Math.min(s.ctx, s.avgIn + s.avgOut)))}</dd>
473
473
  <dt>KV capacity per instance</dt><dd>${fGB(mi.cap)}</dd>