Files
llm-atlas/research/K3_ATTNRES_SPIKE_SCOPING.md

121 lines
4.9 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.
# K3 Attention Residuals 局部梯度尖峰:Round 06 前置定位
研究日期:2026-07-30
阶段身份:**探索性 scoping,不是 Round 06 预注册结果**
上游协议:`llm-atlas-k3-attnres-gradient-scale-v1`
## 1. 为什么先做 scoping
Round 05 已经公开了一个方向分裂:
- Block AttnRes 在 depth 16 / 32、三个 seed 的 6 / 6 配对中都改善首/末四分位失衡;
- 但它也在 6 / 6 配对中提高全层 activation-gradient CV;
- depth 32 的三 seed 平均峰值集中在 layer 21–25。
这意味着下一步不该再问一个笼统的“梯度是否均匀”,而应该问:
1. 尖峰在 attention / MLP block 的哪个位置已经出现?
2. 它是否与 learned mixer 的 source 权重有关?
3. 相关来自 mixer softmax / key 的导数路径,还是来自 learned value coefficients?
4. 换一种公开、合理的 gradient reduction 后,尖峰是否还存在?
Round 05 已保存每个诊断点的逐层 post-MLP gradient RMS 和 64 个子层 mixer
分布。这里先用那些**已经见过的数据**定位假设,再冻结新协议。Round 06 的因果式
backward-path intervention 不能被描述成盲验证。
## 2. 对齐规则
depth 32 的 Block AttnRes 使用 8 个 aggregation groups,每组 4 个 Transformer
blocks、8 个 attention / MLP residual sublayers。
对 1-based Transformer layer `l`:
```text
attention mixer index = 2 × (l - 1)
MLP mixer index = 2 × (l - 1) + 1
group = floor((l - 1) / 4) + 1
offset in group = ((l - 1) mod 4) + 1
```
`latest source mass` 定义为对应 mixer `mean_weights` 的最后一个元素。它在不同
group offset 的语义并不完全相同:
- group 首层 attention mixer 没有 current partial,最后源是最近完成的 group;
- 其他 attention mixer 的最后源是 current partial;
- 每层 MLP mixer 的最后源都是刚加入 attention branch 后的 current partial。
因此不能把所有 `last` 自动命名为同一种“最近层贡献”。
## 3. layer 19–28 的三 seed 均值
下表的 gradient 是每个 seed 先按该 seed 的 32 层均值归一化,再跨 seed 平均。
权重和 normalized entropy 也跨三个 seed 平均。
| layer | group / offset | gradient / layer mean | attn last | MLP last | attn H/logN | MLP H/logN |
|---:|---:|---:|---:|---:|---:|---:|
| 19 | 5 / 3 | 1.063 | 0.349 | 0.452 | 0.929 | 0.842 |
| 20 | 5 / 4 | 1.014 | 0.316 | 0.419 | 0.946 | 0.863 |
| 21 | 6 / 1 | **3.042** | 0.250 | **0.513** | 0.969 | 0.763 |
| 22 | 6 / 2 | **2.405** | 0.436 | **0.563** | 0.851 | 0.721 |
| 23 | 6 / 3 | **1.910** | 0.400 | **0.551** | 0.879 | 0.737 |
| 24 | 6 / 4 | **1.548** | 0.384 | **0.515** | 0.889 | 0.771 |
| 25 | 7 / 1 | **1.769** | 0.317 | 0.358 | 0.934 | 0.766 |
| 26 | 7 / 2 | 1.369 | 0.343 | 0.420 | 0.876 | 0.764 |
| 27 | 7 / 3 | 0.986 | 0.325 | 0.402 | 0.891 | 0.775 |
| 28 | 7 / 4 | 0.802 | 0.296 | 0.304 | 0.902 | 0.822 |
layer 21–24 正好是第 6 个 group,layer 25 是第 7 个 group 的首层。梯度峰并不
只是一个 group boundary 单点;它在第 6 组内部递减,并在下一组首层出现较小的第二峰。
## 4. 相关线索
把三个 seed 的 32 层合成 96 个点,post-MLP normalized gradient 与 mixer 摘要的
Pearson 相关为:
| 变量 | 96 点 `r` | layer 19–28 的 30 点 `r` |
|---|---:|---:|
| attention latest-source mass | 0.066 | 0.158 |
| MLP latest-source mass | **0.651** | **0.690** |
| attention normalized entropy | −0.296 | −0.057 |
| MLP normalized entropy | −0.274 | **−0.636** |
| attention max source mass | −0.024 | 0.158 |
| MLP max source mass | 0.230 | **0.702** |
这些数值只支持:
> 尖峰层与更集中的 MLP mixer、尤其较大的 latest-partial mean weight 同时出现。
它们不支持:
- “MLP latest weight 导致梯度尖峰”;
- “第 6 group 是唯一原因”;
- “降低 entropy 就一定增加梯度”;
- “K3 真实 checkpoint 也有相同模式”。
同一个 learned mixer 同时改变 forward activation、value-path gradient coefficient
和 softmax/key derivative path。单看 observational correlation 无法分解这三者。
## 5. Round 06 要冻结的可证伪问题
Round 06 将复跑与 Round 05 完全相同的 depth-32 / Block 三 seed 训练,并要求最终
model / optimizer hash 与 Round 05 exact。新增诊断只在 optimizer step 之外执行。
它将同时测量:
- pre-attention input;
- attention branch output;
- post-attention partial state;
- pre-MLP input;
- MLP branch output;
- post-MLP partial state;
- 同一 raw gradient tensor 的多种 reduction;
- learned backward;
- learned weights detached backward;
- learned forward + uniform value backward。
其中后两项保持**前向 logits、loss 与 activation 完全相同**,只改变反向路径。这样才能
区分“相关”与“哪条 backward path 对尖峰有实质贡献”。
完整阈值、失败规则和复现合同见
`research/K3_ATTNRES_SPIKE_PROTOCOL.md`。