AI model memory and bandwidth sizer
Size the memory and bandwidth an AI model needs for training or inference: weights, activations, optimiser state, KV cache, precision and batch.
AI, systems and startupFree to useHow it worksSourcesWhere it helps
Fills the inputs below with typical figures. Replace any of them with your own.
- Memory on one device
- 28.36 GB
- Fits in 80 GB: 51.64 GB to spare (35% used)
- Parameters
- 8.028 billion
- All used by every token
- Weights, whole model
- 16.06 GB
- 1 devices in the layout
- KV cache, whole batch
- 8.59 GB
- 131,072 bytes a token (128 KiB)
- Bandwidth for the target rate
- 0.7394 TB/s
- On each of 1 tensor parallel devices at 30 tokens/s a sequence
- Fastest decode per sequence
- 108.7 tokens/s
- 869.9 tokens/s over the whole batch and replicas
- Smallest serving layout
- 1 device
- Most sequences that fit on this layout: 51
- Weights16.0657%
- KV cache8.5930%
- Activation workspace0.2191%
- Output logits0.0040960%
- Overhead and runtime3.48712%
Show the data as a table
| Item | Memory |
|---|---|
| Weights | 16.06 |
| KV cache | 8.59 |
| Activation workspace | 0.219 |
| Output logits | 0.004096 |
| Overhead and runtime | 3.487 |
Sign in to save your inputs and come back to them later.
| Component | Whole model, no sharding | One device after sharding | Share of one device |
|---|---|---|---|
| Weights | 16.06 GB | 16.06 GB | 56.6% |
| KV cache | 8.59 GB | 8.59 GB | 30.3% |
| Activation workspace | 0.219 GB | 0.219 GB | 0.8% |
| Output logits | 0.004096 GB | 0.004096 GB | 0.0% |
| Gradients | 0 GB | 0 GB | 0.0% |
| Optimiser state | 0 GB | 0 GB | 0.0% |
| Overhead and runtime | 3.487 GB | 3.487 GB | 12.3% |
| Total | 28.36 GB | 28.36 GB | 100.0% |
- Batch 1 (solid line, circles)
- Batch 8 (dashed line, squares)
- Batch 32 (dotted line, triangles)
- Device memory (dash-dot line, diamonds)
Show the data as a table
| Context length per sequence (tokens, doubling at each step) | Batch 1 | Batch 8 | Batch 32 | Device memory |
|---|---|---|---|---|
| 1k | 19.1 | 20.1 | 23.6 | 80 |
| 2k | 19.2 | 21.3 | 28.4 | 80 |
| 4k | 19.5 | 23.6 | 37.8 | 80 |
| 8k | 20.1 | 28.4 | 56.7 | 80 |
| 16k | 21.3 | 37.8 | 94.5 | 80 |
| 32k | 23.6 | 56.7 | 170 | 80 |
| 64k | 28.4 | 94.5 | 321 | 80 |
| 128k | 37.8 | 170 | 624 | 80 |
| 256k | 56.7 | 321 | 1,230 | 80 |
| 512k | 94.5 | 624 | 2,440 | 80 |
| 1M | 170 | 1,230 | 4,860 | 80 |
| Weight precision | Weights per device | Memory on one device | Fits | Smallest serving layout |
|---|---|---|---|---|
| FP32 (4 bytes) | 32.11 GB | 46.02 GB | Yes | 1 |
| BF16 or FP16 (2 bytes) | 16.06 GB | 28.36 GB | Yes | 1 |
| FP8 (1 byte) | 8.028 GB | 19.53 GB | Yes | 1 |
| INT8 (1 byte) | 8.028 GB | 19.53 GB | Yes | 1 |
| INT4 (0.5 byte) | 4.014 GB | 15.11 GB | Yes | 1 |
| Tokens/s for each sequence | Per tensor parallel device | All devices together | Within the device bandwidth |
|---|---|---|---|
| 5 | 0.1232 TB/s | 0.1232 TB/s | Yes |
| 10 | 0.2465 TB/s | 0.2465 TB/s | Yes |
| 20 | 0.4929 TB/s | 0.4929 TB/s | Yes |
| 50 | 1.232 TB/s | 1.232 TB/s | Yes |
| 100 | 2.465 TB/s | 2.465 TB/s | Yes |
| 200 | 4.929 TB/s | 4.929 TB/s | No |
How it works
Whether a model fits, and how fast it can run, is mostly a memory question. This tool adds up the weights, the KV cache, the activations, the gradients and the optimiser state, splits them across tensor, pipeline and data parallel devices with ZeRO sharding, and compares the result with the memory of one accelerator. For serving it also finds the memory bandwidth a target token rate needs, because each decoded token reads the weights and the cache.
- Count the parameters. Enter the parameters in billions, or let the tool count them from the architecture: embeddings (twice if the output head is not tied), then for every layer the attention projections (queries use all heads, keys and values use the KV heads), the feed-forward block (three matrices when gated, two when plain) and the norms. For a mixture of experts the feed-forward block is repeated for every expert and a router is added.
attention per layer = hidden x heads x head size + 2 x hidden x KV heads x head size + heads x head size x hidden; MLP per expert = 3 (or 2) x hidden x FFN size; total = embeddings + layers x (attention + norms + experts x MLP) - Treat a mixture of experts. All experts must stay in memory, so memory follows the total parameters. Each token uses only the shared parameters plus its chosen experts, so compute follows the active parameters. When you enter totals instead of an architecture, the tool separates the expert and shared parts from the total and the active figures.
per-expert parameters = (total − active) / (experts − active experts); shared = total − experts x per-expert - Size the weights. Weights are the parameter count times the bytes of the chosen precision: 4 for FP32, 2 for BF16, 1 for FP8 or INT8, and 0.5 for INT4. Scales for quantised formats are not counted.
weights = parameters x bytes per parameter - Size the KV cache. Every token of every sequence stores a key and a value in every layer. Grouped-query attention stores only the KV heads, which is why the cache is smaller than with one KV head per query head.
KV cache = 2 x layers x KV heads x head size x context tokens x sequences x bytes - Size the training activations. For a standard transformer layer with 16-bit activations, Korthikanti et al. count 34 sbh bytes plus 5 a s^2 b bytes stored per layer, where s is the sequence length, b the micro-batch, h the hidden size and a the heads. Of the 34, layer norms take 4, attention 11 and a feed-forward block of width 4h takes 19. Here the attention share is reduced for grouped-query attention and the feed-forward share follows the real width, with a gated block storing about 8 times its width. Selective recomputation drops the s^2 term, full recomputation keeps only each layer's input (2 sbh), and sequence parallelism splits what tensor parallelism leaves whole. The first pipeline stage holds one micro-batch per stage, so it stores the activations of all layers.
per layer = s x b x h x (4 + (7 + 4 x KV heads / heads) + MLP share + 5 x a x s / h) x width / 2, divided by tensor parallel degree with sequence parallelism; selective: without the 5 a s / h term; full: 2 s b h - Add gradients and optimiser state. Gradients take the weight width (never below 16 bits). Adam with FP32 master weights keeps a master copy and two moments, 12 bytes a parameter, which with 2-byte weights and gradients makes the 16 bytes a parameter that Rajbhandari et al. use. SGD with momentum keeps a master copy and one moment; plain SGD keeps only the master copy. A trainable share below 100% (an adapter) limits gradients and state to that share. The output logits and their gradient are held in FP32.
gradients = trainable parameters x bytes; optimiser state = trainable parameters x (4 master + 8 Adam moments); logits = 8 x s x b x vocabulary / tensor parallel - Shard across devices. Tensor and pipeline parallelism split the weights, gradients and optimiser state by their product. ZeRO then splits across the data parallel ranks: stage 1 the optimiser state, stage 2 also the gradients, stage 3 also the weights. When serving, the cache splits across the KV heads and pipeline stages, so tensor parallel degrees above the KV head count copy it.
per device = weights / (tp x pp x [dp if ZeRO 3]) + gradients / (tp x pp x [dp if ZeRO 2 or 3]) + state / (tp x pp x [dp if ZeRO 1 to 3]) + activations + logits - Add overhead and compare with the device. A share for fragmentation and framework buffers, and a fixed amount for the runtime, are added to the sum. The tool then reports the headroom, the smallest layout that fits, and for serving the largest number of sequences that fit at the context length.
device total = sum x (1 + overhead share) + reserved memory; headroom = device memory − device total - Find the decode bandwidth. One decode step produces one token for every sequence in the batch. It reads the weights it uses once, and every sequence's cache. For a mixture of experts the weights read are the shared part plus the experts the batch touches, taking routing as uniform. Pipeline stages run one after another on a token, so only tensor parallelism cuts what each device reads.
bytes per step = weights used x bytes + KV cache bytes; bandwidth per device = (weights / tp + cache / min(tp, KV heads)) x tokens per second; experts touched = E x (1 − (1 − k / E)^batch)
Assumptions
- Parameters are spread evenly across devices. Embeddings, uneven layer counts and padded dimensions make real splits a little worse.
- The activation coefficients are Korthikanti et al.'s for a standard layer, adapted here for grouped-query attention and gated feed-forward blocks. They are an engineering estimate, not a measurement; frameworks that fuse operations store less.
- Serving activations are a working-memory estimate (a prefill chunk plus the decode tokens, a few hidden-size and feed-forward-size buffers). Real servers allocate their own pools; measure yours.
- Expert routing is uniform and independent between tokens, so batch decoding of a mixture of experts reads more of the model than one token does. Real routing is skewed and reads fewer experts.
- Overhead is 10% plus 1 GB by default, an editorial allowance for fragmentation and the runtime. Replace it with a measurement from your own framework.
- Quantised weights count their stored bits only. Scales, zero points and the layers kept at higher precision add a few percent.
Limits and warnings
- Multi-head latent attention and other compressed caches store less than the standard formula; enter the effective KV heads and head size for those.
- Offloading to host memory or disk, paged KV caches with shared prefixes, and speculative decoding change what is resident and what is read; none are modelled.
- The decode bandwidth is a memory-bound estimate. Compute, communication between tensor parallel devices and kernel efficiency can set a lower token rate.
- ZeRO-3 needs temporary full copies of a layer's weights while it runs; that buffer is inside the overhead allowance, not counted separately.
- Training memory ignores communication buffers, data loading and checkpoint writing, which can add several gigabytes.
- Expert parallelism, which places experts on separate devices, is not modelled; a mixture of experts is sharded like a dense model here.
Sources
The methods and default figures rest on these public sources. The wording here is our own; read the source for its full text.
- Reducing Activation Recomputation in Large Transformer Models (opens in a new tab), arXiv:2205.05198 (Korthikanti, Casper, Lym, McAfee, Andersch, Shoeybi, Catanzaro; NVIDIA), 10 May 2022. Activation memory per layer, selective and full recomputation, sequence parallelism.
- ZeRO: Memory Optimizations Toward Training Trillion Parameter Models (opens in a new tab), SC20, International Conference for High Performance Computing, Networking, Storage and Analysis (Rajbhandari, Rasley, Ruwase, He; Microsoft), November 2020 (arXiv v3, 13 May 2020). Sixteen bytes a parameter for mixed-precision Adam and the three ZeRO stages.
- GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints (opens in a new tab), arXiv:2305.13245 (Ainslie, Lee-Thorp, de Jong, Zemlyanskiy, Lebron, Sanghai; Google Research), EMNLP 2023, 22 May 2023. Grouped-query attention and its smaller KV cache.
- The Llama 3 Herd of Models (opens in a new tab), Meta AI, arXiv:2407.21783, 31 July 2024. Architecture of the 8B and 70B models: layers, hidden size, feed-forward size, heads, KV heads, vocabulary.
- Mixtral of Experts (opens in a new tab), Mistral AI, arXiv:2401.04088 (Jiang and others), 8 January 2024. Eight experts with two active per token: about 47 billion total and 13 billion active parameters.
- NVIDIA H100 Tensor Core GPU (opens in a new tab), NVIDIA, page read 25 October 2026. 80 GB HBM3 at 3.35 TB/s.
- ThinkSystem NVIDIA HGX B200 180GB 1000W GPU Product Guide (LP2226) (opens in a new tab), Lenovo Press, last updated 13 January 2026. 180 GB HBM3e at 7.7 TB/s.
- AMD Instinct MI300X Accelerator data sheet (opens in a new tab), Advanced Micro Devices, 2025. 192 GB HBM3 at 5.3 TB/s.
- TPU v5p (opens in a new tab), Google Cloud documentation, page updated 22 October 2026, read 25 October 2026. 95 GiB HBM at 2,765 GB/s per chip.
- Intel Gaudi 3 AI Accelerator White Paper (opens in a new tab), Intel, March 2025 (V1 Rev. 2). 128 GB HBM2e at 3.7 TB/s.
Where it helps
The lifecycle stages this tool serves: 2 stages in 1 lifecycle.
More ai, systems and startup tools
Method notev1Formula, ranges, sources and limits
Sizes the weights, KV cache, activations, gradients and optimiser state of a transformer model for inference or training, shards them across tensor, pipeline and data parallel devices with ZeRO, and finds the decode bandwidth a token rate needs.
Formula
attention per layer = hidden x heads x head size + 2 x hidden x KV heads x head size + heads x head size x hidden; MLP per expert = 3 (or 2) x hidden x FFN size; total = embeddings + layers x (attention + norms + experts x MLP); per-expert parameters = (total − active) / (experts − active experts); shared = total − experts x per-expert; weights = parameters x bytes per parameter; KV cache = 2 x layers x KV heads x head size x context tokens x sequences x bytes; per layer = s x b x h x (4 + (7 + 4 x KV heads / heads) + MLP share + 5 x a x s / h) x width / 2, divided by tensor parallel degree with sequence parallelism; selective: without the 5 a s / h term; full: 2 s b h; gradients = trainable parameters x bytes; optimiser state = trainable parameters x (4 master + 8 Adam moments); logits = 8 x s x b x vocabulary / tensor parallel; per device = weights / (tp x pp x [dp if ZeRO 3]) + gradients / (tp x pp x [dp if ZeRO 2 or 3]) + state / (tp x pp x [dp if ZeRO 1 to 3]) + activations + logits; device total = sum x (1 + overhead share) + reserved memory; headroom = device memory − device total; bytes per step = weights used x bytes + KV cache bytes; bandwidth per device = (weights / tp + cache / min(tp, KV heads)) x tokens per second; experts touched = E x (1 − (1 − k / E)^batch)
| Input | Unit | Range it holds for | Comes from |
|---|---|---|---|
| Where the parameter count comes from | choice | arch, params | Your figure |
| Parameters | billions | 0.001 to 20000 | Your figure |
| Active parameters per token, 0 for dense | billions | 0 to 20000 | Your figure |
| Experts | count | 1 to 4096 | Your figure |
| Active experts per token | count | 1 to 64 | Your figure |
| Layers | count | 1 to 400 | Your figure |
| Hidden size | values | 64 to 200000 | Your figure |
| Attention heads | count | 1 to 1024 | Your figure |
| KV heads | count | 1 to 1024 | Your figure |
| Head size, 0 for hidden over heads | values | 0 to 1024 | Your figure |
| Feed-forward size | values | 1 to 1000000 | Your figure |
| Feed-forward block | choice | gated, plain | Your figure |
| Vocabulary | tokens | 0 to 2000000 | Your figure |
| Output head shares the embedding | choice | no, yes | Your figure |
| Mode | choice | inference, training | Your figure |
| Weight precision | choice | fp32, bf16, fp8, int8, int4 | Your figure |
| Activation precision | choice | fp32, bf16, fp8 | Your figure |
| KV cache precision | choice | fp32, bf16, fp8, int8, int4 | Your figure |
| Sequences (inference) or micro-batch (training) | sequences | 1 to 100000 | Your figure |
| Context or sequence length | tokens | 1 to 10000000 | Your figure |
| Prefill chunk for serving workspace | tokens | 0 to 1000000 | Your figure |
| Optimiser | choice | adam, sgd-momentum, sgd | Your figure |
| FP32 master weights | choice | yes, no | Your figure |
| Trainable share of parameters | % | 0.001 to 100 | Your figure |
| Activation recomputation | choice | none, selective, full | Your figure |
| Sequence parallelism | choice | yes, no | Your figure |
| Tensor parallel degree | devices | 1 to 4096 | Your figure |
| Pipeline parallel degree | devices | 1 to 1024 | Your figure |
| Data parallel degree | devices | 1 to 100000 | Your figure |
| ZeRO stage | stage | 0 to 3 | Your figure |
| Accelerator preset | choice | custom, h100, b200, mi300x, tpu-v5p, gaudi3 | Your figure |
| Memory of one accelerator | entered unit | from 1 | Your figure |
| Unit of device memory | choice | gb, gib, tb, tib | Your figure |
| Unit for results | choice | gb, gib, tb, tib | Your figure |
| Overhead for fragmentation and buffers | % | 0 to 100 | Your figure |
| Reserved runtime memory | GB | 0 to 64 | Your figure |
| Target tokens per second for each sequence | tokens/s | 0 to 100000 | Your figure |
| Memory bandwidth of one accelerator | entered unit | from 0 | Your figure |
| Unit of device bandwidth | choice | gbs, tbs | Your figure |
| Share of bandwidth reached | % | 1 to 100 | Your figure |
Outputs: Total parameters (billions); Weights, whole model (GB); KV cache, whole batch (inference) (GB); Memory on one device (GB); Devices in the layout (count); Smallest layout that fits (devices or data parallel ranks); Decode bandwidth needed on one device (TB/s); Most tokens a second for each sequence (tokens/s).
Assumptions
- Parameters are spread evenly across devices. Embeddings, uneven layer counts and padded dimensions make real splits a little worse.
- The activation coefficients are Korthikanti et al.'s for a standard layer, adapted here for grouped-query attention and gated feed-forward blocks. They are an engineering estimate, not a measurement; frameworks that fuse operations store less.
- Serving activations are a working-memory estimate (a prefill chunk plus the decode tokens, a few hidden-size and feed-forward-size buffers). Real servers allocate their own pools; measure yours.
- Expert routing is uniform and independent between tokens, so batch decoding of a mixture of experts reads more of the model than one token does. Real routing is skewed and reads fewer experts.
- Overhead is 10% plus 1 GB by default, an editorial allowance for fragmentation and the runtime. Replace it with a measurement from your own framework.
- Quantised weights count their stored bits only. Scales, zero points and the layers kept at higher precision add a few percent.
Uncertainty: The weight, cache, gradient and optimiser arithmetic is exact for the inputs given. Activations and serving workspace are engineering estimates and real frameworks differ by tens of percent; keep headroom of at least 10%.
Known limits
- Multi-head latent attention and other compressed caches store less than the standard formula; enter the effective KV heads and head size for those.
- Offloading to host memory or disk, paged KV caches with shared prefixes, and speculative decoding change what is resident and what is read; none are modelled.
- The decode bandwidth is a memory-bound estimate. Compute, communication between tensor parallel devices and kernel efficiency can set a lower token rate.
- ZeRO-3 needs temporary full copies of a layer's weights while it runs; that buffer is inside the overhead allowance, not counted separately.
- Training memory ignores communication buffers, data loading and checkpoint writing, which can add several gigabytes.
- Expert parallelism, which places experts on separate devices, is not modelled; a mixture of experts is sharded like a dense model here.
Where the method comes from
Follows Rajbhandari, Rasley, Ruwase and He, ZeRO: Memory Optimizations Toward Training Trillion Parameter Models (SC20, 2020), with Korthikanti et al., Reducing Activation Recomputation in Large Transformer Models (2022) (opens in a new tab). The platform's version departs from it as follows.
- Adds serving: the KV cache, grouped-query attention, a workspace for activations and the decode bandwidth Why: Both papers address training memory; most sizing questions today are about serving a trained model.
- Adapts the activation coefficients for grouped-query attention and gated feed-forward blocks, and adds the FP32 logits Why: The published coefficients are for a standard layer with a 4h feed-forward block; current models are gated and use grouped-query attention.
Reference example, checked by test: Worked example in this method note: Llama-class 8B inference (32 layers, hidden 4096, 8 KV heads of size 128, feed-forward 14,336, vocabulary 128,000) with 8 billion parameters entered, BF16 weights and cache, 8 sequences of 8,192 tokens on one 80 GB GPU. Weights are 8e9 x 2 = 16 GB; the cache is 2 x 32 x 8 x 128 x 2 = 131,072 bytes a token, times 65,536 tokens = 8.59 GB. The remaining terms are in the tool's unit test. Total parameters 8; Weights, whole model 16; KV cache, whole batch (inference) 8.58993; Memory on one device 28.2943; Devices in the layout 1; Smallest layout that fits 1; Decode bandwidth needed on one device 0.737698; Most tokens a second for each sequence 108.988.
Versions
- v1 (2026-10-25): First version, built from the tool idea.
Terms on this page
- Bandwidth
- In meeting jargon, a person's or team's available working capacity rather than any data rate.
- AI
- Artificial intelligence (AI): software that learns patterns from data to classify, predict or generate, rather than following only hand-written rules.
- Inference
- Running a trained model on new inputs to produce outputs.
- KV cache
- The stored per-layer key and value tensors for tokens already processed, kept so each new token attends to the context without recomputing it.
- Pipeline
- In commercial jargon, the set of identified sales or design-in opportunities at various stages of maturity, weighted by probability.
- Accelerator
- Any specialised processor attached to a host system to run a class of work faster or more efficiently than a CPU can.
- Memory bandwidth
- The rate at which data can be moved between memory and a processor, quoted in GB/s or TB/s.
- Cache
- A small fast memory holding recently or likely used data close to the processor, normally SRAM arranged in levels L1, L2 and L3.
- BF16
- A 16-bit float with the same 8-bit exponent as FP32 but only 7 mantissa bits, so it covers the full FP32 dynamic range and can be converted by truncation.
- FP8
- An 8-bit float defined by OCP in two variants, E4M3 favouring precision and E5M2 favouring range, used with per-tensor scaling or, in the OCP MX formats, a shared scale per block of 32 values, for...
- INT8
- An 8-bit signed integer format used with per-tensor or per-channel scale factors for neural network inference.
- INT4
- A 4-bit integer format used for aggressive weight-only quantisation of large language models, typically with group-wise scales.
Tell us what you're after and leave your email: we'll connect you with the right person on the Hub.