How to Tune Batch Size: Separate Physical from Logical
A practical workflow for choosing batch size in training and inference. Learn to separate physical memory limits from logical update size, then tune with gradient accumulation, quantization, and throughput monitoring.
Batch size is not one number but two: the physical batch that fits in device memory and the logical batch that shapes the learning update. This explainer walks through a practical tuning workflow. Start by measuring memory headroom, set the physical batch, choose a logical batch for convergence or throughput, then bridge them with gradient accumulation or continuous batching. Monitor results and adjust with quantization, speculative decoding, or mixture-of-experts routing. The goal is to stop guessing and start tuning with a repeatable process.
FAQ
Why decouple physical and logical batch sizes?
Physical batch is limited by device memory, while logical batch controls the effective gradient update. Decoupling lets you fit a large logical batch without exceeding memory, as shown in recent masked diffusion work that removed batch size tuning.
When should I use gradient accumulation instead of increasing batch size?
Use gradient accumulation when memory is the bottleneck and you need a larger logical batch. It simulates a larger batch by accumulating gradients over multiple forward and backward passes before updating weights.
How do quantization and speculative decoding affect batch size choices?
Quantization reduces memory per parameter, allowing larger physical batches. Speculative decoding increases throughput per request, which can shift the optimal batch size for latency-sensitive serving. Revisit both after setting a baseline.
A five-step path from fragmented payment silos to a canonical, governed record that AI agents can act on: model the payment, unify the copy, stream events, wrap writes in transactions, and scope agent authority.
A five-step loop for treating bots as accountable actors: verify identity, honor opt-out preferences, measure sustained behavior, band trust, and bound blast radius.
A four-checkpoint how-to for agent loops: name a measurable job, bound the tool surface, refresh sandbox fixtures from real traffic, and verify at agent speed.
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.