DL0174 Wide vs Deep LLM Architectures

Under a fixed parameter budget, what are the trade-offs between wider (more hidden dimensions, fewer layers) and deeper (more layers, narrower) Transformer architectures for LLMs, in terms of expressivity, training stability, and inference latency?

Answer

A decoder layer costs about 4d^{2} parameters in the attention projections and about 8d^{2} in the MLP, so a fixed budget pins the product L d^{2} and the only remaining freedom is the aspect ratio \rho = d/L. Cutting depth by 4x buys only 2x width, which is why the two axes are so asymmetric in practice. Depth buys serial computation: each layer is one more composition step, and multi-hop reasoning and compositional generalization improve with layers in a way that width cannot replicate. Width buys parallel capacity and hardware efficiency: larger GEMMs, higher arithmetic intensity, clean tensor-parallel sharding, and a smaller KV cache per token because the cache grows linearly in L. Empirically the pretraining loss is remarkably insensitive to shape across the middle of the range, so the decision is usually settled by systems constraints rather than by quality. Depth is the axis that costs you latency and training stability, and width is the axis that costs you head redundancy, embedding budget, and eventual depth starvation.

(1) The Budget Is Quadratic In Width: the iso-parameter constraint is L d^{2} = \mathrm{const}, so width is an expensive axis and depth is a cheap one. Doubling d forces you to delete three quarters of the layers.
(2) Depth Is Serial Expressivity: a layer is one composition step, and tasks requiring k chained inferences need enough layers to host them. Depth-efficiency saturates, though, with the useful depth for a given width growing only logarithmically in d.
(3) Width Is Capacity And Throughput: knowledge storage tracks total parameters rather than shape, but wide layers give larger matrix multiplies, better MFU, and more heads per layer for parallel feature lookup.
(4) Depth Destabilizes Training: residual variance accumulates over L branches, so deep stacks need 1/\sqrt{2L} output-projection init, Pre-LN or DeepNet-style residual scaling, and they show more loss spikes and attention rank collapse.
(5) Depth Is A Latency Multiplier: autoregressive decode pays a fixed per-layer serial cost (kernel launches plus two tensor-parallel all-reduces), so L\tau adds directly to time per token even though total FLOPs are unchanged.
(6) Small Budgets Flip The Answer: the embedding matrix costs Vd, which at a 128k vocabulary swamps a sub-billion model, so on-device work favors deep and thin shapes.

Log-log plot of model width d against number of layers L along the constant-parameter curve L times d squared equals 6.04e8, with three marked shapes: wide and shallow at 16 layers and width 6144 with aspect ratio 384, balanced at 36 layers and width 4096 with aspect ratio 114, and deep and thin at 64 layers and width 3072 with aspect ratio 48, plus region labels above the curve for exceeding the budget and below for budget unspent

Figure 1: Every shape on the curve costs the same parameters. The curve is a straight line in log-log space with slope -1/2, which is the whole trade-off in one picture: width is quadratically expensive, so moving from 64 layers to 16 layers pays for only a 2x wider residual stream. Real production shapes cluster in the middle band, roughly \rho between 60 and 160.

The stability side is where depth stops being free. In a Pre-LN residual stack the output is a sum of L branch contributions, so without correction the variance entering the final norm grows roughly linearly in depth, gradients through the early layers get squeezed, and the effective learning rate per layer drifts as you add layers. The standard fixes are scaling the residual output projections by 1/\sqrt{2L} at init, DeepNet-style residual weighting for very deep stacks, and QK-norm to stop attention logits from drifting. Deep stacks also suffer token-uniformity (rank) collapse, where repeated pure attention drives representations toward a rank-one subspace and the MLPs plus residual path are what hold it off. Width has the opposite profile. Hyperparameter transfer across width is well understood through muP, so you can tune a small proxy model and reuse the learning rate, whereas transfer across depth needed its own theory. The failure mode of extreme width is not divergence but waste: many heads become redundant, the per-layer computation is over-provisioned relative to the number of serial steps available, and the model has no place to put a long chain of dependent inferences.

Mathematical Formulation:
N \approx 12 L d^{2}
\rho = d / L
C_{\mathrm{kv}} = 2 L n_{\mathrm{kv}} d_{h} b
t_{\mathrm{dec}} \approx W / B + L \tau

Where:

  • N is the non-embedding parameter count, from 4d^{2} of attention projections plus 8d^{2} of MLP weights per layer (a SwiGLU MLP with hidden width 8d/3 matches the same count).
  • L is depth and d the residual width; a fixed budget holds L d^{2} constant, so 4x fewer layers buys 2x width.
  • \rho is the aspect ratio, the single knob this question is really about. GPT-3 175B sits at 12288/96 = 128.
  • C_{\mathrm{kv}} is KV-cache bytes per token, with n_{\mathrm{kv}} key-value heads, head dimension d_{h}, and b bytes per element. Under GQA with a fixed head count it is proportional to L alone.
  • t_{\mathrm{dec}} is per-token decode latency, W the weight bytes read per step, B the achievable HBM bandwidth, and \tau the fixed serial cost per layer from kernel launches and collective synchronization.
  • Because W is set by the budget and not by the shape, the W/B term is identical across shapes and only the L\tau term differs.

Iso-Parameter Shapes At About 7.2B Non-Embedding Parameters:
64 \times 3072^{2} \approx 6.04 \times 10^{8}
36 \times 4096^{2} \approx 6.04 \times 10^{8}
16 \times 6144^{2} \approx 6.04 \times 10^{8}
N \approx 12 \times 6.04 \times 10^{8} \approx 7.2 \times 10^{9}

These three shapes are interchangeable on the training-cost sheet and nearly interchangeable on validation loss, yet they behave very differently in a serving stack. With GQA at 8 key-value heads and d_{h} = 128 in fp16, each layer stores 4 KiB per token, so the 64-layer shape carries 4x the KV cache of the 16-layer shape and supports a proportionally smaller batch at the same context length. On the latency side, a plausible tensor-parallel-8 deployment has roughly \tau \approx 40 microseconds per layer once you count two all-reduces plus launch overhead, which turns depth into 2.56 ms of pure serial cost at 64 layers against 0.64 ms at 16 layers, on top of an identical weight-read term.

Two panel chart: left panel shows stacked bars of per-token decode latency for the three iso-parameter shapes, each with an identical 0.90 millisecond weight-read term plus a serial per-layer term of 2.56, 1.44 and 0.64 milliseconds, giving totals of 3.46, 2.34 and 1.54 milliseconds and single-stream rates of 289, 427 and 649 tokens per second; right panel shows KV cache per 8192-token sequence of 2.0, 1.125 and 0.5 gibibytes for 64, 36 and 16 layers

Figure 2: Same parameters, same FLOPs, 2.2x difference in single-stream decode latency. The green weight-read term is fixed by the budget, so all of the spread comes from the L\tau serial term. The right panel shows the second penalty of depth: KV cache is linear in L, so the deep shape gives up 4x in memory per sequence and therefore in achievable batch size.

PropertyDeep and thin (L=64, d=3072)Balanced (L=36, d=4096)Wide and shallow (L=16, d=6144)
Aspect ratio48114384
Serial steps per token64 composition steps, best compositional depth36, enough for most multi-hop patterns16, depth-starved on chained inference
GEMM shapeMany small matmuls, lower MFU in decodeGood balance on current acceleratorsFew large matmuls, highest arithmetic intensity
KV cache per 8k sequence2.00 GiB1.125 GiB0.50 GiB
Decode latency (TP=8 estimate)3.46 ms per token, 289 tok/s2.34 ms per token, 427 tok/s1.54 ms per token, 649 tok/s
Parallelism fitPipeline stages are easy, but bubbles hurt small batchesBoth TP and PP viableTensor-parallel friendly, hard to pipeline
Stability riskResidual variance growth, loss spikes, rank collapseStandard recipe sufficesBenign, muP transfers cleanly across width
Tied embedding cost (V=128k)0.39B parameters0.52B parameters0.79B parameters

Login to view more content


Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *