Repository navigation
VRAM & KV-Cache Sizing Calculator for High-Throughput Serving & RadixAttention Planning (Zero-Dependency CLI & WebApp) #47143
DangerousANEN
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
When deploying high-throughput model serving engines like SGLang (
python3 -m sglang.launch_server), one of the key tuning parameters is memory budgeting (--mem-fraction-static) and sizing the KV-cache pool to support long context windows and concurrent request streams without triggering CUDA OOMs or cache thrashing.With long sequence lengths (16k–128k) and high concurrency, the dynamic KV-cache footprint frequently outgrows the static model weights (e.g. for a 70B model in FP8 at 64k tokens, KV-cache alone requires dozens of gigabytes). Understanding exact memory allocation boundaries is essential before deploying on cluster hardware (A100, H100, L40S, RTX 4090/6000 Ada).
To help engineer and size GPU memory budgets for serving environments, I created llm-vram-calculator — an open-source utility featuring both an interactive browser WebApp and a standalone zero-dependency Python CLI:
vram_calc.py), works seamlessly on Linux, macOS, and Windows.Key Capabilities for Serving & Inference Planning
Complete Memory Footprint Decomposition:
$$\text{Total VRAM} = M_{\text{weights}} + M_{\text{kv-cache}} + \text{CUDA Overhead} + \text{Peak Activations}$$
FP8,NVFP4,AWQ,GPTQ,BF16/FP16, and GGUF (Q4_K_M,Q5_K_M,Q8_0).fp16,fp8,q8_0,q4_0(essential when sizing quantized KV cache pools).Concurrency & Context Scaling:
--mem-fraction-staticmargins.Lightweight Benchmarking CLI:
benchsubcommand to measure Time to First Token (TTFT), Time Per Output Token (TPOT), and Tokens Per Second (TPS) directly against SGLang OpenAI-compatible endpoints (/v1/chat/completions) with streaming latency breakdowns.Feedback, suggestions, and feature requests from the SGLang community are very welcome!
All reactions