↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
Loading the recording…

Splitting a layer across GPUs

A model too large or too busy for one GPU is split across several ranks. The usual split for attention is tensor parallelism (TP): each rank computes some of the heads for every request and keeps the key-value cache of its own heads, so the cache is divided among the ranks. That stops working for multi-head latent attention (MLA), where every head reads the same compressed cache: each rank needs all of it. DP attention splits attention the other way, by request: each rank runs every head, but only for its own requests, and keeps only their cache. The mixture-of-experts (MoE) layer that follows stays shared by all ranks, with collectives around it.

The page serves DeepSeek-V2-Lite's second layer (its first MoE layer) on eight real prompts, 106 tokens in all, with four ranks both ways. The ranks are simulated one after another in one process, nothing is timed, and memory and communication are counted from the tensors in bfloat16.

One latent per token

MLA caches, for each token and layer, a 512-dimensional latent and one 64-dimensional rotary key shared by all 16 heads. Each head rebuilds its own keys and values from the latent with up-projections:

with 128 content dimensions plus the 64 rotary ones per key, and 128 per value. The cache is bytes bytes a token, about 1.1 KiB, however many heads read it. The head card (Request 1, head 1 until another is picked) follows one head's query, keys and values; the MLA tab explains the latent in full.

Tensor parallel: heads split

With TP = 4, rank computes heads for every request. Its heads read the whole latent, so it computes and stores the latent of all 106 tokens: 119 KiB on every rank, four identical copies. Each rank holds the slice of the output projection for its heads, which gives a partial sum of the attention output, and an all-reduce adds the four:

The MoE then runs expert-parallel on every token on every rank: each rank holds 16 of the 64 routed experts and a quarter of the columns of the two shared experts, and a second all-reduce adds the ranks' parts.

DP attention: requests split

With DP attention, request goes to rank , which runs all 16 heads for it and keeps its latent. The ranks hold 15, 41, 31 and 19 tokens, and the largest cache is 46 KiB, 2.6× smaller than TP's. The 4 ranks panel draws each rank's cache, token by token. The price is weights: every rank needs the full attention weights, 26 MiB for this layer against 8.3 MiB per rank under TP, while the MoE's share, 273 MiB per rank, is the same either way.

The MoE still needs every token on every rank. An all-gather before it gives each rank all tokens; each rank's experts compute partial outputs for all of them; a reduce-scatter adds the partial outputs and hands each rank back only its own tokens. Collectives need equal shares, so the ranks are padded to the largest, 41 tokens, with 58 padding tokens in all. The Around the MoE panel shows this flow and how many of the 636 routings (106 tokens, 6 experts each) landed on each expert.

Communication and the same answer

With ring collectives over ranks, an all-reduce of a payload of bytes sends bytes from each rank, and an all-gather or a reduce-scatter . Here TP sends two all-reduces of 636 KiB per rank per layer, 1.2 MiB, and DP attention an all-gather and a reduce-scatter of 492 KiB each, 984 KiB, padding included. The Per rank bars compare cache, weights and traffic for the two plans.

Both plans compute the same layer. The Same output either way strip adds TP's four partial attention outputs and sets them beside the DP rank's single output: they agree to , float rounding, and the DP output equals the unsplit computation exactly. This batch is tiny; a server's cache holds thousands of requests, and there DP attention's smaller cache per rank leaves room for larger batches, at the cost of a full copy of the attention weights on every rank.

Where it came from

Megatron-LM (Shoeybi et al., 2019) split attention heads and MLP columns across GPUs with one all-reduce after each, and GShard (Lepikhin et al., 2020) spread a mixture of experts across devices. DeepSeek-V2 (2024) introduced MLA; its paper reports a KV cache 93.3 % smaller than DeepSeek 67B's. SGLang added data-parallel attention for DeepSeek models in its v0.4 release (December 2024), reporting up to 1.9× decoding throughput. DeepSeek-V3's own deployment decodes with four-way tensor parallelism inside 80-way data parallelism for attention and expert parallelism over 320 GPUs for the MoE, with all-to-all transfers that send each token only to the ranks holding its experts. The HiCache tab looks at the same server from the cache's side.

Papers

  1. SGLang v0.4: Zero-Overhead Batch Scheduler, Cache-Aware Load Balancer, Faster Structured Outputs The SGLang Team · 2024 The release that introduced data-parallel attention for DeepSeek's MLA models, with an all-gather before the MoE and a scatter after it; a blog post, not a paper.
  2. DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Model DeepSeek-AI · arXiv 2024 Multi-head latent attention and the DeepSeekMoE layer, and the V2 family whose Lite model is served here.
  3. Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism Mohammad Shoeybi, Mostofa Patwary, Raul Puri, Patrick LeGresley, Jared Casper, Bryan Catanzaro · arXiv 2019 Tensor parallelism for transformers: heads split across GPUs and partial outputs added by an all-reduce, the TP plan on this page.
  4. GShard: Scaling Giant Models with Conditional Computation and Automatic Sharding Dmitry Lepikhin et al. · arXiv 2020 Experts spread across devices with tokens sent to them and back, the expert parallelism both plans use for the MoE.
  5. DeepSeek-V3 Technical Report DeepSeek-AI · arXiv 2024 A production deployment of MLA with data-parallel attention (TP4 with DP80 for decoding) and expert parallelism over 320 GPUs.
  6. Bandwidth optimal all-reduce algorithms for clusters of workstations Pitch Patarasuk, Xin Yuan · Journal of Parallel and Distributed Computing 2009 The ring all-reduce and its bandwidth-optimal cost, which the page uses to count the bytes each rank sends.
  7. SGLang: Efficient Execution of Structured Language Model Programs Lianmin Zheng et al. · NeurIPS 2024 The serving system in which DP attention and HiCache were built.

See also