@tokcalc/mcp-server 0.1.1 → 0.1.3
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/.zscripts/build.sh +175 -0
- package/.zscripts/database-runtime-build.sh +33 -0
- package/.zscripts/dev.pid +1 -0
- package/.zscripts/dev.sh +154 -0
- package/.zscripts/mini-services-build.sh +78 -0
- package/.zscripts/mini-services-install.sh +65 -0
- package/.zscripts/mini-services-start.sh +123 -0
- package/.zscripts/python-runtime-build.sh +120 -0
- package/.zscripts/start.sh +145 -0
- package/CAPACITY_STUDY.md +283 -0
- package/CODE_OF_CONDUCT.md +55 -0
- package/CONTRIBUTING.md +177 -0
- package/Caddyfile +23 -0
- package/LICENSE +204 -0
- package/README.md +406 -86
- package/bun.lock +1965 -0
- package/components.json +21 -0
- package/db/custom.db +0 -0
- package/download/README.md +1 -0
- package/download/tokcalc-dark-calculator.png +0 -0
- package/download/tokcalc-dark-default.png +0 -0
- package/download/tokcalc-demo.webm +0 -0
- package/download/tokcalc-github-link.png +0 -0
- package/download/tokcalc-hydration-fixed.png +0 -0
- package/download/tokcalc-issue-resolved.png +0 -0
- package/download/tokcalc-light-mode.png +0 -0
- package/download/tokcalc-light-reference.png +0 -0
- package/download/tokcalc-long-context-qwen.png +0 -0
- package/download/tokcalc-long-context.png +0 -0
- package/download/tokcalc-og-image-preview.png +0 -0
- package/download/tokcalc-phase2-3.png +0 -0
- package/download/tokcalc-plain-english.png +0 -0
- package/download/tokcalc-preview.png +0 -0
- package/download/tokcalc-share-bvb.png +0 -0
- package/download/tokcalc-share-feature.png +0 -0
- package/download/tokcalc-tab-build-vs-buy.png +0 -0
- package/download/tokcalc-tab-calculator.png +0 -0
- package/download/tokcalc-tab-reference.png +0 -0
- package/eslint.config.mjs +50 -0
- package/examples/websocket/frontend.tsx +196 -0
- package/examples/websocket/server.ts +138 -0
- package/mini-services/.gitkeep +0 -0
- package/mini-services/mcp-server/README.md +86 -0
- package/mini-services/mcp-server/bun.lock +202 -0
- package/mini-services/mcp-server/index.ts +504 -0
- package/mini-services/mcp-server/package.json +40 -0
- package/next.config.ts +12 -0
- package/package.json +92 -35
- package/postcss.config.mjs +5 -0
- package/prisma/schema.prisma +32 -0
- package/public/google6f58ca6be85fa903.html +1 -0
- package/public/logo.svg +29 -0
- package/public/manifest.json +51 -0
- package/public/og-icon-256.png +0 -0
- package/public/og.png +0 -0
- package/public/robots.txt +25 -0
- package/public/sitemap.xml +23 -0
- package/public/tokcalc-demo.gif +0 -0
- package/scripts/og-template.html +120 -0
- package/scripts/render-og.mjs +43 -0
- package/server.json +21 -0
- package/src/app/api/pricing/aws/route.ts +186 -0
- package/src/app/api/pricing/azure/route.ts +168 -0
- package/src/app/api/pricing/gcp/route.ts +230 -0
- package/src/app/api/pricing/vast-ai/route.ts +164 -0
- package/src/app/api/route.ts +5 -0
- package/src/app/compare/h100-vs-h200/layout.tsx +30 -0
- package/src/app/compare/h100-vs-h200/page.tsx +328 -0
- package/src/app/globals.css +122 -0
- package/src/app/layout.tsx +276 -0
- package/src/app/page.tsx +2670 -0
- package/src/components/azure-live-pricing.tsx +185 -0
- package/src/components/benchmark-import.tsx +340 -0
- package/src/components/confidence-badge.tsx +116 -0
- package/src/components/live-pricing-comparison.tsx +241 -0
- package/src/components/theme-provider.tsx +11 -0
- package/src/components/theme-toggle.tsx +55 -0
- package/src/components/ui/accordion.tsx +66 -0
- package/src/components/ui/alert-dialog.tsx +157 -0
- package/src/components/ui/alert.tsx +66 -0
- package/src/components/ui/aspect-ratio.tsx +11 -0
- package/src/components/ui/avatar.tsx +53 -0
- package/src/components/ui/badge.tsx +46 -0
- package/src/components/ui/breadcrumb.tsx +109 -0
- package/src/components/ui/button.tsx +59 -0
- package/src/components/ui/calendar.tsx +213 -0
- package/src/components/ui/card.tsx +92 -0
- package/src/components/ui/carousel.tsx +241 -0
- package/src/components/ui/chart.tsx +353 -0
- package/src/components/ui/checkbox.tsx +32 -0
- package/src/components/ui/collapsible.tsx +33 -0
- package/src/components/ui/command.tsx +184 -0
- package/src/components/ui/context-menu.tsx +252 -0
- package/src/components/ui/dialog.tsx +143 -0
- package/src/components/ui/drawer.tsx +135 -0
- package/src/components/ui/dropdown-menu.tsx +257 -0
- package/src/components/ui/form.tsx +167 -0
- package/src/components/ui/hover-card.tsx +44 -0
- package/src/components/ui/input-otp.tsx +77 -0
- package/src/components/ui/input.tsx +21 -0
- package/src/components/ui/label.tsx +24 -0
- package/src/components/ui/menubar.tsx +276 -0
- package/src/components/ui/navigation-menu.tsx +168 -0
- package/src/components/ui/pagination.tsx +127 -0
- package/src/components/ui/popover.tsx +48 -0
- package/src/components/ui/progress.tsx +31 -0
- package/src/components/ui/radio-group.tsx +45 -0
- package/src/components/ui/resizable.tsx +56 -0
- package/src/components/ui/scroll-area.tsx +58 -0
- package/src/components/ui/select.tsx +185 -0
- package/src/components/ui/separator.tsx +28 -0
- package/src/components/ui/sheet.tsx +139 -0
- package/src/components/ui/sidebar.tsx +726 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/slider.tsx +63 -0
- package/src/components/ui/sonner.tsx +25 -0
- package/src/components/ui/switch.tsx +31 -0
- package/src/components/ui/table.tsx +116 -0
- package/src/components/ui/tabs.tsx +66 -0
- package/src/components/ui/textarea.tsx +18 -0
- package/src/components/ui/toast.tsx +129 -0
- package/src/components/ui/toaster.tsx +35 -0
- package/src/components/ui/toggle-group.tsx +73 -0
- package/src/components/ui/toggle.tsx +47 -0
- package/src/components/ui/tooltip.tsx +61 -0
- package/src/components/vast-ai-live-pricing.tsx +176 -0
- package/src/hooks/use-mobile.ts +19 -0
- package/src/hooks/use-toast.ts +194 -0
- package/src/lib/benchmark-parser-sglang.ts +150 -0
- package/src/lib/benchmark-parser-tokcalc.ts +247 -0
- package/src/lib/benchmark-parser-trtllm.ts +152 -0
- package/src/lib/benchmark-parser-vllm.ts +198 -0
- package/src/lib/benchmark-schema.ts +263 -0
- package/src/lib/db.ts +13 -0
- package/src/lib/engine-presets.ts +183 -0
- package/src/lib/price-schema.ts +141 -0
- package/src/lib/token-calc.ts +808 -0
- package/src/lib/track.ts +31 -0
- package/src/lib/url-state.ts +256 -0
- package/src/lib/utils.ts +6 -0
- package/tailwind.config.ts +64 -0
- package/tests/database-runtime-build.sh +75 -0
- package/tests/python-runtime-build.sh +64 -0
- package/tests/python-runtime-container.sh +31 -0
- package/tool-results/bash_1789888171144_2c5381860539.txt +161 -0
- package/tool-results/bash_1789888175925_49c53ba3c61b.txt +191 -0
- package/tool-results/bash_1789888181202_49c53ba3c61b.txt +191 -0
- package/tool-results/bash_1789888195219_4a86a5c91411.txt +200 -0
- package/tool-results/bash_1789888203128_6cca13c71b47.txt +199 -0
- package/tool-results/bash_1789929256963_2a52aff0d0a8.txt +160 -0
- package/tool-results/read_1789888151021_69f58eec6a5b.txt +653 -0
- package/tool-results/read_1789888153837_1d3a8bfc2a94.txt +653 -0
- package/tool-results/read_1789888163087_ccc406d47505.txt +122 -0
- package/tool-results/read_1789888167347_67d1d7c9830a.txt +122 -0
- package/tool-results/read_1789929252529_d90e8f383a25.txt +285 -0
- package/tsconfig.json +42 -0
- package/upload/Pasted Content_1789887800864.txt +652 -0
- package/upload/Pasted Content_1789887909561.txt +652 -0
- package/upload/Pasted Content_1789887918428.txt +652 -0
- package/upload/Pasted Content_1789887959420.txt +652 -0
- package/upload/Pasted Content_1789888020485.txt +652 -0
- package/upload/Pasted Content_1789888058079.txt +652 -0
- package/upload/Pasted Content_1789888885033.txt +686 -0
- package/upload/Pasted Content_1789928912741.txt +285 -0
- package/upload/Pasted Content_1789928938402.txt +285 -0
- package/upload/Pasted Content_1789929160389.txt +285 -0
- package/upload/Pasted Content_1789929176660.txt +285 -0
- package/upload/issue_vision.json +28 -0
- package/upload/pasted_image_1789883175209.png +0 -0
- package/upload/pasted_image_1789899056690.png +0 -0
- package/upload/pasted_image_1789900371483.png +0 -0
- package/upload/pasted_image_1789900472823.png +0 -0
- package/upload/pasted_image_1789900490374.png +0 -0
- package/upload/pasted_image_1789900585552.png +0 -0
- package/upload/pasted_image_1789900606519.png +0 -0
- package/upload/pasted_image_1789901598705.png +0 -0
- package/upload/pasted_image_1789901613545.png +0 -0
- package/upload/pasted_image_1789978382674.png +0 -0
- package/upload/pasted_image_1789978392749.png +0 -0
- package/upload/pasted_image_1789978474879.png +0 -0
- package/upload/pasted_image_1789978523652.png +0 -0
- package/upload/pasted_image_1789984219089.png +0 -0
- package/upload/pasted_image_1789984491896.png +0 -0
- package/upload/pasted_image_1789985017950.png +0 -0
- package/upload/pasted_image_1789985036765.png +0 -0
- package/upload/pasted_image_1789985049848.png +0 -0
- package/upload/pasted_image_1790002427833.png +0 -0
- package/upload/pasted_image_1790002659944.png +0 -0
- package/upload/pasted_image_1790037038476.png +0 -0
- package/upload/screenshot_analysis.json +28 -0
- package/upload/vision_output.json +28 -0
- package/dist/index.js +0 -21014
package/README.md
CHANGED
|
@@ -1,86 +1,406 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
###
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
> "
|
|
63
|
-
|
|
64
|
-
> "
|
|
65
|
-
|
|
66
|
-
> "
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# tokcalc
|
|
4
|
+
|
|
5
|
+
### The open-source LLM serving capacity planner
|
|
6
|
+
|
|
7
|
+
**Plan your LLM deployment before you rent the GPUs.**
|
|
8
|
+
|
|
9
|
+
[](https://tokcalc.dev)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
[](CONTRIBUTING.md)
|
|
12
|
+
[](https://nextjs.org)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<div align="center">
|
|
19
|
+
|
|
20
|
+

|
|
21
|
+
|
|
22
|
+
*Switch model → multi-GPU → long-context capacity planner → Build vs Buy → Reference catalog*
|
|
23
|
+
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
tokcalc turns your LLM traffic, context length, latency SLOs, cache behavior,
|
|
29
|
+
and model choice into a **defensible serving topology and cost plan** —
|
|
30
|
+
with transparent formulas and cited benchmarks.
|
|
31
|
+
|
|
32
|
+
It's the engineering-grade pre-deployment decision layer for LLM inference.
|
|
33
|
+
Not another static "tokens per second" calculator.
|
|
34
|
+
|
|
35
|
+
## Try it now
|
|
36
|
+
|
|
37
|
+
**[tokcalc.dev](https://tokcalc.dev)** — no signup, no tracking, no paywall.
|
|
38
|
+
|
|
39
|
+
Pick a model, a GPU, and a workload. Get an instant capacity plan:
|
|
40
|
+
|
|
41
|
+
- Generation speed (tok/s)
|
|
42
|
+
- Time-to-first-token (TTFT) + inter-token latency (ITL)
|
|
43
|
+
- VRAM budget with KV-cache sizing
|
|
44
|
+
- Multi-GPU topology recommendation (Single GPU → TP×2/4/8 → Context Parallel)
|
|
45
|
+
- Monthly cost + break-even vs API pricing
|
|
46
|
+
- **Shareable URL** — your config encoded in the URL hash, send to colleagues
|
|
47
|
+
|
|
48
|
+
## Why tokcalc?
|
|
49
|
+
|
|
50
|
+
The market has dozens of "tokens per second" calculators and self-host-vs-API
|
|
51
|
+
break-even tools (induwara.lk, gigagpu, kickllm, cloudparity, curlscape,
|
|
52
|
+
profitable.ai). None of them are unified capacity planners.
|
|
53
|
+
|
|
54
|
+
### What tokcalc answers that competitors can't
|
|
55
|
+
|
|
56
|
+
> *"Can I serve Qwen 2.5 72B at 128K context on 2× H100 with 20 concurrent users?"*
|
|
57
|
+
|
|
58
|
+
> *"How many H200s do I need for 1,000 req/min with P95 TTFT < 2s?"*
|
|
59
|
+
|
|
60
|
+
> *"Does FP8 or AWQ save more money once quality, KV cache, and engine support are included?"*
|
|
61
|
+
|
|
62
|
+
> *"At what daily volume does an H100 beat GPT-4o pricing?"*
|
|
63
|
+
|
|
64
|
+
> *"What happens to cost and latency if an agent makes 8 model calls, has 3 tool calls, and its context grows by 5K tokens each turn?"*
|
|
65
|
+
|
|
66
|
+
> *"Would prefix caching, continuous batching, or PD disaggregation save more for this workload?"*
|
|
67
|
+
|
|
68
|
+
## Features
|
|
69
|
+
|
|
70
|
+
### Calculator tab
|
|
71
|
+
|
|
72
|
+
| Feature | What it computes |
|
|
73
|
+
|---|---|
|
|
74
|
+
| **Model fit / VRAM** | Will the model + KV cache fit in the GPU's memory? |
|
|
75
|
+
| **Throughput** | Decode tok/s (per-stream) + aggregate (batched) + prefill tok/s |
|
|
76
|
+
| **Latency split** | Time-to-first-token (= prefill) + inter-token latency (= decode) |
|
|
77
|
+
| **Continuous batching** | User-tunable 1.0–4× multiplier (cited 1.5–4× SOSP range) |
|
|
78
|
+
| **Reasoning tokens** | Hidden reasoning budget added to billed output (o1 / R1 / Claude thinking) |
|
|
79
|
+
| **Prompt caching** | Self-hosted vLLM APC + Anthropic 5m/1h TTL + OpenAI 50%-off cached tokens |
|
|
80
|
+
| **Speculative decoding** | User-tunable 1.2–4× boost factor |
|
|
81
|
+
| **Multi-GPU TP** | 1× → 8× tensor parallel with NVLink efficiency factor |
|
|
82
|
+
| **Long-context capacity** | KV memory + max concurrency + prefill time at 4K → 1M context |
|
|
83
|
+
| **Topology recommendation** | Single GPU → TP×2 → TP×4 → TP×8 → TP×8 + Context Parallel (RingAttention) |
|
|
84
|
+
| **Cost economics** | GPU $/hr → $/M output tokens → $/request → monthly cost |
|
|
85
|
+
|
|
86
|
+
### Build vs Buy tab
|
|
87
|
+
|
|
88
|
+
Independent calculator (separate state) that compares:
|
|
89
|
+
- **Self-host**: model + GPU + quant + utilization + batch → $/M tokens + monthly cost
|
|
90
|
+
- **API**: 13 providers (OpenAI / Anthropic / Gemini / Groq / DeepSeek / Mistral / Together)
|
|
91
|
+
- **Verdict**: Self-host cheaper / API cheaper / Not enough volume — with break-even reqs/day
|
|
92
|
+
|
|
93
|
+
### Reference tab
|
|
94
|
+
|
|
95
|
+
5 sub-tables — fully transparent, every record source-linked where available:
|
|
96
|
+
- **Models** (35 entries: Llama 4 Scout/Maverick, Qwen 3 family, DeepSeek V3/R1, Pixtral, BGE-M3, ...)
|
|
97
|
+
- **GPUs** (30 entries: H100/H200/B200/B300, AMD MI300X/MI325X, Intel Gaudi 3, TPU v5p/Trillium, Groq LPU, Cerebras WSE-3, Apple M2/M3/M4 Ultra, ...)
|
|
98
|
+
- **Quantization** (16 formats: FP16/BF16, GGUF Q2_K→Q8_0, GPTQ, AWQ, EXL2, FP8, NVFP4)
|
|
99
|
+
- **API pricing** (13 models with input/cached/output + retired/current status)
|
|
100
|
+
- **Cloud GPU pricing** (all GPUs with $/hr > 0 + typical providers)
|
|
101
|
+
|
|
102
|
+
### The long-context capacity planner (the differentiator)
|
|
103
|
+
|
|
104
|
+
This is the formula the Perplexity research brief called "the most important
|
|
105
|
+
tokcalc should visibly expose":
|
|
106
|
+
|
|
107
|
+
$$
|
|
108
|
+
\text{KV bytes/request} = 2 \cdot L \cdot T \cdot H_{\text{kv}} \cdot D_h \cdot B
|
|
109
|
+
$$
|
|
110
|
+
|
|
111
|
+
For dense attention, prefill cost grows **superlinearly** with context length:
|
|
112
|
+
|
|
113
|
+
$$
|
|
114
|
+
\text{prefill FLOPs} = \underbrace{2 \cdot N \cdot T}_{\text{linear}} + \underbrace{T^2 \cdot H_{\text{kv}} \cdot D_h \cdot L}_{\text{attention}}
|
|
115
|
+
$$
|
|
116
|
+
|
|
117
|
+
tokcalc shows you:
|
|
118
|
+
- Max concurrent users at 4K / 8K / 16K / 32K / 64K / 128K / 256K / 512K / 1M context
|
|
119
|
+
- KV memory per request at each context length
|
|
120
|
+
- Prefill time (with superlinear attention correction beyond 32K)
|
|
121
|
+
- Required topology (Single GPU → TP×2/4/8 → TP×8 + Context Parallel)
|
|
122
|
+
- RingAttention citation when CP is needed
|
|
123
|
+
|
|
124
|
+
## The math, transparently
|
|
125
|
+
|
|
126
|
+
Every number above comes from a formula you can inspect. No black boxes.
|
|
127
|
+
|
|
128
|
+
<details>
|
|
129
|
+
<summary><b>Decode tokens/sec (memory-bandwidth bound)</b></summary>
|
|
130
|
+
|
|
131
|
+
$$
|
|
132
|
+
\text{decode tok/sec} \approx \frac{\text{HBM BW} \cdot \eta_{\text{mem}} \cdot \text{quant\_eff}}{\text{model size}}
|
|
133
|
+
$$
|
|
134
|
+
|
|
135
|
+
Where:
|
|
136
|
+
- `HBM BW` = GPU memory bandwidth (e.g., 3350 GB/s for H100 SXM)
|
|
137
|
+
- `η_mem = 0.65` = typical real-world memory utilization (35% overhead)
|
|
138
|
+
- `quant_eff` = dequantization efficiency multiplier (1.0 for FP16, 1.5 for FP8 on H100, 0.85 for INT4)
|
|
139
|
+
- `model size = active_params × bytes_per_param` (uses ACTIVE params for MoE, not total)
|
|
140
|
+
|
|
141
|
+
Refs: PagedAttention paper ([arxiv.org/abs/2309.06180](https://arxiv.org/abs/2309.06180))
|
|
142
|
+
</details>
|
|
143
|
+
|
|
144
|
+
<details>
|
|
145
|
+
<summary><b>Prefill tokens/sec (compute bound)</b></summary>
|
|
146
|
+
|
|
147
|
+
$$
|
|
148
|
+
\text{prefill tok/sec} \approx \frac{\text{GPU FLOPS} \cdot \eta_{\text{compute}}}{2 \cdot \text{active params}}
|
|
149
|
+
$$
|
|
150
|
+
|
|
151
|
+
Where:
|
|
152
|
+
- `GPU FLOPS` = dense FP16/BF16 TFLOPS (sparse values not used)
|
|
153
|
+
- `η_compute = 0.50` = typical compute utilization
|
|
154
|
+
- Factor of 2 = one multiply + one add per parameter per token
|
|
155
|
+
|
|
156
|
+
For long context (>32K), the superlinear attention correction above applies.
|
|
157
|
+
</details>
|
|
158
|
+
|
|
159
|
+
<details>
|
|
160
|
+
<summary><b>Continuous batching multiplier (workload-specific)</b></summary>
|
|
161
|
+
|
|
162
|
+
$$
|
|
163
|
+
\text{aggregate tok/sec} = \text{decode tok/sec} \cdot \text{batch size} \cdot \text{continuous batching multiplier}
|
|
164
|
+
$$
|
|
165
|
+
|
|
166
|
+
**Critical caveat**: There is no universal continuous batching multiplier. vLLM
|
|
167
|
+
reported 14–24× vs HF Transformers (extreme), 2.2–2.5× vs TGI. SOSP paper
|
|
168
|
+
finds 2–4× typical vs FasterTransformer/Orca. tokcalc defaults to a
|
|
169
|
+
conservative **1.5×** and lets you tune.
|
|
170
|
+
|
|
171
|
+
Refs:
|
|
172
|
+
- [vLLM blog (2023-06-20)](https://vllm.ai/blog/2023-06-20-vllm)
|
|
173
|
+
- [PagedAttention paper](https://arxiv.org/abs/2309.06180)
|
|
174
|
+
- [Anyscale continuous batching study](https://www.anyscale.com/blog/continuous-batching-llm-inference)
|
|
175
|
+
</details>
|
|
176
|
+
|
|
177
|
+
<details>
|
|
178
|
+
<summary><b>Prompt caching economics (Anthropic / OpenAI)</b></summary>
|
|
179
|
+
|
|
180
|
+
For shared prefix of length $T_p$, suffix of length $T_u$, output $O$,
|
|
181
|
+
cache hit rate $h$:
|
|
182
|
+
|
|
183
|
+
$$
|
|
184
|
+
\text{API input cost} = N \cdot \left[ (1-h) \cdot T_p \cdot P_{\text{write}} + h \cdot T_p \cdot P_{\text{read}} + T_u \cdot P_{\text{input}} \right]
|
|
185
|
+
$$
|
|
186
|
+
|
|
187
|
+
Anthropic multipliers (verified 2025-2026):
|
|
188
|
+
- 5-minute cache write: 1.25× base input
|
|
189
|
+
- 1-hour cache write: 2.0× base input
|
|
190
|
+
- Cache read: 0.1× base input (90% savings)
|
|
191
|
+
|
|
192
|
+
OpenAI: cached input discounted 50%, no separate write fee.
|
|
193
|
+
|
|
194
|
+
Refs:
|
|
195
|
+
- [Anthropic prompt caching docs](https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching)
|
|
196
|
+
- [OpenAI prompt caching guide](https://platform.openai.com/docs/guides/prompt-caching)
|
|
197
|
+
</details>
|
|
198
|
+
|
|
199
|
+
<details>
|
|
200
|
+
<summary><b>Multi-GPU topology recommendation</b></summary>
|
|
201
|
+
|
|
202
|
+
$$
|
|
203
|
+
\text{total needed} = \text{model weights} + (\text{KV per request} \cdot \text{batch size})
|
|
204
|
+
$$
|
|
205
|
+
|
|
206
|
+
Walk the smallest topology that fits:
|
|
207
|
+
- **Single GPU**: total ≤ VRAM × 1
|
|
208
|
+
- **Tensor Parallel ×2/4/8**: total ≤ VRAM × N (weights + KV split evenly)
|
|
209
|
+
- **TP×8 + Context Parallel**: total > VRAM × 8 — use RingAttention to shard KV across nodes
|
|
210
|
+
|
|
211
|
+
Refs: [RingAttention paper](https://arxiv.org/abs/2310.01889)
|
|
212
|
+
</details>
|
|
213
|
+
|
|
214
|
+
<details>
|
|
215
|
+
<summary><b>Self-host vs API break-even</b></summary>
|
|
216
|
+
|
|
217
|
+
$$
|
|
218
|
+
\text{self-host $/M tokens} = \frac{\text{GPU $/hr}}{3600 \cdot \text{effective tok/s} \cdot \text{utilization}} \cdot 10^6
|
|
219
|
+
$$
|
|
220
|
+
|
|
221
|
+
$$
|
|
222
|
+
\text{break-even req/day} = \frac{\text{monthly self-host cost}}{30 \cdot \text{API cost per request}}
|
|
223
|
+
$$
|
|
224
|
+
|
|
225
|
+
The decisive term is **effective utilization** — not peak throughput. A GPU
|
|
226
|
+
running at 10% utilization pays 10× more per token than the theoretical minimum.
|
|
227
|
+
</details>
|
|
228
|
+
|
|
229
|
+
## Comparison with adjacent tools
|
|
230
|
+
|
|
231
|
+
| Capability | induwara / techfuelhq / pcmasterstudio | gigagpu / kickllm / cloudparity | HF Open LLM Leaderboard / MLPerf | **tokcalc** |
|
|
232
|
+
|---|:---:|:---:|:---:|:---:|
|
|
233
|
+
| Model × GPU × quant tok/s | ✓ | some | some | **✓** |
|
|
234
|
+
| Model-fit / VRAM | basic | rare | rare | **✓** |
|
|
235
|
+
| KV-cache by context + concurrency | — | — | implicit | **✓** |
|
|
236
|
+
| Prefill vs decode split (TTFT/ITL) | — | — | engine-specific | **✓** |
|
|
237
|
+
| Continuous batching / paged attention | — | — | docs only | **✓** |
|
|
238
|
+
| Long-context (128K–1M) planning | — | — | — | **✓** |
|
|
239
|
+
| Topology recommendation (TP/CP) | — | — | partial | **✓** |
|
|
240
|
+
| Prompt-cache economics | — | partial API only | — | **✓** |
|
|
241
|
+
| Reasoning tokens (o1/R1/Claude thinking) | — | — | — | **✓** |
|
|
242
|
+
| API vs self-host break-even | some | ✓ | — | **✓** |
|
|
243
|
+
| Transparent formulas / open source | mixed | usually no | mixed | **✓** |
|
|
244
|
+
| Cited benchmark evidence per config | rare | rare | ✓ (not planning) | **✓ (in progress)** |
|
|
245
|
+
| Shareable URL per config | — | — | — | **✓** |
|
|
246
|
+
|
|
247
|
+
## Roadmap
|
|
248
|
+
|
|
249
|
+
### Shipped
|
|
250
|
+
- ✅ 35 models, 30 GPUs, 16 quantization formats
|
|
251
|
+
- ✅ Continuous batching, reasoning tokens, prompt caching
|
|
252
|
+
- ✅ TTFT/ITL split, long-context superlinear attention
|
|
253
|
+
- ✅ Long-context capacity planner + topology recommendation
|
|
254
|
+
- ✅ Build-vs-Buy calculator (13 API providers with retired/current status)
|
|
255
|
+
- ✅ Reference catalog (5 sub-tables)
|
|
256
|
+
- ✅ Share URL + localStorage persistence
|
|
257
|
+
- ✅ Dark mode toggle
|
|
258
|
+
- ✅ Plain-English glossary (28 terms with hover tooltips)
|
|
259
|
+
- ✅ OG image + Twitter card + social metadata
|
|
260
|
+
|
|
261
|
+
### Next 30 days
|
|
262
|
+
- ⏳ GitHub Action (`tokcalc/plan` PR comment)
|
|
263
|
+
- ⏳ MCP server (read-only capacity-planning tools for AI agents)
|
|
264
|
+
- ⏳ 3 SEO landing pages (`/compare/h100-vs-h200`, `/gguf-q4-k-m-vs-q5-k-m`, `/vllm-vs-sglang`)
|
|
265
|
+
- ⏳ i18n: Chinese, Japanese, Korean
|
|
266
|
+
|
|
267
|
+
### Next 90 days
|
|
268
|
+
- ⏳ Workload-trace / SLO capacity planner (prompt/output/arrival distributions, p50/p95 TTFT/ITL)
|
|
269
|
+
- ⏳ P/D disaggregation planner (separate prefill + decode pools)
|
|
270
|
+
- ⏳ Cache-aware economics (prefix-sharing distribution, multi-turn/agent traces)
|
|
271
|
+
- ⏳ Engine-aware presets (vLLM / SGLang / TensorRT-LLM / llama.cpp)
|
|
272
|
+
- ⏳ Versioned price + benchmark provenance system
|
|
273
|
+
|
|
274
|
+
### Long-term
|
|
275
|
+
- 🔮 Agentic workflow calculator (multi-turn + tool calls + growing context)
|
|
276
|
+
- 🔮 Multi-LoRA capacity planner (Punica / S-LoRA economics)
|
|
277
|
+
- 🔮 VLM image-token accounting (per-model patch/tile tokenization)
|
|
278
|
+
- 🔮 Embedding model mode (vectors/sec, separate workload)
|
|
279
|
+
- 🔮 Training/fine-tuning estimator (LoRA / QLoRA / full-SFT FLOPs)
|
|
280
|
+
- 🔮 Energy / carbon per million tokens (region-specific grid intensity)
|
|
281
|
+
|
|
282
|
+
## Open core model
|
|
283
|
+
|
|
284
|
+
tokcalc is **open core** — the calculator and catalog are open source; the
|
|
285
|
+
cloud/data/team features are paid.
|
|
286
|
+
|
|
287
|
+
| Asset | License | Notes |
|
|
288
|
+
|---|---|---|
|
|
289
|
+
| Source code | Apache 2.0 | This repo. Free to use, modify, distribute |
|
|
290
|
+
| Model/GPU/quant catalog | CC0 1.0 | Public domain data. Anyone can use, no attribution required |
|
|
291
|
+
| Benchmark provenance data | CC-BY-SA 4.0 | Anyone can use, but must attribute + share-alike |
|
|
292
|
+
| Documentation | CC-BY 4.0 | Attribution required if copied |
|
|
293
|
+
| "tokcalc" name + logo | Trademark | Even without formal registration, common-law rights apply |
|
|
294
|
+
| Cloud SaaS layer | Proprietary | Real-time pricing API, benchmark DB, team workspaces (coming soon) |
|
|
295
|
+
|
|
296
|
+
### Why this structure
|
|
297
|
+
- **Trust**: Open-source formulas build credibility vs opaque competitors
|
|
298
|
+
- **Community**: Contributors can submit models, GPUs, quants, benchmarks
|
|
299
|
+
- **Defensibility**: Trademark + cloud features + URL-share viral loop protect against forks
|
|
300
|
+
- **Revenue**: Cloud tier funds ongoing development + pricing/benchmark data maintenance
|
|
301
|
+
|
|
302
|
+
## Contributing
|
|
303
|
+
|
|
304
|
+
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for:
|
|
305
|
+
|
|
306
|
+
- How to add a model (with HuggingFace config.json as source)
|
|
307
|
+
- How to add a GPU (with critical guardrails for B200/B300 null FP16 fields)
|
|
308
|
+
- How to add a quantization format (with measured file sizes as source)
|
|
309
|
+
- How to submit a benchmark (3-tier confidence model)
|
|
310
|
+
- How to improve a formula (cite the source, no magic numbers)
|
|
311
|
+
|
|
312
|
+
### Most-needed contributions
|
|
313
|
+
- 🟢 New models (Qwen 3, Mistral Large 4, Llama 4 variants as they release)
|
|
314
|
+
- 🟢 New GPUs (B300, AMD MI400, Apple M5 Ultra when shipping)
|
|
315
|
+
- 🟢 New quantization formats (mxFP8, MXFP4, BitNet 2)
|
|
316
|
+
- 🟢 Real benchmark data (run vLLM benchmarks and submit with provenance)
|
|
317
|
+
- 🟢 Translations (especially Chinese, Japanese, Korean)
|
|
318
|
+
|
|
319
|
+
## MCP server — use tokcalc from AI agents
|
|
320
|
+
|
|
321
|
+
tokcalc ships an [MCP (Model Context Protocol)](https://modelcontextprotocol.io) server that lets AI agents (Cursor, Claude Desktop, Cline) call tokcalc during design reviews.
|
|
322
|
+
|
|
323
|
+
### 6 read-only tools
|
|
324
|
+
|
|
325
|
+
| Tool | What it does |
|
|
326
|
+
|---|---|
|
|
327
|
+
| `estimate_capacity` | VRAM/KV/throughput/latency/cost for one config |
|
|
328
|
+
| `compare_gpus` | Ranked GPU comparison for one workload |
|
|
329
|
+
| `recommend_topology` | TP/CP topology recommendation |
|
|
330
|
+
| `estimate_api_vs_self_host` | Break-even analysis |
|
|
331
|
+
| `list_models` | Discover supported model IDs |
|
|
332
|
+
| `list_gpus` | Discover supported GPU IDs |
|
|
333
|
+
|
|
334
|
+
All tools are **read-only** — no side effects, no cloud credentials, no deployments.
|
|
335
|
+
|
|
336
|
+
### Install
|
|
337
|
+
|
|
338
|
+
Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
|
|
339
|
+
|
|
340
|
+
```json
|
|
341
|
+
{
|
|
342
|
+
"mcpServers": {
|
|
343
|
+
"tokcalc": {
|
|
344
|
+
"command": "npx",
|
|
345
|
+
"args": ["-y", "@tokcalc/mcp-server"]
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
Or run locally:
|
|
352
|
+
|
|
353
|
+
```bash
|
|
354
|
+
git clone https://github.com/stevecrates489-commits/tokcalc.git
|
|
355
|
+
cd tokcalc
|
|
356
|
+
bun install
|
|
357
|
+
bun mini-services/mcp-server/index.ts
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### Example agent prompt
|
|
361
|
+
|
|
362
|
+
> "I need to serve Llama 3.3 70B at 32K context for 50 concurrent users. What GPU topology do you recommend, and how much will it cost per month?"
|
|
363
|
+
|
|
364
|
+
The agent calls `list_models` → `list_gpus` → `recommend_topology` → `estimate_capacity` → returns a structured plan with VRAM, throughput, latency, cost, and confidence.
|
|
365
|
+
|
|
366
|
+
## Tech stack
|
|
367
|
+
|
|
368
|
+
- **Framework**: Next.js 16 with App Router
|
|
369
|
+
- **Language**: TypeScript 5
|
|
370
|
+
- **Styling**: Tailwind CSS 4 + shadcn/ui (New York)
|
|
371
|
+
- **Charts**: Recharts
|
|
372
|
+
- **State**: React hooks (useState + useEffect + useMemo)
|
|
373
|
+
- **Theme**: next-themes (dark mode default)
|
|
374
|
+
- **Database**: None (pure client-side, no backend required for core features)
|
|
375
|
+
|
|
376
|
+
## Acknowledgments
|
|
377
|
+
|
|
378
|
+
tokcalc builds on the work of:
|
|
379
|
+
|
|
380
|
+
- **vLLM team** — PagedAttention, continuous batching ([arxiv.org/abs/2309.06180](https://arxiv.org/abs/2309.06180))
|
|
381
|
+
- **llama.cpp / ggml-org** — GGUF format and quantization variants
|
|
382
|
+
- **MLPerf / MLCommons** — standardized inference benchmark methodology
|
|
383
|
+
- **Stanford HELM** — efficiency-aware model evaluation framework
|
|
384
|
+
- **Anthropic / OpenAI / Google** — published prompt-caching pricing rules
|
|
385
|
+
- **NVIDIA / AMD / Intel / Google / Groq / Cerebras** — published hardware specs
|
|
386
|
+
|
|
387
|
+
Every formula has a citation. Every model/GPU/quant entry has a source URL
|
|
388
|
+
where available. If you spot an unsourced claim, please open an issue.
|
|
389
|
+
|
|
390
|
+
## Star history
|
|
391
|
+
|
|
392
|
+
[](https://star-history.com/#tokcalc/tokcalc&Date)
|
|
393
|
+
|
|
394
|
+
---
|
|
395
|
+
|
|
396
|
+
<div align="center">
|
|
397
|
+
|
|
398
|
+
**[Live demo](https://tokcalc.dev)** ·
|
|
399
|
+
**[Documentation](https://tokcalc.dev/docs)** ·
|
|
400
|
+
**[Contributing](CONTRIBUTING.md)** ·
|
|
401
|
+
**[License](LICENSE)** ·
|
|
402
|
+
**[Code of Conduct](CODE_OF_CONDUCT.md)**
|
|
403
|
+
|
|
404
|
+
Made with care by the tokcalc community. Apache 2.0 licensed.
|
|
405
|
+
|
|
406
|
+
</div>
|