What is Batch size?
The number of inputs processed together. Larger batches reuse weights for efficiency but increase latency and memory.
Read the beginner explainer: Matrix Multiplication FLOPs (2mnk) and Arithmetic Intensity
Japanese name: バッチサイズ
The number of inputs processed together. Larger batches reuse weights for efficiency but increase latency and memory.
Read the beginner explainer: Matrix Multiplication FLOPs (2mnk) and Arithmetic Intensity
Japanese name: バッチサイズ
In a neural-network layer, the weights are the same for every input. With batch size 1, a fully connected layer is a matrix-vector product: each weight is fetched from memory for a single multiply-add, giving an arithmetic intensity of about 1 FLOP/byte in FP16, so compute units mostly wait for memory. With batch size B, the layer becomes a matrix-matrix product: weight traffic stays the same while operations grow B-fold, so intensity rises roughly B-fold and the workload moves from memory-bound toward compute-bound. Servers exploit this by grouping requests from many users.
A bigger batch raises total throughput but not individual speed. Requests may wait for others to arrive, and each batch takes longer to compute, so per-request latency grows; interactive services raise the batch only as far as their response-time targets allow. Memory grows too. In LLM (large language model) inference the KV cache, which stores attention keys and values of earlier tokens so they are not recomputed, scales with layers, key and value dimensions, tokens, batch size and bytes per element. With long contexts or many requests it can reach tens of gigabytes, more than the weights.
During decoding at batch size 1, every generated token requires reading all the weights. A model with about 14 GB of FP16 weights on a GPU with 2 TB/s of bandwidth therefore needs at leastper token, at most about 140 tokens per second. Quantizing weights to 4 bits, about 3.5 GB, lowers the per-token time bound to about 1.75 ms. A larger batch generates several tokens per weight read, multiplying aggregate throughput until compute or KV-cache memory becomes the limit. KV-cache pressure is eased by lower-precision caches, sharing keys and values across heads and block-based memory management.
In training, the batch (mini-batch) is the set of samples whose gradients are averaged for one weight update. Larger batches use hardware more efficiently and need fewer update steps per pass over the data (an epoch), but activation memory for backpropagation grows with batch size and model depth. Gradient checkpointing counters this by storing only some activations and recomputing the rest for roughly one extra forward pass. Changing the batch size substantially usually means retuning the learning rate, since it changes gradient noise.
Answer: C. Each weight read from memory is used in only one multiply-add, so arithmetic intensity is very low
In a matrix-vector product, each element of the weight matrix is read once and used for a single multiply-add with one input element. In FP16 that is two operations per 2 bytes, an arithmetic intensity of about 1. Reading the weights takes most of the time while the arithmetic units mostly wait. Grouping inputs so the same weights serve several of them (a larger batch) raises arithmetic intensity.
Answer: C. Weights read once serve several inputs, raising arithmetic intensity and keeping the arithmetic units busy
With batch size B, multiplying the weight matrix by B vectors becomes a product of the weight matrix and a B-wide matrix. Weight reads stay the same while operations grow B-fold, so arithmetic intensity rises roughly B-fold and the workload moves from memory-bound toward compute-bound. Server inference uses GPUs efficiently by batching requests from many users together.
It increases total throughput because each weight read serves more inputs, but each individual request usually waits longer, so latency gets worse.
Activations, and in LLMs the KV cache, are stored per input, so they scale linearly with batch size while the weights stay the same.
Batch size is how many samples are processed per step or weight update; an epoch is one full pass over the training dataset, which takes dataset size divided by batch size steps.
Batch size appears in 7 practice questions across 1 topic, including AI Hardware & Software Stack.
As an Amazon Associate I earn from qualifying purchases.
This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.