aiinfra-tools 0.5.0 → 0.5.1

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,89 @@
3
3
  All notable changes. Versions follow [Semantic Versioning](https://semver.org/); before 1.0, a minor version may
4
4
  change the `--json` output, and when it does the change is listed here (see [schemas/](schemas/README.md)).
5
5
 
6
+ ## Unreleased
7
+
8
+ ## 0.5.1 (2026-11-30)
9
+
10
+ Stays current on its own, and is easier to start with. Model prices and the Inference Sizer's model catalog are
11
+ checked every week. The AWS deploy paths are now tested against AWS Emulator in CI. A getting-started guide covers the
12
+ first suggestion and deploying anywhere. Fixes: Gemma 4's KV cache was undercounted, DeepSeek V4's sparse top-k was
13
+ wrong, and `up.sh vm` clashed with dcgm-exporter's port. One `--json` change: `harness-ledger.economics` per-resolved
14
+ figures can be `null`. One prediction changed: Gemma 4's time per output token is longer (12.5 → 15.6 ms on H100 at the
15
+ default load), because its sliding-window layers keep 4× the KV that was counted. GPU counts at the defaults are the
16
+ same.
17
+
18
+ ### New: kept current every week
19
+
20
+ - **Prices** (#92): harness-ledger's default prices come from LiteLLM's model price list, stored in
21
+ `harness-ledger/src/prices.json`. They cover 81 Anthropic, OpenAI and Gemini models, up from 7, including the newer
22
+ Claude and GPT models that were unpriced before. A weekly workflow (`.github/workflows/refresh.yml`) refreshes them:
23
+ when a price changes or a model appears, it runs the tests and opens one pull request (`scripts/refresh-prices.mjs`).
24
+ - **Model catalog check** (#92, #97): the same workflow compares the Inference Sizer's models with their Hugging Face
25
+ `config.json`. It compares layers, hidden size, heads, KV heads (and full-attention KV heads), attention kind,
26
+ experts, top-k and sparse top-k. It lists new open-weight models from the organizations the catalog follows, and
27
+ opens one "model catalog" issue when there is something to do (`scripts/check-catalog.mjs`). An entry's
28
+ `alsoRepos` names repos with the same layout (Kimi K3.1 Pro, MiniMax M3.1 Flash). A repo looked at and left out goes
29
+ in `REVIEWED`, with the reason, and the issue lists it as reviewed rather than new. A gated repo says it needs an
30
+ `HF_TOKEN` from an account that accepted the license.
31
+ - **AWS paths against AWS Emulator** (#99): `.github/workflows/aws-emulator.yml` installs AWS Emulator on the runner,
32
+ with no AWS account. `tests/aws-emulator/run.sh` then checks:
33
+ - the Capacity Blocks command `fleetops procure aws-blocks` prints (H100, H200, B200);
34
+ - `deploy/cloud/up.sh aws` and `down.sh aws` with an EKS cluster made in the emulator;
35
+ - `deploy/terraform/aws`: plan, and apply of its VPC and EKS modules.
36
+
37
+ It runs on pull requests that touch these paths, weekly, and on demand. An operation the emulator doesn't
38
+ implement is reported as an emulator gap.
39
+
40
+ ### New: getting started
41
+
42
+ - **Getting started guide** (#92, [docs/GETTING-STARTED.md](docs/GETTING-STARTED.md)): ten minutes from nothing to the
43
+ first suggestion on your own agent logs. It has commands for macOS, Linux, Windows Command Prompt and PowerShell, and
44
+ fixes for what can look off.
45
+ - **Deploying** (#93): the guide covers:
46
+ - Google Cloud, AWS and Azure, from their browser shells;
47
+ - a neocloud or on-prem Kubernetes cluster;
48
+ - one GPU server;
49
+ - your laptop (Docker, or kind/k3d);
50
+ - a hybrid hub with many sites;
51
+ - how to open it and take it down.
52
+ - **Video** (#94, #98): "What's new in 0.5.1", 56 seconds, landscape and LinkedIn 4:5. It opens with the payoff, says
53
+ AIInfraTools builds on the tools you already run, and covers:
54
+ - assess and suggest;
55
+ - where suggestions show up;
56
+ - dry runs and gates;
57
+ - the Sizer and FleetScope cards;
58
+ - the weekly checks;
59
+ - deploying anywhere.
60
+
61
+ Render it with `node scripts/render-scenes.mjs --video highlights` in `video/`.
62
+
63
+ ### Fixed
64
+
65
+ - **Gemma 4 KV cache** (#97): its sliding-window layers have 16 KV heads of 256, and its full-attention layers have 4
66
+ heads of 512 with keys and values in one tensor. The catalog used the full-attention shape for every layer, so
67
+ sliding-window KV was undercounted 4×. Three new model fields describe the full-attention layers: `globalKvHeads`,
68
+ `globalHeadDim` and `kvShared`. The Sizer's KV math and the FleetScope export use them, and `fromHFConfig` reads
69
+ them from a config.
70
+ - **DeepSeek V4** (#97): `fromHFConfig` reads its compressed attention. That is one shared KV head plus
71
+ `compress_ratios`, sized like MLA. Before, the importer read it as GQA. The catalog's sparse top-k is now 1024
72
+ (Pro) and 512 (Flash), not 2048.
73
+ - **MiniMax** block-sparse attention (`sparse_topk_blocks` × `sparse_block_size`) is read as `sparseTopK` (#97).
74
+ - **`up.sh vm` on a GPU server** (#93): fleetops listens on 9400, which is also dcgm-exporter's default port. When
75
+ 9400 is taken, fleetops now moves to the next free port (9410, …) and says so. Before, the install failed with a
76
+ port conflict. `--port P` picks the port yourself.
77
+ - **NVSentinel v1.34.0** (#97): the format check's baseline. The adapter reads the same fields, and doesn't read
78
+ `HealthEvent.id`, which v1.34.0 documents as not unique.
79
+ - **CLI** (#92): `aiinfra sizer --help` prints the usage instead of sizing the default model. Dry runs no longer print
80
+ rows that have no data (TTFT for calls without timings).
81
+
82
+ ### Changed
83
+
84
+ - **`--json` (`harness-ledger.economics`)** (#92): `fixes.rows[].perResolved` and `costPerResolvedAfter` can now be
85
+ `null`. That happens when calls are priced but have no outcomes to divide by. With more models priced, such rows
86
+ appear where none did before. `harness-ledger.advise` and `harness-ledger.assess` list their `costUnit`: `USD`, or
87
+ `units` with relative prices.
88
+
6
89
  ## 0.5.0 (2026-11-29)
7
90
 
8
91
  Optimize across the stack, and raise what is worth changing where people already work. `aiinfra assess`, `advise`
package/README.md CHANGED
@@ -7,7 +7,9 @@ and a person approves every change. Each tool is also an Agent Skill.
7
7
  **Try it in your browser:** [Inference Sizer](https://hardikashah-eng.github.io/AIInfraTools/sizer/) ·
8
8
  [What fits on my GPUs](https://hardikashah-eng.github.io/AIInfraTools/sizer/#fit) ·
9
9
  [FleetScope](https://hardikashah-eng.github.io/AIInfraTools/fleetscope/) ·
10
- **Install:** `npx aiinfra-tools --help`
10
+ **Install:** `npx aiinfra-tools --help` ·
11
+ **New here?** [Getting started](docs/GETTING-STARTED.md): ten minutes from nothing to the first change worth making on
12
+ your own agent logs.
11
13
 
12
14
  Each tool lives in its own folder with its own README. What has been checked against real data, and what it found:
13
15
  [docs/RESULTS.md](docs/RESULTS.md).
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetops",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "license": "Apache-2.0",
5
5
  "private": true,
6
6
  "description": "Shared data layer, continuous calibration, root-cause analysis and safe optimization across the AIInfraTools utilities.",
@@ -9,7 +9,8 @@
9
9
  // - datastore documents: { createdAt, healthEvent, healthEventStatus } (nodeQuarantined, faultRemediated, …)
10
10
  // - HealthEventResource objects (healthevents.dgxc.nvidia.com): { spec: HealthEvent, status: HealthEventStatus }
11
11
  // - bare HealthEvent objects (protobuf JSON: camelCase; enums as names or numbers; timestamps RFC 3339 or {seconds})
12
- // Fields as in NVSentinel v1.33.0's data-models/protobufs/health_event.proto and event-exporter.
12
+ // Fields as in NVSentinel v1.34.0's data-models/protobufs/health_event.proto and event-exporter (v1.33.0 had the same
13
+ // fields). HealthEvent.id is not read: it is set by producers and is not unique (v1.34.0's proto says so).
13
14
  import { xidClass, DEVICE_CLASSES } from './logs.mjs';
14
15
 
15
16
  const ACTIONS = { 0: 'NONE', 2: 'COMPONENT_RESET', 5: 'CONTACT_SUPPORT', 6: 'RUN_FIELDDIAG', 15: 'RESTART_VM', 24: 'RESTART_BM', 25: 'REPLACE_VM', 26: 'RUN_DCGMEUD', 27: 'CUSTOM', 99: 'UNKNOWN' };
@@ -617,6 +617,9 @@ button, select, input { font: inherit; color: inherit; }
617
617
  { k: 'qHeads', label: 'Query heads', min: 1, max: 4096, int: true, required: true },
618
618
  { k: 'kvHeads', label: 'KV heads', min: 1, max: 4096, int: true, required: true },
619
619
  { k: 'headDim', label: 'Head dim', min: 8, max: 4096, int: true, required: true },
620
+ { k: 'globalKvHeads', label: 'KV heads on full-attention layers', min: 0, max: 4096, int: true, hint: 'When full-attention layers differ from sliding-window ones (Gemma 4: num_global_key_value_heads). 0 = same as KV heads.' },
621
+ { k: 'globalHeadDim', label: 'Head dim on full-attention layers', min: 0, max: 4096, int: true, hint: 'Gemma 4: global_head_dim. 0 = same as head dim.' },
622
+ { k: 'kvShared', label: 'Keys and values share one tensor on full-attention layers (1 = yes)', min: 0, max: 1, int: true, hint: 'Gemma 4: attention_k_eq_v. Halves the KV those layers keep.' },
620
623
  { k: 'attn', type: 'enum', opts: ['gqa', 'mla'], label: 'Attention', required: true },
621
624
  { k: 'mlaLatent', label: 'MLA KV latent (kv_lora_rank)', min: 1, max: 1e5, int: true },
622
625
  { k: 'mlaRope', label: 'MLA RoPE dim', min: 0, max: 1e4, int: true },
@@ -663,14 +666,14 @@ button, select, input { font: inherit; color: inherit; }
663
666
  // ---- 2026 open-weight models (config.json values; see docs/CATALOG.md for where each figure comes from) ----
664
667
  // Kimi K3 (K3.1 Pro shares the architecture): 69 Kimi Delta Attention layers (96 heads × 128 × 128 fp32 state) and
665
668
  // 24 gated MLA layers; MXFP4 weights from quantization-aware training.
666
- 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' }),
669
+ 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', alsoRepos: ['moonshotai/Kimi-K3.1-Pro'] }),
667
670
  // Kimi K2.5 / K2.6: K2's shape with 256K context and native INT4 weights (sized as 4-bit)
668
671
  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' }),
669
672
  // DeepSeek V4: one 512-wide latent per token, kept at 1/4 (CSA) or 1/128 (HCA) on alternating layers (≈ 0.129 on
670
673
  // average); CSA attends its index top-1024, HCA all compressed blocks: modelled as 2048 attended tokens per query.
671
674
  // Experts in FP4, the rest FP8.
672
- 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' }),
673
- 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' }),
675
+ 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: 1024, experts: 384, topk: 6, maxCtx: 1048576, wprec: 'fp4', source: 'https://huggingface.co/deepseek-ai/DeepSeek-V4-Pro' }),
676
+ 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: 512, experts: 256, topk: 6, maxCtx: 1048576, wprec: 'fp8', source: 'https://huggingface.co/deepseek-ai/DeepSeek-V4-Flash' }),
674
677
  // GLM-5.1 and GLM-5.3: MLA with DeepSeek-style sparse attention (index top-2048); GLM-5.3 extends the context to 1M.
675
678
  // GLM-5.3's active parameters are not published: the GLM-5 lineage's 40B is assumed.
676
679
  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' }),
@@ -681,15 +684,15 @@ button, select, input { font: inherit; color: inherit; }
681
684
  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' }),
682
685
  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' }),
683
686
  // MiniMax M3: sparse attention (16 blocks of 128 tokens) in 57 of 60 layers, modelled on all of them
684
- 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' }),
687
+ 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', alsoRepos: ['MiniMaxAI/MiniMax-M3.1-Flash'] }),
685
688
  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' }),
686
689
  // Muse Spark Open: 46 sliding-window layers (2048 tokens) and 16 full-attention layers
687
690
  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' }),
688
691
  // Gemma 4 31B: 50 sliding-window layers (1024 tokens) and 10 global layers with 4 KV heads of 512 and keys reused as
689
692
  // 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.
690
- 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' }),
693
+ Object.assign({}, G, { id: 'gemma4-31b', name: 'Gemma 4 31B', total: 30.7, active: 30.7, layers: 60, hidden: 5376, qHeads: 32, kvHeads: 16, headDim: 256, globalKvHeads: 4, globalHeadDim: 512, kvShared: 1, swaFrac: 50 / 60, swaWindow: 1024, maxCtx: 262144, wprec: 'fp8', source: 'https://huggingface.co/google/gemma-4-31B' }),
691
694
  ];
692
- 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' };
695
+ const MODEL_DEFAULTS = { attn: 'gqa', globalKvHeads: 0, globalHeadDim: 0, kvShared: 0, 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' };
693
696
  const GPU_DEFAULTS = { tfFp8: 0, tfFp4: 0, nodeKW: 0, price: 0, vendor: '' };
694
697
 
695
698
  // ---------- validation ----------
@@ -790,6 +793,22 @@ button, select, input { font: inherit; color: inherit; }
790
793
  const mlaLatent = mla ? +c.kv_lora_rank : 512, mlaRope = mla ? +first(c, ['qk_rope_head_dim'], 64) : 64;
791
794
  const mlaNope = mla ? +first(c, ['qk_nope_head_dim'], 128) : 128, mlaV = mla ? +first(c, ['v_head_dim'], 128) : 128;
792
795
  if (mla) kvHeads = 1;
796
+ // Gemma 4: full-attention layers have their own KV shape (num_global_key_value_heads, global_head_dim), and with
797
+ // attention_k_eq_v keys and values share one tensor there
798
+ const globalKvHeads = c.num_global_key_value_heads != null ? +c.num_global_key_value_heads : 0;
799
+ const globalHeadDim = globalKvHeads && c.global_head_dim != null ? +c.global_head_dim : 0;
800
+ const kvShared = globalKvHeads && c.attention_k_eq_v === true ? 1 : 0;
801
+ if (globalKvHeads) notes.push(`Full-attention layers: ${globalKvHeads} KV heads of ${globalHeadDim || headDim}${kvShared ? ', keys and values in one tensor' : ''}; sliding-window layers: ${kvHeads} of ${headDim}.`);
802
+ // DeepSeek V4 compressed attention: one shared KV head (head_dim, of which qk_rope_head_dim is RoPE) per layer, kept
803
+ // for 1 in compress_ratios[layer] tokens. Sized like MLA: a latent of head_dim − rope plus the rope part per kept token.
804
+ let csa = false, kvKeep = 1;
805
+ if (!mla && kvHeads === 1 && Array.isArray(c.compress_ratios) && /^deepseek_v4$/.test(String(c.model_type || ''))) {
806
+ csa = true;
807
+ const r = c.compress_ratios.map(Number);
808
+ kvKeep = +(r.reduce((a, x) => a + (x > 0 ? 1 / x : 1), 0) / r.length).toFixed(4);
809
+ notes.push(`Compressed attention: KV kept for ${(kvKeep * 100).toFixed(1)}% of tokens on average (layers with ratio 0 counted as uncompressed); the ${c.sliding_window || 0}-token window each layer also keeps is not added.`);
810
+ } else if (Array.isArray(c.compress_ratios)) notes.push(`compress_ratios is set but this importer reads it only for DeepSeek V4 (model_type ${c.model_type}); KV is sized without compression.`);
811
+ const ropeD = +first(c, ['qk_rope_head_dim'], 64);
793
812
  // sliding window
794
813
  let swaFrac = 0, swaWindow = 0;
795
814
  if (Array.isArray(c.layer_types) && c.sliding_window) {
@@ -801,7 +820,7 @@ button, select, input { font: inherit; color: inherit; }
801
820
  swaFrac = +(n / c.no_rope_layers.length).toFixed(3); swaWindow = +c.attention_chunk_size;
802
821
  notes.push('Chunked-attention layers modelled as sliding-window layers.');
803
822
  }
804
- if (c.sliding_window && !swaFrac) notes.push('sliding_window is set but not enabled for these layers; KV is sized for full attention.');
823
+ if (c.sliding_window && !swaFrac && !csa) notes.push('sliding_window is set but not enabled for these layers; KV is sized for full attention.');
805
824
  // linear-attention layers (Qwen3-Next / Qwen3.5 Gated DeltaNet: layer_types "linear_attention" or full_attention_interval)
806
825
  let linFrac = 0, linStateMB = 0;
807
826
  const linN = Array.isArray(c.layer_types) ? c.layer_types.filter(t => /linear/i.test(String(t))).length
@@ -813,7 +832,8 @@ button, select, input { font: inherit; color: inherit; }
813
832
  notes.push(`${linN} linear-attention layers: a ${linStateMB} MB state per layer per sequence (fp32), no KV per token.`);
814
833
  }
815
834
  // sparse attention: an index picks the tokens each query attends (DeepSeek Sparse Attention and its descendants)
816
- const sparseTopK = c.index_topk ? +c.index_topk : 0;
835
+ // MiniMax M3: block-sparse, sparse_topk_blocks blocks of sparse_block_size tokens
836
+ const sparseTopK = c.index_topk ? +c.index_topk : c.use_sparse_attention && c.sparse_topk_blocks ? +c.sparse_topk_blocks * +first(c, ['sparse_block_size'], 128) : 0;
817
837
  if (sparseTopK) notes.push(`Sparse attention: each query attends ${sparseTopK} selected tokens.`);
818
838
  // context
819
839
  let maxCtx = +first(c, ['max_position_embeddings', 'n_positions', 'seq_length', 'max_sequence_length'], 4096);
@@ -829,7 +849,11 @@ button, select, input { font: inherit; color: inherit; }
829
849
  const denseLayers = layers - moeLayers;
830
850
  // attention params per layer
831
851
  let attnP;
832
- if (mla) {
852
+ if (csa) {
853
+ const qP = c.q_lora_rank ? hidden * c.q_lora_rank + c.q_lora_rank * qHeads * headDim : hidden * qHeads * headDim;
854
+ const oP = c.o_lora_rank ? qHeads * headDim * c.o_lora_rank + c.o_lora_rank * hidden : qHeads * headDim * hidden;
855
+ attnP = qP + hidden * headDim + oP;
856
+ } else if (mla) {
833
857
  const qk = mlaNope + mlaRope;
834
858
  const qP = c.q_lora_rank ? hidden * c.q_lora_rank + c.q_lora_rank * qHeads * qk : hidden * qHeads * qk;
835
859
  attnP = qP + hidden * (mlaLatent + mlaRope) + mlaLatent * qHeads * (mlaNope + mlaV) + qHeads * mlaV * hidden;
@@ -849,7 +873,9 @@ button, select, input { font: inherit; color: inherit; }
849
873
  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');
850
874
  const model = {
851
875
  name, total: +(total / 1e9).toFixed(2), active: +(active / 1e9).toFixed(2), layers, hidden, qHeads, kvHeads, headDim,
852
- attn: mla ? 'mla' : 'gqa', mlaLatent, mlaRope, mlaNope, mlaV, experts, topk, swaFrac, swaWindow, linFrac, linStateMB, sparseTopK, maxCtx,
876
+ attn: mla || csa ? 'mla' : 'gqa',
877
+ mlaLatent: csa ? headDim - ropeD : mlaLatent, mlaRope: csa ? ropeD : mlaRope, mlaNope: csa ? headDim - ropeD : mlaNope, mlaV: csa ? headDim : mlaV,
878
+ globalKvHeads, globalHeadDim, kvShared, kvKeep, experts, topk, swaFrac, swaWindow, linFrac, linStateMB, sparseTopK, maxCtx,
853
879
  wprec: /fp8|float8/i.test(JSON.stringify(j.quantization_config || '')) ? 'fp8' : /mxfp4|nvfp4|fp4/i.test(JSON.stringify(j.quantization_config || '')) ? 'fp4' : 'fp8',
854
880
  };
855
881
  return { model, notes };
@@ -901,7 +927,10 @@ button, select, input { font: inherit; color: inherit; }
901
927
  bpp, kvb, isMoE, mla, computeFallback,
902
928
  Wd: dense * 1e9 * bpp, We: Eall * 1e9 * bpp,
903
929
  denseP: dense * 1e9, activeP: (isMoE ? s.active : s.total) * 1e9,
904
- kvTokLayer: mla ? (lat + rope) * kvb : 2 * s.kvHeads * s.headDim * kvb,
930
+ // KV elements per token per layer: full-attention layers may have their own shape (Gemma 4), sliding-window layers
931
+ // use kvHeads × headDim
932
+ kvTokLayer: mla ? (lat + rope) * kvb : (s.kvShared ? 1 : 2) * (s.globalKvHeads || s.kvHeads) * (s.globalHeadDim || s.headDim) * kvb,
933
+ kvTokSwa: mla ? (lat + rope) * kvb : 2 * s.kvHeads * s.headDim * kvb,
905
934
  swaLayers, linLayers, fullLayers: s.layers - swaLayers - linLayers, win: s.swaWindow || 0, keep, topK, linState,
906
935
  // FLOPs per token per linear-attention layer: read and update the state (fp32, 4 bytes an element), ~4 FLOPs an element
907
936
  Alin: (s.linStateMB || 0) * 1e6,
@@ -919,7 +948,7 @@ button, select, input { font: inherit; color: inherit; }
919
948
  // the last W, linear-attention layers a fixed state
920
949
  function kvBytes(md, L) {
921
950
  const w = md.win || L, keep = md.keep || 1;
922
- return md.kvTokLayer * (md.fullLayers * L * keep + md.swaLayers * Math.min(L, w)) + (md.linState || 0);
951
+ return md.kvTokLayer * md.fullLayers * L * keep + (md.kvTokSwa != null ? md.kvTokSwa : md.kvTokLayer) * md.swaLayers * Math.min(L, w) + (md.linState || 0);
923
952
  }
924
953
  // context tokens one query attends in a full-attention layer, and its integral over query positions 0..x
925
954
  const attended = (md, L) => { const n = L * (md.keep || 1); return md.topK ? Math.min(n, md.topK) : n; };
@@ -1393,7 +1422,7 @@ button, select, input { font: inherit; color: inherit; }
1393
1422
  if (CAT && SZ) {
1394
1423
  for (const c of CAT.MODELS) {
1395
1424
  if (IN_LIST[c.id] || MODELS[c.id]) continue;
1396
- const m = { label: c.name, params: c.total, active: c.active, layers: c.layers, kvHeads: c.attn === 'mla' ? 0 : c.kvHeads, headDim: c.attn === 'mla' ? 0 : c.headDim, mla: c.attn === 'mla' ? (c.mlaLatent || 512) + (c.mlaRope == null ? 64 : c.mlaRope) : 0 };
1425
+ const m = { label: c.name, params: c.total, active: c.active, layers: c.layers, kvHeads: c.attn === 'mla' ? 0 : (c.globalKvHeads || c.kvHeads) * (c.kvShared ? 0.5 : 1), headDim: c.attn === 'mla' ? 0 : c.globalHeadDim || c.headDim, mla: c.attn === 'mla' ? (c.mlaLatent || 512) + (c.mlaRope == null ? 64 : c.mlaRope) : 0 };
1397
1426
  const md = SZ.derive(Object.assign({}, SZ.SETTINGS, CAT.MODEL_DEFAULTS, c, { kvprec: 'fp8', tfBf16: 1, hbmTBs: 1, scaleUpGBs: 1, nicGbps: 1, hbmGB: 1 }));
1398
1427
  m.kvScale = +(SZ.kvBytes(md, 32768) / 32768 / kvDimTotal(m)).toFixed(4);
1399
1428
  MODELS[c.id] = m;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetscope",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "license": "Apache-2.0",
5
5
  "private": true,
6
6
  "description": "Node editor for replaying LLM traffic on a modelled hybrid (on-prem + neocloud) GPU fleet",
@@ -53,7 +53,7 @@
53
53
  if (CAT && SZ) {
54
54
  for (const c of CAT.MODELS) {
55
55
  if (IN_LIST[c.id] || MODELS[c.id]) continue;
56
- const m = { label: c.name, params: c.total, active: c.active, layers: c.layers, kvHeads: c.attn === 'mla' ? 0 : c.kvHeads, headDim: c.attn === 'mla' ? 0 : c.headDim, mla: c.attn === 'mla' ? (c.mlaLatent || 512) + (c.mlaRope == null ? 64 : c.mlaRope) : 0 };
56
+ const m = { label: c.name, params: c.total, active: c.active, layers: c.layers, kvHeads: c.attn === 'mla' ? 0 : (c.globalKvHeads || c.kvHeads) * (c.kvShared ? 0.5 : 1), headDim: c.attn === 'mla' ? 0 : c.globalHeadDim || c.headDim, mla: c.attn === 'mla' ? (c.mlaLatent || 512) + (c.mlaRope == null ? 64 : c.mlaRope) : 0 };
57
57
  const md = SZ.derive(Object.assign({}, SZ.SETTINGS, CAT.MODEL_DEFAULTS, c, { kvprec: 'fp8', tfBf16: 1, hbmTBs: 1, scaleUpGBs: 1, nicGbps: 1, hbmGB: 1 }));
58
58
  m.kvScale = +(SZ.kvBytes(md, 32768) / 32768 / kvDimTotal(m)).toFixed(4);
59
59
  MODELS[c.id] = m;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gpu-health",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "license": "Apache-2.0",
5
5
  "private": true,
6
6
  "description": "GPU health checks, efficiency and savings analysis, and an approval queue that runs fixes once approved.",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gpu-ledger",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "license": "Apache-2.0",
5
5
  "private": true,
6
6
  "description": "GPU billing and waste for any cluster: who used which GPUs, what it cost, how much was useful, and where to save. Exports FOCUS.",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "harness-ledger",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "license": "Apache-2.0",
5
5
  "private": true,
6
6
  "description": "Where agent harnesses waste model resources, across harnesses: cache misses, bloated tool output, repeats, retries, unused tools; in tokens, dollars and GPU time.",
@@ -399,7 +399,7 @@ export function adviseText(R) {
399
399
  }
400
400
  if (R.dryRun) {
401
401
  const D = R.dryRun; L.push('', `Dry run of ${D.applied.join(' + ')}:`);
402
- for (const k of Object.keys(D.before)) L.push(` ${k.padEnd(13)} ${fv(k, D.before[k]).padStart(10)} → ${fv(k, D.after[k]).padEnd(10)} ${fmtC(D.change[k])}`);
402
+ for (const k of Object.keys(D.before).filter(k => D.before[k] != null || D.after[k] != null)) L.push(` ${k.padEnd(13)} ${fv(k, D.before[k]).padStart(10)} → ${fv(k, D.after[k]).padEnd(10)} ${fmtC(D.change[k])}`);
403
403
  L.push('', ' How to make each change:'); for (const c of D.changes) L.push(` ${c.id}: ${Object.entries(c.how || {}).map(([k, v]) => `${k}: ${v}`).join('; ')} → verify: ${c.verify}`);
404
404
  L.push(` Then: ${D.next.join('; ')}`);
405
405
  if (R.gate) L.push('', R.gate.pass ? 'Gate: pass' : `Gate: FAIL (${R.gate.fails.map(f => f.condition).join(', ')})`);
@@ -59,7 +59,7 @@ export function adviseMarkdown(R) {
59
59
  const L = [`## ${R.goalLabel}: dry run`, ''];
60
60
  if (R.dryRun) {
61
61
  const D = R.dryRun; L.push(`Changes: ${D.applied.map(x => `\`${x}\``).join(' + ')}`, '', '| Metric | Before | After | Change |', '|---|---|---|---|');
62
- for (const k of Object.keys(D.before)) L.push(`| ${k} | ${fmtK(k, D.before[k], R.costUnit)} | ${fmtK(k, D.after[k], R.costUnit)} | ${sgn(D.change[k])} |`);
62
+ for (const k of Object.keys(D.before).filter(k => D.before[k] != null || D.after[k] != null)) L.push(`| ${k} | ${fmtK(k, D.before[k], R.costUnit)} | ${fmtK(k, D.after[k], R.costUnit)} | ${sgn(D.change[k])} |`);
63
63
  if (R.gate) L.push('', R.gate.pass ? '**Gate: pass**' : `**Gate: FAIL** — ${R.gate.fails.map(f => `\`${f.condition}\``).join(', ')}`);
64
64
  } else L.push('No changes applied (--apply).');
65
65
  return L.join('\n') + '\n';