Create and explore imaginative 3D worlds with our new product Dreamfield (opens in a new tab)
Papers
Topics
Authors
Recent
Search
2000 character limit reached

A Training-Memory Regression in MLA Sequence Parallelism: Why Megatron-Core Forbids Absorption, and LAGA -- a Communication-Efficient Fix

Published 20 Jul 2026 in cs.DC | (2607.17644v1)

Abstract: Multi-head Latent Attention (MLA) ships two implementations in Megatron-Core: an explicit form used for training and an absorbed form -- which slashes collective communication by gathering only the compressed latent -- that is fully implemented but hard-asserted out of training (the forward opens with "assert not (self.training and self.cache_mla_latents)"), allowed only in inference decode. The library documents no reason. We show the restriction is well-founded and quantify why: ported to training, the absorbed form is a memory trap -- its intermediates live in n_h x d_kv dimensions per token, larger than the per-head K/V they replace -- inflating activation memory by 20-34%, up to 9.2 GB at DeepSeek-V3 scale (n_h=128, seq=16384, SP=8, eager kernel; the gap widens to 19.2 GB under a fused kernel), enough to change device-fit. This measurement, validated on two axes (linear in seq and n_h) and cross-verified on NVIDIA A100, explains the otherwise-undocumented restriction and leaves practitioners with no low-communication MLA training path. We then provide one. LAGA (Latent All-Gather Attention) keeps the absorbed form's latent-gather communication but rejects the absorb reformulation, instead reconstructing per-head K/V locally from the gathered latent. On 8x Ascend 910B at real DeepSeek-V3 dimensions, LAGA cuts collective communication 1.98x, matches explicit memory within 0.5%, is bit-identical to explicit at SP=1 and equivalent to within 1e-3 at SP=2-8, and under a fused attention kernel improves attention-block throughput 1.04-1.06x single-node and 1.07-1.24x cross-node -- leading at all sequence lengths in the cross-node regime MLA is deployed for.

Authors (1)

Summary

  • The paper demonstrates that absorbed MLA increases peak training activation memory by 20–34%—up to 9.2 GB with eager execution and 19.2 GB with fused attention—because intermediates scale with the number of heads.
  • The paper introduces LAGA, which all-gathers compressed latent states instead of per-head K/V tensors, matching explicit MLA memory use within 0.5% while reducing communication by 1.98×.
  • The paper finds that LAGA delivers up to 1.24× throughput across two nodes at long sequence lengths, while preserving numerical correctness and compatibility with expert parallelism.

The puzzle: an undocumented assertion in production code

Megatron-Core's MLASelfAttention class contains a fully implemented "absorbed" form of Multi-head Latent Attention (MLA) — the reformulation that folds the KV up-projection Wkv_bW_{kv\_b} into the query so that attention runs against the compressed latent and only the small latent crosses the collective — yet its forward pass opens with a hard assertion that bans this path from training, permitting it only in inference decode. The library documents no rationale. This paper answers that question quantitatively: porting the absorbed form to training produces a substantial activation-memory regression, and the assertion is, in effect, an undocumented guard against it. The paper then proposes LAGA (Latent All-Gather Attention), a training-time sequence-parallel scheme that retains the absorbed form's low communication without its memory penalty.

Background: why MLA breaks head-dimension sequence parallelism

MLA compresses per-head K/V into a single shared low-rank latent of dimension dkv=512d_{kv}=512 (plus a decoupled RoPE band kpek_{pe}), which is roughly 32× smaller than equivalent per-head KV at DeepSeek-V3 dimensions. Ulysses-style sequence parallelism (SP) — including Megatron-SP, Ring Attention, USP, and LoongTrain — repartitions seq↔head via all-to-all so each rank attends full-sequence for a subset of heads. This assumes each rank owns a per-head KV shard to scatter, which holds for MHA/GQA but fails under MLA: in the absorbed formulation there is no per-head KV, and the effective Ulysses degree collapses to one. Consequently, the only head-dimension SP path for MLA is the explicit form — materialize per-head K/V first, then all-to-all them along heads — which moves nh(dnope+dv)n_h(d_{nope}+d_v) elements per token and is expensive when nhn_h is large (128 heads for DeepSeek-V3). Production stacks therefore train MLA long-context under this communication-heavy pattern.

The absorbed memory trap

The paper's central empirical finding is that the absorbed form, though an inference KV-cache optimization (a ≈32× cache win from storing the latent rather than per-head KV), becomes a memory trap in training. In training there is no cache; every forward recomputes, and the absorbed intermediates — the absorbed query qabsorbed=Wkv_b⊤qnopeq_{\text{absorbed}} = W_{kv\_b}^{\top} q_{\text{nope}} and the post-attention latent accumulator — live in nh⋅dkv=128×512n_h \cdot d_{kv} = 128 \times 512 dimensions per token, larger than the per-head K/V they replace whenever dkv>dheadd_{kv} > d_{head}.

Measured at DeepSeek-V3 scale (nh=128n_h{=}128, dmodel=7168d_{model}{=}7168, seq=16384, SP=8, eager kernel), the absorbed form inflates peak activation memory by 20–34%, reaching +9.2 GB over the explicit form — enough to change device-fit; under a fused attention kernel the gap widens to +19.2 GB, because removing the shared dkv=512d_{kv}=5120 score matrix eliminates a confound that had masked part of the inflation under eager execution. Two properties strengthen the claim:

  • Linearity on two independent axes: the inflation grows linearly with both sequence length and dkv=512d_{kv}=5121 (337/657/1269/2512 MB as dkv=512d_{kv}=5122 doubles 16→128), confirming the dkv=512d_{kv}=5123-intermediate mechanism.
  • Cross-hardware reproduction: on NVIDIA A100 the inflation matches Ascend 910B within ≤6% allocator noise (+575/+2221/+8734 MB vs +575/+2362/+9247 MB across S = 4K/8K/16K).

The implication is direct: the absorbed path is disqualified for training regardless of kernel choice, which explains Megatron-Core's otherwise-undocumented restriction and leaves practitioners with no low-communication MLA training path — the gap LAGA fills.

LAGA: latent all-gather with local up-projection

LAGA keeps the explicit attention math but changes only what crosses the wire. Its forward pass, for SP degree dkv=512d_{kv}=5124: compute Q and the latent locally; all-to-all Q along heads (cheap); all-gather the latent and dkv=512d_{kv}=5125 along the sequence axis (dkv=512d_{kv}=5126 elements/token instead of B1's dkv=512d_{kv}=5127); then reconstruct per-head K/V locally for each rank's head shard via dkv=512d_{kv}=5128, landing K/V in the head dimension at exactly B1's post-all-to-all footprint. Backward requires one additional head-axis gradient all-reduce for the sharded dkv=512d_{kv}=5129.

Correctness follows structurally: step 4 computes the same linear maps on the same tensor as explicit, differing only in view order. At SP=1 the outputs are bit-identical (kpek_{pe}0, with kpek_{pe}1 gradients exactly zero); at SP=2–8 outputs agree to kpek_{pe}2 and gradients to kpek_{pe}3 after SP-consistent aggregation. A 60-step convergence run shows all three forms descending from loss 7.711 to ≈0.004, with transient trajectory differences attributable to generic floating-point optimizer chaos. LAGA also composes cleanly with expert parallelism, since its collectives operate on head/seq axes inside the attention block while EP dispatch operates on the token/expert axis in the MoE block.

Evaluation results

All experiments use real DeepSeek-V3 dimensions on 8×Ascend 910B (single node) and 16 ranks across two nodes over RoCE (~11 GB/s), cross-validated on A100.

Communication is structural and implementation-independent: LAGA and the absorbed baseline move identical data, cutting per-forward communication to 50.5% of explicit — a stable 1.98× reduction across SP=4–16 and S=4K–16K, strengthening from 1.88× to 1.98× as kpek_{pe}4 grows 16→128, since only explicit's K-side term scales with kpek_{pe}5.

Memory: LAGA matches explicit within ≤0.5% (<27 MB) at every configuration, while absorbed balloons by up to 9.2 GB eager / 19.2 GB fused. Notably, absorbed OOMs at S=16384 under eager on both hardware platforms while explicit/LAGA run.

Throughput exhibits a crossover governed by communication-boundedness. At small kpek_{pe}6 single-node, LAGA reaches parity (1.01×) at S=16384 but is ~21% slower in the compute-bound short-sequence regime — a kernel-efficiency effect (smaller per-shard GEMMs), not a FLOPs difference, since total FLOPs are identical. At production scale (kpek_{pe}7, SP=8, fused kernel), the crossover flips in LAGA's favor: 1.04–1.06× at all sequence lengths. Cross-node (SP=16, fused), LAGA leads at all lengths — 1.07×/1.15×/1.24× at S=4096/8192/16384 — precisely the long-context regime MLA is deployed for. An apparent eager-kernel regression (0.73× at S=4096 cross-node) is shown to be an artifact of the materialized score matrix and small-shard launch overhead; it vanishes entirely under the fused npu_fusion_attention kernel, which natively supports MLA's asymmetric head dimensions.

Limitations and open questions

The paper is candid about scope. Communication and memory are measured on a single attention layer and throughput on a 4-layer stack, not an end-to-end 61-layer DeepSeek-V3 run; end-to-end wall-clock and MFU at full depth remain unmeasured. The convergence check uses a toy 4-layer model on random-data memorization, with bit-identical SP=1 equivalence serving as the primary correctness guarantee. Throughput is measured against the authors' own explicit-form prototype reproducing Megatron-Core's math, not against Megatron-Core itself (the CUDA/NPU stack mismatch precludes a head-to-head). The fused kernel covers score computation but not LAGA's local up-projection einsums; a fused up-proj→attention kernel is left as future work, as are ring-style SP for kpek_{pe}8 and overlapping the latent all-gather with preceding compute. The multi-node result spans only two nodes. Separately, the paper reports a hardware-contingent reproducibility caveat: MoE top-kpek_{pe}9 routing amplifies matmul nondeterminism into cliff-shaped run-to-run divergence on NPU (≈16× the dense control's divergence), absent on CUDA at prototype scale — reported as a caveat, not a characterized result.

Conclusion

This paper resolves an undocumented design decision in Megatron-Core with measurement: the absorbed MLA form is an inference-cache optimization whose nh(dnope+dv)n_h(d_{nope}+d_v)0-dimensional intermediates make it a 20–34% activation-memory trap in training, linear in both sequence length and head count and reproducible across Ascend 910B and A100. It then supplies the missing low-communication training path: LAGA preserves the explicit form's memory profile and exact numerical semantics while replacing the per-head K/V all-to-all with a latent all-gather, yielding a 1.98× communication reduction and throughput wins of up to 1.24× cross-node under fused attention at long context. The broader lesson the authors draw is methodological: optimizations designed around the inference KV-cache do not transfer to training, where activation footprint, not communication alone, determines viability.

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Tweets

Sign up for free to view the 1 tweet with 0 likes about this paper.