How much memory do the weights of a 7-billion-parameter LLM (large language model) need in fp32, fp16, int8 and int4? What are these four number formats, why does lower precision help, and what else uses GPU (graphics processing unit) memory at inference time?
Sequence models and transformers, Inference
Level L1 Beginner. Length Short. Nature Th+Mat Both.
What's being asked
Whether you can convert parameter counts and precision bit-widths into memory size, and know that weights are only part of inference memory.
Key idea
Total weight memory is simply the number of parameters multiplied by the bytes per parameter. Using , a -parameter model needs in fp32, in fp16, in int8 and in int4, leaving room on smaller GPUs for activations and the KV cache (key–value cache).
Steps
- Explain each number format in one line: fp32 (32-bit floating point, 4 bytes) is full training precision; fp16 (16-bit floating point, 2 bytes) halves storage while keeping enough precision for most inference; int8 (8-bit integer, 1 byte) and int4 (4-bit integer, 0.5 bytes) store quantised whole numbers in small buckets.
- Compute the weight memory for parameters using :
- Explain why lower precision lets a model fit on smaller hardware: cutting weights from (gigabytes) to or lets a 7-billion-parameter model run on a single consumer or laptop GPU instead of requiring an expensive server GPU, and reduces the data read from GPU memory per generated token.
- Note what else uses GPU memory: weights are not the whole story—intermediate activations during the forward pass, framework buffers, and especially the KV cache (the stored keys and values of past tokens in long conversations) also take substantial memory. Harder inference questions cover exact KV-cache memory budgets and bandwidth limits.
Common mistakes
- Confusing bits with bytes—dividing by 8 converts 32, 16, 8 and 4 bits into 4, 2, 1 and 0.5 bytes.
- Assuming a 14 GB fp16 model fits comfortably on a 16 GB GPU for long contexts, forgetting the KV cache and activations.
- Thinking int4 only cuts memory; it also risks a small drop in output quality unless careful quantisation is used.
How long your answer should be
About 2 minutes; four one-line definitions and four quick multiplications.
Read this
Previous in Sequence models and transformers: How do the training objectives of BERT (masked language modelling) and GPT (causal language modelling) differ, and what does each allow the model to attend to?
Next in Sequence models and transformers: What is retrieval-augmented generation (RAG), and when should you choose it instead of fine-tuning an LLM (large language model)?