Files
myWiki/concepts/multi-head-latent-attention.md

42 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: Multi-head Latent Attention (MLA)
created: 2025-04-15
updated: 2026-05-01
type: concept
tags: []
sources: []
---
# Multi-head Latent Attention (MLA)
**多潜在头注意力**DeepSeek 团队在 DeepSeek-V2 (2024) 中提出的革命性注意力机制。
## 核心思想
MLA 通过**低秩联合压缩**将 KV 映射到远小于原始维度的潜在空间,推理时只需缓存压缩后的潜在向量,解码时再解压重建 KV。这与 MQA/GQA 的"共享头"策略不同——MLA 是**信息论意义上的压缩**,而非简单的共享。
## 关键机制
1. **低秩压缩**: KV 先映射到 d_latent << d 的潜在空间
2. **潜在缓存**: 推理时只缓存压缩后的潜在向量而非完整 KV
3. **按需重建**: 解码时从潜在向量高效重建完整 KV
## 里程碑意义
- **缓存缩减**: KV 缓存可减少至 MHA 1/10 ~ 1/20
- **质量保持**: 压缩不显著影响模型性能
- **工业落地**: DeepSeek-V2/V3 的核心推理效率引擎
## 与 HCA 关系
MLA 可视为 [[heavily-compressed-attention|HCA]] 的泛化形式——HCA DeepSeek-V4 MLA 的增强版融合了流形约束
## 相关概念
- [[multi-head-attention]] MHA 基线
- [[grouped-query-attention]] GQA 分组方案
- [[kv-cache-bottleneck]] 缓存瓶颈问题
- [[heavily-compressed-attention]] DeepSeek-V4 HCA
- [[deepseek-v4-million-token-context]] 百万 Token 上下文应用
- [[llm-attention-survey-2026]] 综述参考