Zero Labs
Industry News / AI

What Do You Do With a Model That’s Too Big for Your GPU?

Source · Towards AI By Rinit Jain

From the publisher’s feed, collected in the ZeroLabs newsroom.

Quantization, Sharding and Parallelism ExplainedTL;DRModel weights need roughly 1 GB per billion parameters at 8-bit, double that at 16-bit. A 70B model in FP16 is ~140 GB of weights before anything else.Quantization shrinks the model. Offloading moves parts of it off the GPU. Both trade something away.Sharding splits one model across GPUs. Replication makes copies. These solve different problems and are constantly confused.Tensor parallelism splits inside layers and needs a fast interconnect. Pipeline parallelism splits by depth and tolerates slower links. Expert parallelism applies only to MoE models.Once a model is distributed, communication bandwidth becomes a first-class constraint. More GPUs is not automatically more performance.Weights are not the only thing in VRAM. The KV cache competes for the same memory.A modern LLM can contain billions or even hundreds of billions of parameters.The problem is straightforward:GPU memory is finite.If a model requires more memory than one GPU provides, you cannot simply load the entire model onto that GPU and start serving requests.So what do inference systems do?They have several options:Make the model smaller through quantizationMove some data outside GPU memory through offloadingSplit the model across multiple GPUs through shardingReplicate the model across GPUs when memory allows and more throughput is neededCombine different forms of parallelism to distribute the computationThese techniques solve different problems.Understanding that distinction is important because “use more GPUs” is not a single strategy. There are several fundamentally different ways to use those GPUs.This article starts from the memory problem and works upward to the distributed inference architecture.1. Start with the memory problemAn LLM is a collection of learned parameters called weights. During inference, those weights must be available to the hardware doing the computation. That is the first constraint: the weights have to fit somewhere.A simplified estimate:weight memory ≈ number of parameters × bytes per parameterA 70-billion-parameter model at 16-bit precision:16 bits = 2 bytes70,000,000,000 × 2 ≈ 140 GBA rule of thumb worth memorising: about 1 GB per billion parameters at 8-bit precision, halve it for 4-bit, double it for 16-bit.But that is only the weights. Real inference also needs memory for the KV cache, activations and temporary buffers, CUDA and runtime overhead, and communication buffers.So a 140 GB weight estimate does not mean a 140 GB GPU is enough. The actual requirement is meaningfully larger, and the gap widens with long context and high concurrency, because the KV cache scales with both.2. The First Question: Can We Make the Model Smaller?Before distributing a model across GPUs, there is an obvious question:Do we actually need all those bits?This is where quantization enters.QuantizationQuantization represents model values using fewer bits.For example:FP32 ████████████████████████████████ 280 GBFP16 / BF16 ████████████████ 140 GBINT8 ████████ 70 GBINT4 ████ 35 GBThese are simplified raw-weight estimates. Real implementations have additional metadata and overhead.The important idea is the relationship:Fewer bits → smaller weights → lower memory requirementHugging Face documents quantization as a way to reduce both memory footprint and computational cost, with 8-bit and 4-bit approaches commonly used for large models.But quantization is not freeReducing precision can introduce accuracy loss, and the performance impact depends on the model, hardware and quantization method.Modern inference stacks support several approaches, including GPTQ, AWQ, bitsandbytes and other quantization schemes.So quantization is usually the first question:Can we reduce the model enough to fit on fewer GPUs without unacceptable quality or performance loss?If yes, the problem may become much easier.If not, we need to distribute the model.3. What About CPU Offloading?There is another possibility:Keep some of the model outside GPU memory.The basic architecture becomes:CPU RAM → GPU VRAM → computationInstead of keeping everything permanently in VRAM, some data can be transferred between system memory and GPU memory when needed.CUDA’s memory system supports mechanisms that allow applications to work with data larger than the physical memory of an individual processor, although actual performance depends heavily on the hardware and access pattern.This can help when memory capacity is the immediate problem.But there is a fundamental trade-off.GPU memory is extremely fast.Moving data across the CPU-GPU boundary is much slower than accessing data already resident in GPU memory.If the inference workload constantly needs to move model weights back and forth, the GPU can spend more time waiting for data than performing computation.So CPU offloading is generally a memory-capacity technique, not a magical way of turning CPU RAM into equivalent GPU VRAM.For high-performance production inference, keeping the active model state in GPU memory is usually preferable when possible.4. The More Scalable Answer: ShardingSuppose the model still does not fit.You have four GPUs.Instead of putting the entire model on one GPU:GPU 0 → entire modelwe can divide the model:GPU 0 → part of modelGPU 1 → part of modelGPU 2 → part of modelGPU 3 → part of modelThis is model sharding.The model is still logically one model.Physically, however, its parameters and computation are distributed across multiple devices.But there is an important consequence.The GPUs now have to communicate.That communication becomes one of the central engineering constraints of distributed inference.5. Communication is now a first-class constraintFour resources govern inference performance:compute capacity (how much arithmetic the GPU can do), memory capacity (how much fits in VRAM), memory bandwidth (how fast data moves between VRAM and the compute units), and communication bandwidth (how fast GPUs exchange data).The fourth one only starts to matter once you shard, and then it dominates the design. A model that fits neatly across four GPUs is not automatically efficient — those GPUs may spend a large fraction of their time exchanging intermediate results.The scale of the problem is easier to see with numbers. Approximate figures for a current-generation datacenter GPU:Each step down is roughly an order of magnitude. That single hierarchy explains most distributed inference design decisions — including, as we will see, why some parallelism strategies work well inside a server and badly across a network.More GPUs give you more memory and more compute, but they introduce communication overhead. Distributed inference is a balance, not a multiplierThat leads to the real question: how exactly should we split the model?6. Tensor parallelism: split each layerThe first major approach is tensor parallelism (TP). Rather than giving entire layers to different GPUs, it splits the large tensor operations inside the layers.Take a matrix multiplication:Y = X × WInstead of storing the complete weight matrix W on every GPU, we divide it:GPU 0 → W₀GPU 1 → W₁GPU 2 → W₂GPU 3 → W₃Each GPU performs part of the multiplication, and the partial results are combined. NVIDIA describes tensor parallelism as sharding individual Transformer layers across devices.Why use it? Every GPU participates in computing the same layer. That reduces memory per GPU and can give low latency when the GPUs have a fast link. vLLM supports distributed tensor-parallel inference and recommends it for multi-GPU setups where a model is too large for one device.The cost. The GPUs must synchronise intermediate results, so collective operations like all-reduce and all-gather sit on the critical path. The faster the interconnect, the less this hurts — which is why TP is most attractive across GPUs linked by NVLink inside a single server.A practical constraint people hit immediately: the tensor-parallel degree generally has to divide the number of attention heads evenly. You cannot scale TP to an arbitrary GPU count. With grouped-query attention, the relevant number is often the KV head count, which is smaller still.7. What does GPU communication actually look like?It is easy to say TP requires GPUs to communicate. What does that mean concretely?Split W across two GPUs:GPU 0: Y₀ = X × W₀GPU 1: Y₁ = X × W₁Neither GPU has the complete result — each has its own portion. If the split was column-wise, the full result is formed by concatenating:Y = [Y₀ | Y₁]Crucially, the GPUs are not sending the model to each other. They exchange only the intermediate data needed to continue.For other partitionings the combination is a sum instead. Say the two GPUs hold partial results:GPU 0: [3, 5]GPU 1: [7, 2] ↓ communication ↓both GPUs hold: [10, 7]That is an all-reduce. Which collective is needed depends on how the layer was partitioned; all-reduce, all-gather and reduce-scatter are the common ones.So the GPUs run a continuous cycle:compute → communicate → compute → communicate → …If communication is fast, distributing the computation pays off. If it is slow, the GPUs spend their time waiting for each other. When we say a model is “split across GPUs”, we do not mean each GPU independently runs an isolated piece — they participate in one coordinated computation.8. Pipeline parallelism: split the model by depthPipeline parallelism (PP) takes the opposite approach. Suppose the model has 80 Transformer layers:Pipeline ParallelismEach GPU owns a different section. Activations produced by one stage pass to the next, so communication happens only between adjacent stages rather than inside every layer. That is dramatically less traffic than TP.NVIDIA’s model sharding guidance draws the distinction directly: pipeline parallelism places contiguous groups of layers on different GPUs, while tensor parallelism distributes each layer and requires far more frequent collective communication.The trade-off is pipeline bubbles. At any moment some stages may be idle waiting for work from an earlier stage. Training systems address this by splitting work into micro-batches; for inference, the scheduler has to account for requests moving through stages sequentially.So PP reduces communication but introduces scheduling constraints.9. Tensor vs pipeline parallelismBoth distribute a model across GPUs. They divide the work differently.Tensor parallelism splits computation within a layer, so multiple GPUs work on the same layer simultaneously. High communication, low latency, wants NVLink.Pipeline parallelism splits the model into groups of layers, each GPU owning a stage. Low communication, tolerates slower links, introduces bubbles.In practice they combine. A model might use TP across the GPUs inside a server and PP across servers:Tensor Parallelism VS Pipeline ParallelismThis lets very large models span machines while still exploiting fast GPU-to-GPU links within each one. It follows directly from the bandwidth hierarchy in Section 5: use the chatty strategy where bandwidth is cheap, the quiet one where it is expensive.10. Data parallelism is differentData parallelism does not split the model. It replicates it:GPU 0 → full modelGPU 1 → full modelGPU 2 → full modelGPU 3 → full modelEach GPU processes different requests. Excellent for throughput — and useless for the original problem. If the model needs 100 GB and each GPU has 80 GB, four copies do not help. You still cannot load one complete copy anywhere.Sharding solves model capacity. Replication solves workload capacity.11. Sharding vs replicationConsider four GPUs. There are two fundamentally different ways to use them.Option A — sharding. All four GPUs hold one model replica.GPU 0 ┐GPU 1 ├─→ one model replicaGPU 2 │GPU 3 ┘Use this when the model is too large to fit on fewer GPUs.Option B — replication. Two replicas of two GPUs each.GPU 0 ┐→ replica AGPU 1 ┘GPU 2 ┐→ replica BGPU 3 ┘Use this when the model already fits in two GPUs and you want more serving capacity.And you combine them. Suppose a model requires four GPUs and you have sixteen:Replica 1 → GPU 0–3Replica 2 → GPU 4–7Replica 3 → GPU 8–11Replica 4 → GPU 12–15Each replica internally uses tensor or pipeline parallelism; the replicas together provide data-parallel scaling. This is how a production fleet grows beyond a single distributed model instance.Sharding VS Replication12. Expert parallelism: a different kind of modelSo far we have assumed a dense model, where essentially every parameter participates for every token.Many modern LLMs use Mixture-of-Experts (MoE) instead. An MoE model contains multiple expert networks, and a router selects which experts process each token:Token ↓Router ↓Expert 1 / Expert 4 / Expert 7 ↓CombineThe key property: not every expert processes every token. That creates a distribution opportunity.Expert parallelism distributes experts across GPUs instead of replicating them all everywhere:GPU 0 → experts 1–4GPU 1 → experts 5–8GPU 2 → experts 9–12GPU 3 → experts 13–16The router sends tokens toward the GPUs holding the required experts. This substantially reduces expert weight memory per GPU — but introduces a new communication pattern, because now the tokens themselves move between GPUs. Megatron Core describes expert parallelism this way, and current vLLM deployments can combine data, tensor and expert parallelism depending on the architecture.Expert Parallelism (MoE)So EP is not “another version of tensor parallelism.” It applies specifically when the architecture contains independently routable experts.13. The parallelism stackWe now have five ways to distribute a model:Tensor parallelism — split the computation inside layers. Pipeline parallelism — split the model by depth. Data parallelism — replicate the model and split requests. Expert parallelism — distribute MoE experts across GPUs. Context parallelism — distribute the context dimension itself, for very long sequences.These compose. A large production model might run:Data Parallelism × Tensor Parallelism × Pipeline Parallelismor, for an MoE model:Data Parallelism × Tensor Parallelism × Expert ParallelismMegatron Core supports combinations of these strategies, and vLLM and TensorRT-LLM both support tensor, pipeline, data and expert-parallel deployment configurations.The right configuration depends on model architecture, model size, GPU memory, interconnect, GPUs per node, node count, and your latency and throughput targets. There is no universally optimal parallelism configuration.14. The model is not the only thing consuming VRAMGetting weights onto multiple GPUs solves one problem. It does not mean the remaining memory is free for serving requests.During generation, an LLM maintains a KV cache — previously computed key and value tensors reused when generating subsequent tokens. Every active sequence occupies some, and it grows as that sequence gets longer. So GPU memory is shared:VRAM = model weights + KV cache + runtime memorySharding changes the shape of this budget in a way that catches people out. Splitting a model across four GPUs cuts the weight footprint per GPU by roughly four. It does not shrink the KV cache the same way — with tensor parallelism the cache is partitioned across GPUs, but total cache demand still scales with concurrency and context length, and under some attention configurations parts of it are replicated on every device.Fitting the model is a capacity problem. Serving many concurrent requests is a separate KV-cache capacity problem.The KV cache’s memory behaviour has large enough consequences that it gets its own article — see Related reading.15. A model replica becomes a small distributed systemThis changes how to think about a model server. With one GPU:Request → Model Server → GPUWith a distributed model:Request ↓Model Server ↓Distributed inference runtime ↓GPU 0 ↔ GPU 1 ↔ GPU 2 ↔ GPU 3From the outside it still looks like one logical service. Internally it coordinates multiple workers.16. Leader and worker architectureA simplified distributed model server looks like this: API / Model Server │ ▼ Coordinator / Leader │ ┌──────┬─────┴─────┬──────┐ ▼ ▼ ▼ ▼ GPU GPU GPU GPUworker worker worker worker 0 1 2 3The coordinator handles orchestration; the workers perform GPU-side computation. The exact architecture differs between engines, but the general idea holds:One logical model-serving endpoint can represent a coordinated group of GPU processes.vLLM’s architecture, for example, includes an API server, engine core, scheduler, GPU workers and distributed coordination components. This matters even more once the model spans machines.17. One model can span multiple machinesSuppose each server has eight GPUs and the model needs sixteen:Now the model spans the network between machines, and the communication hierarchy has three tiers:GPU memory fastest ↓GPU ↔ GPU (in node) ↓Node ↔ Node slowestThe farther communication travels, the more carefully the system must be designed. This is precisely why tensor parallelism is attractive within a node while pipeline parallelism becomes useful across nodes. vLLM’s guidance describes exactly this: single-node tensor parallelism, and multi-node combinations of tensor and pipeline parallelism.18. So how do we choose?A practical sequence:How to choose parallelism strategy for LLM inferenceThe model fits on one GPU → use single-GPU inference. Don’t shard without a reason.It does not fit, but fits across GPUs in one node → tensor parallelism. The fast interconnect makes frequent communication practical.It does not fit in one node → tensor parallelism within nodes, pipeline parallelism across them.It fits on one distributed replica, but throughput is insufficient → add data-parallel replicas.It is a Mixture-of-Experts model → expert parallelism, usually combined with TP and DP.It barely misses the memory limit → try quantization before adding hardware, assuming the resulting quality is acceptable.This is not a rigid decision tree, but it is a useful starting point.19. The real production equationServing a large LLM is not:model size It is closer to:model weights + KV cache + runtime memory+ communication buffers + concurrencymust fit within the available distributed GPU memoryand then:compute + memory bandwidth + interconnect bandwidthmust be fast enough to meet latency and throughput targetsThat is why two systems with identical GPU counts can have very different inference performance. The hardware matters — but so does how the model is distributed across it.20. The bigger pictureWe started with one problem: the model does not fit on one GPU. There are six responses, and they combine.Quantization makes the model smaller. Offloading moves data outside GPU memory. Tensor parallelism splits layers across GPUs. Pipeline parallelism splits the model into stages. Data parallelism replicates it to serve more requests. Expert parallelism distributes experts in an MoE model.A real deployment might end up looking like:USERS │ Load Balancer │ ┌─────────┴─────────┐ ▼ ▼ MODEL REPLICA A MODEL REPLICA B GPU 0–3 GPU 4–7Each replica internally using tensor or pipeline parallelism. This is the point where a model stops being a single GPU process and becomes a distributed serving system.The next problemThe model now fits. It is quantized, sharded, spread across GPUs that can talk to each other quickly enough to be useful.But look at what we actually sized for: weights. Every calculation in this article was about making a fixed, read-only block of parameters fit into memory. And Section 14 already hinted at the catch — the weights are not the only thing in VRAM, and they are not the part that grows.Now put the replica into production. Hundreds of users start sending requests to it simultaneously. They are not each getting their own copy of the model; there is only one, and they all share it. What each of them does get is a slice of the memory left over after the weights — and those slices grow as their conversations get longer.So the question changes shape entirely. Not “does the model fit?”, which we have answered, but:How does a single GPU serve hundreds of users at once, and what actually decides how many it can hold?That means going inside the inference server itself — the queues, the scheduler, and the batching machinery that lets one set of weights produce tokens for many people at the same time.The series1. What really happens when you click ‘Send’ on ChatGPT — A journey through modern AI Infrastructure2. What Do You Do With a Model That’s Too Big for Your GPU? — Quantization, Sharding and Parallelism Explained3. How Does One GPU Serve Hundreds of Users at the Same Time? — Inside an LLM inference server (Next Article)4. The KV Cache Explained: Why Long Conversations Get Expensive — How LLMs remember context without recomputing everything5. Why Is Your LLM Recomputing the Same Prompt 1,000 Times a Day? — Prefix caching, radix trees and block hashing explained6. Why Traditional Load Balancing Breaks for LLMs — Building an LLM-aware router7. Kubernetes for LLM Inference: How AI Workloads Run Across a GPU Cluster8. LLM-D Explained — How modern AI infrastructure routes, schedules and scales LLM inference9. Inside a Modern AI Inference Platform — The full stack end-to-endSourcesNVIDIA — Mastering LLM Techniques: Inference OptimizationTensorRT-LLM — Deciding Model Sharding StrategyTensorRT-LLM — Parallelism strategiesHugging Face — QuantizationvLLM — Distributed inference and servingWhat Do You Do With a Model That’s Too Big for Your GPU? was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.