Files
myWiki/concepts/stem-sparse-attention.md

50 lines
2.0 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: "Stem Sparse Attention"
created: 2026-06-05
updated: 2026-06-05
type: concept
tags: [sparse-attention, causal, training-free, pre-filling]
sources: [[niu-stem-causal-sparse-attention]]
---
# Stem Sparse Attention
**Stem** 是 Niu et al. (2026) 提出的 training-free 稀疏注意力框架,从 [[causal-information-flow|因果信息流]] 的角度重新思考稀疏化策略。名称 Stem隐喻早期 token 作为信息流的结构性"主干"。
## 核心思想
> In causal attention, V₁ participates in every output; V_N only in the last. Uniform sparsity ignores this fundamental asymmetry.
Stem 将因果注意力中的 token 分为两类:
- **茎 TokenStem Tokens**:初始位置的 token参与所有后续 token 的聚合 → 需要更多预算保护
- **叶 TokenLeaf Tokens**:尾部位置的 token仅影响局部 → 可以激进稀疏化
## 双组件架构
```
Stem
├── TPD (Token Position-Decay)
│ └── 位置依赖的 top-k前面多后面少
└── OAM (Output-Aware Metric)
└── 基于输出幅度选 token不止看注意力分数
```
## 与现有方法的根本差异
| 维度 | 传统稀疏方法 | Stem |
|------|------------|------|
| 预算分配 | 统一 top-k所有位置相同 | 位置衰减(前多后少) |
| 选择标准 | 仅注意力分数 | 注意力分数 + Value 信息OAM |
| 信息流意识 | 无(逐层独立决策) | 有(保护递归依赖链) |
| 训练需求 | 部分需要微调 | Training-free即插即用 |
## 性能
在 H20 GPU 上Stem 在 128K 上下文中将 attention kernel 时间从 dense 的 401ms 压缩到 90ms约 4.5× 加速),同时保持 lossless 精度。还可以作为插件叠加到 [[native-sparse-attention|NSA]] 等训练型稀疏模型上进一步压缩。
## 技术栈
- 底层实现:[[block-sparse-attention|Block Sparse Attention]] 内核Triton
- 目标阶段pre-filling首次 token 生成前的批量编码)
- 适用模型Llama 系列、Qwen 系列、DeepSeek-V3.2、MiniCPM-4.1