Sparse Models › Dense Models and Their Limitations
Language AI HandbookAll chapters Sparse Models › Dense Models and Their LimitationsOne section · Sections in this chapter2 / 10 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Every transformer architecture we've studied so far follows the same pattern. When a token enters the model, it flows through every layer, every attention head, and every feed-forward network. The model's full parameter count participates in every computation. This uniformity of computation, where the same operations apply regardless of the input's content, has been both a strength and a limitation of the transformer architecture.
A model where all parameters are activated and participate in the forward pass for every input. The computational cost scales directly with the total parameter count.
The "dense" property means every parameter contributes to every prediction, creating a direct relationship between model size and computational cost. If we double the parameters, we double the compute required per token. This tight coupling between capacity and computation is a design choice rather than a basic constraint of neural networks.
Consider the feed-forward network we examined in Part XV. For a model with hidden dimension and FFN intermediate dimension , each token passes through two linear transformations. The feed-forward network is where sparse models make their intervention.
The feed-forward network transforms each token through an expansion to a larger intermediate dimension, applies a non-linearity, then projects back to the original dimension. This two-stage transformation allows the network to learn complex non-linear mappings. The network first projects into a higher-dimensional space where patterns are easier to separate, then projects back to the model dimension. This expansion and contraction pattern is remarkably effective at capturing complex relationships in the data. Given an input token , the FFN computes:
where:
- : input token representation with dimension
- : first weight matrix that projects to the intermediate dimension
- : bias vector for the first transformation
- : activation function (typically ReLU or GELU) applied element-wise
- : second weight matrix that projects back to
- : bias vector for the output transformation
The activation function has two key properties that make it ideal for the transformation. It ensures non-linearity in the transformation and allows the network to learn complex patterns by projecting into a space where features can be more easily separated before projecting back to the model dimension. Without this non-linearity, the composition of two linear transformations would simply collapse into a single linear transformation, severely limiting the network's expressive power.
We can derive the total parameter count for these two weight matrices as follows. This derivation helps us understand exactly where the computational burden lies in a transformer layer:
In a typical transformer where , substituting into our formula gives parameters per FFN layer. To put this in concrete terms, for GPT-3 with , that's over 1.2 billion parameters per layer, and every single parameter gets used for every single token. This enormous parameter count per layer, multiplied across all layers, explains why large language models require such substantial hardware resources.
This creates a coupling between three quantities that we might prefer to scale independently:
- Model capacity: The ability to store and process complex patterns, which is tied to parameter count
- Training compute: The FLOPs required to update parameters during training
- Inference compute: The FLOPs required to process each token at runtime
In dense models, these three quantities move together in lockstep. Want more capacity? Add parameters. More parameters means more compute for both training and inference. The Chinchilla scaling laws help us balance compute and data efficiently, but they don't break this basic coupling. This coupling is a significant constraint: we cannot increase the model's knowledge capacity without simultaneously increasing the cost of using that knowledge.
The practical impact is severe. A 175 billion parameter dense model requires roughly 350 billion FLOPs per token (using the approximation that FLOPs = 2 times parameters per forward pass). At scale, this determines your hardware requirements, inference latency, and operating costs. For organizations deploying these models to millions of users, even small inefficiencies translate into substantial infrastructure expenses.
def estimate_dense_model_cost(
params_billions: float, tokens_per_second: float = 1000
) -> dict:
"""Estimate computational costs for a dense model."""
params = params_billions * 1e9
# FLOPs per token: forward pass only, approximately 2x parameters
flops_per_token = 2 * params
# Total FLOPs per second
flops_per_second = flops_per_token * tokens_per_second
# A100 GPU theoretical peak: 312 TFLOPS (FP16)
a100_tflops = 312e12
# Realistic utilization typically ranges from 30-50%
utilization = 0.4
effective_tflops = a100_tflops * utilization
# GPUs needed for real-time inference
gpus_needed = flops_per_second / effective_tflops
return {
"params_billions": params_billions,
"flops_per_token": flops_per_token,
"tflops_per_second": flops_per_second / 1e12,
"a100_gpus_needed": gpus_needed,
}
model_sizes = [7, 70, 175, 540]7B parameters: 1.40e+10 FLOPs/token, 0.1 A100 GPUs needed 70B parameters: 1.40e+11 FLOPs/token, 1.1 A100 GPUs needed 175B parameters: 3.50e+11 FLOPs/token, 2.8 A100 GPUs needed 540B parameters: 1.08e+12 FLOPs/token, 8.7 A100 GPUs needed


The results reveal the scaling problem. As model size increases from 7B to 540B parameters, computational requirements grow proportionally. The 7B model processes 1000 tokens per second with approximately 1 A100 GPU, while the 540B model requires nearly 9 GPUs for the same throughput. This linear scaling between parameters and compute creates a basic efficiency barrier. Even with optimized hardware running at 40% utilization, the infrastructure costs become prohibitive at large scales. This growth in hardware requirements motivates the search for sparse architectures that can decouple model capacity from computational cost.