Files
myWiki/concepts/mixture-of-depths-attention.md

60 lines
2.2 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: "Mixture-of-Depths Attention (MoDA)"
created: 2026-04-19
updated: 2026-04-19
type: concept
tags: [architecture, deep-learning, transformer]
sources: [raw/papers/zhu-moda-mixture-of-depths-2026.md]
---
# Mixture-of-Depths Attention (MoDA)
**提出者:** Zhu et al. (2026) · arXiv:2603.15619
## 定义
MoDA 是一种改进的注意力机制,旨在解决深层 Transformer 模型中的**信号退化**问题。它允许每个注意力头在计算注意力时,不仅关注当前层的序列 KV还能直接访问前序若干层的深度 KV形成跨层的信息通路。
## 动机:信号退化 (Signal Degradation)
在标准 Transformer 中,信息通过残差连接逐层传递。随着网络深度增加:
- 浅层提取的精细特征在多次残差更新中被逐渐"稀释"
- 深层网络难以有效利用浅层形成的关键信息
- 简单的残差连接不足以保留所有重要特征
## 机制设计
### 核心思想
每个注意力头的查询 $Q$ 不仅与当前层的 $K, V$ 计算注意力,还与前序 $D$ 层的 $K, V$ 计算注意力:
$$\text{MoDA}(Q_l) = \text{Softmax}\left(\frac{Q_l [K_{l-D:l}]^T}{\sqrt{d}}\right) V_{l-D:l}$$
### 硬件高效实现
- **挑战**:跨层 KV 访问导致非连续内存访问,降低 GPU 利用率
- **解决方案**:设计专门的内存访问算法,重组 KV 缓存布局
- **性能**:在 64K 序列长度下达到 FlashAttention-2 的 97.3% 效率
## 实验表现
| 指标 | 基线 | MoDA | 提升 |
|------|------|------|------|
| 平均困惑度 (10 benchmarks) | - | -0.2 | ✓ |
| 下游任务性能 (10 tasks) | - | +2.11% | ✓ |
| FLOPs 开销 | 1.0x | 1.037x | +3.7% |
## 归一化位置
- **Post-Norm** + MoDA > **Pre-Norm** + MoDA
- 这与标准 Transformer 的常见实践Pre-Norm 更稳定)不同,表明 MoDA 改变了梯度流动特性
## 开放问题
- MoDA 与混合注意力架构的结合效果?
- 在超大规模模型(>100B上的扩展性如何
- 是否可以与 [[memory-caching-rnn]] 等技术结合?
## 相关概念
- [[zhu-moda-mixture-of-depths]] — 原始论文
- [[depth-scaling-signal-degradation]] — LLM 深度扩展
- [[depth-scaling-signal-degradation]] — 信号退化问题