← Back to Calculator

Methodology & Data Sources

How the LLM Sizing Guide calculates memory, latency, and throughput — and where the numbers come from.

Contents
  1. Data Sources
  2. Key Concepts
  3. Sizing Formulas
  4. Mixture-of-Experts (MoE) Handling
  5. Limitations & Caveats

1. Data Sources

Model Specifications

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 Architecture Details Used in Calculator

Model Params (B) Hidden Size Attn Heads KV Heads Head Dim Layers Max Context Experts Active Experts Weight Size
Llama-3.1-8B8409632812832131,072——16 GB
Llama-3.1-70B70819264812880131,072——140 GB
Mistral-7B-v0.3740963281283232,768——14 GB
Qwen2.5-14B14.7512040812848131,072——29.4 GB
GPT-oss-120B117 (5.1 active)28806486436131,0721284~63 GB
GPT-oss-20B21 (3.6 active)28806486424131,072324~14 GB

GPU Specifications

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
Note on FP16 TFLOPS: We use the with sparsity (structured sparsity) FP16 TFLOPS for NVIDIA GPUs where available, as this reflects the theoretical peak for Tensor Core workloads. Actual achievable TFLOPS depends on the serving framework and kernel efficiency.

2. Key Concepts

Weight Memory

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.

KV Cache

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.

Prefill vs. Decode

LLM inference has two phases:

Grouped-Query Attention (GQA)

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.

3. Sizing Formulas

Weight Memory

For standard FP16/BF16 dense models:

Weight Memory (GB) = params_billion × 2

For models with mixed-precision or quantization (e.g. GPT-oss with MXFP4), an explicit override is used based on actual measured model size:

GPT-oss-120B example: Expert weights (MXFP4): ~114B params × 0.5 bytes/param = ~57 GB Non-expert weights (BF16): ~3B params × 2 bytes/param = ~6 GB Total ≈ 63 GB (verified: fits a single 80 GB H100)

KV Cache Size per Token

KV per token (bytes) = 2 × n_layers × n_kv_heads × head_dim × 2 ↑ ↑ K and V FP16 = 2 bytes

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.

Total Memory Footprint

Total Memory (GB) = Weight Memory + KV_per_token × context_window × concurrent_requests where: context_window = input_tokens + output_tokens
This is a worst-case estimate, assuming all concurrent requests use the full context window simultaneously. Real serving engines use paged attention and dynamic memory management for better utilization.

Minimum GPUs

Min GPUs = ⌈ Total Memory / GPU Memory ⌉

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 Time per Token

Prefill is compute-bound. The time to process each input token:

Prefill time/token (ms) = (2 × compute_params_billion) / GPU_FP16_TFLOPS

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.

TPOT — Time per Output Token

Decode is memory-bandwidth-bound. Each generated token requires reading the model weights from HBM:

TPOT (ms) = (2 × compute_params_billion) / memory_bandwidth_GBps × 1000

For MoE models, only the active expert weights are read per token, so we use active parameters.

TTFT — Time to First Token

TTFT (s) ≈ prefill_time_per_token + TPOT / 1000

This approximation assumes the first token is produced after processing the full prompt plus one decode step.

End-to-End Latency

E2E Latency (s) = (input_tokens × prefill_time + output_tokens × TPOT) / 1000

Total wall-clock time from sending the request to receiving the complete response.

Throughput

Throughput (tok/s) = output_tokens / E2E_latency

This is the single-request output token rate. Actual serving throughput with batching will be higher.

4. Mixture-of-Experts (MoE) Handling

Mixture-of-Experts models like GPT-oss use a routing mechanism where each token is processed by only a subset of "expert" sub-networks:

How MoE Affects Sizing

AspectDense ModelMoE 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 MXFP4 Quantization

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:

GPT-oss-120B weight breakdown: 117B total parameters ├── ~114B in expert MLP weights → MXFP4 (0.5 bytes/param) = ~57 GB └── ~3B in shared/non-expert weights → BF16 (2 bytes/param) = ~6 GB Total weight memory ≈ 63 GB GPT-oss-20B weight breakdown: 21B total parameters ├── ~19B in expert MLP weights → MXFP4 (0.5 bytes/param) = ~9.5 GB └── ~2B in shared/non-expert weights → BF16 (2 bytes/param) = ~4 GB Total weight memory ≈ 14 GB
Verification: OpenAI states GPT-oss-120B is designed to run on a single H100 GPU (80 GB). With 63 GB weight memory, this leaves ~17 GB for KV cache and overhead — consistent with the claim.

5. Limitations & Caveats

These are theoretical first-order estimates. Real-world performance will differ due to the factors below.

References

  1. openai/gpt-oss — Official GPT-oss repository with model architecture, MXFP4 details, and training methodology.
  2. GPT-oss-120B config.json — Exact model architecture configuration (layers, heads, experts, dimensions).
  3. GPT-oss-20B config.json — Exact model architecture configuration.
  4. Llama-3.1-8B Model Card — Meta's model card with architecture details.
  5. Llama-3.1-70B Model Card — Meta's model card with architecture details.
  6. Meta Llama 3.1 Blog Post — Official announcement with model family details.
  7. Mistral-7B-v0.3 Model Card — Mistral AI model card.
  8. Qwen2.5-14B Model Card — Alibaba Cloud model card.
  9. NVIDIA L40s Datasheet
  10. NVIDIA H100 Datasheet
  11. NVIDIA H200 Datasheet
  12. AMD MI300X Product Page
  13. Kipply, Transformer Inference Arithmetic — foundational analysis of compute-bound vs. bandwidth-bound LLM inference.
  14. Pope et al., Efficiently Scaling Transformer Inference (2022) — Google's analysis of LLM inference performance.