Files
myWiki/concepts/hybrid-attention-architecture.md

56 lines
1.7 KiB
Markdown
Raw Permalink 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: "Hybrid Attention Architecture"
domain: "Deep Learning / Attention Mechanisms"
tags: [attention, long-context, transformer, architecture]
sources: [[deepseek-v4-million-token-context]]
---
# Hybrid Attention Architecture
> **类型**: Concept (Tier 2 — Foundation)
> **来源**: [[deepseek-v4-million-token-context]]
## 定义
混合注意力架构是 DeepSeek-V4 系列为解决超长上下文效率问题而设计的核心创新,它通过在 Transformer 层中交替或组合使用不同压缩策略的注意力机制,在计算效率和上下文覆盖之间取得最优平衡。
## 组成
### [[compressed-sparse-attention]] (CSA)
- KV cache 沿序列维度压缩后进行稀疏注意力
- 保留局部信息(滑动窗口)+ 选择性全局信息(稀疏选择)
### [[heavily-compressed-attention]] (HCA)
- 更高强度的 KV 压缩,但保持密集注意力
- 最大化全局上下文效率,牺牲部分局部细节
## 设计原则
1. **分层部署**:不同层采用不同注意力类型
2. **效率递进**CSA 层保持中等压缩比HCA 层激进压缩
3. **互补覆盖**局部CSA滑动窗口+ 全局HCA密集= 完整上下文
## 效率数据
| 配置 | 1M 上下文 KV Cache (相对基线) |
|------|------------------------------|
| BF16 GQA8 基线 | 100% |
| DeepSeek-V3.2 | ~基线的 10% |
| DeepSeek-V4-Pro | ~基线的 2% |
## 工程实现要点
- FP4/BF16/FP8 混合精度RoPE 维度 BF16其他 FP8/FP4
- 闪电索引器Lightning Indexer用于 CSA 的 KV 选择
- Multi-Query Attention 共享 K/V
## 相关概念
- [[compressed-sparse-attention]] — CSA
- [[heavily-compressed-attention]] — HCA
- [[million-token-context]] — 百万 Token 上下文
---
*Last Updated: 2026-04-27*