Batch Size
The number of independent inputs processed simultaneously during training or inference, affecting computational efficiency and memory usage.
Batch size determines how many input sequences are processed in parallel by the model on a given GPU iteration. During training, larger batch sizes produce more stable gradients, enable higher learning rates, and better utilize parallel hardware (tensor cores). However, they demand more GPU memory for activations and gradients. Typical batch sizes range from 8 to 2048 depending on model size and hardware memory. For inference, batch size directly influences throughput vs latency tradeoff: larger batches increase tokens-per-second overall but increase per-request latency because all requests must be padded to the same sequence length (or use dynamic batching). Techniques like continuous batching (vLLM) allow each sequence to run independently, reducing wasted computation on padding tokens. For autoregressive decoding, batch size multiplies the KV cache memory footprint linearly-a batch of 32 with 4096 tokens per sequence demands 32x more cache than a single sequence. Thus, memory-bound models (e.g., 70B parameters) may fit only a small batch on one GPU. For AI builders, profiling optimal batch size is crucial: start with batch=1, increase until GPU memory is 90-95% utilized, then observe throughput saturation. Precision (FP16, int8) also changes effective batch size limits. Batch size also affects quantization calibration: you need representative batch samples for per-tensor or per-channel scaling.
Increasing batch size always speeds up inference; in reality, after a certain point, memory bottlenecks and diminishing returns kick in.
Related terms
Concepts you'll usually encounter alongside this one.
A key tradeoff in LLM serving: throughput measures total requests processed per time, while latency measures response time per individual request.
The KV cache stores intermediate key and value tensors from previous tokens during autoregressive generation, enabling subquadratic computation by avoiding redundant re-encoding of the full context.
A high-performance DRAM technology stacked vertically with GPU dies, providing massive memory bandwidth for LLM inference and training.
Mentioned in tutorials
Hands-on guides that put this concept to work.
Scale a single model across multiple GPUs with tensor parallelism. Configure vLLM and llama.cpp, fix PCIe bottlenecks, double your VRAM.
Squeeze 10-15% more performance from your RTX card with smarter power and thermal settings. Less heat, less noise, lower power bill.
Skip the CLI, call Ollama directly from Python, JavaScript, or curl. Covers the native API, the OpenAI-compatible endpoint, streaming, and structured output.
See how this term affects your memory budget.
Real numbers, real chips, every workload.
Picks for builders, by use case.
Stay Ahead of the AI Curve
Get weekly AI hardware news, benchmark updates, and deals in your inbox. Founding-subscriber list, be one of the first.