How the LLM Sizing Guide calculates memory, latency, and throughput — and where the numbers come from.
Architecture parameters (layers, hidden size, attention heads, KV heads, context window, expert counts) were sourced from official model cards and configuration files:
| Model | Type | Primary Source | Verified From |
|---|---|---|---|
| Llama-3.1-8B Dense | 8B params | HuggingFace Model Card | GitHub Model Card, Meta Blog Post |
| Llama-3.1-70B Dense | 70B params | HuggingFace Model Card | GitHub Model Card, Meta Blog Post |
| Mistral-7B-v0.3 Dense | 7B params | HuggingFace Model Card | config.json |
| Qwen2.5-14B Dense | 14.7B params | HuggingFace Model Card | config.json, Qwen Blog |
| GPT-oss-120B MoE | 117B total, 5.1B active | HuggingFace config.json | GitHub openai/gpt-oss (README & model code) |
| GPT-oss-20B MoE | 21B total, 3.6B active | HuggingFace config.json | GitHub openai/gpt-oss (README & model code) |
| Model | Params (B) | Hidden Size | Attn Heads | KV Heads | Head Dim | Layers | Max Context | Experts | Active Experts | Weight Size |
|---|---|---|---|---|---|---|---|---|---|---|
| Llama-3.1-8B | 8 | 4096 | 32 | 8 | 128 | 32 | 131,072 | — | — | 16 GB |
| Llama-3.1-70B | 70 | 8192 | 64 | 8 | 128 | 80 | 131,072 | — | — | 140 GB |
| Mistral-7B-v0.3 | 7 | 4096 | 32 | 8 | 128 | 32 | 32,768 | — | — | 14 GB |
| Qwen2.5-14B | 14.7 | 5120 | 40 | 8 | 128 | 48 | 131,072 | — | — | 29.4 GB |
| GPT-oss-120B | 117 (5.1 active) | 2880 | 64 | 8 | 64 | 36 | 131,072 | 128 | 4 | ~63 GB |
| GPT-oss-20B | 21 (3.6 active) | 2880 | 64 | 8 | 64 | 24 | 131,072 | 32 | 4 | ~14 GB |
GPU specs (FP16 TFLOPS, memory capacity, HBM bandwidth) are sourced from official vendor datasheets and product pages:
| GPU | FP16 TFLOPS | Memory | Bandwidth | Source |
|---|---|---|---|---|
| NVIDIA L40s | 362 | 48 GB GDDR6 | 864 GB/s | NVIDIA L40s Datasheet |
| NVIDIA H100 NVL | 835.5 | 94 GB HBM3 | 3,900 GB/s | NVIDIA H100 Datasheet, Tensor Core GPU Whitepaper |
| NVIDIA H200 NVL | 835.5 | 141 GB HBM3e | 4,800 GB/s | NVIDIA H200 Datasheet |
| AMD Instinct MI300X | 1,307 | 192 GB HBM3 | 5,300 GB/s | AMD MI300X Product Page |
The model's parameters (weights) must reside in GPU memory (VRAM). For FP16/BF16 precision, each parameter occupies 2 bytes. Quantized models use fewer bytes — for example, MXFP4 uses just 0.5 bytes per parameter for quantized layers.
During autoregressive generation, the Key and Value tensors from self-attention are cached to avoid recomputation. The KV cache grows linearly with sequence length and concurrent requests. It is often the dominant memory consumer for long-context workloads.
LLM inference has two phases:
Modern models use GQA where multiple query heads share fewer KV heads. This reduces KV cache size significantly. For example, Llama-3.1-70B has 64 attention heads but only 8 KV heads — an 8× reduction in KV cache compared to full multi-head attention.
For standard FP16/BF16 dense models:
For models with mixed-precision or quantization (e.g. GPT-oss with MXFP4), an explicit override is used based on actual measured model size:
The head_dim is usually d_model / n_heads, but some models (like GPT-oss) specify it explicitly when the hidden size doesn't divide evenly.
This indicates how many GPUs of a given type are needed purely for memory capacity. In practice, multi-GPU inference also requires tensor parallelism or pipeline parallelism communication overhead.
Prefill is compute-bound. The time to process each input token:
The factor of 2 accounts for the multiply-accumulate operations (1 multiply + 1 add per parameter). For MoE models, compute_params_billion = the active parameters per token, not total parameters.
Decode is memory-bandwidth-bound. Each generated token requires reading the model weights from HBM:
For MoE models, only the active expert weights are read per token, so we use active parameters.
This approximation assumes the first token is produced after processing the full prompt plus one decode step.
Total wall-clock time from sending the request to receiving the complete response.
This is the single-request output token rate. Actual serving throughput with batching will be higher.
Mixture-of-Experts models like GPT-oss use a routing mechanism where each token is processed by only a subset of "expert" sub-networks:
| Aspect | Dense Model | MoE Model |
|---|---|---|
| Memory | All parameters in VRAM | All parameters in VRAM (all experts must be loaded) |
| Compute per token | All parameters | Only active expert parameters (e.g., 5.1B out of 117B for GPT-oss-120B) |
| Bandwidth per token | Read all weights from HBM | Read only active expert weights from HBM |
| Net effect | — | Much faster inference despite larger total model size |
GPT-oss models use MXFP4 (Microscaling 4-bit floating point) quantization for the expert MLP weights, while keeping the rest in BF16. This is critical for accurate sizing: