aiinfra-tools 0.3.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.
- package/CHANGELOG.md +58 -0
- package/README.md +13 -0
- package/fleetops/deploy/shadow-live/README.md +8 -0
- package/fleetops/deploy/shadow-live/kit.yaml +2 -0
- package/fleetops/deploy/shadow-live/run.sh +6 -1
- package/fleetops/package.json +1 -1
- package/fleetops/src/ingest.mjs +9 -2
- package/fleetops/src/serving.mjs +11 -1
- package/fleetscope/build.mjs +3 -0
- package/fleetscope/dist/index.html +719 -3
- package/fleetscope/package.json +1 -1
- package/fleetscope/src/engine.js +19 -2
- package/fleetscope/src/index.src.html +6 -0
- package/gpu-health/package.json +1 -1
- package/gpu-ledger/package.json +1 -1
- package/harness-ledger/package.json +1 -1
- package/hybrid-tracing/package.json +1 -1
- package/inference-sizer/dist/index.html +97 -12
- package/inference-sizer/docs/CATALOG.md +71 -0
- package/inference-sizer/docs/METHOD.md +1 -1
- package/inference-sizer/package.json +1 -1
- package/inference-sizer/src/accelerators.js +23 -1
- package/inference-sizer/src/catalog.js +49 -3
- package/inference-sizer/src/model.js +24 -7
- package/inference-sizer/src/ui.js +1 -1
- package/inference-sizer/tools/validate-agentx.mjs +8 -2
- package/inference-sizer/tools/validate-inferencex.mjs +1 -1
- package/package.json +2 -3
|
@@ -431,6 +431,11 @@ button, select, input { font: inherit; color: inherit; }
|
|
|
431
431
|
|
|
432
432
|
const A = (o) => Object.assign({ kind: 'gpu', tfFp4: 0 }, o);
|
|
433
433
|
const ACCELERATORS = [
|
|
434
|
+
// Vera Rubin NVL72 (VR200; first called NVL144 for its 144 dies): per Rubin package, 288 GB HBM4 at 22 TB/s; dense
|
|
435
|
+
// NVFP4 35 PF (the 50 PF inference figure uses adaptive compression), FP8 17.5 PF, BF16 4 PF; NVLink 6 3.6 TB/s
|
|
436
|
+
// bidirectional; ConnectX-9 1.6 Tb/s. NVIDIA publishes no board power: 2.3 kW is the reported Max-P TGP.
|
|
437
|
+
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',
|
|
438
|
+
source: 'https://developer.nvidia.com/blog/inside-the-NVIDIA-rubin-platform-six-new-chips-one-ai-supercomputer' }),
|
|
434
439
|
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',
|
|
435
440
|
// 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
|
|
436
441
|
source: 'https://www.nvidia.com/en-us/data-center/gb300-nvl72/' }),
|
|
@@ -446,8 +451,17 @@ button, select, input { font: inherit; color: inherit; }
|
|
|
446
451
|
source: 'https://www.nvidia.com/en-us/data-center/h100/' }),
|
|
447
452
|
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',
|
|
448
453
|
source: 'https://www.nvidia.com/en-us/data-center/a100/' }),
|
|
454
|
+
// RTX PRO 6000 Blackwell Server Edition: 96 GB GDDR7 at 1.6 TB/s; 4 / 2 / 1 PF FP4 / FP8 / BF16 with sparsity
|
|
455
|
+
// (halved here); PCIe 5.0 x16 between cards; up to 600 W
|
|
456
|
+
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',
|
|
457
|
+
source: 'https://www.nvidia.com/en-us/data-center/rtx-pro-6000-blackwell-server-edition/' }),
|
|
449
458
|
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',
|
|
450
459
|
source: 'https://www.nvidia.com/en-us/data-center/l40s/' }),
|
|
460
|
+
// 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
|
|
461
|
+
// (UALink over Ethernet, bidirectional), 43 TB/s scale-out per rack (2.4 Tb/s per GPU per direction), 246 kW per
|
|
462
|
+
// rack (AMD's validated reference design). AMD publishes no board power: ~1.7 kW is the reported projection.
|
|
463
|
+
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',
|
|
464
|
+
source: 'https://www.amd.com/en/products/accelerators/instinct/mi400.html' }),
|
|
451
465
|
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',
|
|
452
466
|
// Infinity Fabric: 7 links × 144 GB/s (bidirectional) = 504 GB/s per direction
|
|
453
467
|
source: 'https://www.amd.com/en/products/accelerators/instinct/mi350/mi355x.html' }),
|
|
@@ -486,7 +500,7 @@ button, select, input { font: inherit; color: inherit; }
|
|
|
486
500
|
// ---------- cloud instance types ----------
|
|
487
501
|
// AWS: docs.aws.amazon.com/AWSEC2/latest/UserGuide/accelerated-computing-instances.html and aws.amazon.com/ec2/instance-types/p6/
|
|
488
502
|
const INSTANCES = {};
|
|
489
|
-
const add = (cloud, chip, list) => { for (const [type, gpus] of list) INSTANCES[type] = { cloud, chip, gpus }; };
|
|
503
|
+
const add = (cloud, chip, list) => { for (const [type, gpus] of list) INSTANCES[type.toLowerCase()] = { cloud, chip, gpus }; };
|
|
490
504
|
const sizes = (fam, one, more) => one.map(s => [`${fam}.${s}`, 1]).concat(more.map(([s, n]) => [`${fam}.${s}`, n]));
|
|
491
505
|
add('aws', 'A100-40GB', [['p4d.24xlarge', 8]]);
|
|
492
506
|
add('aws', 'A100', [['p4de.24xlarge', 8]]);
|
|
@@ -512,6 +526,14 @@ button, select, input { font: inherit; color: inherit; }
|
|
|
512
526
|
add('gcp', 'TPU-v5p', [['ct5p-hightpu-4t', 4]]);
|
|
513
527
|
add('gcp', 'TPU7x', [['tpu7x-standard-4t', 4]]);
|
|
514
528
|
add('gcp', 'TPU-v5e', [['ct5lp-hightpu-1t', 1], ['ct5lp-hightpu-4t', 4], ['ct5lp-hightpu-8t', 8]]);
|
|
529
|
+
// Azure: learn.microsoft.com/azure/virtual-machines/sizes/gpu-accelerated (ND H100/H200/MI300X v5, ND GB200 v6, ND A100 v4);
|
|
530
|
+
// AKS puts the size in node.kubernetes.io/instance-type with this capitalisation (matched case-insensitively)
|
|
531
|
+
add('azure', 'H100', [['Standard_ND96isr_H100_v5', 8]]);
|
|
532
|
+
add('azure', 'H200', [['Standard_ND96isr_H200_v5', 8]]);
|
|
533
|
+
add('azure', 'MI300X', [['Standard_ND96isr_MI300X_v5', 8]]);
|
|
534
|
+
add('azure', 'GB200-NVL72', [['Standard_ND128isr_NDR_GB200_v6', 4]]); // 18 VMs per NVL72 rack
|
|
535
|
+
add('azure', 'A100-40GB', [['Standard_ND96asr_v4', 8]]);
|
|
536
|
+
add('azure', 'A100', [['Standard_ND96amsr_A100_v4', 8]]);
|
|
515
537
|
const instanceOf = type => INSTANCES[String(type || '').toLowerCase()] || null;
|
|
516
538
|
// TPU slice topology for a chip count: 2D (v5e, v6e) or 3D torus (v4, v5p, 7x), as GKE's node selector wants it
|
|
517
539
|
const TOPO2 = { 1: '1x1', 4: '2x2', 8: '2x4', 16: '4x4', 32: '4x8', 64: '8x8', 128: '8x16', 256: '16x16' };
|
|
@@ -558,6 +580,683 @@ button, select, input { font: inherit; color: inherit; }
|
|
|
558
580
|
else root.AIInfraAccelerators = api;
|
|
559
581
|
})(typeof globalThis !== 'undefined' ? globalThis : this);
|
|
560
582
|
|
|
583
|
+
</script>
|
|
584
|
+
<script>
|
|
585
|
+
/* Inference Sizer catalog: GPUs and models, spec-sheet import/export, and Hugging Face config.json parsing.
|
|
586
|
+
Plain data plus validation, so the browser page, the CLI and FleetScope can share it. */
|
|
587
|
+
(function (root) {
|
|
588
|
+
'use strict';
|
|
589
|
+
|
|
590
|
+
// ---------- schemas ----------
|
|
591
|
+
// Every field a GPU or model entry may carry, with its unit, range and a one-line meaning.
|
|
592
|
+
// The UI builds its edit forms from these, and imports are checked against them.
|
|
593
|
+
const GPU_FIELDS = [
|
|
594
|
+
{ k: 'label', type: 'text', label: 'Name', required: true },
|
|
595
|
+
{ k: 'vendor', type: 'text', label: 'Vendor' },
|
|
596
|
+
{ k: 'hbmGB', label: 'HBM per GPU', unit: 'GB', min: 1, max: 4096, required: true, hint: 'Memory the GPU exposes (e.g. 180 for HGX B200).' },
|
|
597
|
+
{ k: 'hbmTBs', label: 'HBM bandwidth', unit: 'TB/s', min: 0.1, max: 100, required: true },
|
|
598
|
+
{ k: 'tfBf16', label: 'BF16 dense', unit: 'TFLOPS', min: 1, max: 1e6, required: true, hint: 'Dense, not the "with sparsity" figure.' },
|
|
599
|
+
{ k: 'tfFp8', label: 'FP8 dense', unit: 'TFLOPS', min: 0, max: 1e6, hint: '0 if the GPU has no FP8 tensor cores.' },
|
|
600
|
+
{ k: 'tfFp4', label: 'FP4 dense', unit: 'TFLOPS', min: 0, max: 1e6, hint: '0 if the GPU has no FP4 tensor cores.' },
|
|
601
|
+
{ k: 'scaleUpGBs', label: 'GPU-to-GPU link, per direction', unit: 'GB/s', min: 1, max: 1e5, required: true, hint: 'NVLink / Infinity Fabric. Half the bidirectional figure.' },
|
|
602
|
+
{ k: 'domain', label: 'GPUs per scale-up domain', unit: 'GPUs', min: 1, max: 576, required: true, hint: '8 for an HGX server, 72 for an NVL72 rack.' },
|
|
603
|
+
{ k: 'nicGbps', label: 'Scale-out NIC per GPU', unit: 'Gb/s', min: 1, max: 1e4, required: true },
|
|
604
|
+
{ k: 'nodeKW', label: 'Power per domain (max)', unit: 'kW', min: 0, max: 2000 },
|
|
605
|
+
{ k: 'price', label: 'Price', unit: '$/GPU-hr', min: 0, max: 1000, hint: 'Placeholder unless you set your own.' },
|
|
606
|
+
{ k: 'source', type: 'text', label: 'Spec sheet URL' },
|
|
607
|
+
];
|
|
608
|
+
const MODEL_FIELDS = [
|
|
609
|
+
{ k: 'name', type: 'text', label: 'Name', required: true },
|
|
610
|
+
{ k: 'total', label: 'Total params', unit: 'B', min: 0.01, max: 1e5, required: true },
|
|
611
|
+
{ k: 'active', label: 'Active params per token', unit: 'B', min: 0.01, max: 1e5, required: true },
|
|
612
|
+
{ k: 'layers', label: 'Layers', min: 1, max: 1000, int: true, required: true },
|
|
613
|
+
{ k: 'hidden', label: 'Hidden size', min: 64, max: 1e6, int: true, required: true },
|
|
614
|
+
{ k: 'qHeads', label: 'Query heads', min: 1, max: 4096, int: true, required: true },
|
|
615
|
+
{ k: 'kvHeads', label: 'KV heads', min: 1, max: 4096, int: true, required: true },
|
|
616
|
+
{ k: 'headDim', label: 'Head dim', min: 8, max: 4096, int: true, required: true },
|
|
617
|
+
{ k: 'attn', type: 'enum', opts: ['gqa', 'mla'], label: 'Attention', required: true },
|
|
618
|
+
{ k: 'mlaLatent', label: 'MLA KV latent (kv_lora_rank)', min: 1, max: 1e5, int: true },
|
|
619
|
+
{ k: 'mlaRope', label: 'MLA RoPE dim', min: 0, max: 1e4, int: true },
|
|
620
|
+
{ k: 'mlaNope', label: 'MLA QK no-PE dim', min: 0, max: 1e4, int: true },
|
|
621
|
+
{ k: 'mlaV', label: 'MLA V head dim', min: 1, max: 1e4, int: true },
|
|
622
|
+
{ k: 'experts', label: 'Routed experts (0 = dense)', min: 0, max: 1e5, int: true },
|
|
623
|
+
{ k: 'topk', label: 'Experts per token', min: 0, max: 1e4, int: true },
|
|
624
|
+
{ k: 'swaFrac', label: 'Share of sliding-window layers', min: 0, max: 1 },
|
|
625
|
+
{ k: 'swaWindow', label: 'Sliding window', unit: 'tokens', min: 0, max: 1e8, int: true },
|
|
626
|
+
{ 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.' },
|
|
627
|
+
{ 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).' },
|
|
628
|
+
{ 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.' },
|
|
629
|
+
{ 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.' },
|
|
630
|
+
{ k: 'maxCtx', label: 'Max context', unit: 'tokens', min: 256, max: 1e8, int: true, required: true },
|
|
631
|
+
{ k: 'wprec', type: 'enum', opts: ['bf16', 'fp8', 'fp4'], label: 'Default weight precision' },
|
|
632
|
+
{ k: 'source', type: 'text', label: 'Model card URL' },
|
|
633
|
+
];
|
|
634
|
+
|
|
635
|
+
// ---------- built-in GPUs ----------
|
|
636
|
+
// From the shared accelerator registry (accelerators.js): per-GPU dense figures, HGX/DGX system totals divided by 8
|
|
637
|
+
// (or 72 for NVL72), "with sparsity" figures halved. Prices are placeholder on-demand rents, not quotes.
|
|
638
|
+
const REG = (typeof module !== 'undefined' && module.exports) ? require('./accelerators.js') : root.AIInfraAccelerators;
|
|
639
|
+
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'];
|
|
640
|
+
const KEEP = ['id', 'kind', 'vendorKey', 'gkeAccelerator', 'tdpW'].concat(GPU_FIELDS.map(f => f.k)); // tdpW: board power, for tokens per MW
|
|
641
|
+
const GPUS = REG.ACCELERATORS.slice().sort((a, b) => (ORDER.indexOf(a.id) + 1 || 99) - (ORDER.indexOf(b.id) + 1 || 99))
|
|
642
|
+
.map(g => Object.fromEntries(KEEP.filter(k => g[k] !== undefined).map(k => [k, g[k]])));
|
|
643
|
+
|
|
644
|
+
// ---------- built-in models ----------
|
|
645
|
+
const MLA = { attn: 'mla', kvHeads: 1, headDim: 128, mlaLatent: 512, mlaRope: 64, mlaNope: 128, mlaV: 128 };
|
|
646
|
+
const G = { attn: 'gqa', experts: 0, topk: 0, swaFrac: 0, swaWindow: 0 };
|
|
647
|
+
const MODELS = [
|
|
648
|
+
Object.assign({ id: 'llama31-8b', name: 'Llama 3.1 8B', total: 8.03, active: 8.03, layers: 32, hidden: 4096, qHeads: 32, kvHeads: 8, headDim: 128, maxCtx: 131072, wprec: 'fp8', source: 'https://huggingface.co/meta-llama/Llama-3.1-8B-Instruct' }, G),
|
|
649
|
+
Object.assign({ id: 'qwen3-32b', name: 'Qwen3 32B', total: 32.8, active: 32.8, layers: 64, hidden: 5120, qHeads: 64, kvHeads: 8, headDim: 128, maxCtx: 131072, wprec: 'fp8', source: 'https://huggingface.co/Qwen/Qwen3-32B' }, G),
|
|
650
|
+
Object.assign({ id: 'llama33-70b', name: 'Llama 3.3 70B', total: 70.6, active: 70.6, layers: 80, hidden: 8192, qHeads: 64, kvHeads: 8, headDim: 128, maxCtx: 131072, wprec: 'fp8', source: 'https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct' }, G),
|
|
651
|
+
Object.assign({ id: 'qwen25-72b', name: 'Qwen2.5 72B', total: 72.7, active: 72.7, layers: 80, hidden: 8192, qHeads: 64, kvHeads: 8, headDim: 128, maxCtx: 131072, wprec: 'fp8', source: 'https://huggingface.co/Qwen/Qwen2.5-72B-Instruct' }, G),
|
|
652
|
+
Object.assign({ id: 'llama31-405b', name: 'Llama 3.1 405B', total: 405.9, active: 405.9, layers: 126, hidden: 16384, qHeads: 128, kvHeads: 8, headDim: 128, maxCtx: 131072, wprec: 'fp8', source: 'https://huggingface.co/meta-llama/Llama-3.1-405B-Instruct' }, G),
|
|
653
|
+
Object.assign({}, G, { id: 'gpt-oss-120b', name: 'gpt-oss-120b (MoE)', total: 116.8, active: 5.1, layers: 36, hidden: 2880, qHeads: 64, kvHeads: 8, headDim: 64, experts: 128, topk: 4, swaFrac: 0.5, swaWindow: 128, maxCtx: 131072, wprec: 'fp4', source: 'https://huggingface.co/openai/gpt-oss-120b' }),
|
|
654
|
+
Object.assign({}, G, { id: 'mixtral-8x22b', name: 'Mixtral 8x22B (MoE)', total: 141, active: 39, layers: 56, hidden: 6144, qHeads: 48, kvHeads: 8, headDim: 128, experts: 8, topk: 2, maxCtx: 65536, wprec: 'fp8', source: 'https://huggingface.co/mistralai/Mixtral-8x22B-Instruct-v0.1' }),
|
|
655
|
+
Object.assign({}, G, { id: 'qwen3-235b', name: 'Qwen3 235B-A22B (MoE)', total: 235, active: 22, layers: 94, hidden: 4096, qHeads: 64, kvHeads: 4, headDim: 128, experts: 128, topk: 8, maxCtx: 131072, wprec: 'fp8', source: 'https://huggingface.co/Qwen/Qwen3-235B-A22B' }),
|
|
656
|
+
Object.assign({}, G, { id: 'llama4-maverick', name: 'Llama 4 Maverick 400B (MoE)', total: 400, active: 17, layers: 48, hidden: 5120, qHeads: 40, kvHeads: 8, headDim: 128, experts: 128, topk: 1, swaFrac: 0.75, swaWindow: 8192, maxCtx: 1048576, wprec: 'fp8', source: 'https://huggingface.co/meta-llama/Llama-4-Maverick-17B-128E-Instruct' }),
|
|
657
|
+
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' }),
|
|
658
|
+
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' }),
|
|
659
|
+
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' }),
|
|
660
|
+
// ---- 2026 open-weight models (config.json values; see docs/CATALOG.md for where each figure comes from) ----
|
|
661
|
+
// Kimi K3 (K3.1 Pro shares the architecture): 69 Kimi Delta Attention layers (96 heads × 128 × 128 fp32 state) and
|
|
662
|
+
// 24 gated MLA layers; MXFP4 weights from quantization-aware training.
|
|
663
|
+
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' }),
|
|
664
|
+
// Kimi K2.5 / K2.6: K2's shape with 256K context and native INT4 weights (sized as 4-bit)
|
|
665
|
+
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' }),
|
|
666
|
+
// DeepSeek V4: one 512-wide latent per token, kept at 1/4 (CSA) or 1/128 (HCA) on alternating layers (≈ 0.129 on
|
|
667
|
+
// average); CSA attends its index top-1024, HCA all compressed blocks: modelled as 2048 attended tokens per query.
|
|
668
|
+
// Experts in FP4, the rest FP8.
|
|
669
|
+
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' }),
|
|
670
|
+
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' }),
|
|
671
|
+
// GLM-5.1 and GLM-5.3: MLA with DeepSeek-style sparse attention (index top-2048); GLM-5.3 extends the context to 1M.
|
|
672
|
+
// GLM-5.3's active parameters are not published: the GLM-5 lineage's 40B is assumed.
|
|
673
|
+
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' }),
|
|
674
|
+
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' }),
|
|
675
|
+
// Mistral Large 4: MLA with sparse token selection (top-2048); nope/v head dims not published (DeepSeek's 128 assumed)
|
|
676
|
+
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' }),
|
|
677
|
+
// Qwen3.5-397B and Qwen3.8 27B: three Gated DeltaNet layers per gated-attention layer (64 / 48 value heads × 128 × 128 fp32 state)
|
|
678
|
+
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' }),
|
|
679
|
+
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' }),
|
|
680
|
+
// MiniMax M3: sparse attention (16 blocks of 128 tokens) in 57 of 60 layers, modelled on all of them
|
|
681
|
+
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' }),
|
|
682
|
+
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' }),
|
|
683
|
+
// Muse Spark Open: 46 sliding-window layers (2048 tokens) and 16 full-attention layers
|
|
684
|
+
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' }),
|
|
685
|
+
// Gemma 4 31B: 50 sliding-window layers (1024 tokens) and 10 global layers with 4 KV heads of 512 and keys reused as
|
|
686
|
+
// 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.
|
|
687
|
+
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' }),
|
|
688
|
+
];
|
|
689
|
+
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' };
|
|
690
|
+
const GPU_DEFAULTS = { tfFp8: 0, tfFp4: 0, nodeKW: 0, price: 0, vendor: '' };
|
|
691
|
+
|
|
692
|
+
// ---------- validation ----------
|
|
693
|
+
const slug = s => String(s || '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '').slice(0, 60) || 'item';
|
|
694
|
+
function check(entry, fields, defaults, kind) {
|
|
695
|
+
const errors = [];
|
|
696
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) return { ok: false, errors: [kind + ' entry must be an object.'] };
|
|
697
|
+
const out = Object.assign({}, defaults);
|
|
698
|
+
const nameKey = kind === 'GPU' ? 'label' : 'name';
|
|
699
|
+
out.id = entry.id ? String(entry.id).replace(/[^A-Za-z0-9._-]+/g, '-').slice(0, 60) : slug(entry[nameKey]);
|
|
700
|
+
for (const f of fields) {
|
|
701
|
+
let v = entry[f.k];
|
|
702
|
+
if (v === undefined || v === null || v === '') {
|
|
703
|
+
if (f.required) errors.push(`${kind} "${entry[nameKey] || entry.id || '?'}": missing ${f.label} (${f.k}).`);
|
|
704
|
+
continue;
|
|
705
|
+
}
|
|
706
|
+
if (f.type === 'text') { out[f.k] = String(v).slice(0, 300); continue; }
|
|
707
|
+
if (f.type === 'enum') {
|
|
708
|
+
v = String(v).toLowerCase();
|
|
709
|
+
if (!f.opts.includes(v)) { errors.push(`${kind} "${entry[nameKey] || out.id}": ${f.k} must be one of ${f.opts.join(', ')}.`); continue; }
|
|
710
|
+
out[f.k] = v; continue;
|
|
711
|
+
}
|
|
712
|
+
v = Number(v);
|
|
713
|
+
if (!isFinite(v)) { errors.push(`${kind} "${entry[nameKey] || out.id}": ${f.k} must be a number.`); continue; }
|
|
714
|
+
if (f.int) v = Math.round(v);
|
|
715
|
+
if (v < f.min || v > f.max) { errors.push(`${kind} "${entry[nameKey] || out.id}": ${f.k} = ${v} is outside ${f.min}–${f.max}${f.unit ? ' ' + f.unit : ''}.`); continue; }
|
|
716
|
+
out[f.k] = v;
|
|
717
|
+
}
|
|
718
|
+
if (kind === 'Model' && out.active > out.total) errors.push(`Model "${out.name}": active params (${out.active}B) exceed total (${out.total}B).`);
|
|
719
|
+
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.`);
|
|
720
|
+
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}.`);
|
|
721
|
+
if (kind === 'Model' && out.experts > 0 && out.active >= out.total) errors.push(`Model "${out.name}": an MoE model needs active params below total params.`);
|
|
722
|
+
return { ok: errors.length === 0, errors, value: out };
|
|
723
|
+
}
|
|
724
|
+
const validateGPU = g => check(g, GPU_FIELDS, GPU_DEFAULTS, 'GPU');
|
|
725
|
+
const validateModel = m => check(m, MODEL_FIELDS, MODEL_DEFAULTS, 'Model');
|
|
726
|
+
|
|
727
|
+
// ---------- spec sheets ----------
|
|
728
|
+
// A spec sheet is JSON: { "kind": "inference-sizer/catalog", "version": 1, "gpus": [...], "models": [...] }.
|
|
729
|
+
// An entry whose id matches a built-in one replaces it ("update via spec sheet"); new ids are added.
|
|
730
|
+
// A single GPU or model object, or a Hugging Face config.json, is also accepted.
|
|
731
|
+
const SHEET_KIND = 'inference-sizer/catalog';
|
|
732
|
+
function parseSheet(text) {
|
|
733
|
+
let j;
|
|
734
|
+
try { j = typeof text === 'string' ? JSON.parse(text) : text; } catch (e) { return { ok: false, errors: ['Not valid JSON: ' + e.message], gpus: [], models: [] }; }
|
|
735
|
+
const res = { ok: true, errors: [], gpus: [], models: [], notes: [] };
|
|
736
|
+
if (!j || typeof j !== 'object') return { ok: false, errors: ['Expected a JSON object.'], gpus: [], models: [] };
|
|
737
|
+
let gpus = [], models = [];
|
|
738
|
+
if (Array.isArray(j.gpus) || Array.isArray(j.models)) { gpus = j.gpus || []; models = j.models || []; }
|
|
739
|
+
else if (isHFConfig(j)) { const m = fromHFConfig(j); models = [m.model]; res.notes.push(...m.notes); }
|
|
740
|
+
else if ('hbmGB' in j || 'tfBf16' in j) gpus = [j];
|
|
741
|
+
else if ('layers' in j || 'qHeads' in j) models = [j];
|
|
742
|
+
else return { ok: false, errors: ['Could not recognise this file. Use a spec sheet with "gpus" and/or "models" arrays, a single GPU or model entry, or a Hugging Face config.json.'], gpus: [], models: [] };
|
|
743
|
+
for (const g of gpus) { const r = validateGPU(g); if (r.ok) res.gpus.push(r.value); else res.errors.push(...r.errors); }
|
|
744
|
+
for (const m of models) { const r = validateModel(m); if (r.ok) res.models.push(r.value); else res.errors.push(...r.errors); }
|
|
745
|
+
res.ok = res.errors.length === 0 && (res.gpus.length + res.models.length) > 0;
|
|
746
|
+
if (!res.gpus.length && !res.models.length && !res.errors.length) { res.ok = false; res.errors.push('The file holds no GPUs or models.'); }
|
|
747
|
+
return res;
|
|
748
|
+
}
|
|
749
|
+
function makeSheet(gpus, models) {
|
|
750
|
+
const strip = o => { const c = Object.assign({}, o); delete c.builtin; delete c.custom; return c; };
|
|
751
|
+
return { kind: SHEET_KIND, version: 1, gpus: (gpus || []).map(strip), models: (models || []).map(strip) };
|
|
752
|
+
}
|
|
753
|
+
// Built-ins overlaid with user entries (same id replaces).
|
|
754
|
+
function merge(builtin, custom) {
|
|
755
|
+
const out = builtin.map(x => Object.assign({ builtin: true }, x));
|
|
756
|
+
for (const c of custom || []) {
|
|
757
|
+
const i = out.findIndex(x => x.id === c.id);
|
|
758
|
+
const e = Object.assign({ custom: true }, c);
|
|
759
|
+
if (i >= 0) out[i] = Object.assign(e, { overrides: true }); else out.push(e);
|
|
760
|
+
}
|
|
761
|
+
return out;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
// ---------- Hugging Face config.json ----------
|
|
765
|
+
function isHFConfig(j) {
|
|
766
|
+
const c = j.text_config || j;
|
|
767
|
+
return ('num_hidden_layers' in c || 'n_layer' in c) && ('hidden_size' in c || 'n_embd' in c || 'd_model' in c);
|
|
768
|
+
}
|
|
769
|
+
const first = (o, keys, d) => { for (const k of keys) if (o[k] !== undefined && o[k] !== null) return o[k]; return d; };
|
|
770
|
+
// Reads architecture fields and estimates parameter counts from the layer shapes (embeddings, attention, MLP/experts).
|
|
771
|
+
function fromHFConfig(j) {
|
|
772
|
+
const notes = [];
|
|
773
|
+
const c = j.text_config ? Object.assign({}, j.text_config) : j;
|
|
774
|
+
if (j.text_config) notes.push('Read the text model from text_config.');
|
|
775
|
+
const layers = +first(c, ['num_hidden_layers', 'n_layer', 'num_layers']);
|
|
776
|
+
const hidden = +first(c, ['hidden_size', 'n_embd', 'd_model']);
|
|
777
|
+
const qHeads = +first(c, ['num_attention_heads', 'n_head', 'num_heads']);
|
|
778
|
+
let kvHeads = +first(c, ['num_key_value_heads', 'num_kv_heads', 'n_head_kv'], c.multi_query ? 1 : qHeads);
|
|
779
|
+
const headDim = +first(c, ['head_dim'], Math.round(hidden / qHeads));
|
|
780
|
+
const V = +first(c, ['vocab_size', 'padded_vocab_size'], 32000);
|
|
781
|
+
const inter = +first(c, ['intermediate_size', 'ffn_hidden_size', 'n_inner'], 4 * hidden);
|
|
782
|
+
const experts = +first(c, ['num_local_experts', 'n_routed_experts', 'num_experts', 'moe_num_experts'], 0) || 0;
|
|
783
|
+
const topk = experts ? +first(c, ['num_experts_per_tok', 'experts_per_token', 'moe_top_k', 'num_experts_per_token', 'top_k'], 2) : 0;
|
|
784
|
+
const moeInter = +first(c, ['moe_intermediate_size', 'expert_intermediate_size'], inter);
|
|
785
|
+
const denseInter = +first(c, ['intermediate_size_mlp'], inter);
|
|
786
|
+
const mla = c.kv_lora_rank != null;
|
|
787
|
+
const mlaLatent = mla ? +c.kv_lora_rank : 512, mlaRope = mla ? +first(c, ['qk_rope_head_dim'], 64) : 64;
|
|
788
|
+
const mlaNope = mla ? +first(c, ['qk_nope_head_dim'], 128) : 128, mlaV = mla ? +first(c, ['v_head_dim'], 128) : 128;
|
|
789
|
+
if (mla) kvHeads = 1;
|
|
790
|
+
// sliding window
|
|
791
|
+
let swaFrac = 0, swaWindow = 0;
|
|
792
|
+
if (Array.isArray(c.layer_types) && c.sliding_window) {
|
|
793
|
+
const n = c.layer_types.filter(t => /slid/i.test(String(t))).length;
|
|
794
|
+
swaFrac = +(n / c.layer_types.length).toFixed(3); swaWindow = +c.sliding_window;
|
|
795
|
+
} else if (c.sliding_window && c.use_sliding_window === true) { swaFrac = 1; swaWindow = +c.sliding_window; }
|
|
796
|
+
else if (c.attention_chunk_size && c.no_rope_layers) {
|
|
797
|
+
const n = c.no_rope_layers.filter(x => x).length;
|
|
798
|
+
swaFrac = +(n / c.no_rope_layers.length).toFixed(3); swaWindow = +c.attention_chunk_size;
|
|
799
|
+
notes.push('Chunked-attention layers modelled as sliding-window layers.');
|
|
800
|
+
}
|
|
801
|
+
if (c.sliding_window && !swaFrac) notes.push('sliding_window is set but not enabled for these layers; KV is sized for full attention.');
|
|
802
|
+
// linear-attention layers (Qwen3-Next / Qwen3.5 Gated DeltaNet: layer_types "linear_attention" or full_attention_interval)
|
|
803
|
+
let linFrac = 0, linStateMB = 0;
|
|
804
|
+
const linN = Array.isArray(c.layer_types) ? c.layer_types.filter(t => /linear/i.test(String(t))).length
|
|
805
|
+
: c.full_attention_interval > 1 ? layers - Math.floor(layers / c.full_attention_interval) : 0;
|
|
806
|
+
if (linN) {
|
|
807
|
+
linFrac = +(linN / layers).toFixed(4);
|
|
808
|
+
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);
|
|
809
|
+
linStateMB = +(vh * kd * vd * 4 / 1e6).toFixed(3);
|
|
810
|
+
notes.push(`${linN} linear-attention layers: a ${linStateMB} MB state per layer per sequence (fp32), no KV per token.`);
|
|
811
|
+
}
|
|
812
|
+
// sparse attention: an index picks the tokens each query attends (DeepSeek Sparse Attention and its descendants)
|
|
813
|
+
const sparseTopK = c.index_topk ? +c.index_topk : 0;
|
|
814
|
+
if (sparseTopK) notes.push(`Sparse attention: each query attends ${sparseTopK} selected tokens.`);
|
|
815
|
+
// context
|
|
816
|
+
let maxCtx = +first(c, ['max_position_embeddings', 'n_positions', 'seq_length', 'max_sequence_length'], 4096);
|
|
817
|
+
const rs = c.rope_scaling;
|
|
818
|
+
if (rs && rs.factor && rs.original_max_position_embeddings) maxCtx = Math.max(maxCtx, Math.round(rs.factor * rs.original_max_position_embeddings));
|
|
819
|
+
// which layers are MoE
|
|
820
|
+
let moeLayers = experts ? layers : 0;
|
|
821
|
+
if (experts && c.first_k_dense_replace != null) moeLayers = layers - c.first_k_dense_replace;
|
|
822
|
+
if (experts && c.interleave_moe_layer_step > 1) moeLayers = Math.floor(layers / c.interleave_moe_layer_step);
|
|
823
|
+
if (experts && c.decoder_sparse_step > 1) moeLayers = Math.floor(layers / c.decoder_sparse_step);
|
|
824
|
+
if (experts && Array.isArray(c.mlp_only_layers)) moeLayers -= c.mlp_only_layers.length;
|
|
825
|
+
if (experts && Array.isArray(c.moe_layers)) moeLayers = c.moe_layers.length;
|
|
826
|
+
const denseLayers = layers - moeLayers;
|
|
827
|
+
// attention params per layer
|
|
828
|
+
let attnP;
|
|
829
|
+
if (mla) {
|
|
830
|
+
const qk = mlaNope + mlaRope;
|
|
831
|
+
const qP = c.q_lora_rank ? hidden * c.q_lora_rank + c.q_lora_rank * qHeads * qk : hidden * qHeads * qk;
|
|
832
|
+
attnP = qP + hidden * (mlaLatent + mlaRope) + mlaLatent * qHeads * (mlaNope + mlaV) + qHeads * mlaV * hidden;
|
|
833
|
+
} else attnP = hidden * qHeads * headDim * 2 + hidden * kvHeads * headDim * 2;
|
|
834
|
+
const gated = !(c.hidden_act === 'gelu' && /gpt2|bloom|opt/.test(c.model_type || ''));
|
|
835
|
+
const mlp = n => (gated ? 3 : 2) * hidden * n;
|
|
836
|
+
const sharedN = +first(c, ['n_shared_experts', 'num_shared_experts'], 0) || 0;
|
|
837
|
+
const sharedInter = c.shared_expert_intermediate_size ? +c.shared_expert_intermediate_size : sharedN * moeInter;
|
|
838
|
+
const llama4Shared = /llama4/.test(c.model_type || '') && experts ? mlp(moeInter) : 0;
|
|
839
|
+
const expertP = mlp(moeInter);
|
|
840
|
+
const tied = j.tie_word_embeddings === true || c.tie_word_embeddings === true;
|
|
841
|
+
const emb = V * hidden * (tied ? 1 : 2);
|
|
842
|
+
const perMoE = experts * expertP + (sharedInter ? mlp(sharedInter) : 0) + llama4Shared + hidden * experts;
|
|
843
|
+
const total = emb + layers * attnP + denseLayers * mlp(denseInter) + moeLayers * perMoE;
|
|
844
|
+
const active = total - moeLayers * (experts - topk) * expertP;
|
|
845
|
+
notes.push('Parameter counts are estimated from layer shapes; check them against the model card.');
|
|
846
|
+
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');
|
|
847
|
+
const model = {
|
|
848
|
+
name, total: +(total / 1e9).toFixed(2), active: +(active / 1e9).toFixed(2), layers, hidden, qHeads, kvHeads, headDim,
|
|
849
|
+
attn: mla ? 'mla' : 'gqa', mlaLatent, mlaRope, mlaNope, mlaV, experts, topk, swaFrac, swaWindow, linFrac, linStateMB, sparseTopK, maxCtx,
|
|
850
|
+
wprec: /fp8|float8/i.test(JSON.stringify(j.quantization_config || '')) ? 'fp8' : /mxfp4|nvfp4|fp4/i.test(JSON.stringify(j.quantization_config || '')) ? 'fp4' : 'fp8',
|
|
851
|
+
};
|
|
852
|
+
return { model, notes };
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
const api = { GPU_FIELDS, MODEL_FIELDS, GPUS, MODELS, MODEL_DEFAULTS, GPU_DEFAULTS, SHEET_KIND, validateGPU, validateModel, parseSheet, makeSheet, merge, fromHFConfig, isHFConfig, slug };
|
|
856
|
+
if (typeof module !== 'undefined' && module.exports) module.exports = api; else root.SizerCatalog = api;
|
|
857
|
+
})(this);
|
|
858
|
+
|
|
859
|
+
</script>
|
|
860
|
+
<script>
|
|
861
|
+
/* Inference Sizer model: how many GPUs, in what layout, serve a model at TTFT/TPOT targets.
|
|
862
|
+
First-order roofline per layout, M/D/1 queueing for prefill, disaggregated vs aggregated serving.
|
|
863
|
+
Pure functions over one flat input object `s` (model + GPU + traffic + targets + assumptions). See docs/METHOD.md. */
|
|
864
|
+
(function (root) {
|
|
865
|
+
'use strict';
|
|
866
|
+
|
|
867
|
+
// Engine and traffic defaults. Model and GPU fields come from the catalog entry the user picks.
|
|
868
|
+
const SETTINGS = {
|
|
869
|
+
kvprec: 'fp8', ctx: 32768,
|
|
870
|
+
conc: 500, dau: 50000, rpu: 20, peakFactor: 3, concSource: 'max',
|
|
871
|
+
avgIn: 2000, peakIn: 16000, avgOut: 400, peakOut: 2000,
|
|
872
|
+
ttft: 1000, tpot: 30,
|
|
873
|
+
mode: 'auto', kvPolicy: 'paged', prefixHit: 0,
|
|
874
|
+
memUtil: 0.9, reserveGB: 8,
|
|
875
|
+
effPrefill: 0.40, effDecodeBW: 0.65, effDecodeComp: 0.30, stepMs: 1.5,
|
|
876
|
+
maxSeqPerGPU: 256, headroom: 15, nPlus1: true, kvMaxUtil: 0.9, sloMargin: 10,
|
|
877
|
+
};
|
|
878
|
+
|
|
879
|
+
function derive(s) {
|
|
880
|
+
const bpp = { bf16: 2, fp8: 1.0, fp4: 0.5625 }[s.wprec] || 1;
|
|
881
|
+
const kvb = { bf16: 2, fp8: 1 }[s.kvprec] || 1;
|
|
882
|
+
const isMoE = s.experts > 0 && s.topk > 0 && s.topk < s.experts && s.active < s.total;
|
|
883
|
+
let Eall = 0, dense = s.total;
|
|
884
|
+
if (isMoE) { Eall = Math.min((s.total - s.active) / (1 - s.topk / s.experts), s.total * 0.98); dense = s.total - Eall; }
|
|
885
|
+
const mla = s.attn === 'mla';
|
|
886
|
+
const lat = s.mlaLatent || 512, rope = s.mlaRope == null ? 64 : s.mlaRope, nope = s.mlaNope == null ? 128 : s.mlaNope, vh = s.mlaV || 128;
|
|
887
|
+
const swaLayers = s.swaWindow > 0 ? Math.round(s.layers * (s.swaFrac || 0)) : 0;
|
|
888
|
+
// linear-attention layers (Kimi Delta Attention, Gated DeltaNet): a fixed recurrent state per sequence, no KV per token
|
|
889
|
+
const linLayers = s.linFrac > 0 ? Math.min(s.layers - swaLayers, Math.round(s.layers * s.linFrac)) : 0;
|
|
890
|
+
const linState = linLayers * (s.linStateMB || 0) * 1e6;
|
|
891
|
+
// compressed attention keeps the KV of a share of the tokens (DeepSeek V4: 1/4 or 1/128 per layer); sparse attention
|
|
892
|
+
// (DSA, CSA, MSA) attends a fixed number of selected tokens per query instead of all of them
|
|
893
|
+
const keep = s.kvKeep > 0 && s.kvKeep < 1 ? s.kvKeep : 1, topK = s.sparseTopK > 0 ? s.sparseTopK : 0;
|
|
894
|
+
// tensor-core rate for the weight precision; fall back when the GPU lacks that precision
|
|
895
|
+
const tf = { bf16: s.tfBf16, fp8: s.tfFp8 || s.tfBf16, fp4: s.tfFp4 || s.tfFp8 || s.tfBf16 }[s.wprec] || s.tfBf16;
|
|
896
|
+
const computeFallback = (s.wprec === 'fp4' && !s.tfFp4) ? (s.tfFp8 ? 'fp8' : 'bf16') : (s.wprec === 'fp8' && !s.tfFp8) ? 'bf16' : null;
|
|
897
|
+
return {
|
|
898
|
+
bpp, kvb, isMoE, mla, computeFallback,
|
|
899
|
+
Wd: dense * 1e9 * bpp, We: Eall * 1e9 * bpp,
|
|
900
|
+
denseP: dense * 1e9, activeP: (isMoE ? s.active : s.total) * 1e9,
|
|
901
|
+
kvTokLayer: mla ? (lat + rope) * kvb : 2 * s.kvHeads * s.headDim * kvb,
|
|
902
|
+
swaLayers, linLayers, fullLayers: s.layers - swaLayers - linLayers, win: s.swaWindow || 0, keep, topK, linState,
|
|
903
|
+
// FLOPs per token per linear-attention layer: read and update the state (fp32, 4 bytes an element), ~4 FLOPs an element
|
|
904
|
+
Alin: (s.linStateMB || 0) * 1e6,
|
|
905
|
+
// attention FLOPs per (query token, context token) per layer
|
|
906
|
+
Apre: mla ? s.qHeads * (2 * (nope + rope) + 2 * vh) : 4 * s.qHeads * s.headDim,
|
|
907
|
+
Adec: mla ? s.qHeads * (2 * (lat + rope) + 2 * lat) : 4 * s.qHeads * s.headDim,
|
|
908
|
+
Fw: tf * 1e12, Fa: s.tfBf16 * 1e12,
|
|
909
|
+
BW: s.hbmTBs * 1e12, nvl: s.scaleUpGBs * 1e9 * 0.8, nic: s.nicGbps / 8 * 1e9 * 0.8,
|
|
910
|
+
hbm: s.hbmGB * 1e9 * s.memUtil, reserve: s.reserveGB * 1e9,
|
|
911
|
+
D: Math.max(1, Math.round(s.domain || 8)),
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
// KV bytes one sequence of L tokens holds: full-attention layers keep (a share of) every token, sliding-window layers
|
|
916
|
+
// the last W, linear-attention layers a fixed state
|
|
917
|
+
function kvBytes(md, L) {
|
|
918
|
+
const w = md.win || L, keep = md.keep || 1;
|
|
919
|
+
return md.kvTokLayer * (md.fullLayers * L * keep + md.swaLayers * Math.min(L, w)) + (md.linState || 0);
|
|
920
|
+
}
|
|
921
|
+
// context tokens one query attends in a full-attention layer, and its integral over query positions 0..x
|
|
922
|
+
const attended = (md, L) => { const n = L * (md.keep || 1); return md.topK ? Math.min(n, md.topK) : n; };
|
|
923
|
+
function attendedSum(md, x) {
|
|
924
|
+
const k = md.keep || 1;
|
|
925
|
+
if (!md.topK) return k * x * x / 2;
|
|
926
|
+
const t = md.topK / k;
|
|
927
|
+
return x <= t ? k * x * x / 2 : k * t * t / 2 + md.topK * (x - t);
|
|
928
|
+
}
|
|
929
|
+
function attnPre(md, Lc, L) {
|
|
930
|
+
const W = md.win;
|
|
931
|
+
const g = x => x <= W ? x * x / 2 : W * W / 2 + W * (x - W);
|
|
932
|
+
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);
|
|
933
|
+
}
|
|
934
|
+
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); }
|
|
935
|
+
|
|
936
|
+
// ---------- parallel layouts ----------
|
|
937
|
+
// Instances of g GPUs. Inside one scale-up domain (D GPUs): TP, or TP+EP for MoE, or DP-attention+EP for MLA.
|
|
938
|
+
// Larger than a domain: dense models pipeline across domains (TP=D × PP), MoE models use wide EP.
|
|
939
|
+
function configs(s, md) {
|
|
940
|
+
const out = [], D = md.D;
|
|
941
|
+
for (const g of [1, 2, 4, 8, 16, 32, 64]) {
|
|
942
|
+
const inDomain = g <= D;
|
|
943
|
+
if (!inDomain && g % D !== 0) continue;
|
|
944
|
+
let kind;
|
|
945
|
+
if (!md.isMoE) { if (g > 32 && !inDomain) continue; kind = inDomain ? 'TP' : 'TPPP'; }
|
|
946
|
+
else if (md.mla) kind = 'DPEP';
|
|
947
|
+
else kind = inDomain ? 'TPEP' : 'DPEP';
|
|
948
|
+
out.push({ g, kind, pp: kind === 'TPPP' ? g / D : 1, tpl: kind === 'TPPP' ? D : g });
|
|
949
|
+
}
|
|
950
|
+
return out;
|
|
951
|
+
}
|
|
952
|
+
function decodeLabel(c) {
|
|
953
|
+
if (c.g === 1) return '1 GPU';
|
|
954
|
+
if (c.kind === 'TP') return 'TP' + c.g;
|
|
955
|
+
if (c.kind === 'TPPP') return 'TP' + c.tpl + ' × PP' + c.pp;
|
|
956
|
+
if (c.kind === 'TPEP') return 'TP' + c.g + ' · EP' + c.g;
|
|
957
|
+
return 'DP' + c.g + ' attn · EP' + c.g;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
// ---------- memory (decode-side layout) ----------
|
|
961
|
+
function memInfo(s, md, c) {
|
|
962
|
+
let wGPU, rep, cap, single;
|
|
963
|
+
if (c.kind === 'DPEP') { wGPU = md.Wd + md.We / c.g; rep = 1; }
|
|
964
|
+
else { wGPU = (md.Wd + md.We) / c.g; rep = md.mla ? c.tpl : Math.max(1, c.tpl / s.kvHeads); }
|
|
965
|
+
const avail = md.hbm - md.reserve - wGPU;
|
|
966
|
+
if (c.kind === 'DPEP') { cap = avail * c.g; single = avail; }
|
|
967
|
+
else { cap = avail * c.g / rep; single = cap; }
|
|
968
|
+
const ctxBytes = kvBytes(md, s.ctx);
|
|
969
|
+
const perSeq = s.kvPolicy === 'reserve' ? ctxBytes : kvBytes(md, Math.min(s.ctx, s.avgIn + s.avgOut)) * 1.1;
|
|
970
|
+
const fitsW = avail > 2e9;
|
|
971
|
+
const fitsCtx = fitsW && single >= ctxBytes;
|
|
972
|
+
const Bmem = fitsW ? Math.floor(cap * (s.kvMaxUtil || 1) / perSeq) : 0;
|
|
973
|
+
return { wGPU, rep, avail, cap, single, ctxBytes, perSeq, fitsW, fitsCtx, Bmem };
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
function allreduce(s, md, tp, tokens) {
|
|
977
|
+
if (tp <= 1) return 0;
|
|
978
|
+
const bw = tp <= md.D ? md.nvl : md.nic;
|
|
979
|
+
return 2 * s.layers * (8e-6 + 2 * (tp - 1) / tp * tokens * s.hidden * 2 / bw);
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
// One decode step with B sequences (per micro-batch when pipelined).
|
|
983
|
+
function decodeStep(s, md, c, B) {
|
|
984
|
+
const L = Math.min(s.ctx, s.avgIn + s.avgOut / 2);
|
|
985
|
+
const kvL = kvBytes(md, L);
|
|
986
|
+
const frac = md.isMoE ? 1 - Math.pow(1 - s.topk / s.experts, B) : 1;
|
|
987
|
+
const linF = 2 * md.activeP * B, atF = B * attnDec(md, L);
|
|
988
|
+
let bytes, gl = c.g, comm = 0;
|
|
989
|
+
if (c.kind === 'DPEP') {
|
|
990
|
+
const imb = c.g > 1 ? 1.15 : 1;
|
|
991
|
+
bytes = md.Wd + md.We * frac / c.g * imb + (B / c.g) * kvL;
|
|
992
|
+
const tok = (B / c.g) * s.topk * s.hidden * 1.5;
|
|
993
|
+
if (c.g > 1) comm = c.g <= md.D ? 2 * s.layers * (10e-6 + tok / md.nvl) : 2 * s.layers * (25e-6 + tok / md.nic) * 0.6;
|
|
994
|
+
} else {
|
|
995
|
+
const rep = md.mla ? c.tpl : Math.max(1, c.tpl / s.kvHeads);
|
|
996
|
+
gl = c.tpl;
|
|
997
|
+
bytes = (md.Wd + md.We * frac) / gl + B * kvL * rep / gl;
|
|
998
|
+
comm = allreduce(s, md, gl, B) * (c.kind === 'TPEP' ? 1.3 : 1);
|
|
999
|
+
if (c.kind === 'TPPP') comm += (c.pp - 1) * (15e-6 + B * s.hidden * 2 / md.nic);
|
|
1000
|
+
}
|
|
1001
|
+
const tm = bytes / (md.BW * s.effDecodeBW);
|
|
1002
|
+
const tc = linF / gl / (md.Fw * s.effDecodeComp) + atF / gl / (md.Fa * s.effDecodeComp);
|
|
1003
|
+
const ovh = s.stepMs / 1000;
|
|
1004
|
+
return { t: Math.max(tm, tc) + comm + ovh, tm, tc, comm, ovh, bytes, bound: tm >= tc ? 'memory' : 'compute' };
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
function decodeCap(s, md, c, mi) {
|
|
1008
|
+
return Math.max(0, Math.min(Math.floor(mi.Bmem / c.pp), s.maxSeqPerGPU * c.tpl));
|
|
1009
|
+
}
|
|
1010
|
+
// Largest per-micro-batch B whose step time stays within the TPOT target.
|
|
1011
|
+
function bmax(s, md, c, mi, tpotS) {
|
|
1012
|
+
const cap = decodeCap(s, md, c, mi);
|
|
1013
|
+
if (cap < 1) return { B: 0, limit: 'memory' };
|
|
1014
|
+
if (decodeStep(s, md, c, 1).t > tpotS) return { B: 0, limit: 'latency' };
|
|
1015
|
+
if (decodeStep(s, md, c, cap).t <= tpotS) return { B: cap, limit: cap === Math.floor(mi.Bmem / c.pp) ? 'kv-memory' : 'seq-cap' };
|
|
1016
|
+
let lo = 1, hi = cap;
|
|
1017
|
+
while (hi - lo > 1) { const mid = (lo + hi) >> 1; if (decodeStep(s, md, c, mid).t <= tpotS) lo = mid; else hi = mid; }
|
|
1018
|
+
return { B: lo, limit: 'tpot' };
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
// ---------- prefill: TP inside a domain, context parallel (CP) across domains, EP for MoE ----------
|
|
1022
|
+
function preCfg(md, c) { const tp = Math.min(c.g, md.D); return { g: c.g, tp, cp: Math.max(1, Math.round(c.g / tp)) }; }
|
|
1023
|
+
function prefillLabel(c, md) {
|
|
1024
|
+
const p = preCfg(md, c);
|
|
1025
|
+
let l = p.g === 1 ? '1 GPU' : 'TP' + p.tp + (p.cp > 1 ? ' × CP' + p.cp : '');
|
|
1026
|
+
if (md.isMoE && p.g > 1) l += ' · EP' + p.g;
|
|
1027
|
+
return l;
|
|
1028
|
+
}
|
|
1029
|
+
function prefillTime(s, md, c, Lnew, Lc, n) {
|
|
1030
|
+
const p = preCfg(md, c);
|
|
1031
|
+
const lin = 2 * md.activeP * Lnew * n;
|
|
1032
|
+
const at = n * attnPre(md, Lc, Lc + Lnew);
|
|
1033
|
+
const par = p.cp > 1 ? 0.85 : 1;
|
|
1034
|
+
const tc = lin / p.g / (md.Fw * s.effPrefill * par) + at / p.g / (md.Fa * s.effPrefill * par);
|
|
1035
|
+
const tm = (md.Wd / p.tp + md.We / p.g) / (md.BW * s.effDecodeBW);
|
|
1036
|
+
const tokens = Lnew * n;
|
|
1037
|
+
let comm = allreduce(s, md, p.tp, tokens / p.cp) * 0.5;
|
|
1038
|
+
if (md.isMoE && p.g > 1) comm += 2 * s.layers * (10e-6 + tokens / p.g * s.topk * s.hidden * 1.5 / (p.g > md.D ? md.nic : md.nvl)) * 0.5;
|
|
1039
|
+
if (p.cp > 1) comm += (kvBytes(md, Lc + Lnew) * n * (p.cp - 1) / p.cp / (p.tp * md.nic) + s.layers * 20e-6) * 0.5;
|
|
1040
|
+
return Math.max(tc, tm) + comm + 0.004;
|
|
1041
|
+
}
|
|
1042
|
+
function prefillStats(s, md, c) {
|
|
1043
|
+
const hit = s.prefixHit / 100;
|
|
1044
|
+
const aIn = Math.min(s.avgIn, s.ctx), pIn = Math.min(s.peakIn, s.ctx);
|
|
1045
|
+
const Lavg = Math.max(1, aIn * (1 - hit)), LcA = aIn * hit;
|
|
1046
|
+
const Lpk = Math.max(1, pIn * (1 - hit)), LcP = pIn * hit;
|
|
1047
|
+
const budget = Math.max(Lavg, 8192);
|
|
1048
|
+
const n = budget / Lavg;
|
|
1049
|
+
const tBatch = prefillTime(s, md, c, Lavg, LcA, n);
|
|
1050
|
+
const cap = n * Lavg / tBatch; // new prompt tokens / s
|
|
1051
|
+
const Speak = prefillTime(s, md, c, Lpk, LcP, 1);
|
|
1052
|
+
const p = preCfg(md, c);
|
|
1053
|
+
const wGPU = md.Wd / p.tp + md.We / p.g;
|
|
1054
|
+
const rep = md.mla ? p.tp : Math.max(1, p.tp / s.kvHeads);
|
|
1055
|
+
const avail = md.hbm - md.reserve - wGPU;
|
|
1056
|
+
const fits = avail > 2e9 && kvBytes(md, pIn) * rep / p.g * 2 <= avail;
|
|
1057
|
+
return { cap, Sbatch: tBatch, Speak, Lavg, Lpk, fits, wGPU, avail };
|
|
1058
|
+
}
|
|
1059
|
+
function kvXfer(s, md, gP, L) { return kvBytes(md, L) / (Math.min(md.D, gP) * md.nic) + 0.002; }
|
|
1060
|
+
const mdWait = (rho, S) => rho * S / (2 * (1 - rho));
|
|
1061
|
+
|
|
1062
|
+
// ---------- load ----------
|
|
1063
|
+
// Cs concurrent decode streams to hold at the TPOT target (from "concurrent sessions")
|
|
1064
|
+
// Dtok output tokens/s to deliver (from DAU traffic)
|
|
1065
|
+
// lam request arrivals/s driving prefill
|
|
1066
|
+
function computeLoad(s) {
|
|
1067
|
+
const dur = s.avgOut * s.tpot / 1000 + s.ttft / 1000;
|
|
1068
|
+
const lamDau = s.dau * s.rpu / 86400 * s.peakFactor;
|
|
1069
|
+
const lamConc = s.conc / dur;
|
|
1070
|
+
const useC = s.concSource !== 'dau', useD = s.concSource !== 'conc';
|
|
1071
|
+
const h = 1 + s.headroom / 100;
|
|
1072
|
+
const lam0 = Math.max(useC ? lamConc : 0, useD ? lamDau : 0);
|
|
1073
|
+
const binding = !useD ? 'concurrency' : !useC ? 'DAU' : (lamDau * dur > s.conc ? 'DAU' : 'concurrency');
|
|
1074
|
+
return { dur, lamDau, lamConc, h, binding, Cs: useC ? s.conc * h : 0, Dtok: useD ? lamDau * s.avgOut * h : 0, lam: lam0 * h, lam0 };
|
|
1075
|
+
}
|
|
1076
|
+
// Smallest per-micro-batch B whose throughput pp*B/t(B) reaches `rate`.
|
|
1077
|
+
function minBforRate(c, tfun, rate, capBm) {
|
|
1078
|
+
if (rate <= 0) return 1;
|
|
1079
|
+
const thr = B => c.pp * B / tfun(B);
|
|
1080
|
+
if (thr(capBm) < rate) return Infinity;
|
|
1081
|
+
let lo = 0, hi = capBm;
|
|
1082
|
+
while (hi - lo > 1) { const mid = (lo + hi) >> 1; if (thr(mid) >= rate) hi = mid; else lo = mid; }
|
|
1083
|
+
return hi;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
// ---------- sizing ----------
|
|
1087
|
+
const fmtMs = t => { const ms = t * 1000; return ms >= 100 ? Math.round(ms) + ' ms' : ms.toFixed(1) + ' ms'; };
|
|
1088
|
+
|
|
1089
|
+
function sizeDisagg(s, md, load, cfgs) {
|
|
1090
|
+
const m = 1 - (s.sloMargin || 0) / 100, T = s.ttft / 1000 * m, P = s.tpot / 1000 * m; // size to targets less the safety margin
|
|
1091
|
+
const pre = cfgs.map(c => {
|
|
1092
|
+
const ps = prefillStats(s, md, c);
|
|
1093
|
+
const xa = kvXfer(s, md, c.g, Math.min(s.avgIn, s.ctx)), xp = kvXfer(s, md, c.g, Math.min(s.peakIn, s.ctx));
|
|
1094
|
+
const r = { c, label: prefillLabel(c, md), ps, xferAvg: xa, xferPeak: xp, feasible: false, why: '' };
|
|
1095
|
+
if (!ps.fits) { r.why = 'weights + prompt KV do not fit'; return r; }
|
|
1096
|
+
if (ps.Speak + xp > T) { r.why = 'peak prompt TTFT ' + fmtMs(ps.Speak + xp) + ' > target'; return r; }
|
|
1097
|
+
const budget = T - xa, S = ps.Sbatch;
|
|
1098
|
+
if (S >= budget) { r.why = 'avg prompt service time exceeds TTFT budget'; return r; }
|
|
1099
|
+
const x = (budget - S) / S, rhoMax = Math.min(0.85, 2 * x / (1 + 2 * x));
|
|
1100
|
+
const need = load.lam * ps.Lavg;
|
|
1101
|
+
const N = Math.max(1, Math.ceil(need / (ps.cap * rhoMax)));
|
|
1102
|
+
const rho = need / (N * ps.cap);
|
|
1103
|
+
Object.assign(r, { feasible: true, N, gpus: N * c.g, rho, rhoMax, ttftAvg: S + mdWait(rho, S) + xa, ttftPeak: ps.Speak + xp });
|
|
1104
|
+
return r;
|
|
1105
|
+
});
|
|
1106
|
+
const dec = cfgs.map(c => {
|
|
1107
|
+
const mi = memInfo(s, md, c);
|
|
1108
|
+
const r = { c, label: decodeLabel(c), mi, feasible: false, why: '' };
|
|
1109
|
+
if (!mi.fitsW) { r.why = 'weights do not fit'; return r; }
|
|
1110
|
+
if (!mi.fitsCtx) { r.why = 'one full-context sequence does not fit'; return r; }
|
|
1111
|
+
const bm = bmax(s, md, c, mi, P);
|
|
1112
|
+
r.bm = bm;
|
|
1113
|
+
if (bm.B < 1) { r.why = bm.limit === 'latency' ? 'TPOT floor ' + fmtMs(decodeStep(s, md, c, 1).t) + ' > target' : 'no KV room'; return r; }
|
|
1114
|
+
const Binst = bm.B * c.pp;
|
|
1115
|
+
const tfun = B => decodeStep(s, md, c, B).t;
|
|
1116
|
+
const thrInst = Binst / tfun(bm.B);
|
|
1117
|
+
const N = Math.max(1, Math.ceil(load.Cs / Binst), Math.ceil(load.Dtok / thrInst));
|
|
1118
|
+
const Bm = Math.max(1, Math.ceil(load.Cs / N / c.pp), minBforRate(c, tfun, load.Dtok / N, bm.B));
|
|
1119
|
+
const st = decodeStep(s, md, c, Bm), Bop = Bm * c.pp;
|
|
1120
|
+
Object.assign(r, { feasible: true, N, gpus: N * c.g, Binst, Bop, st, tpotOp: st.t, thrInst, kvUse: Bop * mi.perSeq / 1.1 / mi.cap });
|
|
1121
|
+
return r;
|
|
1122
|
+
});
|
|
1123
|
+
const best = arr => arr.filter(r => r.feasible).sort((a, b) => a.gpus - b.gpus || a.c.g - b.c.g)[0] || null;
|
|
1124
|
+
return { pre, dec, P: best(pre), D: best(dec) };
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
// Aggregated: each step carries the decode batch plus a prefill chunk sized to keep the step within TPOT.
|
|
1128
|
+
function sizeAgg(s, md, load, cfgs) {
|
|
1129
|
+
const m = 1 - (s.sloMargin || 0) / 100, T = s.ttft / 1000 * m, P = s.tpot / 1000 * m; // size to targets less the safety margin
|
|
1130
|
+
const rows = cfgs.map(c => {
|
|
1131
|
+
const mi = memInfo(s, md, c);
|
|
1132
|
+
const r = { c, label: decodeLabel(c), mi, feasible: false, why: '' };
|
|
1133
|
+
if (!mi.fitsW) { r.why = 'weights do not fit'; return r; }
|
|
1134
|
+
if (!mi.fitsCtx) { r.why = 'one full-context sequence does not fit'; return r; }
|
|
1135
|
+
const capBm = decodeCap(s, md, c, mi), capB = capBm * c.pp;
|
|
1136
|
+
if (capB < 1) { r.why = 'no KV room'; return r; }
|
|
1137
|
+
const ps = prefillStats(s, md, c);
|
|
1138
|
+
if (!ps.fits) { r.why = 'weights + prompt KV do not fit'; return r; }
|
|
1139
|
+
if (ps.Speak + s.stepMs / 1000 > T) { r.why = 'peak prompt TTFT ' + fmtMs(ps.Speak) + ' > target'; return r; }
|
|
1140
|
+
if (decodeStep(s, md, c, 1).t > P) { r.why = 'TPOT floor ' + fmtMs(decodeStep(s, md, c, 1).t) + ' > target'; return r; }
|
|
1141
|
+
const Nmin = Math.max(1, Math.ceil(load.Cs / capB));
|
|
1142
|
+
const Nmax = Math.max(Nmin * 64, 4096);
|
|
1143
|
+
for (let N = Nmin; N <= Nmax; N++) {
|
|
1144
|
+
const fp0 = load.lam * ps.Lavg / N / ps.cap;
|
|
1145
|
+
if (fp0 >= 0.85) continue;
|
|
1146
|
+
const tAvgF = B => { const q = decodeStep(s, md, c, B); return Math.max(q.tm, q.tc / (1 - fp0)) * 1.1 + q.comm + q.ovh; };
|
|
1147
|
+
const Bm = Math.max(1, Math.ceil(load.Cs / N / c.pp), minBforRate(c, tAvgF, load.Dtok / N, capBm));
|
|
1148
|
+
if (!isFinite(Bm) || Bm > capBm) continue;
|
|
1149
|
+
const st = decodeStep(s, md, c, Bm);
|
|
1150
|
+
const Pcore = (P - st.comm - st.ovh) / 1.1;
|
|
1151
|
+
if (Math.max(st.tm, st.tc) >= Pcore) continue;
|
|
1152
|
+
const chunk = (Pcore - st.tc) * ps.cap;
|
|
1153
|
+
const mu = chunk / P;
|
|
1154
|
+
const rArr = load.lam * ps.Lavg / N;
|
|
1155
|
+
const rho = rArr / mu;
|
|
1156
|
+
if (rho >= 0.85) continue;
|
|
1157
|
+
const S = ps.Lavg / mu;
|
|
1158
|
+
const ttftAvg = S + mdWait(rho, S) + P, ttftPeak = ps.Lpk / mu + P;
|
|
1159
|
+
if (ttftAvg > T || ttftPeak > T) continue;
|
|
1160
|
+
const tAvg = Math.min(P, tAvgF(Bm)), Bop = Bm * c.pp;
|
|
1161
|
+
Object.assign(r, { feasible: true, N, gpus: N * c.g, Bop, st, tpotOp: tAvg, ttftAvg, ttftPeak, fp: fp0, rho, chunk, ps, kvUse: Bop * mi.perSeq / 1.1 / mi.cap, thrInst: Bop / tAvg });
|
|
1162
|
+
return r;
|
|
1163
|
+
}
|
|
1164
|
+
r.why = 'no instance count meets both targets';
|
|
1165
|
+
return r;
|
|
1166
|
+
});
|
|
1167
|
+
const best = rows.filter(r => r.feasible).sort((a, b) => a.gpus - b.gpus || a.c.g - b.c.g)[0] || null;
|
|
1168
|
+
return { rows, best };
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
// The operating point of one fixed layout at a fixed concurrency: what an engine running config c with B sequences
|
|
1172
|
+
// in flight delivers, by the same physics sizeAgg uses (each step carries the decode batch plus prefill chunks; the
|
|
1173
|
+
// prefill share fp slows the compute part). For checking the model against measured runs (e.g. InferenceX):
|
|
1174
|
+
// returns TPOT, TTFT, and output tokens/s per GPU.
|
|
1175
|
+
function operatingPoint(s, md, c, B) {
|
|
1176
|
+
const st = decodeStep(s, md, c, B), ps = prefillStats(s, md, c), osl = s.avgOut, isl = Math.min(s.avgIn, s.ctx);
|
|
1177
|
+
let tpot = st.t, ttft = ps.Sbatch, fp = 0;
|
|
1178
|
+
for (let i = 0; i < 50; i++) {
|
|
1179
|
+
const lam = B / (osl * tpot + ttft); // requests/s through this instance
|
|
1180
|
+
fp = Math.min(0.95, lam * isl / ps.cap); // share of compute spent on prefill
|
|
1181
|
+
const t = Math.max(st.tm, st.tc / (1 - fp)) * 1.1 + st.comm + st.ovh;
|
|
1182
|
+
// a new prompt is prefilled in chunks between decode steps: its share of each step is what decode leaves
|
|
1183
|
+
const free = Math.max(0.05, 1 - Math.max(st.tm, st.tc) / t);
|
|
1184
|
+
const tt = prefillTime(s, md, c, isl, 0, 1) / free + mdWait(Math.min(0.85, fp), isl / ps.cap) + t;
|
|
1185
|
+
if (Math.abs(t - tpot) < 1e-7 && Math.abs(tt - ttft) < 1e-6) { tpot = t; ttft = tt; break; }
|
|
1186
|
+
tpot = t; ttft = tt;
|
|
1187
|
+
}
|
|
1188
|
+
const outPerGpu = B * osl / (osl * tpot + ttft) / c.g;
|
|
1189
|
+
return { tpot, ttft, outPerGpu, prefillShare: fp, bound: st.bound, step: st };
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
// Nodes (scale-up domains) needed: instances that span domains take whole domains; smaller ones pack first-fit-decreasing.
|
|
1193
|
+
function packNodes(pools, D) {
|
|
1194
|
+
const items = [];
|
|
1195
|
+
let whole = 0;
|
|
1196
|
+
for (const p of pools) for (let i = 0; i < p.N; i++) { if (p.g >= D) whole += Math.ceil(p.g / D); else items.push(p.g); }
|
|
1197
|
+
items.sort((a, b) => b - a);
|
|
1198
|
+
const bins = [];
|
|
1199
|
+
for (const g of items) { const b = bins.findIndex(x => x + g <= D); if (b >= 0) bins[b] += g; else bins.push(g); }
|
|
1200
|
+
return whole + bins.length;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
function plan(s, opts) {
|
|
1204
|
+
opts = opts || {};
|
|
1205
|
+
const md = derive(s);
|
|
1206
|
+
const load = computeLoad(s);
|
|
1207
|
+
const cfgs = configs(s, md);
|
|
1208
|
+
const dis = sizeDisagg(s, md, load, cfgs);
|
|
1209
|
+
const agg = sizeAgg(s, md, load, cfgs);
|
|
1210
|
+
const D = md.D;
|
|
1211
|
+
// N+1: room for one more instance of the largest layout, using free GPUs in existing nodes first
|
|
1212
|
+
const spareFor = pools => s.nPlus1 ? packNodes(pools.concat([{ N: 1, g: Math.max(...pools.map(p => p.g)) }]), D) - packNodes(pools, D) : 0;
|
|
1213
|
+
let disOpt = null, aggOpt = null;
|
|
1214
|
+
if (dis.P && dis.D) {
|
|
1215
|
+
const pools = [{ N: dis.P.N, g: dis.P.c.g }, { N: dis.D.N, g: dis.D.c.g }];
|
|
1216
|
+
const nodes = packNodes(pools, D), sp = spareFor(pools);
|
|
1217
|
+
disOpt = { mode: 'disagg', gpus: dis.P.gpus + dis.D.gpus, nodes, spareNodes: sp, totalNodes: nodes + sp };
|
|
1218
|
+
}
|
|
1219
|
+
if (agg.best) {
|
|
1220
|
+
const pools = [{ N: agg.best.N, g: agg.best.c.g }];
|
|
1221
|
+
const nodes = packNodes(pools, D), sp = spareFor(pools);
|
|
1222
|
+
aggOpt = { mode: 'agg', gpus: agg.best.gpus, nodes, spareNodes: sp, totalNodes: nodes + sp };
|
|
1223
|
+
}
|
|
1224
|
+
const plural = n => n === 1 ? '' : 's', U = D > 8 ? 'rack' : 'node';
|
|
1225
|
+
let chosen = null, reason = '';
|
|
1226
|
+
if (s.mode === 'disagg') { chosen = disOpt; reason = 'Disaggregated serving selected.'; }
|
|
1227
|
+
else if (s.mode === 'agg') { chosen = aggOpt; reason = 'Aggregated serving selected.'; }
|
|
1228
|
+
else if (disOpt && (!aggOpt || disOpt.totalNodes < aggOpt.totalNodes * 0.9)) {
|
|
1229
|
+
chosen = disOpt;
|
|
1230
|
+
reason = aggOpt ? `Disaggregated prefill/decode needs ${aggOpt.totalNodes - disOpt.totalNodes} fewer ${U}${plural(aggOpt.totalNodes - disOpt.totalNodes)} than aggregated (${disOpt.totalNodes} vs ${aggOpt.totalNodes}).` : 'Aggregated serving cannot meet both targets on any layout; splitting prefill and decode can.';
|
|
1231
|
+
} else if (aggOpt) {
|
|
1232
|
+
chosen = aggOpt;
|
|
1233
|
+
reason = disOpt ? (aggOpt.totalNodes <= disOpt.totalNodes ? `Aggregated serving with chunked prefill fits in ${aggOpt.totalNodes} ${U}${plural(aggOpt.totalNodes)} (disaggregated: ${disOpt.totalNodes}), with fewer moving parts.` : `Disaggregation would save under 10% (${disOpt.totalNodes} vs ${aggOpt.totalNodes} ${U}s); aggregated is simpler to run.`) : 'Only aggregated serving meets both targets.';
|
|
1234
|
+
} else if (disOpt) { chosen = disOpt; reason = 'Only disaggregated serving meets both targets.'; }
|
|
1235
|
+
const res = { s, md, load, cfgs, dis, agg, disOpt, aggOpt, chosen, reason };
|
|
1236
|
+
if (chosen) { chosen.nodeGPUs = D; chosen.provGPUs = chosen.totalNodes * D; chosen.kw = chosen.totalNodes * (s.nodeKW || 0); }
|
|
1237
|
+
res.tpotFloor = Math.min(...cfgs.map(c => memInfo(s, md, c).fitsW ? decodeStep(s, md, c, 1).t : Infinity));
|
|
1238
|
+
res.ttftFloor = Math.min(...cfgs.map(c => { const p = prefillStats(s, md, c); return p.fits ? p.Speak : Infinity; }));
|
|
1239
|
+
const reqDay = s.dau * s.rpu;
|
|
1240
|
+
res.econ = { reqDay, inDay: reqDay * s.avgIn, outDay: reqDay * s.avgOut };
|
|
1241
|
+
if (chosen) {
|
|
1242
|
+
const costDay = chosen.provGPUs * 24 * (s.price || 0);
|
|
1243
|
+
res.econ.costDay = costDay;
|
|
1244
|
+
res.econ.perMOut = res.econ.outDay > 0 ? costDay / (res.econ.outDay / 1e6) : NaN;
|
|
1245
|
+
res.econ.avgVsPeak = load.lam > 0 ? (reqDay / 86400) / load.lam : NaN;
|
|
1246
|
+
}
|
|
1247
|
+
if (!opts.noSens) {
|
|
1248
|
+
res.sens = [10, 15, 20, 25, 30, 40, 50, 60, 80, 100].map(tp => {
|
|
1249
|
+
const r = plan(Object.assign({}, s, { tpot: tp }), { noSens: true });
|
|
1250
|
+
return { tpot: tp, gpus: r.chosen ? r.chosen.provGPUs : null };
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
return res;
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
const api = { SETTINGS, plan, derive, kvBytes, attnPre, attnDec, decodeStep, memInfo, prefillStats, prefillTime, configs, computeLoad, decodeLabel, prefillLabel, decodeCap, packNodes, operatingPoint };
|
|
1257
|
+
if (typeof module !== 'undefined' && module.exports) module.exports = api; else root.SizerModel = api;
|
|
1258
|
+
})(this);
|
|
1259
|
+
|
|
561
1260
|
</script>
|
|
562
1261
|
<script>
|
|
563
1262
|
/* FleetScope engine: time-stepped fleet simulation for LLM serving and training.
|
|
@@ -604,14 +1303,31 @@ button, select, input { font: inherit; color: inherit; }
|
|
|
604
1303
|
'llama-405b': { label: 'Llama 3.1 405B', params: 405, active: 405, layers: 126, kvHeads: 8, headDim: 128, mla: 0 },
|
|
605
1304
|
'moe-671b': { label: 'MoE 671B, 37B active (MLA)', params: 671, active: 37, layers: 61, kvHeads: 0, headDim: 0, mla: 576 }
|
|
606
1305
|
};
|
|
1306
|
+
// Every other model in the Inference Sizer's catalog (one list for both tools, kept current there). kvScale: the KV a
|
|
1307
|
+
// token holds, averaged over a 32K context, against the plain kvDim × layers figure, so sliding-window, linear-attention
|
|
1308
|
+
// and compressed layers count; it scales with the layers and heads if they are edited.
|
|
1309
|
+
const node = typeof module !== 'undefined' && module.exports;
|
|
1310
|
+
const CAT = node ? require('../../inference-sizer/src/catalog.js') : root.SizerCatalog, SZ = node ? require('../../inference-sizer/src/model.js') : root.SizerModel;
|
|
1311
|
+
const kvDimTotal = m => (m.mla ? m.layers * m.mla : 2 * m.layers * m.kvHeads * m.headDim);
|
|
1312
|
+
for (const k of Object.keys(MODELS)) MODELS[k].kvScale = 1;
|
|
1313
|
+
const IN_LIST = { 'llama31-8b': 'llama-8b', 'llama33-70b': 'llama-70b', 'llama31-405b': 'llama-405b', 'deepseek-v3': 'moe-671b' };
|
|
1314
|
+
if (CAT && SZ) {
|
|
1315
|
+
for (const c of CAT.MODELS) {
|
|
1316
|
+
if (IN_LIST[c.id] || MODELS[c.id]) continue;
|
|
1317
|
+
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 };
|
|
1318
|
+
const md = SZ.derive(Object.assign({}, SZ.SETTINGS, CAT.MODEL_DEFAULTS, c, { kvprec: 'fp8', tfBf16: 1, hbmTBs: 1, scaleUpGBs: 1, nicGbps: 1, hbmGB: 1 }));
|
|
1319
|
+
m.kvScale = +(SZ.kvBytes(md, 32768) / 32768 / kvDimTotal(m)).toFixed(4);
|
|
1320
|
+
MODELS[c.id] = m;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
607
1323
|
|
|
608
1324
|
// ---------- performance profile ----------
|
|
609
1325
|
// tpFixed: GPUs per instance set on the pool (0 or absent = smallest power of two whose share of the weights fits).
|
|
610
1326
|
function profile(gpuKey, m, tpFixed) {
|
|
611
1327
|
const G = GPUS[gpuKey];
|
|
612
|
-
const wBytes = m.params * 1e9 * (m.wPrec === 'bf16' ? 2 : 1);
|
|
1328
|
+
const wBytes = m.params * 1e9 * (m.wPrec === 'bf16' ? 2 : m.wPrec === 'fp4' ? 0.5625 : 1);
|
|
613
1329
|
const kvElem = m.kvPrec === 'bf16' ? 2 : 1;
|
|
614
|
-
const kvBytesPerToken = m
|
|
1330
|
+
const kvBytesPerToken = kvDimTotal(m) * kvElem * (m.kvScale > 0 ? m.kvScale : 1);
|
|
615
1331
|
let tp = 1;
|
|
616
1332
|
if (tpFixed > 0) tp = Math.round(tpFixed);
|
|
617
1333
|
else while (tp < 16 && wBytes / tp > 0.65 * G.hbm * 1e9) tp *= 2;
|