Compare commits
7 Commits
592599fd59
...
4ce780dcc9
| Author | SHA1 | Date | |
|---|---|---|---|
| 4ce780dcc9 | |||
| d1d9d22bf3 | |||
| 5f49906be6 | |||
| 1f20f81939 | |||
| f99872039f | |||
| e3617532de | |||
| 9039de1b02 |
+13
-3
@@ -8,7 +8,7 @@
|
|||||||
|---|---:|---:|---|
|
|---|---:|---:|---|
|
||||||
| 研究框架与规范 | 进行中 | 83% | Scaling Laws 二轮拟合复现与逐图精读 |
|
| 研究框架与规范 | 进行中 | 83% | Scaling Laws 二轮拟合复现与逐图精读 |
|
||||||
| 网站设计系统 | 进行中 | 89% | 打印样式与更多通用可视化组件 |
|
| 网站设计系统 | 进行中 | 89% | 打印样式与更多通用可视化组件 |
|
||||||
| Kimi K3 深读 | 三轮实证进行中 | 94% | 接入真实 hidden-state / expert-load / cache traces,并重绘报告数值图 |
|
| Kimi K3 深读 | 四轮实证进行中 | 96% | 对齐论文梯度定义、扩展深度/预算,并等待 `A_log` 官方转换合同 |
|
||||||
| 语言模型前史 | 完成首版 | 78% | Kneser–Ney、LSTM、Bahdanau 逐图精读与真实小语料复现 |
|
| 语言模型前史 | 完成首版 | 78% | Kneser–Ney、LSTM、Bahdanau 逐图精读与真实小语料复现 |
|
||||||
| Transformer 基础 | 完成首版 | 79% | 多头电路、归一化 traces 与真实 kernel / KV 配置 |
|
| Transformer 基础 | 完成首版 | 79% | 多头电路、归一化 traces 与真实 kernel / KV 配置 |
|
||||||
| 表示、位置与残差高速公路 | 完成首版 | 81% | 真实 hidden-state / norm traces、长上下文位置外推与深层稳定性消融 |
|
| 表示、位置与残差高速公路 | 完成首版 | 81% | 真实 hidden-state / norm traces、长上下文位置外推与深层稳定性消融 |
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
- [x] 完成 486 篇关键论文索引,覆盖 16 个标签专题与 Kimi/DeepSeek 聚光主线。
|
- [x] 完成 486 篇关键论文索引,覆盖 16 个标签专题与 Kimi/DeepSeek 聚光主线。
|
||||||
- [x] 完成可检索、可按专题筛选的论文库页面。
|
- [x] 完成可检索、可按专题筛选的论文库页面。
|
||||||
- [x] 完成 K3、语言模型前史、Transformer 基础、表示/位置/残差、DeepSeek 谱系、Scaling Laws、数据工程、长上下文、MoE、指令微调与人类偏好、推理、Agent、原生多模态、训练系统、推理服务、数值优化与评测安全十七篇首版长文。
|
- [x] 完成 K3、语言模型前史、Transformer 基础、表示/位置/残差、DeepSeek 谱系、Scaling Laws、数据工程、长上下文、MoE、指令微调与人类偏好、推理、Agent、原生多模态、训练系统、推理服务、数值优化与评测安全十七篇首版长文。
|
||||||
- [x] 完成 K3 三轴架构、八联报告实验与四联开放工件实验、语言模型前史四联实验、Transformer 四联实验、表示深度四联实验、DeepSeek 二十二联实验、长上下文、MoE 路由、推理三页签,以及训练系统、推理服务、Scaling、数据工程、数值、Alignment、Agent、原生多模态与评测安全专题各四页签等八十九个原创交互视图。
|
- [x] 完成 K3 三轴架构、八联报告实验、四联开放工件实验与五联 AttnRes 独立实验、语言模型前史四联实验、Transformer 四联实验、表示深度四联实验、DeepSeek 二十二联实验、长上下文、MoE 路由、推理三页签,以及训练系统、推理服务、Scaling、数据工程、数值、Alignment、Agent、原生多模态与评测安全专题各四页签等九十四个原创交互视图。
|
||||||
- [x] 完成长上下文首版:五张成本账、26 篇一手论文、10+ 机制图与 8 策略交互实验室。
|
- [x] 完成长上下文首版:五张成本账、26 篇一手论文、10+ 机制图与 8 策略交互实验室。
|
||||||
- [x] 核验 FlashAttention、DeepSeek-V2/V3.2/V4、Kimi Linear/K3 等六份论文原文,并建立长上下文研究账本。
|
- [x] 核验 FlashAttention、DeepSeek-V2/V3.2/V4、Kimi Linear/K3 等六份论文原文,并建立长上下文研究账本。
|
||||||
- [x] 核验 Switch、ST-MoE、DeepSeekMoE、Loss-Free、V3、LatentMoE 与 K3 原文,并建立 MoE 研究账本。
|
- [x] 核验 Switch、ST-MoE、DeepSeekMoE、Loss-Free、V3、LatentMoE 与 K3 原文,并建立 MoE 研究账本。
|
||||||
@@ -272,10 +272,16 @@
|
|||||||
- [x] 第二十二个 DeepSeek 交互实验用五页签讲解显式 CRN sampler、选定任务 bootstrap、32 题浏览器、4×4 tape 诊断与十二字段复现/失败/偏差账;正式协议、manifest、runner、独立 evaluator、分析、复现与完整/compact 数据均已进入开源树。
|
- [x] 第二十二个 DeepSeek 交互实验用五页签讲解显式 CRN sampler、选定任务 bootstrap、32 题浏览器、4×4 tape 诊断与十二字段复现/失败/偏差账;正式协议、manifest、runner、独立 evaluator、分析、复现与完整/compact 数据均已进入开源树。
|
||||||
- [x] Round 08 本地闸门通过:88 个 Astro 文件零诊断,21 个页面、1,151 个站内引用、12 个跨页锚点零失败;数据合同、DeepSeek 全量历史、Round 06/07/08 三套 sampling 专项真实 Chrome 回归均通过,桌面与 390px 移动端无文档级溢出。
|
- [x] Round 08 本地闸门通过:88 个 Astro 文件零诊断,21 个页面、1,151 个站内引用、12 个跨页锚点零失败;数据合同、DeepSeek 全量历史、Round 06/07/08 三套 sampling 专项真实 Chrome 回归均通过,桌面与 390px 移动端无文档级溢出。
|
||||||
- [x] DeepSeek Round 08 以源提交 `975ed3d`、不可变镜像 `20260729T221654Z-975ed3d` 发布;OCI index digest `sha256:759a8446…21452b`,复用 NAS `12010→8080`、NPM host 31 / cert 41 与门户 `LLM ATLAS / projects / 180`。容器 healthy、0 次重启,21/21 公网路由、HTTPS/2、gzip / immutable assets、Round 08 专项与 DeepSeek 全量生产 Chrome 回归通过;保留 `20260729T195952Z-9211333` 回滚。
|
- [x] DeepSeek Round 08 以源提交 `975ed3d`、不可变镜像 `20260729T221654Z-975ed3d` 发布;OCI index digest `sha256:759a8446…21452b`,复用 NAS `12010→8080`、NPM host 31 / cert 41 与门户 `LLM ATLAS / projects / 180`。容器 healthy、0 次重启,21/21 公网路由、HTTPS/2、gzip / immutable assets、Round 08 专项与 DeepSeek 全量生产 Chrome 回归通过;保留 `20260729T195952Z-9211333` 回滚。
|
||||||
|
- [x] K3 Round 04 在任何正式结果前冻结 `llm-atlas-k3-attnres-reduced-v1`:WikiText-2 固定 revision 与 byte 拼接、192,000-window SHA-256 日程、16-block / 32-sublayer / width-192 公共主干、Baseline / Full / Block 三结构、三个初始化 seed、2,000-step 预算、主 BPC 判据、RMS / mixer / gradient 诊断与独立 replay 合同全部先落盘。
|
||||||
|
- [x] 九个正式训练格全部完成,共消费 147,456,000 target bytes;同一 seed 的 9,541,824 个公共 core 参数初始化 hash 在三结构间 exact。Full − Baseline 三个 paired delta 为 `−.015996 / −.013207 / −.014498`,Block 为 `−.052660 / −.041349 / −.033388`,分别以均值 `−.014567 / −.042466 BPC` 满足预注册方向支持规则。
|
||||||
|
- [x] 反结果同时进入主审计:核心参数 gradient RMS 的 16-block mean CV 为 Baseline `0.3447`、Full `0.5087`、Block `0.6306`;本 reduced metric 没有复现论文的大模型梯度均匀性叙述,不改换指标掩盖。
|
||||||
|
- [x] 指定 Block / seed 2026073001 进行全新进程 2,000-step replay;manifest、model、optimizer、hashes、evaluations、training history、diagnostic、environment 八字段全部 exact,最终 BPC 同为 `1.947877975922777`;timing 明确不要求 exact。
|
||||||
|
- [x] K3 Round 04 五视图实验室完成:三 seed BPC 曲线、Residual RMS / Block 锯齿、Full / Block depth-weight heatmap、梯度反证、成本/哈希/claim boundary 分开展示;完整 9-run JSON、compact 数据、复现清单、协议、审计、训练与聚合代码进入公开仓库。
|
||||||
|
- [x] Round 04 本地闸门通过:91 个受检文件零诊断/提示,21 个页面、1,151 个站内引用、12 个跨页锚点零失败;冻结数据、AttnRes 专项与 K3 全量真实 Chrome 回归通过,桌面/390px 移动端零文档级溢出、零运行时异常。
|
||||||
|
|
||||||
## 正在进行
|
## 正在进行
|
||||||
|
|
||||||
- [ ] K3 三轮下一闸门:获得真实 token hidden states、expert load 与 cache traces,解释或修订 `A_log [128]` 工件冲突,再做 Figure 3/4/5 数值重绘和独立小模型复现。
|
- [ ] K3 四轮下一闸门:对齐 AttnRes 论文的 activation / residual-output gradient 定义,增加模型深度与训练预算,检验本轮梯度反结果是否随尺度翻转;真实 K3 forward 继续等待 `A_log [128]→[96]` 官方转换或权重修订。
|
||||||
- [ ] DeepSeek 八轮下一闸门:推进干预式 mediation、SM90 FlashMLA、FP8 / pipeline traces 与 R1-like RL 小模型复现。
|
- [ ] DeepSeek 八轮下一闸门:推进干预式 mediation、SM90 FlashMLA、FP8 / pipeline traces 与 R1-like RL 小模型复现。
|
||||||
- [ ] 表示、位置与残差二轮:真实 hidden-state / norm traces、长上下文位置外推复现与 mHC / AttnRes 深层稳定性消融。
|
- [ ] 表示、位置与残差二轮:真实 hidden-state / norm traces、长上下文位置外推复现与 mHC / AttnRes 深层稳定性消融。
|
||||||
- [ ] 评测安全二轮:真实 cross-harness / pass@k 复跑、Judge 元评测、动态污染与过拒案例。
|
- [ ] 评测安全二轮:真实 cross-harness / pass@k 复跑、Judge 元评测、动态污染与过拒案例。
|
||||||
@@ -464,6 +470,10 @@
|
|||||||
| 2026-07-30 | 输出长度揭示强任务域交互 | system-at-period 在 Code 为负、Math 为正,两个选定任务带都不跨零;不从长度外推能力 |
|
| 2026-07-30 | 输出长度揭示强任务域交互 | system-at-period 在 Code 为负、Math 为正,两个选定任务带都不跨零;不从长度外推能力 |
|
||||||
| 2026-07-30 | Round 08 十二字段重放过闸 | 64/64 exact;uniform hash、完整 token IDs、文本、stop 与 RNG 一并进入复现合同,评分 gold 提前加载的流程偏差公开保留 |
|
| 2026-07-30 | Round 08 十二字段重放过闸 | 64/64 exact;uniform hash、完整 token IDs、文本、stop 与 RNG 一并进入复现合同,评分 gold 提前加载的流程偏差公开保留 |
|
||||||
| 2026-07-30 | DeepSeek Round 08 任务 bootstrap / CRN 里程碑发布 | 源提交 `975ed3d`、镜像 `20260729T221654Z-975ed3d`、OCI `sha256:759a8446…21452b`;21/21 公网路由与生产专项/全量 Chrome 通过,保留 Round 07 回滚点 |
|
| 2026-07-30 | DeepSeek Round 08 任务 bootstrap / CRN 里程碑发布 | 源提交 `975ed3d`、镜像 `20260729T221654Z-975ed3d`、OCI `sha256:759a8446…21452b`;21/21 公网路由与生产专项/全量 Chrome 通过,保留 Round 07 回滚点 |
|
||||||
|
| 2026-07-30 | K3 `A_log [128]` 冲突继续阻断真实 checkpoint forward | 当前 HF / GitHub / FlashKDA / vLLM / SGLang 均未公开 128→96 转换;不裁剪、不 reshape、不把假设输出冒充 K3 |
|
||||||
|
| 2026-07-30 | AttnRes 缩小实验先冻结再训练 | 三结构共享公共主干、初始化、窗口与优化器;三 seed paired BPC 只按预注册 `3/3 same direction + mean≤−.010` 判为本协议内方向支持 |
|
||||||
|
| 2026-07-30 | 主结果与机制反结果同时发布 | Full / Block BPC 方向支持;核心参数 gradient RMS CV 却高于 Baseline,明确写成未复现论文梯度叙述 |
|
||||||
|
| 2026-07-30 | 独立重放按数值合同而非计时合同验收 | Block / seed-1 的八组冻结字段 2,000 steps exact;wall time 受调度影响,不要求或声称 bit-exact |
|
||||||
|
|
||||||
## 未决问题
|
## 未决问题
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
当前里程碑包含 17 专题学习地图、486 篇关键论文索引、Kimi K3 完整导读,
|
当前里程碑包含 17 专题学习地图、486 篇关键论文索引、Kimi K3 完整导读,
|
||||||
语言模型前史、Transformer 基础、表示/位置/残差、DeepSeek 技术谱系、Scaling Laws、数据工程、长上下文、MoE、指令微调与人类偏好、推理、工具使用与长程 Agent、原生多模态、训练系统、推理服务、数值优化,以及评测与安全深度专题,
|
语言模型前史、Transformer 基础、表示/位置/残差、DeepSeek 技术谱系、Scaling Laws、数据工程、长上下文、MoE、指令微调与人类偏好、推理、工具使用与长程 Agent、原生多模态、训练系统、推理服务、数值优化,以及评测与安全深度专题,
|
||||||
以及 89 个覆盖核心机制的原创交互视图。K3 二轮导读以 32 张问题账、16 图 / 5 表审计、
|
以及 94 个覆盖核心机制的原创交互视图。K3 二轮导读以 32 张问题账、16 图 / 5 表审计、
|
||||||
8 个交互实验和 100 个一手/官方节点,完整覆盖架构、预训练、后训练、系统、评测、案例与附录。
|
8 个交互实验和 100 个一手/官方节点,完整覆盖架构、预训练、后训练、系统、评测、案例与附录。
|
||||||
第三轮已完成开放工件与首个真实 kernel 里程碑:固定官方模型与 FlashKDA revisions,审计 96 个 checkpoint shards、
|
第三轮已完成开放工件与首个真实 kernel 里程碑:固定官方模型与 FlashKDA revisions,审计 96 个 checkpoint shards、
|
||||||
497,220 个 tensor entries、真实 KDA / MLA / MoE / MoonViT shapes 与小范围参数统计,并用 4 个新视图
|
497,220 个 tensor entries、真实 KDA / MLA / MoE / MoonViT shapes 与小范围参数统计,并用 4 个新视图
|
||||||
@@ -27,6 +27,18 @@
|
|||||||
`sm_120a` wheel,在 RTX 5090 上完成 6/6 官方参考 exact-match 和 K3 fixed / varlen 形状计时。详见
|
`sm_120a` wheel,在 RTX 5090 上完成 6/6 官方参考 exact-match 和 K3 fixed / varlen 形状计时。详见
|
||||||
[K3_ARTIFACT_AUDIT.md](./research/K3_ARTIFACT_AUDIT.md) 与
|
[K3_ARTIFACT_AUDIT.md](./research/K3_ARTIFACT_AUDIT.md) 与
|
||||||
[checkpoint_probe.py](./experiments/k3/checkpoint_probe.py)、[FlashKDA probe](./experiments/k3/flashkda/)。
|
[checkpoint_probe.py](./experiments/k3/checkpoint_probe.py)、[FlashKDA probe](./experiments/k3/flashkda/)。
|
||||||
|
第四轮不裁剪仍未解释的 `A_log [128]` 去伪造 K3 forward,而是先冻结
|
||||||
|
`llm-atlas-k3-attnres-reduced-v1`,用相同 16-block / 32-sublayer Transformer 主干、
|
||||||
|
相同 WikiText-2 byte windows 与三个共同初始化 seed,从零训练 Baseline、Full AttnRes
|
||||||
|
与 Block AttnRes 共 9 个 2,000-step 正式格。最终 Full / Block 相对 Baseline 的三 seed
|
||||||
|
平均 paired delta 分别为 `−0.01457 / −0.04247 BPC`,都满足预注册的本协议内方向支持规则;
|
||||||
|
但核心参数梯度 RMS 的跨 block CV 为 `0.3447 / 0.5087 / 0.6306`,没有复现论文式
|
||||||
|
梯度均匀性叙述。指定 Block / seed-1 的全新进程 2,000-step replay 在八组数值与哈希字段
|
||||||
|
上全部 exact,计时不要求 exact。完整 9-run JSON、compact payload、复现清单、训练/
|
||||||
|
聚合代码与五视图实验室均进入开源树。详见
|
||||||
|
[K3_ATTNRES_REDUCED_PROTOCOL.md](./research/K3_ATTNRES_REDUCED_PROTOCOL.md)、
|
||||||
|
[K3_ATTNRES_REDUCED_AUDIT.md](./research/K3_ATTNRES_REDUCED_AUDIT.md) 与
|
||||||
|
[AttnRes experiment](./experiments/k3/attnres/)。
|
||||||
DeepSeek 八轮专题以 24 张问题账、10 次技术转向、
|
DeepSeek 八轮专题以 24 张问题账、10 次技术转向、
|
||||||
22 个交互实验和 60 个一手/官方节点,串起 Dense、MoE、MLA、V3 协同、R1 与 V4;
|
22 个交互实验和 60 个一手/官方节点,串起 Dense、MoE、MLA、V3 协同、R1 与 V4;
|
||||||
并固定官方 V2-Lite revision,在 RTX 5090 上连续执行 7/27 层,记录 3,240 次真实专家选择、
|
并固定官方 V2-Lite revision,在 RTX 5090 上连续执行 7/27 层,记录 3,240 次真实专家选择、
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
# Reduced Attention Residuals reproduction
|
||||||
|
|
||||||
|
This directory implements protocol
|
||||||
|
`llm-atlas-k3-attnres-reduced-v1`, frozen in
|
||||||
|
`research/K3_ATTNRES_REDUCED_PROTOCOL.md`.
|
||||||
|
|
||||||
|
The experiment is a reduced independent mechanism probe. It is not a Kimi K3
|
||||||
|
checkpoint forward pass and not a reproduction of the paper-scale training run.
|
||||||
|
|
||||||
|
## Environment
|
||||||
|
|
||||||
|
The pinned execution environment used by this project is:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Python /home/wuyang/.pyenv/versions/3.10.14/envs/navi-router-cu128/bin/python
|
||||||
|
PyTorch 2.11.0+cu128
|
||||||
|
GPU NVIDIA GeForce RTX 5090
|
||||||
|
CUBLAS_WORKSPACE_CONFIG=:4096:8
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build the frozen dataset
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python experiments/k3/attnres/build_dataset.py \
|
||||||
|
--cache-dir /home/wuyang/.cache/llm-atlas/k3-attnres-reduced-v1 \
|
||||||
|
--manifest experiments/k3/attnres/manifest.json
|
||||||
|
```
|
||||||
|
|
||||||
|
## Run one cell
|
||||||
|
|
||||||
|
```bash
|
||||||
|
CUBLAS_WORKSPACE_CONFIG=:4096:8 \
|
||||||
|
python experiments/k3/attnres/train.py \
|
||||||
|
--architecture baseline \
|
||||||
|
--seed 2026073001 \
|
||||||
|
--cache-dir /home/wuyang/.cache/llm-atlas/k3-attnres-reduced-v1 \
|
||||||
|
--manifest experiments/k3/attnres/manifest.json \
|
||||||
|
--output /home/wuyang/.cache/llm-atlas/k3-attnres-reduced-v1/runs/baseline-2026073001.json
|
||||||
|
```
|
||||||
|
|
||||||
|
Raw parquet and checkpoints stay in the local cache. Frozen manifests, metric
|
||||||
|
JSON, analyses, code, checksums, and a compact website payload enter the public
|
||||||
|
repository.
|
||||||
|
|
||||||
|
## Validate and aggregate the complete study
|
||||||
|
|
||||||
|
After the nine formal cells, the preregistered replay, and the paired smoke runs
|
||||||
|
exist in the cache:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python experiments/k3/attnres/analyze.py \
|
||||||
|
--formal-dir /home/wuyang/.cache/llm-atlas/k3-attnres-reduced-v1/formal \
|
||||||
|
--smoke-dir /home/wuyang/.cache/llm-atlas/k3-attnres-reduced-v1/smoke \
|
||||||
|
--replay /home/wuyang/.cache/llm-atlas/k3-attnres-reduced-v1/replay/block-2026073001.json \
|
||||||
|
--manifest experiments/k3/attnres/manifest.json \
|
||||||
|
--output src/data/k3-attnres-reduced.json \
|
||||||
|
--compact-output src/data/k3-attnres-reduced-compact.json \
|
||||||
|
--reproduction-output experiments/k3/attnres/reproduction.json
|
||||||
|
```
|
||||||
|
|
||||||
|
The aggregator fails closed on protocol identity, grid completeness, byte
|
||||||
|
budget, schedule hashes, shared initialization, non-finite metrics, diagnostic
|
||||||
|
shape, smoke mismatch, or formal replay mismatch. Timing is recorded but is not
|
||||||
|
required to replay bit-for-bit.
|
||||||
@@ -0,0 +1,536 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Validate, aggregate, and compact the reduced Attention Residuals study."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import math
|
||||||
|
import os
|
||||||
|
import statistics
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Any, Iterable
|
||||||
|
|
||||||
|
|
||||||
|
PROTOCOL_ID = "llm-atlas-k3-attnres-reduced-v1"
|
||||||
|
ARCHITECTURES = ("baseline", "full", "block")
|
||||||
|
SEEDS = (2026073001, 2026073002, 2026073003)
|
||||||
|
REPLAY_FIELDS = (
|
||||||
|
"manifest",
|
||||||
|
"model",
|
||||||
|
"optimizer",
|
||||||
|
"hashes",
|
||||||
|
"evaluations",
|
||||||
|
"training_history",
|
||||||
|
"diagnostic",
|
||||||
|
"environment",
|
||||||
|
)
|
||||||
|
SMOKE_FIELDS = REPLAY_FIELDS
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args() -> argparse.Namespace:
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--formal-dir", type=Path, required=True)
|
||||||
|
parser.add_argument("--smoke-dir", type=Path, required=True)
|
||||||
|
parser.add_argument("--replay", type=Path, required=True)
|
||||||
|
parser.add_argument("--manifest", type=Path, required=True)
|
||||||
|
parser.add_argument("--output", type=Path, required=True)
|
||||||
|
parser.add_argument("--compact-output", type=Path, required=True)
|
||||||
|
parser.add_argument("--reproduction-output", type=Path, required=True)
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def read_json(path: Path) -> dict[str, Any]:
|
||||||
|
return json.loads(path.read_text())
|
||||||
|
|
||||||
|
|
||||||
|
def file_sha256(path: Path) -> str:
|
||||||
|
digest = hashlib.sha256()
|
||||||
|
with path.open("rb") as handle:
|
||||||
|
for block in iter(lambda: handle.read(1024 * 1024), b""):
|
||||||
|
digest.update(block)
|
||||||
|
return digest.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def canonical_sha256(value: Any) -> str:
|
||||||
|
payload = json.dumps(
|
||||||
|
value, ensure_ascii=False, sort_keys=True, separators=(",", ":")
|
||||||
|
).encode()
|
||||||
|
return hashlib.sha256(payload).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def write_json(path: Path, value: dict[str, Any]) -> None:
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
temporary = path.with_suffix(path.suffix + ".tmp")
|
||||||
|
temporary.write_text(
|
||||||
|
json.dumps(value, ensure_ascii=False, indent=2, sort_keys=True) + "\n"
|
||||||
|
)
|
||||||
|
os.replace(temporary, path)
|
||||||
|
|
||||||
|
|
||||||
|
def mean(values: Iterable[float]) -> float:
|
||||||
|
return statistics.fmean(values)
|
||||||
|
|
||||||
|
|
||||||
|
def elementwise_summary(rows: list[list[float]]) -> dict[str, list[float]]:
|
||||||
|
length = len(rows[0])
|
||||||
|
if any(len(row) != length for row in rows):
|
||||||
|
raise ValueError("array lengths do not match")
|
||||||
|
return {
|
||||||
|
"mean": [mean(row[index] for row in rows) for index in range(length)],
|
||||||
|
"min": [min(row[index] for row in rows) for index in range(length)],
|
||||||
|
"max": [max(row[index] for row in rows) for index in range(length)],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def coefficient_of_variation(values: list[float]) -> float:
|
||||||
|
average = mean(values)
|
||||||
|
variance = mean((value - average) ** 2 for value in values)
|
||||||
|
return math.sqrt(variance) / average
|
||||||
|
|
||||||
|
|
||||||
|
def verdict(deltas: list[float]) -> dict[str, Any]:
|
||||||
|
average = mean(deltas)
|
||||||
|
if all(delta < 0 for delta in deltas) and average <= -0.010:
|
||||||
|
label = "directional support in this reduced protocol"
|
||||||
|
elif all(delta > 0 for delta in deltas) and average >= 0.010:
|
||||||
|
label = "directional concern in this reduced protocol"
|
||||||
|
else:
|
||||||
|
label = "inconclusive at this budget"
|
||||||
|
return {
|
||||||
|
"paired_deltas_bpc": deltas,
|
||||||
|
"mean_delta_bpc": average,
|
||||||
|
"min_delta_bpc": min(deltas),
|
||||||
|
"max_delta_bpc": max(deltas),
|
||||||
|
"same_direction": len({delta < 0 for delta in deltas}) == 1,
|
||||||
|
"threshold_bpc": 0.010,
|
||||||
|
"verdict": label,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def average_depth_weights(runs: list[dict[str, Any]]) -> dict[str, Any]:
|
||||||
|
rows_by_run = [run["diagnostic"]["depth_weights"] for run in runs]
|
||||||
|
layer_count = len(rows_by_run[0])
|
||||||
|
if any(len(rows) != layer_count for rows in rows_by_run):
|
||||||
|
raise ValueError("depth-weight layer counts differ")
|
||||||
|
rows = []
|
||||||
|
max_sources = 0
|
||||||
|
for layer in range(layer_count):
|
||||||
|
source_count = rows_by_run[0][layer]["sources"]
|
||||||
|
if any(rows[layer]["sources"] != source_count for rows in rows_by_run):
|
||||||
|
raise ValueError("source count differs across seeds")
|
||||||
|
weights = [
|
||||||
|
mean(rows_by_run[seed_index][layer]["mean_weights"][source]
|
||||||
|
for seed_index in range(len(runs)))
|
||||||
|
for source in range(source_count)
|
||||||
|
]
|
||||||
|
entropies = [
|
||||||
|
rows_by_run[seed_index][layer]["entropy_mean"]
|
||||||
|
for seed_index in range(len(runs))
|
||||||
|
]
|
||||||
|
rows.append(
|
||||||
|
{
|
||||||
|
"sublayer": layer + 1,
|
||||||
|
"sources": source_count,
|
||||||
|
"mean_weights": weights,
|
||||||
|
"entropy_mean": mean(entropies),
|
||||||
|
"entropy_min": min(entropies),
|
||||||
|
"entropy_max": max(entropies),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
max_sources = max(max_sources, source_count)
|
||||||
|
|
||||||
|
output_rows = [run["diagnostic"]["output_weights"] for run in runs]
|
||||||
|
output_source_count = output_rows[0]["sources"]
|
||||||
|
output_weights = [
|
||||||
|
mean(row["mean_weights"][source] for row in output_rows)
|
||||||
|
for source in range(output_source_count)
|
||||||
|
]
|
||||||
|
return {
|
||||||
|
"rows": rows,
|
||||||
|
"max_sources": max_sources,
|
||||||
|
"output": {
|
||||||
|
"sources": output_source_count,
|
||||||
|
"mean_weights": output_weights,
|
||||||
|
"entropy_mean": mean(row["entropy_mean"] for row in output_rows),
|
||||||
|
"entropy_min": min(row["entropy_mean"] for row in output_rows),
|
||||||
|
"entropy_max": max(row["entropy_mean"] for row in output_rows),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
args = parse_args()
|
||||||
|
manifest = read_json(args.manifest)
|
||||||
|
if manifest["protocol_id"] != PROTOCOL_ID:
|
||||||
|
raise ValueError("manifest protocol mismatch")
|
||||||
|
|
||||||
|
runs: dict[tuple[str, int], dict[str, Any]] = {}
|
||||||
|
formal_file_hashes: dict[str, str] = {}
|
||||||
|
for seed in SEEDS:
|
||||||
|
for architecture in ARCHITECTURES:
|
||||||
|
path = args.formal_dir / f"{architecture}-{seed}.json"
|
||||||
|
run = read_json(path)
|
||||||
|
if run["protocol_id"] != PROTOCOL_ID:
|
||||||
|
raise ValueError(f"protocol mismatch: {path}")
|
||||||
|
if run["run_kind"] != "formal":
|
||||||
|
raise ValueError(f"not a formal run: {path}")
|
||||||
|
if run["architecture"] != architecture or run["seed"] != seed:
|
||||||
|
raise ValueError(f"cell identity mismatch: {path}")
|
||||||
|
if run["steps"] != 2000 or run["batch_size"] != 32:
|
||||||
|
raise ValueError(f"formal budget mismatch: {path}")
|
||||||
|
if run["target_bytes_seen"] != 16_384_000:
|
||||||
|
raise ValueError(f"target byte count mismatch: {path}")
|
||||||
|
if run["manifest"]["file_sha256"] != file_sha256(args.manifest):
|
||||||
|
raise ValueError(f"manifest file hash mismatch: {path}")
|
||||||
|
if run["manifest"]["formal_schedule_sha256"] != (
|
||||||
|
manifest["windows"]["formal_schedule_sha256"]
|
||||||
|
):
|
||||||
|
raise ValueError(f"schedule mismatch: {path}")
|
||||||
|
if run["evaluations"][-1]["step"] != 2000:
|
||||||
|
raise ValueError(f"missing final evaluation: {path}")
|
||||||
|
if any(
|
||||||
|
not math.isfinite(value)
|
||||||
|
for evaluation in run["evaluations"]
|
||||||
|
for value in (
|
||||||
|
evaluation["cross_entropy_nats"],
|
||||||
|
evaluation["bits_per_byte"],
|
||||||
|
)
|
||||||
|
):
|
||||||
|
raise ValueError(f"non-finite evaluation: {path}")
|
||||||
|
if len(run["diagnostic"]["layer_input_rms"]) != 32:
|
||||||
|
raise ValueError(f"diagnostic depth mismatch: {path}")
|
||||||
|
if len(run["diagnostic"]["core_parameter_grad_rms_by_block"]) != 16:
|
||||||
|
raise ValueError(f"gradient depth mismatch: {path}")
|
||||||
|
runs[(architecture, seed)] = run
|
||||||
|
formal_file_hashes[path.name] = file_sha256(path)
|
||||||
|
|
||||||
|
common_initial_exact = {}
|
||||||
|
for seed in SEEDS:
|
||||||
|
hashes = {
|
||||||
|
architecture: runs[(architecture, seed)]["hashes"][
|
||||||
|
"initial_common_parameters"
|
||||||
|
]
|
||||||
|
for architecture in ARCHITECTURES
|
||||||
|
}
|
||||||
|
common_initial_exact[str(seed)] = {
|
||||||
|
"hashes": hashes,
|
||||||
|
"exact": len(set(hashes.values())) == 1,
|
||||||
|
}
|
||||||
|
if not common_initial_exact[str(seed)]["exact"]:
|
||||||
|
raise ValueError(f"common initialization mismatch for seed {seed}")
|
||||||
|
|
||||||
|
by_seed = []
|
||||||
|
for seed in SEEDS:
|
||||||
|
values = {
|
||||||
|
architecture: runs[(architecture, seed)]["evaluations"][-1][
|
||||||
|
"bits_per_byte"
|
||||||
|
]
|
||||||
|
for architecture in ARCHITECTURES
|
||||||
|
}
|
||||||
|
by_seed.append(
|
||||||
|
{
|
||||||
|
"seed": seed,
|
||||||
|
"final_bpc": values,
|
||||||
|
"full_minus_baseline": values["full"] - values["baseline"],
|
||||||
|
"block_minus_baseline": values["block"] - values["baseline"],
|
||||||
|
"block_minus_full": values["block"] - values["full"],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
final = {
|
||||||
|
"by_seed": by_seed,
|
||||||
|
"means": {
|
||||||
|
architecture: mean(
|
||||||
|
runs[(architecture, seed)]["evaluations"][-1]["bits_per_byte"]
|
||||||
|
for seed in SEEDS
|
||||||
|
)
|
||||||
|
for architecture in ARCHITECTURES
|
||||||
|
},
|
||||||
|
"full_contrast": verdict(
|
||||||
|
[row["full_minus_baseline"] for row in by_seed]
|
||||||
|
),
|
||||||
|
"block_contrast": verdict(
|
||||||
|
[row["block_minus_baseline"] for row in by_seed]
|
||||||
|
),
|
||||||
|
"block_minus_full": {
|
||||||
|
"paired_deltas_bpc": [row["block_minus_full"] for row in by_seed],
|
||||||
|
"mean_delta_bpc": mean(row["block_minus_full"] for row in by_seed),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
evaluation_steps = [
|
||||||
|
evaluation["step"] for evaluation in runs[("baseline", SEEDS[0])]["evaluations"]
|
||||||
|
]
|
||||||
|
curves = {}
|
||||||
|
for architecture in ARCHITECTURES:
|
||||||
|
curve = []
|
||||||
|
for index, step in enumerate(evaluation_steps):
|
||||||
|
values = [
|
||||||
|
runs[(architecture, seed)]["evaluations"][index]["bits_per_byte"]
|
||||||
|
for seed in SEEDS
|
||||||
|
]
|
||||||
|
if any(
|
||||||
|
runs[(architecture, seed)]["evaluations"][index]["step"] != step
|
||||||
|
for seed in SEEDS
|
||||||
|
):
|
||||||
|
raise ValueError("evaluation step mismatch")
|
||||||
|
curve.append(
|
||||||
|
{
|
||||||
|
"step": step,
|
||||||
|
"mean_bpc": mean(values),
|
||||||
|
"min_bpc": min(values),
|
||||||
|
"max_bpc": max(values),
|
||||||
|
"by_seed": values,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
curves[architecture] = curve
|
||||||
|
|
||||||
|
timing = {}
|
||||||
|
for architecture in ARCHITECTURES:
|
||||||
|
cells = [runs[(architecture, seed)]["timing"] for seed in SEEDS]
|
||||||
|
timing[architecture] = {
|
||||||
|
"mean_step_ms": mean(cell["mean_ms"] for cell in cells),
|
||||||
|
"median_step_ms": mean(cell["median_ms"] for cell in cells),
|
||||||
|
"p95_step_ms": mean(cell["p95_ms"] for cell in cells),
|
||||||
|
"mean_peak_allocated_bytes": mean(
|
||||||
|
cell["peak_allocated_bytes"] for cell in cells
|
||||||
|
),
|
||||||
|
"mean_peak_reserved_bytes": mean(
|
||||||
|
cell["peak_reserved_bytes"] for cell in cells
|
||||||
|
),
|
||||||
|
"by_seed": cells,
|
||||||
|
}
|
||||||
|
timing["relative_to_baseline"] = {
|
||||||
|
architecture: {
|
||||||
|
"step_time_ratio": timing[architecture]["mean_step_ms"]
|
||||||
|
/ timing["baseline"]["mean_step_ms"],
|
||||||
|
"allocated_memory_ratio": timing[architecture][
|
||||||
|
"mean_peak_allocated_bytes"
|
||||||
|
]
|
||||||
|
/ timing["baseline"]["mean_peak_allocated_bytes"],
|
||||||
|
}
|
||||||
|
for architecture in ("full", "block")
|
||||||
|
}
|
||||||
|
|
||||||
|
parameters = {
|
||||||
|
architecture: runs[(architecture, SEEDS[0])]["model"]["parameters"]
|
||||||
|
for architecture in ARCHITECTURES
|
||||||
|
}
|
||||||
|
parameters["mixer_overhead_fraction_of_baseline"] = (
|
||||||
|
parameters["full"]["mixer"] / parameters["baseline"]["total"]
|
||||||
|
)
|
||||||
|
|
||||||
|
traces = {}
|
||||||
|
gradients = {}
|
||||||
|
for architecture in ARCHITECTURES:
|
||||||
|
architecture_runs = [runs[(architecture, seed)] for seed in SEEDS]
|
||||||
|
traces[architecture] = {
|
||||||
|
key: elementwise_summary(
|
||||||
|
[run["diagnostic"][key] for run in architecture_runs]
|
||||||
|
)
|
||||||
|
for key in (
|
||||||
|
"layer_input_rms",
|
||||||
|
"branch_output_rms",
|
||||||
|
"stream_state_rms",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
gradient_rows = [
|
||||||
|
run["diagnostic"]["core_parameter_grad_rms_by_block"]
|
||||||
|
for run in architecture_runs
|
||||||
|
]
|
||||||
|
gradients[architecture] = {
|
||||||
|
"by_block": elementwise_summary(gradient_rows),
|
||||||
|
"cv_by_seed": [
|
||||||
|
coefficient_of_variation(row) for row in gradient_rows
|
||||||
|
],
|
||||||
|
"mean_cv": mean(coefficient_of_variation(row) for row in gradient_rows),
|
||||||
|
"first_last_ratio_by_seed": [
|
||||||
|
row[0] / row[-1] for row in gradient_rows
|
||||||
|
],
|
||||||
|
"mean_first_last_ratio": mean(row[0] / row[-1] for row in gradient_rows),
|
||||||
|
}
|
||||||
|
|
||||||
|
mixers = {
|
||||||
|
architecture: average_depth_weights(
|
||||||
|
[runs[(architecture, seed)] for seed in SEEDS]
|
||||||
|
)
|
||||||
|
for architecture in ("full", "block")
|
||||||
|
}
|
||||||
|
|
||||||
|
full_branch = traces["full"]["branch_output_rms"]["mean"]
|
||||||
|
largest_index = max(range(len(full_branch)), key=full_branch.__getitem__)
|
||||||
|
# Full output source 0 is the embedding; branch l is source l+1.
|
||||||
|
largest_source_weight = mixers["full"]["output"]["mean_weights"][
|
||||||
|
largest_index + 1
|
||||||
|
]
|
||||||
|
uniform_output_weight = 1 / mixers["full"]["output"]["sources"]
|
||||||
|
posthoc = {
|
||||||
|
"label": "post-hoc descriptive callout; not a preregistered endpoint",
|
||||||
|
"largest_full_branch_sublayer": largest_index + 1,
|
||||||
|
"largest_full_branch_rms": full_branch[largest_index],
|
||||||
|
"corresponding_final_output_weight": largest_source_weight,
|
||||||
|
"uniform_final_output_weight": uniform_output_weight,
|
||||||
|
"weight_over_uniform": largest_source_weight / uniform_output_weight,
|
||||||
|
}
|
||||||
|
|
||||||
|
replay = read_json(args.replay)
|
||||||
|
formal_replay_source = runs[("block", 2026073001)]
|
||||||
|
replay_exact = {
|
||||||
|
field: formal_replay_source[field] == replay[field]
|
||||||
|
for field in REPLAY_FIELDS
|
||||||
|
}
|
||||||
|
if not all(replay_exact.values()):
|
||||||
|
raise ValueError(f"formal replay mismatch: {replay_exact}")
|
||||||
|
|
||||||
|
smoke = {}
|
||||||
|
for architecture in ARCHITECTURES:
|
||||||
|
first_path = args.smoke_dir / f"{architecture}-2026073001-a.json"
|
||||||
|
second_path = args.smoke_dir / f"{architecture}-2026073001-b.json"
|
||||||
|
first = read_json(first_path)
|
||||||
|
second = read_json(second_path)
|
||||||
|
exact = {field: first[field] == second[field] for field in SMOKE_FIELDS}
|
||||||
|
if not all(exact.values()):
|
||||||
|
raise ValueError(f"smoke mismatch for {architecture}: {exact}")
|
||||||
|
smoke[architecture] = {
|
||||||
|
"fields": exact,
|
||||||
|
"all_exact": True,
|
||||||
|
"first_sha256": file_sha256(first_path),
|
||||||
|
"second_sha256": file_sha256(second_path),
|
||||||
|
}
|
||||||
|
|
||||||
|
reproduction = {
|
||||||
|
"schema_version": 1,
|
||||||
|
"protocol_id": PROTOCOL_ID,
|
||||||
|
"manifest_sha256": file_sha256(args.manifest),
|
||||||
|
"formal_files": formal_file_hashes,
|
||||||
|
"common_initial_parameters": common_initial_exact,
|
||||||
|
"smoke": smoke,
|
||||||
|
"formal_replay": {
|
||||||
|
"architecture": "block",
|
||||||
|
"seed": 2026073001,
|
||||||
|
"fields": replay_exact,
|
||||||
|
"all_numeric_and_hash_fields_exact": all(replay_exact.values()),
|
||||||
|
"timing_exact_required": False,
|
||||||
|
"timing_exact_observed": formal_replay_source["timing"] == replay["timing"],
|
||||||
|
"formal_file_sha256": formal_file_hashes[
|
||||||
|
"block-2026073001.json"
|
||||||
|
],
|
||||||
|
"replay_file_sha256": file_sha256(args.replay),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
reproduction["canonical_sha256_without_self"] = canonical_sha256(reproduction)
|
||||||
|
|
||||||
|
analysis = {
|
||||||
|
"final_validation": final,
|
||||||
|
"evaluation_curves": curves,
|
||||||
|
"timing": timing,
|
||||||
|
"parameters": parameters,
|
||||||
|
"traces": traces,
|
||||||
|
"gradients": gradients,
|
||||||
|
"mixers": mixers,
|
||||||
|
"posthoc": posthoc,
|
||||||
|
"interpretation": {
|
||||||
|
"primary": (
|
||||||
|
"Both Full and Block AttnRes satisfy the preregistered "
|
||||||
|
"directional-support rule in this reduced protocol."
|
||||||
|
),
|
||||||
|
"bounded_depth_pattern": (
|
||||||
|
"Block partial-state RMS resets every four residual sublayers; "
|
||||||
|
"the complete 32-point vectors are reported."
|
||||||
|
),
|
||||||
|
"gradient_boundary": (
|
||||||
|
"The preregistered core-parameter gradient RMS is not more "
|
||||||
|
"uniform for AttnRes here; this metric and scale do not reproduce "
|
||||||
|
"the paper's large-model gradient-magnitude result."
|
||||||
|
),
|
||||||
|
"scope": (
|
||||||
|
"Reduced byte-level WikiText-2 mechanism probe; not a K3 "
|
||||||
|
"checkpoint run, paper-scale reproduction, benchmark, or "
|
||||||
|
"same-FLOP comparison."
|
||||||
|
),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
raw = {
|
||||||
|
"schema_version": 1,
|
||||||
|
"protocol_id": PROTOCOL_ID,
|
||||||
|
"manifest": manifest,
|
||||||
|
"provenance": {
|
||||||
|
"manifest_file_sha256": file_sha256(args.manifest),
|
||||||
|
"formal_file_sha256": formal_file_hashes,
|
||||||
|
"reproduction_sha256": reproduction[
|
||||||
|
"canonical_sha256_without_self"
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"formal_runs": [
|
||||||
|
runs[(architecture, seed)]
|
||||||
|
for seed in SEEDS
|
||||||
|
for architecture in ARCHITECTURES
|
||||||
|
],
|
||||||
|
"analysis": analysis,
|
||||||
|
"reproduction": reproduction,
|
||||||
|
}
|
||||||
|
raw["canonical_sha256_without_self"] = canonical_sha256(raw)
|
||||||
|
|
||||||
|
compact = {
|
||||||
|
"schema_version": 1,
|
||||||
|
"protocol_id": PROTOCOL_ID,
|
||||||
|
"dataset": {
|
||||||
|
"repository": manifest["dataset"]["repository"],
|
||||||
|
"revision": manifest["dataset"]["revision"],
|
||||||
|
"train_bytes": manifest["dataset"]["splits"]["train"][
|
||||||
|
"concatenated_bytes"
|
||||||
|
],
|
||||||
|
"schedule_sha256": manifest["windows"]["formal_schedule_sha256"],
|
||||||
|
"validation_sha256": manifest["windows"][
|
||||||
|
"validation_tensor_sha256"
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"grid": {
|
||||||
|
"architectures": list(ARCHITECTURES),
|
||||||
|
"seeds": list(SEEDS),
|
||||||
|
"runs": 9,
|
||||||
|
"steps_per_run": 2000,
|
||||||
|
"target_bytes_per_run": 16_384_000,
|
||||||
|
"target_bytes_total": 9 * 16_384_000,
|
||||||
|
},
|
||||||
|
"final_validation": final,
|
||||||
|
"evaluation_curves": curves,
|
||||||
|
"timing": timing,
|
||||||
|
"parameters": parameters,
|
||||||
|
"traces": traces,
|
||||||
|
"gradients": gradients,
|
||||||
|
"mixers": mixers,
|
||||||
|
"posthoc": posthoc,
|
||||||
|
"interpretation": analysis["interpretation"],
|
||||||
|
"reproduction": reproduction,
|
||||||
|
"source_sha256": raw["canonical_sha256_without_self"],
|
||||||
|
}
|
||||||
|
compact["canonical_sha256_without_self"] = canonical_sha256(compact)
|
||||||
|
|
||||||
|
write_json(args.reproduction_output, reproduction)
|
||||||
|
write_json(args.output, raw)
|
||||||
|
write_json(args.compact_output, compact)
|
||||||
|
print(
|
||||||
|
json.dumps(
|
||||||
|
{
|
||||||
|
"output": str(args.output),
|
||||||
|
"compact_output": str(args.compact_output),
|
||||||
|
"reproduction_output": str(args.reproduction_output),
|
||||||
|
"raw_sha256": file_sha256(args.output),
|
||||||
|
"compact_sha256": file_sha256(args.compact_output),
|
||||||
|
"reproduction_sha256": file_sha256(args.reproduction_output),
|
||||||
|
"full": final["full_contrast"],
|
||||||
|
"block": final["block_contrast"],
|
||||||
|
"formal_replay": reproduction["formal_replay"],
|
||||||
|
},
|
||||||
|
ensure_ascii=False,
|
||||||
|
indent=2,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,192 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Download and freeze the byte-level WikiText-2 corpus for the AttnRes study."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import urllib.request
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
import pyarrow.parquet as pq
|
||||||
|
|
||||||
|
|
||||||
|
PROTOCOL_ID = "llm-atlas-k3-attnres-reduced-v1"
|
||||||
|
DATASET_REPO = "Salesforce/wikitext"
|
||||||
|
DATASET_REVISION = "b08601e04326c79dfdd32d625aee71d232d685c3"
|
||||||
|
DATASET_VARIANT = "wikitext-2-raw-v1"
|
||||||
|
SPLITS = ("train", "validation", "test")
|
||||||
|
SEEDS = (2026073001, 2026073002, 2026073003)
|
||||||
|
CONTEXT = 256
|
||||||
|
FORMAL_STEPS = 2000
|
||||||
|
FORMAL_BATCH = 32
|
||||||
|
VALIDATION_WINDOWS = 64
|
||||||
|
DIAGNOSTIC_WINDOWS = 16
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args() -> argparse.Namespace:
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--cache-dir", type=Path, required=True)
|
||||||
|
parser.add_argument("--manifest", type=Path, required=True)
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def file_sha256(path: Path) -> str:
|
||||||
|
digest = hashlib.sha256()
|
||||||
|
with path.open("rb") as handle:
|
||||||
|
for block in iter(lambda: handle.read(1024 * 1024), b""):
|
||||||
|
digest.update(block)
|
||||||
|
return digest.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def bytes_sha256(payload: bytes) -> str:
|
||||||
|
return hashlib.sha256(payload).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def atomic_json(path: Path, value: dict[str, Any]) -> None:
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
temporary = path.with_suffix(path.suffix + ".tmp")
|
||||||
|
temporary.write_text(
|
||||||
|
json.dumps(value, ensure_ascii=False, indent=2, sort_keys=True) + "\n"
|
||||||
|
)
|
||||||
|
os.replace(temporary, path)
|
||||||
|
|
||||||
|
|
||||||
|
def download(url: str, path: Path) -> None:
|
||||||
|
if path.exists():
|
||||||
|
return
|
||||||
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
temporary = path.with_suffix(path.suffix + ".part")
|
||||||
|
request = urllib.request.Request(
|
||||||
|
url,
|
||||||
|
headers={"User-Agent": "llm-atlas-k3-attnres-reduced/1.0"},
|
||||||
|
)
|
||||||
|
with urllib.request.urlopen(request, timeout=120) as response:
|
||||||
|
with temporary.open("wb") as output:
|
||||||
|
while block := response.read(1024 * 1024):
|
||||||
|
output.write(block)
|
||||||
|
os.replace(temporary, path)
|
||||||
|
|
||||||
|
|
||||||
|
def window_start(label: str, index: int, corpus_length: int, seed: int | None = None) -> int:
|
||||||
|
fields = [PROTOCOL_ID, label]
|
||||||
|
if seed is not None:
|
||||||
|
fields.append(str(seed))
|
||||||
|
fields.append(str(index))
|
||||||
|
payload = "\0".join(fields).encode()
|
||||||
|
value = int.from_bytes(hashlib.sha256(payload).digest()[:8], "big")
|
||||||
|
return value % (corpus_length - (CONTEXT + 1))
|
||||||
|
|
||||||
|
|
||||||
|
def train_window_start(seed: int, step: int, row: int, corpus_length: int) -> int:
|
||||||
|
payload = "\0".join(
|
||||||
|
[PROTOCOL_ID, "train-window", str(seed), str(step), str(row)]
|
||||||
|
).encode()
|
||||||
|
value = int.from_bytes(hashlib.sha256(payload).digest()[:8], "big")
|
||||||
|
return value % (corpus_length - (CONTEXT + 1))
|
||||||
|
|
||||||
|
|
||||||
|
def concatenate_split(parquet_path: Path) -> tuple[bytes, int]:
|
||||||
|
table = pq.read_table(parquet_path, columns=["text"])
|
||||||
|
rows = table.column("text").to_pylist()
|
||||||
|
payload = b"".join(((row or "") + "\n").encode("utf-8") for row in rows)
|
||||||
|
return payload, len(rows)
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
args = parse_args()
|
||||||
|
args.cache_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
split_manifest: dict[str, Any] = {}
|
||||||
|
split_bytes: dict[str, bytes] = {}
|
||||||
|
for split in SPLITS:
|
||||||
|
relative = f"{DATASET_VARIANT}/{split}-00000-of-00001.parquet"
|
||||||
|
url = (
|
||||||
|
f"https://huggingface.co/datasets/{DATASET_REPO}/resolve/"
|
||||||
|
f"{DATASET_REVISION}/{relative}"
|
||||||
|
)
|
||||||
|
parquet_path = args.cache_dir / f"{split}.parquet"
|
||||||
|
download(url, parquet_path)
|
||||||
|
payload, rows = concatenate_split(parquet_path)
|
||||||
|
binary_path = args.cache_dir / f"{split}.bin"
|
||||||
|
if not binary_path.exists() or binary_path.read_bytes() != payload:
|
||||||
|
temporary = binary_path.with_suffix(".bin.tmp")
|
||||||
|
temporary.write_bytes(payload)
|
||||||
|
os.replace(temporary, binary_path)
|
||||||
|
split_bytes[split] = payload
|
||||||
|
split_manifest[split] = {
|
||||||
|
"source_path": relative,
|
||||||
|
"source_url": url,
|
||||||
|
"parquet_bytes": parquet_path.stat().st_size,
|
||||||
|
"parquet_sha256": file_sha256(parquet_path),
|
||||||
|
"rows": rows,
|
||||||
|
"concatenated_bytes": len(payload),
|
||||||
|
"concatenated_sha256": bytes_sha256(payload),
|
||||||
|
"binary_path": str(binary_path),
|
||||||
|
"binary_sha256": file_sha256(binary_path),
|
||||||
|
}
|
||||||
|
|
||||||
|
train = split_bytes["train"]
|
||||||
|
validation = split_bytes["validation"]
|
||||||
|
|
||||||
|
schedule_digest = hashlib.sha256()
|
||||||
|
schedule_cells = 0
|
||||||
|
for seed in SEEDS:
|
||||||
|
for step in range(1, FORMAL_STEPS + 1):
|
||||||
|
for row in range(FORMAL_BATCH):
|
||||||
|
start = train_window_start(seed, step, row, len(train))
|
||||||
|
schedule_digest.update(start.to_bytes(8, "big"))
|
||||||
|
schedule_cells += 1
|
||||||
|
|
||||||
|
validation_starts = [
|
||||||
|
window_start("validation-window", index, len(validation))
|
||||||
|
for index in range(VALIDATION_WINDOWS)
|
||||||
|
]
|
||||||
|
diagnostic_starts = [
|
||||||
|
window_start("diagnostic-window", index, len(validation))
|
||||||
|
for index in range(DIAGNOSTIC_WINDOWS)
|
||||||
|
]
|
||||||
|
|
||||||
|
def tensor_hash(starts: list[int]) -> str:
|
||||||
|
digest = hashlib.sha256()
|
||||||
|
for start in starts:
|
||||||
|
digest.update(validation[start : start + CONTEXT + 1])
|
||||||
|
return digest.hexdigest()
|
||||||
|
|
||||||
|
manifest = {
|
||||||
|
"schema_version": 1,
|
||||||
|
"protocol_id": PROTOCOL_ID,
|
||||||
|
"status": "frozen-before-model-output",
|
||||||
|
"dataset": {
|
||||||
|
"repository": DATASET_REPO,
|
||||||
|
"revision": DATASET_REVISION,
|
||||||
|
"variant": DATASET_VARIANT,
|
||||||
|
"preprocessing": (
|
||||||
|
"parquet row order; (text or empty string) + LF; UTF-8; "
|
||||||
|
"no normalization; vocabulary is raw bytes 0..255"
|
||||||
|
),
|
||||||
|
"splits": split_manifest,
|
||||||
|
},
|
||||||
|
"windows": {
|
||||||
|
"context": CONTEXT,
|
||||||
|
"target_bytes_per_window": CONTEXT,
|
||||||
|
"seeds": list(SEEDS),
|
||||||
|
"formal_steps": FORMAL_STEPS,
|
||||||
|
"formal_batch": FORMAL_BATCH,
|
||||||
|
"formal_schedule_cells": schedule_cells,
|
||||||
|
"formal_schedule_sha256": schedule_digest.hexdigest(),
|
||||||
|
"validation_starts": validation_starts,
|
||||||
|
"validation_tensor_sha256": tensor_hash(validation_starts),
|
||||||
|
"diagnostic_starts": diagnostic_starts,
|
||||||
|
"diagnostic_tensor_sha256": tensor_hash(diagnostic_starts),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
atomic_json(args.manifest, manifest)
|
||||||
|
print(json.dumps(manifest, ensure_ascii=False, indent=2))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
{
|
||||||
|
"dataset": {
|
||||||
|
"preprocessing": "parquet row order; (text or empty string) + LF; UTF-8; no normalization; vocabulary is raw bytes 0..255",
|
||||||
|
"repository": "Salesforce/wikitext",
|
||||||
|
"revision": "b08601e04326c79dfdd32d625aee71d232d685c3",
|
||||||
|
"splits": {
|
||||||
|
"test": {
|
||||||
|
"binary_path": "/home/wuyang/.cache/llm-atlas/k3-attnres-reduced-v1/test.bin",
|
||||||
|
"binary_sha256": "bfe9eb16ab9987fb88bde4ea9a30a00f2a45db01dfc14bad78d05325789c4f12",
|
||||||
|
"concatenated_bytes": 1292014,
|
||||||
|
"concatenated_sha256": "bfe9eb16ab9987fb88bde4ea9a30a00f2a45db01dfc14bad78d05325789c4f12",
|
||||||
|
"parquet_bytes": 732610,
|
||||||
|
"parquet_sha256": "5f1bea067869d04849c0f975a2b29c4ff47d867f484f5010ea5e861eab246d91",
|
||||||
|
"rows": 4358,
|
||||||
|
"source_path": "wikitext-2-raw-v1/test-00000-of-00001.parquet",
|
||||||
|
"source_url": "https://huggingface.co/datasets/Salesforce/wikitext/resolve/b08601e04326c79dfdd32d625aee71d232d685c3/wikitext-2-raw-v1/test-00000-of-00001.parquet"
|
||||||
|
},
|
||||||
|
"train": {
|
||||||
|
"binary_path": "/home/wuyang/.cache/llm-atlas/k3-attnres-reduced-v1/train.bin",
|
||||||
|
"binary_sha256": "0ca7d3e74dbe44564ea5942b85232f1bbcb525c9cd481cd5d28a87ee90e7e9b4",
|
||||||
|
"concatenated_bytes": 10951563,
|
||||||
|
"concatenated_sha256": "0ca7d3e74dbe44564ea5942b85232f1bbcb525c9cd481cd5d28a87ee90e7e9b4",
|
||||||
|
"parquet_bytes": 6357543,
|
||||||
|
"parquet_sha256": "e83889baabc497075506f91975be5fac0d45c5290b6b20582c8cd1e853d0c9f7",
|
||||||
|
"rows": 36718,
|
||||||
|
"source_path": "wikitext-2-raw-v1/train-00000-of-00001.parquet",
|
||||||
|
"source_url": "https://huggingface.co/datasets/Salesforce/wikitext/resolve/b08601e04326c79dfdd32d625aee71d232d685c3/wikitext-2-raw-v1/train-00000-of-00001.parquet"
|
||||||
|
},
|
||||||
|
"validation": {
|
||||||
|
"binary_path": "/home/wuyang/.cache/llm-atlas/k3-attnres-reduced-v1/validation.bin",
|
||||||
|
"binary_sha256": "a42356f6a8ff1d25daf25ec9db49e10a537c265581b61c74604bb63231dee719",
|
||||||
|
"concatenated_bytes": 1148008,
|
||||||
|
"concatenated_sha256": "a42356f6a8ff1d25daf25ec9db49e10a537c265581b61c74604bb63231dee719",
|
||||||
|
"parquet_bytes": 657209,
|
||||||
|
"parquet_sha256": "204929b7ff9d6184953f867dedb860e40aa69c078fc1e54b3baaa8fb28511c4c",
|
||||||
|
"rows": 3760,
|
||||||
|
"source_path": "wikitext-2-raw-v1/validation-00000-of-00001.parquet",
|
||||||
|
"source_url": "https://huggingface.co/datasets/Salesforce/wikitext/resolve/b08601e04326c79dfdd32d625aee71d232d685c3/wikitext-2-raw-v1/validation-00000-of-00001.parquet"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"variant": "wikitext-2-raw-v1"
|
||||||
|
},
|
||||||
|
"protocol_id": "llm-atlas-k3-attnres-reduced-v1",
|
||||||
|
"schema_version": 1,
|
||||||
|
"status": "frozen-before-model-output",
|
||||||
|
"windows": {
|
||||||
|
"context": 256,
|
||||||
|
"diagnostic_starts": [
|
||||||
|
611936,
|
||||||
|
81370,
|
||||||
|
284950,
|
||||||
|
884010,
|
||||||
|
436549,
|
||||||
|
319425,
|
||||||
|
664210,
|
||||||
|
2929,
|
||||||
|
1120568,
|
||||||
|
1130204,
|
||||||
|
567111,
|
||||||
|
471404,
|
||||||
|
178798,
|
||||||
|
773999,
|
||||||
|
8739,
|
||||||
|
567335
|
||||||
|
],
|
||||||
|
"diagnostic_tensor_sha256": "d970af9b0c656c9826f369b5fe6e3869a6f6cfeccfa5a922fe94ed1d24b86818",
|
||||||
|
"formal_batch": 32,
|
||||||
|
"formal_schedule_cells": 192000,
|
||||||
|
"formal_schedule_sha256": "81521a70ec61f3717968f160cb711e50c5f52a665a6961538d339360cb695f48",
|
||||||
|
"formal_steps": 2000,
|
||||||
|
"seeds": [
|
||||||
|
2026073001,
|
||||||
|
2026073002,
|
||||||
|
2026073003
|
||||||
|
],
|
||||||
|
"target_bytes_per_window": 256,
|
||||||
|
"validation_starts": [
|
||||||
|
990074,
|
||||||
|
30961,
|
||||||
|
68731,
|
||||||
|
926982,
|
||||||
|
644250,
|
||||||
|
11726,
|
||||||
|
878377,
|
||||||
|
825572,
|
||||||
|
874166,
|
||||||
|
182830,
|
||||||
|
392129,
|
||||||
|
822765,
|
||||||
|
583693,
|
||||||
|
287605,
|
||||||
|
117755,
|
||||||
|
463343,
|
||||||
|
1005482,
|
||||||
|
27886,
|
||||||
|
1107742,
|
||||||
|
1025132,
|
||||||
|
190867,
|
||||||
|
563499,
|
||||||
|
375410,
|
||||||
|
611922,
|
||||||
|
576979,
|
||||||
|
959290,
|
||||||
|
139748,
|
||||||
|
855267,
|
||||||
|
439281,
|
||||||
|
268378,
|
||||||
|
205337,
|
||||||
|
638978,
|
||||||
|
916468,
|
||||||
|
1059268,
|
||||||
|
1098648,
|
||||||
|
863779,
|
||||||
|
1028257,
|
||||||
|
340396,
|
||||||
|
547037,
|
||||||
|
682617,
|
||||||
|
217662,
|
||||||
|
744004,
|
||||||
|
288924,
|
||||||
|
890860,
|
||||||
|
856857,
|
||||||
|
312424,
|
||||||
|
12454,
|
||||||
|
1135148,
|
||||||
|
385677,
|
||||||
|
954097,
|
||||||
|
490766,
|
||||||
|
164873,
|
||||||
|
620587,
|
||||||
|
329982,
|
||||||
|
1014567,
|
||||||
|
236028,
|
||||||
|
356220,
|
||||||
|
603142,
|
||||||
|
879272,
|
||||||
|
511832,
|
||||||
|
472270,
|
||||||
|
823189,
|
||||||
|
653568,
|
||||||
|
159430
|
||||||
|
],
|
||||||
|
"validation_tensor_sha256": "5f71fda757fc75010ed16e7636bc394c69f55b34a3713b3b5a7ef8e03eae3c20"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
{
|
||||||
|
"canonical_sha256_without_self": "89a127e625ccefbd9b749e6ffca4ba72868e217e0c7a24773024bd2fafde427a",
|
||||||
|
"common_initial_parameters": {
|
||||||
|
"2026073001": {
|
||||||
|
"exact": true,
|
||||||
|
"hashes": {
|
||||||
|
"baseline": "af2724a1c34bcfd61d8a8bef402246430898c815e56b6e5c5257949a4eb0e7b1",
|
||||||
|
"block": "af2724a1c34bcfd61d8a8bef402246430898c815e56b6e5c5257949a4eb0e7b1",
|
||||||
|
"full": "af2724a1c34bcfd61d8a8bef402246430898c815e56b6e5c5257949a4eb0e7b1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"2026073002": {
|
||||||
|
"exact": true,
|
||||||
|
"hashes": {
|
||||||
|
"baseline": "9fd4f04212ab5cea822f469902d8e80ecc368da329f3c20abacfe6b7a50ed523",
|
||||||
|
"block": "9fd4f04212ab5cea822f469902d8e80ecc368da329f3c20abacfe6b7a50ed523",
|
||||||
|
"full": "9fd4f04212ab5cea822f469902d8e80ecc368da329f3c20abacfe6b7a50ed523"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"2026073003": {
|
||||||
|
"exact": true,
|
||||||
|
"hashes": {
|
||||||
|
"baseline": "7a565cd353efdb3b95e9b8b1844581082c029991ea18d438b4b18566970c8c61",
|
||||||
|
"block": "7a565cd353efdb3b95e9b8b1844581082c029991ea18d438b4b18566970c8c61",
|
||||||
|
"full": "7a565cd353efdb3b95e9b8b1844581082c029991ea18d438b4b18566970c8c61"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"formal_files": {
|
||||||
|
"baseline-2026073001.json": "f5cddecace6a70ee3824f272811d2a6336ab6dc24ad1100b18292f4413692e9a",
|
||||||
|
"baseline-2026073002.json": "4c3b9e1ea2ed6fd3078f1212984327364832a1146bfcbdb3a6f2e61b589bfaa8",
|
||||||
|
"baseline-2026073003.json": "e5ce5a8944dad0c4811f8bf19b4cfec8ce4a9283858fd59cd739dbc37626707b",
|
||||||
|
"block-2026073001.json": "5df870369d9a86ccb4ba4191fbd1d6f3642893dd47a60f8f6d1143006bdfbdaf",
|
||||||
|
"block-2026073002.json": "be1f109a630e27c8469438e33b53806cdaecac2f712af4f885da83f00ef6843b",
|
||||||
|
"block-2026073003.json": "949ec51ca3a219a11f260171da01f737296241536f5e139cf07d444c27efba92",
|
||||||
|
"full-2026073001.json": "648cb25ea98da1868779733da155275e9a16aad5efbbeeced7812c19d75817d5",
|
||||||
|
"full-2026073002.json": "1fa715bbd81a3a04a5aa0ba0fc27feb8883c44a01e9f28e281a309a394447979",
|
||||||
|
"full-2026073003.json": "4e34fa35bbfec460cabc94bce7a08f44fc188d908705ae2e256500f00813b4e3"
|
||||||
|
},
|
||||||
|
"formal_replay": {
|
||||||
|
"all_numeric_and_hash_fields_exact": true,
|
||||||
|
"architecture": "block",
|
||||||
|
"fields": {
|
||||||
|
"diagnostic": true,
|
||||||
|
"environment": true,
|
||||||
|
"evaluations": true,
|
||||||
|
"hashes": true,
|
||||||
|
"manifest": true,
|
||||||
|
"model": true,
|
||||||
|
"optimizer": true,
|
||||||
|
"training_history": true
|
||||||
|
},
|
||||||
|
"formal_file_sha256": "5df870369d9a86ccb4ba4191fbd1d6f3642893dd47a60f8f6d1143006bdfbdaf",
|
||||||
|
"replay_file_sha256": "e74d3323e5fe31378bb8aad7a8efa2fb91995cd7224c158cf03006466cdea2a7",
|
||||||
|
"seed": 2026073001,
|
||||||
|
"timing_exact_observed": false,
|
||||||
|
"timing_exact_required": false
|
||||||
|
},
|
||||||
|
"manifest_sha256": "9778ade5b1c9dd7676d2cdc52b4e4e7ff5ae513cb56c667974e2422702f9dc2b",
|
||||||
|
"protocol_id": "llm-atlas-k3-attnres-reduced-v1",
|
||||||
|
"schema_version": 1,
|
||||||
|
"smoke": {
|
||||||
|
"baseline": {
|
||||||
|
"all_exact": true,
|
||||||
|
"fields": {
|
||||||
|
"diagnostic": true,
|
||||||
|
"environment": true,
|
||||||
|
"evaluations": true,
|
||||||
|
"hashes": true,
|
||||||
|
"manifest": true,
|
||||||
|
"model": true,
|
||||||
|
"optimizer": true,
|
||||||
|
"training_history": true
|
||||||
|
},
|
||||||
|
"first_sha256": "fd8b14f70a6a14978e65f9899b694164ba91753bf82eead436a40837c251e82c",
|
||||||
|
"second_sha256": "fd8b14f70a6a14978e65f9899b694164ba91753bf82eead436a40837c251e82c"
|
||||||
|
},
|
||||||
|
"block": {
|
||||||
|
"all_exact": true,
|
||||||
|
"fields": {
|
||||||
|
"diagnostic": true,
|
||||||
|
"environment": true,
|
||||||
|
"evaluations": true,
|
||||||
|
"hashes": true,
|
||||||
|
"manifest": true,
|
||||||
|
"model": true,
|
||||||
|
"optimizer": true,
|
||||||
|
"training_history": true
|
||||||
|
},
|
||||||
|
"first_sha256": "980a4a534e458199d95b5864b008a81f51b565e05a7b2f24a644b36d2134eccc",
|
||||||
|
"second_sha256": "980a4a534e458199d95b5864b008a81f51b565e05a7b2f24a644b36d2134eccc"
|
||||||
|
},
|
||||||
|
"full": {
|
||||||
|
"all_exact": true,
|
||||||
|
"fields": {
|
||||||
|
"diagnostic": true,
|
||||||
|
"environment": true,
|
||||||
|
"evaluations": true,
|
||||||
|
"hashes": true,
|
||||||
|
"manifest": true,
|
||||||
|
"model": true,
|
||||||
|
"optimizer": true,
|
||||||
|
"training_history": true
|
||||||
|
},
|
||||||
|
"first_sha256": "c6e32b737c7bf7fdc9b647650ebd7c9d2f9f8550f66a5b84f168f16fa7d2eacb",
|
||||||
|
"second_sha256": "c6e32b737c7bf7fdc9b647650ebd7c9d2f9f8550f66a5b84f168f16fa7d2eacb"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,717 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Train one frozen residual variant for the reduced Attention Residuals study."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import math
|
||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import statistics
|
||||||
|
import time
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Any, Iterable
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
import torch
|
||||||
|
import torch.nn as nn
|
||||||
|
import torch.nn.functional as F
|
||||||
|
|
||||||
|
|
||||||
|
PROTOCOL_ID = "llm-atlas-k3-attnres-reduced-v1"
|
||||||
|
ARCHITECTURES = ("baseline", "full", "block")
|
||||||
|
EXPECTED_SEEDS = (2026073001, 2026073002, 2026073003)
|
||||||
|
EVAL_STEPS = (0, 100, 250, 500, 1000, 1500, 2000)
|
||||||
|
VOCABULARY = 256
|
||||||
|
CONTEXT = 256
|
||||||
|
LAYERS = 16
|
||||||
|
SUBLAYERS = LAYERS * 2
|
||||||
|
BLOCKS = 8
|
||||||
|
SUBLAYERS_PER_BLOCK = SUBLAYERS // BLOCKS
|
||||||
|
D_MODEL = 192
|
||||||
|
HEADS = 6
|
||||||
|
D_HEAD = D_MODEL // HEADS
|
||||||
|
D_FF = 768
|
||||||
|
RMS_EPS = 1e-6
|
||||||
|
PEAK_LR = 3e-4
|
||||||
|
MIN_LR = 3e-5
|
||||||
|
WARMUP_STEPS = 100
|
||||||
|
WEIGHT_DECAY = 0.1
|
||||||
|
BETAS = (0.9, 0.95)
|
||||||
|
ADAM_EPS = 1e-8
|
||||||
|
GRAD_CLIP = 1.0
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args() -> argparse.Namespace:
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--architecture", choices=ARCHITECTURES, required=True)
|
||||||
|
parser.add_argument("--seed", type=int, required=True)
|
||||||
|
parser.add_argument("--steps", type=int, default=2000)
|
||||||
|
parser.add_argument("--batch-size", type=int, default=32)
|
||||||
|
parser.add_argument("--cache-dir", type=Path, required=True)
|
||||||
|
parser.add_argument("--manifest", type=Path, required=True)
|
||||||
|
parser.add_argument("--output", type=Path, required=True)
|
||||||
|
parser.add_argument("--validation-windows", type=int, default=64)
|
||||||
|
parser.add_argument("--diagnostic-windows", type=int, default=16)
|
||||||
|
parser.add_argument("--eval-batch-size", type=int, default=8)
|
||||||
|
parser.add_argument("--timing-warmup", type=int, default=20)
|
||||||
|
parser.add_argument("--run-kind", choices=("smoke", "formal", "replay"), default="formal")
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def configure_determinism(seed: int) -> None:
|
||||||
|
if os.environ.get("CUBLAS_WORKSPACE_CONFIG") != ":4096:8":
|
||||||
|
raise RuntimeError("CUBLAS_WORKSPACE_CONFIG must be :4096:8 before Python starts")
|
||||||
|
torch.manual_seed(seed)
|
||||||
|
torch.cuda.manual_seed_all(seed)
|
||||||
|
torch.use_deterministic_algorithms(True)
|
||||||
|
torch.backends.cudnn.benchmark = False
|
||||||
|
torch.backends.cudnn.deterministic = True
|
||||||
|
torch.backends.cuda.matmul.allow_tf32 = False
|
||||||
|
torch.backends.cudnn.allow_tf32 = False
|
||||||
|
torch.set_float32_matmul_precision("highest")
|
||||||
|
|
||||||
|
|
||||||
|
def canonical_json_sha256(value: Any) -> str:
|
||||||
|
payload = json.dumps(
|
||||||
|
value, ensure_ascii=False, sort_keys=True, separators=(",", ":")
|
||||||
|
).encode()
|
||||||
|
return hashlib.sha256(payload).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def file_sha256(path: Path) -> str:
|
||||||
|
digest = hashlib.sha256()
|
||||||
|
with path.open("rb") as handle:
|
||||||
|
for block in iter(lambda: handle.read(1024 * 1024), b""):
|
||||||
|
digest.update(block)
|
||||||
|
return digest.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def tensor_bytes(tensor: torch.Tensor) -> bytes:
|
||||||
|
value = tensor.detach().cpu().contiguous()
|
||||||
|
header = f"{value.dtype}|{tuple(value.shape)}|".encode()
|
||||||
|
return header + value.view(torch.uint8).numpy().tobytes()
|
||||||
|
|
||||||
|
|
||||||
|
def state_hash(
|
||||||
|
model: nn.Module,
|
||||||
|
*,
|
||||||
|
include_mixers: bool | None,
|
||||||
|
) -> str:
|
||||||
|
digest = hashlib.sha256()
|
||||||
|
for name, tensor in sorted(model.state_dict().items()):
|
||||||
|
is_mixer = name.startswith("mixers.") or name.startswith("output_mixer.")
|
||||||
|
if include_mixers is not None and is_mixer != include_mixers:
|
||||||
|
continue
|
||||||
|
digest.update(name.encode())
|
||||||
|
digest.update(b"\0")
|
||||||
|
digest.update(tensor_bytes(tensor))
|
||||||
|
return digest.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def window_start(seed: int, step: int, row: int, corpus_length: int) -> int:
|
||||||
|
payload = "\0".join(
|
||||||
|
[PROTOCOL_ID, "train-window", str(seed), str(step), str(row)]
|
||||||
|
).encode()
|
||||||
|
value = int.from_bytes(hashlib.sha256(payload).digest()[:8], "big")
|
||||||
|
return value % (corpus_length - (CONTEXT + 1))
|
||||||
|
|
||||||
|
|
||||||
|
class ByteCorpus:
|
||||||
|
def __init__(self, cache_dir: Path, manifest: dict[str, Any], device: torch.device):
|
||||||
|
self.device = device
|
||||||
|
self.train = np.memmap(cache_dir / "train.bin", dtype=np.uint8, mode="r")
|
||||||
|
self.validation = np.memmap(
|
||||||
|
cache_dir / "validation.bin", dtype=np.uint8, mode="r"
|
||||||
|
)
|
||||||
|
self.validation_starts = manifest["windows"]["validation_starts"]
|
||||||
|
self.diagnostic_starts = manifest["windows"]["diagnostic_starts"]
|
||||||
|
|
||||||
|
def training_batch(
|
||||||
|
self, seed: int, step: int, batch_size: int
|
||||||
|
) -> tuple[torch.Tensor, torch.Tensor]:
|
||||||
|
rows = np.empty((batch_size, CONTEXT + 1), dtype=np.int64)
|
||||||
|
for row in range(batch_size):
|
||||||
|
start = window_start(seed, step, row, len(self.train))
|
||||||
|
rows[row] = self.train[start : start + CONTEXT + 1]
|
||||||
|
tensor = torch.from_numpy(rows).to(self.device, non_blocking=False)
|
||||||
|
return tensor[:, :-1], tensor[:, 1:]
|
||||||
|
|
||||||
|
def fixed_batch(
|
||||||
|
self, starts: list[int], begin: int, end: int
|
||||||
|
) -> tuple[torch.Tensor, torch.Tensor]:
|
||||||
|
chosen = starts[begin:end]
|
||||||
|
rows = np.empty((len(chosen), CONTEXT + 1), dtype=np.int64)
|
||||||
|
for row, start in enumerate(chosen):
|
||||||
|
rows[row] = self.validation[start : start + CONTEXT + 1]
|
||||||
|
tensor = torch.from_numpy(rows).to(self.device, non_blocking=False)
|
||||||
|
return tensor[:, :-1], tensor[:, 1:]
|
||||||
|
|
||||||
|
|
||||||
|
class RMSNorm(nn.Module):
|
||||||
|
def __init__(self, dimension: int):
|
||||||
|
super().__init__()
|
||||||
|
self.weight = nn.Parameter(torch.ones(dimension))
|
||||||
|
|
||||||
|
def forward(self, value: torch.Tensor) -> torch.Tensor:
|
||||||
|
normalized = value.float() * torch.rsqrt(
|
||||||
|
value.float().square().mean(dim=-1, keepdim=True) + RMS_EPS
|
||||||
|
)
|
||||||
|
return normalized.to(value.dtype) * self.weight
|
||||||
|
|
||||||
|
|
||||||
|
class CausalAttention(nn.Module):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.qkv = nn.Linear(D_MODEL, 3 * D_MODEL, bias=False)
|
||||||
|
self.o_proj = nn.Linear(D_MODEL, D_MODEL, bias=False)
|
||||||
|
mask = torch.triu(torch.ones(CONTEXT, CONTEXT, dtype=torch.bool), diagonal=1)
|
||||||
|
self.register_buffer("causal_mask", mask, persistent=False)
|
||||||
|
|
||||||
|
def forward(self, value: torch.Tensor) -> torch.Tensor:
|
||||||
|
batch, sequence, _ = value.shape
|
||||||
|
qkv = self.qkv(value).view(batch, sequence, 3, HEADS, D_HEAD)
|
||||||
|
query, key, content = qkv.unbind(dim=2)
|
||||||
|
query = query.transpose(1, 2)
|
||||||
|
key = key.transpose(1, 2)
|
||||||
|
content = content.transpose(1, 2)
|
||||||
|
scores = torch.matmul(query, key.transpose(-1, -2)).float() / math.sqrt(D_HEAD)
|
||||||
|
scores = scores.masked_fill(
|
||||||
|
self.causal_mask[:sequence, :sequence], float("-inf")
|
||||||
|
)
|
||||||
|
probabilities = torch.softmax(scores, dim=-1).to(query.dtype)
|
||||||
|
mixed = torch.matmul(probabilities, content)
|
||||||
|
mixed = mixed.transpose(1, 2).contiguous().view(batch, sequence, D_MODEL)
|
||||||
|
return self.o_proj(mixed)
|
||||||
|
|
||||||
|
|
||||||
|
class SwiGLU(nn.Module):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.gate = nn.Linear(D_MODEL, D_FF, bias=False)
|
||||||
|
self.up = nn.Linear(D_MODEL, D_FF, bias=False)
|
||||||
|
self.down = nn.Linear(D_FF, D_MODEL, bias=False)
|
||||||
|
|
||||||
|
def forward(self, value: torch.Tensor) -> torch.Tensor:
|
||||||
|
return self.down(F.silu(self.gate(value)) * self.up(value))
|
||||||
|
|
||||||
|
|
||||||
|
class TransformerBlock(nn.Module):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.attention_norm = RMSNorm(D_MODEL)
|
||||||
|
self.attention = CausalAttention()
|
||||||
|
self.mlp_norm = RMSNorm(D_MODEL)
|
||||||
|
self.mlp = SwiGLU()
|
||||||
|
|
||||||
|
|
||||||
|
class DepthMixer(nn.Module):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.query = nn.Parameter(torch.zeros(D_MODEL))
|
||||||
|
self.key_norm = RMSNorm(D_MODEL)
|
||||||
|
|
||||||
|
def forward(
|
||||||
|
self, sources: list[torch.Tensor], capture: bool = False
|
||||||
|
) -> tuple[torch.Tensor, dict[str, Any] | None]:
|
||||||
|
values = torch.stack(sources, dim=0)
|
||||||
|
keys = self.key_norm(values)
|
||||||
|
logits = torch.einsum("d,nbtd->nbt", self.query, keys.float())
|
||||||
|
weights = torch.softmax(logits, dim=0)
|
||||||
|
output = torch.einsum("nbt,nbtd->btd", weights, values.float()).to(
|
||||||
|
values.dtype
|
||||||
|
)
|
||||||
|
if not capture:
|
||||||
|
return output, None
|
||||||
|
entropy = -(weights * torch.log(weights.clamp_min(1e-30))).sum(dim=0)
|
||||||
|
return output, {
|
||||||
|
"mean_weights": weights.mean(dim=(1, 2)).detach().cpu().tolist(),
|
||||||
|
"entropy_mean": entropy.mean().detach().cpu().item(),
|
||||||
|
"sources": len(sources),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class TraceAccumulator:
|
||||||
|
layer_input_rms: list[float]
|
||||||
|
branch_output_rms: list[float]
|
||||||
|
stream_state_rms: list[float]
|
||||||
|
depth_weights: list[dict[str, Any]]
|
||||||
|
output_weights: dict[str, Any] | None = None
|
||||||
|
|
||||||
|
|
||||||
|
def rms(value: torch.Tensor) -> float:
|
||||||
|
return value.float().square().mean().sqrt().detach().cpu().item()
|
||||||
|
|
||||||
|
|
||||||
|
class ReducedLanguageModel(nn.Module):
|
||||||
|
def __init__(self, architecture: str):
|
||||||
|
super().__init__()
|
||||||
|
self.architecture = architecture
|
||||||
|
self.token_embedding = nn.Embedding(VOCABULARY, D_MODEL)
|
||||||
|
self.position_embedding = nn.Embedding(CONTEXT, D_MODEL)
|
||||||
|
self.blocks = nn.ModuleList([TransformerBlock() for _ in range(LAYERS)])
|
||||||
|
self.final_norm = RMSNorm(D_MODEL)
|
||||||
|
if architecture == "baseline":
|
||||||
|
self.mixers = nn.ModuleList()
|
||||||
|
self.output_mixer = None
|
||||||
|
else:
|
||||||
|
self.mixers = nn.ModuleList([DepthMixer() for _ in range(SUBLAYERS)])
|
||||||
|
self.output_mixer = DepthMixer()
|
||||||
|
self.reset_parameters()
|
||||||
|
|
||||||
|
def reset_parameters(self) -> None:
|
||||||
|
for module in self.modules():
|
||||||
|
if isinstance(module, nn.Embedding):
|
||||||
|
nn.init.normal_(module.weight, mean=0.0, std=0.02)
|
||||||
|
elif isinstance(module, nn.Linear):
|
||||||
|
nn.init.normal_(module.weight, mean=0.0, std=0.02)
|
||||||
|
elif isinstance(module, RMSNorm):
|
||||||
|
nn.init.ones_(module.weight)
|
||||||
|
scaled = 0.02 / math.sqrt(2 * LAYERS)
|
||||||
|
for block in self.blocks:
|
||||||
|
nn.init.normal_(block.attention.o_proj.weight, mean=0.0, std=scaled)
|
||||||
|
nn.init.normal_(block.mlp.down.weight, mean=0.0, std=scaled)
|
||||||
|
for mixer in self.mixers:
|
||||||
|
nn.init.zeros_(mixer.query)
|
||||||
|
nn.init.ones_(mixer.key_norm.weight)
|
||||||
|
if self.output_mixer is not None:
|
||||||
|
nn.init.zeros_(self.output_mixer.query)
|
||||||
|
nn.init.ones_(self.output_mixer.key_norm.weight)
|
||||||
|
|
||||||
|
def embed(self, input_ids: torch.Tensor) -> torch.Tensor:
|
||||||
|
positions = torch.arange(input_ids.shape[1], device=input_ids.device)
|
||||||
|
return self.token_embedding(input_ids) + self.position_embedding(positions)[None]
|
||||||
|
|
||||||
|
def forward(
|
||||||
|
self, input_ids: torch.Tensor, capture: bool = False
|
||||||
|
) -> tuple[torch.Tensor, TraceAccumulator | None]:
|
||||||
|
embedded = self.embed(input_ids)
|
||||||
|
trace = (
|
||||||
|
TraceAccumulator([], [], [], [])
|
||||||
|
if capture
|
||||||
|
else None
|
||||||
|
)
|
||||||
|
|
||||||
|
if self.architecture == "baseline":
|
||||||
|
hidden = embedded
|
||||||
|
for block in self.blocks:
|
||||||
|
attention_input = hidden
|
||||||
|
attention_output = block.attention(block.attention_norm(attention_input))
|
||||||
|
hidden = hidden + attention_output
|
||||||
|
if trace is not None:
|
||||||
|
trace.layer_input_rms.append(rms(attention_input))
|
||||||
|
trace.branch_output_rms.append(rms(attention_output))
|
||||||
|
trace.stream_state_rms.append(rms(hidden))
|
||||||
|
mlp_input = hidden
|
||||||
|
mlp_output = block.mlp(block.mlp_norm(mlp_input))
|
||||||
|
hidden = hidden + mlp_output
|
||||||
|
if trace is not None:
|
||||||
|
trace.layer_input_rms.append(rms(mlp_input))
|
||||||
|
trace.branch_output_rms.append(rms(mlp_output))
|
||||||
|
trace.stream_state_rms.append(rms(hidden))
|
||||||
|
elif self.architecture == "full":
|
||||||
|
sources = [embedded]
|
||||||
|
mixer_index = 0
|
||||||
|
for block in self.blocks:
|
||||||
|
attention_input, weights = self.mixers[mixer_index](sources, capture)
|
||||||
|
mixer_index += 1
|
||||||
|
attention_output = block.attention(block.attention_norm(attention_input))
|
||||||
|
sources.append(attention_output)
|
||||||
|
if trace is not None:
|
||||||
|
trace.layer_input_rms.append(rms(attention_input))
|
||||||
|
trace.branch_output_rms.append(rms(attention_output))
|
||||||
|
trace.stream_state_rms.append(
|
||||||
|
rms(torch.stack(sources, dim=0))
|
||||||
|
)
|
||||||
|
trace.depth_weights.append(weights or {})
|
||||||
|
mlp_input, weights = self.mixers[mixer_index](sources, capture)
|
||||||
|
mixer_index += 1
|
||||||
|
mlp_output = block.mlp(block.mlp_norm(mlp_input))
|
||||||
|
sources.append(mlp_output)
|
||||||
|
if trace is not None:
|
||||||
|
trace.layer_input_rms.append(rms(mlp_input))
|
||||||
|
trace.branch_output_rms.append(rms(mlp_output))
|
||||||
|
trace.stream_state_rms.append(
|
||||||
|
rms(torch.stack(sources, dim=0))
|
||||||
|
)
|
||||||
|
trace.depth_weights.append(weights or {})
|
||||||
|
assert self.output_mixer is not None
|
||||||
|
hidden, output_weights = self.output_mixer(sources, capture)
|
||||||
|
if trace is not None:
|
||||||
|
trace.output_weights = output_weights
|
||||||
|
else:
|
||||||
|
completed = [embedded]
|
||||||
|
partial: torch.Tensor | None = None
|
||||||
|
mixer_index = 0
|
||||||
|
for block in self.blocks:
|
||||||
|
for branch_index in range(2):
|
||||||
|
sources = completed + ([] if partial is None else [partial])
|
||||||
|
branch_input, weights = self.mixers[mixer_index](sources, capture)
|
||||||
|
mixer_index += 1
|
||||||
|
if branch_index == 0:
|
||||||
|
branch_output = block.attention(
|
||||||
|
block.attention_norm(branch_input)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
branch_output = block.mlp(block.mlp_norm(branch_input))
|
||||||
|
partial = (
|
||||||
|
branch_output if partial is None else partial + branch_output
|
||||||
|
)
|
||||||
|
if trace is not None:
|
||||||
|
trace.layer_input_rms.append(rms(branch_input))
|
||||||
|
trace.branch_output_rms.append(rms(branch_output))
|
||||||
|
trace.stream_state_rms.append(rms(partial))
|
||||||
|
trace.depth_weights.append(weights or {})
|
||||||
|
if mixer_index % SUBLAYERS_PER_BLOCK == 0:
|
||||||
|
completed.append(partial)
|
||||||
|
partial = None
|
||||||
|
assert partial is None
|
||||||
|
assert len(completed) == BLOCKS + 1
|
||||||
|
assert self.output_mixer is not None
|
||||||
|
hidden, output_weights = self.output_mixer(completed, capture)
|
||||||
|
if trace is not None:
|
||||||
|
trace.output_weights = output_weights
|
||||||
|
|
||||||
|
normalized = self.final_norm(hidden)
|
||||||
|
logits = F.linear(normalized, self.token_embedding.weight)
|
||||||
|
return logits, trace
|
||||||
|
|
||||||
|
|
||||||
|
def learning_rate(step: int, total_steps: int) -> float:
|
||||||
|
if step <= WARMUP_STEPS:
|
||||||
|
return PEAK_LR * step / WARMUP_STEPS
|
||||||
|
progress = (step - WARMUP_STEPS) / max(1, total_steps - WARMUP_STEPS)
|
||||||
|
cosine = 0.5 * (1 + math.cos(math.pi * progress))
|
||||||
|
return MIN_LR + (PEAK_LR - MIN_LR) * cosine
|
||||||
|
|
||||||
|
|
||||||
|
def cross_entropy(logits: torch.Tensor, targets: torch.Tensor) -> torch.Tensor:
|
||||||
|
return F.cross_entropy(
|
||||||
|
logits.float().reshape(-1, VOCABULARY), targets.reshape(-1)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@torch.no_grad()
|
||||||
|
def evaluate(
|
||||||
|
model: ReducedLanguageModel,
|
||||||
|
corpus: ByteCorpus,
|
||||||
|
starts: list[int],
|
||||||
|
window_count: int,
|
||||||
|
eval_batch_size: int,
|
||||||
|
) -> dict[str, float]:
|
||||||
|
model.eval()
|
||||||
|
loss_sum = 0.0
|
||||||
|
target_count = 0
|
||||||
|
for begin in range(0, window_count, eval_batch_size):
|
||||||
|
end = min(begin + eval_batch_size, window_count)
|
||||||
|
inputs, targets = corpus.fixed_batch(starts, begin, end)
|
||||||
|
with torch.autocast(device_type="cuda", dtype=torch.bfloat16):
|
||||||
|
logits, _ = model(inputs)
|
||||||
|
loss = F.cross_entropy(
|
||||||
|
logits.float().reshape(-1, VOCABULARY),
|
||||||
|
targets.reshape(-1),
|
||||||
|
reduction="sum",
|
||||||
|
)
|
||||||
|
loss_sum += loss.detach().cpu().item()
|
||||||
|
target_count += targets.numel()
|
||||||
|
nats = loss_sum / target_count
|
||||||
|
return {"cross_entropy_nats": nats, "bits_per_byte": nats / math.log(2)}
|
||||||
|
|
||||||
|
|
||||||
|
def percentile(values: list[float], quantile: float) -> float:
|
||||||
|
return float(np.quantile(np.asarray(values, dtype=np.float64), quantile))
|
||||||
|
|
||||||
|
|
||||||
|
def core_parameter_gradient_rms(model: ReducedLanguageModel) -> list[float]:
|
||||||
|
values = []
|
||||||
|
for block in model.blocks:
|
||||||
|
sum_square = 0.0
|
||||||
|
count = 0
|
||||||
|
for parameter in block.parameters():
|
||||||
|
if parameter.grad is None:
|
||||||
|
continue
|
||||||
|
gradient = parameter.grad.detach().float()
|
||||||
|
sum_square += gradient.square().sum().detach().cpu().item()
|
||||||
|
count += gradient.numel()
|
||||||
|
values.append(math.sqrt(sum_square / count))
|
||||||
|
return values
|
||||||
|
|
||||||
|
|
||||||
|
def diagnostic(
|
||||||
|
model: ReducedLanguageModel,
|
||||||
|
corpus: ByteCorpus,
|
||||||
|
window_count: int,
|
||||||
|
) -> dict[str, Any]:
|
||||||
|
model.eval()
|
||||||
|
model.zero_grad(set_to_none=True)
|
||||||
|
inputs, targets = corpus.fixed_batch(
|
||||||
|
corpus.diagnostic_starts, 0, window_count
|
||||||
|
)
|
||||||
|
with torch.autocast(device_type="cuda", dtype=torch.bfloat16):
|
||||||
|
logits, trace = model(inputs, capture=True)
|
||||||
|
loss = cross_entropy(logits, targets)
|
||||||
|
loss.backward()
|
||||||
|
gradients = core_parameter_gradient_rms(model)
|
||||||
|
assert trace is not None
|
||||||
|
return {
|
||||||
|
"loss_nats": loss.detach().cpu().item(),
|
||||||
|
"bits_per_byte": loss.detach().cpu().item() / math.log(2),
|
||||||
|
"layer_input_rms": trace.layer_input_rms,
|
||||||
|
"branch_output_rms": trace.branch_output_rms,
|
||||||
|
"stream_state_rms": trace.stream_state_rms,
|
||||||
|
"core_parameter_grad_rms_by_block": gradients,
|
||||||
|
"depth_weights": trace.depth_weights,
|
||||||
|
"output_weights": trace.output_weights,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def parameter_inventory(model: ReducedLanguageModel) -> dict[str, int]:
|
||||||
|
total = sum(parameter.numel() for parameter in model.parameters())
|
||||||
|
mixer = sum(
|
||||||
|
parameter.numel()
|
||||||
|
for name, parameter in model.named_parameters()
|
||||||
|
if name.startswith("mixers.") or name.startswith("output_mixer.")
|
||||||
|
)
|
||||||
|
embedding = model.token_embedding.weight.numel() + model.position_embedding.weight.numel()
|
||||||
|
return {
|
||||||
|
"total": total,
|
||||||
|
"core": total - mixer,
|
||||||
|
"mixer": mixer,
|
||||||
|
"embedding": embedding,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
args = parse_args()
|
||||||
|
if not torch.cuda.is_available():
|
||||||
|
raise RuntimeError("CUDA is required by the frozen protocol")
|
||||||
|
if args.run_kind != "smoke" and args.seed not in EXPECTED_SEEDS:
|
||||||
|
raise ValueError(f"formal/replay seed is not preregistered: {args.seed}")
|
||||||
|
configure_determinism(args.seed)
|
||||||
|
device = torch.device("cuda")
|
||||||
|
|
||||||
|
manifest = json.loads(args.manifest.read_text())
|
||||||
|
if manifest["protocol_id"] != PROTOCOL_ID:
|
||||||
|
raise ValueError("manifest protocol mismatch")
|
||||||
|
if manifest["dataset"]["revision"] != (
|
||||||
|
"b08601e04326c79dfdd32d625aee71d232d685c3"
|
||||||
|
):
|
||||||
|
raise ValueError("dataset revision mismatch")
|
||||||
|
corpus = ByteCorpus(args.cache_dir, manifest, device)
|
||||||
|
|
||||||
|
model = ReducedLanguageModel(args.architecture).to(device)
|
||||||
|
initial_common_hash = state_hash(model, include_mixers=False)
|
||||||
|
initial_mixer_hash = (
|
||||||
|
state_hash(model, include_mixers=True)
|
||||||
|
if args.architecture != "baseline"
|
||||||
|
else None
|
||||||
|
)
|
||||||
|
inventory = parameter_inventory(model)
|
||||||
|
|
||||||
|
decay_parameters: list[nn.Parameter] = []
|
||||||
|
no_decay_parameters: list[nn.Parameter] = []
|
||||||
|
for parameter in model.parameters():
|
||||||
|
if parameter.ndim >= 2:
|
||||||
|
decay_parameters.append(parameter)
|
||||||
|
else:
|
||||||
|
no_decay_parameters.append(parameter)
|
||||||
|
optimizer = torch.optim.AdamW(
|
||||||
|
[
|
||||||
|
{"params": decay_parameters, "weight_decay": WEIGHT_DECAY},
|
||||||
|
{"params": no_decay_parameters, "weight_decay": 0.0},
|
||||||
|
],
|
||||||
|
lr=PEAK_LR,
|
||||||
|
betas=BETAS,
|
||||||
|
eps=ADAM_EPS,
|
||||||
|
)
|
||||||
|
|
||||||
|
evaluation_steps = sorted(
|
||||||
|
set(step for step in EVAL_STEPS if step <= args.steps) | {0, args.steps}
|
||||||
|
)
|
||||||
|
evaluations = [
|
||||||
|
{
|
||||||
|
"step": 0,
|
||||||
|
**evaluate(
|
||||||
|
model,
|
||||||
|
corpus,
|
||||||
|
corpus.validation_starts,
|
||||||
|
args.validation_windows,
|
||||||
|
args.eval_batch_size,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
]
|
||||||
|
training_history: list[dict[str, float | int]] = []
|
||||||
|
step_times: list[float] = []
|
||||||
|
model.train()
|
||||||
|
|
||||||
|
for step in range(1, args.steps + 1):
|
||||||
|
lr = learning_rate(step, args.steps)
|
||||||
|
for group in optimizer.param_groups:
|
||||||
|
group["lr"] = lr
|
||||||
|
inputs, targets = corpus.training_batch(args.seed, step, args.batch_size)
|
||||||
|
optimizer.zero_grad(set_to_none=True)
|
||||||
|
|
||||||
|
torch.cuda.synchronize()
|
||||||
|
started = time.perf_counter()
|
||||||
|
with torch.autocast(device_type="cuda", dtype=torch.bfloat16):
|
||||||
|
logits, _ = model(inputs)
|
||||||
|
loss = cross_entropy(logits, targets)
|
||||||
|
if not torch.isfinite(loss):
|
||||||
|
raise RuntimeError(f"non-finite loss at step {step}: {loss}")
|
||||||
|
loss.backward()
|
||||||
|
unclipped_norm = torch.nn.utils.clip_grad_norm_(
|
||||||
|
model.parameters(), GRAD_CLIP
|
||||||
|
)
|
||||||
|
optimizer.step()
|
||||||
|
torch.cuda.synchronize()
|
||||||
|
elapsed_ms = (time.perf_counter() - started) * 1000
|
||||||
|
|
||||||
|
if step == args.timing_warmup:
|
||||||
|
torch.cuda.reset_peak_memory_stats()
|
||||||
|
elif step > args.timing_warmup:
|
||||||
|
step_times.append(elapsed_ms)
|
||||||
|
|
||||||
|
if step == 1 or step % 10 == 0 or step == args.steps:
|
||||||
|
training_history.append(
|
||||||
|
{
|
||||||
|
"step": step,
|
||||||
|
"loss_nats": loss.detach().cpu().item(),
|
||||||
|
"bits_per_byte": loss.detach().cpu().item() / math.log(2),
|
||||||
|
"learning_rate": lr,
|
||||||
|
"unclipped_grad_norm": float(unclipped_norm.detach().cpu()),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if step in evaluation_steps and step != 0:
|
||||||
|
evaluations.append(
|
||||||
|
{
|
||||||
|
"step": step,
|
||||||
|
**evaluate(
|
||||||
|
model,
|
||||||
|
corpus,
|
||||||
|
corpus.validation_starts,
|
||||||
|
args.validation_windows,
|
||||||
|
args.eval_batch_size,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
model.train()
|
||||||
|
|
||||||
|
training_peak_allocated = torch.cuda.max_memory_allocated()
|
||||||
|
training_peak_reserved = torch.cuda.max_memory_reserved()
|
||||||
|
diagnostic_result = diagnostic(model, corpus, args.diagnostic_windows)
|
||||||
|
final_common_hash = state_hash(model, include_mixers=False)
|
||||||
|
final_mixer_hash = (
|
||||||
|
state_hash(model, include_mixers=True)
|
||||||
|
if args.architecture != "baseline"
|
||||||
|
else None
|
||||||
|
)
|
||||||
|
timing = {
|
||||||
|
"warmup_steps_excluded": args.timing_warmup,
|
||||||
|
"measured_steps": len(step_times),
|
||||||
|
"mean_ms": statistics.fmean(step_times) if step_times else None,
|
||||||
|
"median_ms": statistics.median(step_times) if step_times else None,
|
||||||
|
"p95_ms": percentile(step_times, 0.95) if step_times else None,
|
||||||
|
"peak_allocated_bytes": training_peak_allocated,
|
||||||
|
"peak_reserved_bytes": training_peak_reserved,
|
||||||
|
}
|
||||||
|
|
||||||
|
result = {
|
||||||
|
"schema_version": 1,
|
||||||
|
"protocol_id": PROTOCOL_ID,
|
||||||
|
"run_kind": args.run_kind,
|
||||||
|
"architecture": args.architecture,
|
||||||
|
"seed": args.seed,
|
||||||
|
"steps": args.steps,
|
||||||
|
"batch_size": args.batch_size,
|
||||||
|
"target_bytes_seen": args.steps * args.batch_size * CONTEXT,
|
||||||
|
"manifest": {
|
||||||
|
"path": str(args.manifest),
|
||||||
|
"file_sha256": file_sha256(args.manifest),
|
||||||
|
"formal_schedule_sha256": manifest["windows"][
|
||||||
|
"formal_schedule_sha256"
|
||||||
|
],
|
||||||
|
"validation_tensor_sha256": manifest["windows"][
|
||||||
|
"validation_tensor_sha256"
|
||||||
|
],
|
||||||
|
"diagnostic_tensor_sha256": manifest["windows"][
|
||||||
|
"diagnostic_tensor_sha256"
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"model": {
|
||||||
|
"layers": LAYERS,
|
||||||
|
"sublayers": SUBLAYERS,
|
||||||
|
"blocks_for_block_attnres": BLOCKS,
|
||||||
|
"sublayers_per_attnres_block": SUBLAYERS_PER_BLOCK,
|
||||||
|
"d_model": D_MODEL,
|
||||||
|
"heads": HEADS,
|
||||||
|
"d_head": D_HEAD,
|
||||||
|
"d_ff": D_FF,
|
||||||
|
"context": CONTEXT,
|
||||||
|
"vocabulary": VOCABULARY,
|
||||||
|
"parameters": inventory,
|
||||||
|
},
|
||||||
|
"optimizer": {
|
||||||
|
"name": "AdamW",
|
||||||
|
"betas": list(BETAS),
|
||||||
|
"epsilon": ADAM_EPS,
|
||||||
|
"weight_decay_ndim_ge_2": WEIGHT_DECAY,
|
||||||
|
"peak_lr": PEAK_LR,
|
||||||
|
"min_lr": MIN_LR,
|
||||||
|
"warmup_steps": WARMUP_STEPS,
|
||||||
|
"grad_clip": GRAD_CLIP,
|
||||||
|
},
|
||||||
|
"hashes": {
|
||||||
|
"initial_common_parameters": initial_common_hash,
|
||||||
|
"initial_mixer_parameters": initial_mixer_hash,
|
||||||
|
"final_common_parameters": final_common_hash,
|
||||||
|
"final_mixer_parameters": final_mixer_hash,
|
||||||
|
},
|
||||||
|
"evaluations": evaluations,
|
||||||
|
"training_history": training_history,
|
||||||
|
"diagnostic": diagnostic_result,
|
||||||
|
"timing": timing,
|
||||||
|
"environment": {
|
||||||
|
"python": platform.python_version(),
|
||||||
|
"torch": torch.__version__,
|
||||||
|
"cuda": torch.version.cuda,
|
||||||
|
"gpu": torch.cuda.get_device_name(0),
|
||||||
|
"compute_capability": list(torch.cuda.get_device_capability(0)),
|
||||||
|
"cublas_workspace_config": os.environ["CUBLAS_WORKSPACE_CONFIG"],
|
||||||
|
"deterministic_algorithms": torch.are_deterministic_algorithms_enabled(),
|
||||||
|
"autocast": "cuda-bfloat16",
|
||||||
|
"compile": False,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
result["canonical_sha256_without_self"] = canonical_json_sha256(result)
|
||||||
|
args.output.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
temporary = args.output.with_suffix(args.output.suffix + ".tmp")
|
||||||
|
temporary.write_text(
|
||||||
|
json.dumps(result, ensure_ascii=False, indent=2, sort_keys=True) + "\n"
|
||||||
|
)
|
||||||
|
os.replace(temporary, args.output)
|
||||||
|
print(
|
||||||
|
json.dumps(
|
||||||
|
{
|
||||||
|
"output": str(args.output),
|
||||||
|
"architecture": args.architecture,
|
||||||
|
"seed": args.seed,
|
||||||
|
"steps": args.steps,
|
||||||
|
"final_bpc": evaluations[-1]["bits_per_byte"],
|
||||||
|
"initial_common_hash": initial_common_hash,
|
||||||
|
"final_common_hash": final_common_hash,
|
||||||
|
"canonical_sha256": result["canonical_sha256_without_self"],
|
||||||
|
"timing": timing,
|
||||||
|
},
|
||||||
|
ensure_ascii=False,
|
||||||
|
indent=2,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
"build:data:deepseek-chat-cross-source-sampling": "node scripts/build-deepseek-chat-cross-source-sampling-compact.mjs",
|
"build:data:deepseek-chat-cross-source-sampling": "node scripts/build-deepseek-chat-cross-source-sampling-compact.mjs",
|
||||||
"build:data:deepseek-chat-task-bootstrap": "node scripts/build-deepseek-chat-task-bootstrap-crn-compact.mjs",
|
"build:data:deepseek-chat-task-bootstrap": "node scripts/build-deepseek-chat-task-bootstrap-crn-compact.mjs",
|
||||||
"check:data:deepseek-chat-task-bootstrap": "node scripts/check-deepseek-chat-task-bootstrap-crn-data.mjs",
|
"check:data:deepseek-chat-task-bootstrap": "node scripts/check-deepseek-chat-task-bootstrap-crn-data.mjs",
|
||||||
|
"check:data:k3-attnres": "node scripts/check-k3-attnres-data.mjs",
|
||||||
"check:site": "node scripts/check-site.mjs",
|
"check:site": "node scripts/check-site.mjs",
|
||||||
"check:moe-browser": "node scripts/check-moe-browser.mjs",
|
"check:moe-browser": "node scripts/check-moe-browser.mjs",
|
||||||
"check:reasoning-browser": "node scripts/check-reasoning-browser.mjs",
|
"check:reasoning-browser": "node scripts/check-reasoning-browser.mjs",
|
||||||
@@ -38,6 +39,7 @@
|
|||||||
"check:deepseek-sampling-browser": "node scripts/check-deepseek-sampling-browser.mjs",
|
"check:deepseek-sampling-browser": "node scripts/check-deepseek-sampling-browser.mjs",
|
||||||
"check:deepseek-cross-source-sampling-browser": "node scripts/check-deepseek-cross-source-sampling-browser.mjs",
|
"check:deepseek-cross-source-sampling-browser": "node scripts/check-deepseek-cross-source-sampling-browser.mjs",
|
||||||
"check:deepseek-task-bootstrap-browser": "node scripts/check-deepseek-task-bootstrap-browser.mjs",
|
"check:deepseek-task-bootstrap-browser": "node scripts/check-deepseek-task-bootstrap-browser.mjs",
|
||||||
|
"check:k3-attnres-browser": "node scripts/check-k3-attnres-browser.mjs",
|
||||||
"check:k3-browser": "node scripts/check-k3-browser.mjs"
|
"check:k3-browser": "node scripts/check-k3-browser.mjs"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -438,11 +438,19 @@ src/data/k3-flashkda-runtime.json
|
|||||||
- [x] 使用 CUDA 13.0 / glibc 2.39 隔离环境产出可校验 `sm_120a` wheel;
|
- [x] 使用 CUDA 13.0 / glibc 2.39 隔离环境产出可校验 `sm_120a` wheel;
|
||||||
- [x] RTX 5090 上六组 FlashKDA / official torch reference exact correctness;
|
- [x] RTX 5090 上六组 FlashKDA / official torch reference exact correctness;
|
||||||
- [x] K3 fixed / varlen shape、三种 state mode 的 1,800 个 CUDA Event samples;
|
- [x] K3 fixed / varlen shape、三种 state mode 的 1,800 个 CUDA Event samples;
|
||||||
|
- [x] 在不裁剪 `A_log` 的前提下完成独立缩小 AttnRes 机制实验;
|
||||||
|
- [x] Baseline / Full / Block × 三 seed × 2,000 steps 与指定正式格全新进程 exact replay;
|
||||||
|
- [x] BPC 主结果、Residual RMS、depth weights、gradient counterevidence 与执行成本公开入账;
|
||||||
- [ ] 取得真实 hidden-state / router load trace;
|
- [ ] 取得真实 hidden-state / router load trace;
|
||||||
- [ ] 取得可加载的 reduced checkpoint、官方 trace 或多机资源;
|
- [ ] 取得可加载的 reduced checkpoint、官方 trace 或多机资源;
|
||||||
- [ ] 对 Figure 3 / 4 / 5 做真实数值重绘;
|
- [ ] 对 Figure 3 / 4 / 5 做真实数值重绘;
|
||||||
- [ ] 对 AttnRes 读取分布做真实 token / layer trace。
|
- [ ] 对 AttnRes 读取分布做真实 token / layer trace。
|
||||||
|
|
||||||
|
这里的“缩小 AttnRes 实验”只完成独立机制 probe,不满足最后一项真实 K3 trace。完整合同与
|
||||||
|
审计见 `K3_ATTNRES_REDUCED_PROTOCOL.md` / `K3_ATTNRES_REDUCED_AUDIT.md`。下一轮优先
|
||||||
|
对齐论文 gradient 观测对象并增加 depth / budget;真实 checkpoint forward 继续等待公开
|
||||||
|
`A_log [128] → [96]` 转换或权重修订。
|
||||||
|
|
||||||
## 11. 发布与回归证据
|
## 11. 发布与回归证据
|
||||||
|
|
||||||
- 源提交:`2ef846f`;
|
- 源提交:`2ef846f`;
|
||||||
|
|||||||
@@ -0,0 +1,568 @@
|
|||||||
|
# Kimi K3 第四轮:Attention Residuals 缩小版独立机制实验审计
|
||||||
|
|
||||||
|
> 协议:`llm-atlas-k3-attnres-reduced-v1`
|
||||||
|
>
|
||||||
|
> 预注册:`research/K3_ATTNRES_REDUCED_PROTOCOL.md`
|
||||||
|
>
|
||||||
|
> 数据清单:`experiments/k3/attnres/manifest.json`
|
||||||
|
>
|
||||||
|
> 执行日期:2026-07-30
|
||||||
|
>
|
||||||
|
> 执行设备:NVIDIA GeForce RTX 5090;PyTorch `2.11.0+cu128`
|
||||||
|
|
||||||
|
## 0. 先说结论
|
||||||
|
|
||||||
|
这一轮没有伪装成“跑通了 K3”。它做的是一个刻意缩小、从零训练、可公开复查的
|
||||||
|
Attention Residuals(AttnRes)机制实验:
|
||||||
|
|
||||||
|
```text
|
||||||
|
3 个结构
|
||||||
|
× 3 个预先冻结的初始化 seed
|
||||||
|
× 每格 2,000 steps
|
||||||
|
× 每步 32 × 256 target bytes
|
||||||
|
= 9 个正式训练格,147,456,000 target bytes
|
||||||
|
```
|
||||||
|
|
||||||
|
三个结构共享完全相同的 16 个 Transformer blocks、32 个残差子层、初始公共参数、
|
||||||
|
训练窗口、优化器与验证集。唯一设计变量是“前面产生的 residual states 怎样供下一层读取”:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Baseline:只读上一残差状态
|
||||||
|
Full AttnRes:对全部历史残差状态做按维 softmax 混合
|
||||||
|
Block AttnRes:每 4 个残差子层形成一个局部块,块间再混合
|
||||||
|
```
|
||||||
|
|
||||||
|
在冻结的 64 个验证窗口上,最终 bits per byte(BPC,越低越好)为:
|
||||||
|
|
||||||
|
| seed | Baseline | Full | Block | Full − Base | Block − Base |
|
||||||
|
|---:|---:|---:|---:|---:|---:|
|
||||||
|
| 2026073001 | 2.00054 | 1.98454 | 1.94788 | −0.01600 | −0.05266 |
|
||||||
|
| 2026073002 | 1.99844 | 1.98523 | 1.95709 | −0.01321 | −0.04135 |
|
||||||
|
| 2026073003 | 1.99842 | 1.98392 | 1.96503 | −0.01450 | −0.03339 |
|
||||||
|
| 三 seed 均值 | 1.99913 | 1.98457 | 1.95667 | **−0.01457** | **−0.04247** |
|
||||||
|
|
||||||
|
按照看结果前冻结的判据——三个 seed 同为负,并且均值不高于 `−0.010 BPC`——Full 与
|
||||||
|
Block 都得到:
|
||||||
|
|
||||||
|
> **directional support in this reduced protocol**
|
||||||
|
|
||||||
|
中文应该读成:
|
||||||
|
|
||||||
|
> 在这套缩小训练合同中,允许子层重新读取更早的残差状态,方向一致地改善了验证 BPC。
|
||||||
|
|
||||||
|
它**不应该**读成:
|
||||||
|
|
||||||
|
- 已复现 AttnRes 论文的大模型收益;
|
||||||
|
- 已运行 Kimi K3 checkpoint;
|
||||||
|
- 已证明 Block 一般优于 Full;
|
||||||
|
- 已得到同参数、同 FLOPs 或同 wall time 的优势;
|
||||||
|
- 三个 seed 可以支持总体显著性、置信区间或 scaling-law 外推。
|
||||||
|
|
||||||
|
本轮还有一个同样重要的反结果:预注册的“16 个 Transformer blocks 的核心参数梯度 RMS
|
||||||
|
变异系数”在本实验中,Baseline 为 `0.3447`,Full 为 `0.5087`,Block 为 `0.6306`。
|
||||||
|
在这个定义和尺度下,AttnRes **没有**表现出更均匀的跨深度梯度。这个结果与论文的大模型
|
||||||
|
梯度叙述不能直接对齐,网站必须把它作为边界而不是藏起来。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. 为什么不是直接跑 K3
|
||||||
|
|
||||||
|
### 1.1 公开 checkpoint 的未决形状冲突
|
||||||
|
|
||||||
|
第三轮工件审计在 K3 第一层 KDA 中发现:
|
||||||
|
|
||||||
|
| 官方工件 | `A_log` 所要求或实际给出的形状 |
|
||||||
|
|---|---|
|
||||||
|
| `config.json` | `num_heads = 96` |
|
||||||
|
| Hugging Face remote code | 按 `num_heads` 构造,即 `[96]` |
|
||||||
|
| FlashKDA kernel API | `[H]`,K3 中应为 `[96]` |
|
||||||
|
| checkpoint safetensors header | `[128]` |
|
||||||
|
|
||||||
|
本轮再次检查了当前官方 Hugging Face / GitHub 工件,并额外检查当前 vLLM 与 SGLang
|
||||||
|
Kimi K3 loader。两者都按 local head 维构造和切分 `A_log`,没有公开 `128 → 96` 的转换规则。
|
||||||
|
|
||||||
|
因此,以下做法都会越过证据:
|
||||||
|
|
||||||
|
```text
|
||||||
|
裁掉最后 32 个值
|
||||||
|
把 128 强行 reshape 成别的语义
|
||||||
|
把 128 解释成 head_dim
|
||||||
|
绕过 loader 后把输出叫作“K3 forward”
|
||||||
|
```
|
||||||
|
|
||||||
|
在 Moonshot 给出转换合同、修订权重,或一个官方 loader 明确处理这 32 个额外值之前,
|
||||||
|
本站不制造“真实 K3 前向结果”。
|
||||||
|
|
||||||
|
### 1.2 为什么缩小版仍有价值
|
||||||
|
|
||||||
|
不能诚实执行 1.56 TB checkpoint,不等于只能停在架构示意图。AttnRes 的核心问题可以被
|
||||||
|
缩成一个更小、但仍可被证伪的问题:
|
||||||
|
|
||||||
|
> 在相同 Transformer 主干、相同输入窗口与相同初始化下,把“固定单位 residual
|
||||||
|
> connection”替换成“学习的历史 residual 混合”,短预算训练是否出现一致方向?
|
||||||
|
|
||||||
|
这个问题不依赖 KDA、MLA、MoE、MXFP4、视觉塔或完整 K3 参数。它只检验 AttnRes
|
||||||
|
的局部机制方向,并且可以把全部代码、清单、聚合指标和复现哈希开源。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. 先冻结什么
|
||||||
|
|
||||||
|
首版协议在正式结果产生前冻结以下项目:
|
||||||
|
|
||||||
|
- 数据仓库、revision、config、split 拼接规则与 byte tokenizer;
|
||||||
|
- 模型层数、宽度、head 数、FFN 宽度、位置编码、RMSNorm 与激活函数;
|
||||||
|
- Baseline / Full / Block 的精确定义;
|
||||||
|
- 三个初始化 seed;
|
||||||
|
- 每格训练步数、batch、context 与总 target bytes;
|
||||||
|
- AdamW、学习率曲线、weight decay、gradient clipping;
|
||||||
|
- 验证步、固定验证窗口与主指标;
|
||||||
|
- 主对比、方向判据和“不能宣称什么”;
|
||||||
|
- 深度 RMS、混合权重与梯度诊断;
|
||||||
|
- smoke 与正式独立进程 replay 合同。
|
||||||
|
|
||||||
|
正式协议不是从本轮曲线倒推的。关键提交顺序为:
|
||||||
|
|
||||||
|
```text
|
||||||
|
9039de1 research: preregister reduced AttnRes study
|
||||||
|
e361753 research: lock reduced AttnRes model contract
|
||||||
|
f998720 research: add reduced AttnRes runner
|
||||||
|
1f20f81 research: freeze reduced AttnRes corpus
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2.1 一次被公开保留的预训练故障
|
||||||
|
|
||||||
|
第一次 smoke 在 step 0 的验证 forward 后停止:
|
||||||
|
|
||||||
|
```text
|
||||||
|
RuntimeError:
|
||||||
|
view size is not compatible with input tensor's size and stride
|
||||||
|
```
|
||||||
|
|
||||||
|
原因是切片后的 target tensor 不连续,而 loss 路径用了 `.view()`。当时:
|
||||||
|
|
||||||
|
- 尚未执行一个 optimizer step;
|
||||||
|
- 没有正式结果文件;
|
||||||
|
- 没有任何条件的训练或最终 BPC 可供选择。
|
||||||
|
|
||||||
|
修复仅把 `.view()` 改为语义等价且支持非连续输入的 `.reshape()`:
|
||||||
|
|
||||||
|
```text
|
||||||
|
5f49906 fix: flatten noncontiguous AttnRes targets
|
||||||
|
```
|
||||||
|
|
||||||
|
随后三个结构分别完成两次独立 smoke,冻结字段逐字段 exact。这个故障不改变实验设计,
|
||||||
|
但应留在审计链中,避免“第一次就完美运行”的虚假叙事。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. 数据合同:文本怎样变成 byte 任务
|
||||||
|
|
||||||
|
### 3.1 固定数据源
|
||||||
|
|
||||||
|
| 项目 | 固定值 |
|
||||||
|
|---|---|
|
||||||
|
| repository | `Salesforce/wikitext` |
|
||||||
|
| revision | `b08601e04326c79dfdd32d625aee71d232d685c3` |
|
||||||
|
| config | `wikitext-2-raw-v1` |
|
||||||
|
| 行处理 | `(text or "") + "\n"` |
|
||||||
|
| 编码 | UTF-8 |
|
||||||
|
| tokenizer | byte ID `0..255` |
|
||||||
|
| vocabulary | 256 |
|
||||||
|
|
||||||
|
拼接后的 split:
|
||||||
|
|
||||||
|
| split | bytes | SHA-256 |
|
||||||
|
|---|---:|---|
|
||||||
|
| train | 10,951,563 | `0ca7d3e74dbe44564ea5942b85232f1bbcb525c9cd481cd5d28a87ee90e7e9b4` |
|
||||||
|
| validation | 1,148,008 | `a42356f6a8ff1d25daf25ec9db49e10a537c265581b61c74604bb63231dee719` |
|
||||||
|
| test | 1,292,014 | `bfe9eb16ab9987fb88bde4ea9a30a00f2a45db01dfc14bad78d05325789c4f12` |
|
||||||
|
|
||||||
|
这里的 byte tokenizer 不是为了追求最佳语言模型性能,而是为了移除另一个潜在变量:
|
||||||
|
不同 BPE 模型、词表和 normalization。BPC 也因此可以直接比较,而不受 tokenization
|
||||||
|
长度变化影响。
|
||||||
|
|
||||||
|
### 3.2 无状态窗口计划
|
||||||
|
|
||||||
|
训练窗口不靠进程内 RNG 顺序产生。对每个:
|
||||||
|
|
||||||
|
```text
|
||||||
|
architecture + seed + step + batch row
|
||||||
|
```
|
||||||
|
|
||||||
|
协议用 SHA-256 派生 train start offset。三种结构在同一 seed 下使用相同窗口;结构名不进入
|
||||||
|
窗口选择的有效随机盐。冻结计划包含 192,000 个起点,SHA-256 为:
|
||||||
|
|
||||||
|
```text
|
||||||
|
81521a70ec61f3717968f160cb711e50c5f52a665a6961538d339360cb695f48
|
||||||
|
```
|
||||||
|
|
||||||
|
固定 64 个验证窗口 tensor hash:
|
||||||
|
|
||||||
|
```text
|
||||||
|
5f71fda757fc75010ed16e7636bc394c69f55b34a3713b3b5a7ef8e03eae3c20
|
||||||
|
```
|
||||||
|
|
||||||
|
固定 16 个诊断窗口 hash:
|
||||||
|
|
||||||
|
```text
|
||||||
|
d970af9b0c656c9826f369b5fe6e3869a6f6cfeccfa5a922fe94ed1d24b86818
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. 模型合同:只改变 residual 读取拓扑
|
||||||
|
|
||||||
|
### 4.1 公共主干
|
||||||
|
|
||||||
|
| 项目 | 值 |
|
||||||
|
|---|---:|
|
||||||
|
| Transformer blocks | 16 |
|
||||||
|
| residual sublayers | 32(每 block attention + FFN) |
|
||||||
|
| model width | 192 |
|
||||||
|
| attention heads | 6 |
|
||||||
|
| head dimension | 32 |
|
||||||
|
| SwiGLU hidden | 768 |
|
||||||
|
| context | 256 bytes |
|
||||||
|
| dropout | 0 |
|
||||||
|
| position | learned absolute embedding |
|
||||||
|
| norm | pre-RMSNorm + final RMSNorm |
|
||||||
|
| attention softmax | causal, float32 |
|
||||||
|
| embedding / LM head | tied |
|
||||||
|
|
||||||
|
Attention projection 与 SwiGLU 都不使用 bias。三个结构的公共 core 参数均为
|
||||||
|
`9,541,824`,每个 seed 的公共参数初始化哈希在三种结构间 exact。
|
||||||
|
|
||||||
|
### 4.2 Baseline
|
||||||
|
|
||||||
|
普通 residual 子层:
|
||||||
|
|
||||||
|
```text
|
||||||
|
x_(l+1) = x_l + F_l(RMSNorm(x_l))
|
||||||
|
```
|
||||||
|
|
||||||
|
它只保留一个随深度持续累积的 residual stream。
|
||||||
|
|
||||||
|
### 4.3 Full AttnRes
|
||||||
|
|
||||||
|
第 `l` 个子层先对从 embedding 到当前深度的全部 residual states 做学习混合:
|
||||||
|
|
||||||
|
```text
|
||||||
|
α_l = softmax(q_l · RMSNorm(states))
|
||||||
|
x̃_l = Σ_i α_(l,i) state_i
|
||||||
|
state_(l+1) = F_l(RMSNorm(x̃_l))
|
||||||
|
```
|
||||||
|
|
||||||
|
`q_l` 是按 hidden dimension 学习的 pseudoquery,初始化为 0,所以初始 softmax 为均匀
|
||||||
|
读取。最后还有一个 output mixer,把 33 个可见 sources 混成 LM head 的输入。
|
||||||
|
|
||||||
|
### 4.4 Block AttnRes
|
||||||
|
|
||||||
|
32 个 residual sublayers 被分成 8 块,每块 4 层:
|
||||||
|
|
||||||
|
```text
|
||||||
|
块内:新 branch state 做普通局部累加
|
||||||
|
块边界:对历史块状态做学习混合,产生下一块输入
|
||||||
|
```
|
||||||
|
|
||||||
|
它保留“可以回读历史”的机制,同时把 Full 随深度增长的状态集合限制在块级。
|
||||||
|
|
||||||
|
### 4.5 参数公平与计算不公平
|
||||||
|
|
||||||
|
| 结构 | core | mixer | total | 相对 Baseline mixer overhead |
|
||||||
|
|---|---:|---:|---:|---:|
|
||||||
|
| Baseline | 9,541,824 | 0 | 9,541,824 | 0 |
|
||||||
|
| Full | 9,541,824 | 12,672 | 9,554,496 | 0.1328% |
|
||||||
|
| Block | 9,541,824 | 12,672 | 9,554,496 | 0.1328% |
|
||||||
|
|
||||||
|
这是近似同参数,不是同 FLOPs。当前教学实现用 PyTorch eager 保存和混合历史 states,
|
||||||
|
没有使用论文的大模型优化 kernel,所以它适合机制观察,不适合推断生产吞吐。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. 训练与主指标
|
||||||
|
|
||||||
|
### 5.1 每格预算
|
||||||
|
|
||||||
|
```text
|
||||||
|
2,000 steps
|
||||||
|
× batch 32
|
||||||
|
× context 256 target bytes
|
||||||
|
= 16,384,000 target bytes / run
|
||||||
|
```
|
||||||
|
|
||||||
|
优化器:
|
||||||
|
|
||||||
|
```text
|
||||||
|
AdamW β=(0.9, 0.95), ε=1e-8
|
||||||
|
peak LR=3e-4, min LR=3e-5
|
||||||
|
100-step warmup + cosine decay
|
||||||
|
weight decay=0.1 for ndim>=2
|
||||||
|
global grad clip=1.0
|
||||||
|
BF16 autocast
|
||||||
|
```
|
||||||
|
|
||||||
|
验证发生在 `0, 100, 250, 500, 1000, 1500, 2000` steps。主指标只使用 step 2000
|
||||||
|
的固定验证 BPC;曲线用于帮助理解,不用于重新选择终点。
|
||||||
|
|
||||||
|
### 5.2 判据为什么这么保守
|
||||||
|
|
||||||
|
只有三个 seed,不能可靠估计总体方差或给出有意义的 population confidence interval。
|
||||||
|
所以预注册不用 p-value,而只问两个简单问题:
|
||||||
|
|
||||||
|
```text
|
||||||
|
三个 paired deltas 是否同方向?
|
||||||
|
mean delta 是否至少达到 0.010 BPC?
|
||||||
|
```
|
||||||
|
|
||||||
|
如果答案都是“是”,只写作本协议内的 directional support / concern。它是一道防止
|
||||||
|
夸大结论的阈值,不是一个通用显著性标准。
|
||||||
|
|
||||||
|
### 5.3 正式结果
|
||||||
|
|
||||||
|
Full 的三组配对差:
|
||||||
|
|
||||||
|
```text
|
||||||
|
−0.015996
|
||||||
|
−0.013207
|
||||||
|
−0.014498
|
||||||
|
mean = −0.014567 BPC
|
||||||
|
```
|
||||||
|
|
||||||
|
Block 的三组配对差:
|
||||||
|
|
||||||
|
```text
|
||||||
|
−0.052660
|
||||||
|
−0.041349
|
||||||
|
−0.033388
|
||||||
|
mean = −0.042466 BPC
|
||||||
|
```
|
||||||
|
|
||||||
|
两组都满足预注册的方向支持规则。Block 相对 Full 的均值差为 `−0.027898 BPC`,三个
|
||||||
|
seed 也同为负;但“Block − Full”不是预注册主判据,而且本实现的计算图与优化效率不同,
|
||||||
|
所以它只适合描述,不升级成一般性排名。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. 它花了多少计算与显存
|
||||||
|
|
||||||
|
排除每次前 20 个计时 warmup steps 后,三个 seed 的均值:
|
||||||
|
|
||||||
|
| 结构 | mean step | 相对 Baseline | peak allocated | 相对 Baseline |
|
||||||
|
|---|---:|---:|---:|---:|
|
||||||
|
| Baseline | 21.62 ms | 1.00× | 3.04 GB | 1.00× |
|
||||||
|
| Full | 146.81 ms | 6.79× | 14.26 GB | 4.70× |
|
||||||
|
| Block | 54.63 ms | 2.53× | 6.52 GB | 2.15× |
|
||||||
|
|
||||||
|
这张表应该怎样读:
|
||||||
|
|
||||||
|
- Full 在教学实现中为每层保留并读取更多历史 states,因此最贵;
|
||||||
|
- Block 把可见历史限制在块级,成本明显下降;
|
||||||
|
- 时间与显存是“这份 PyTorch eager 实现 + RTX 5090”的观测;
|
||||||
|
- 不能把 6.79× / 2.53× 外推到论文 kernel、K3 训练系统或生产推理;
|
||||||
|
- BPC 改善不能被写成同 FLOPs 改善。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 7. 看 residual stream:Block 为什么呈现锯齿
|
||||||
|
|
||||||
|
Baseline 的 stream-state RMS 从平均 `0.0661` 增到 `0.2110`:普通 residual
|
||||||
|
connection 把分支输出一路累积。
|
||||||
|
|
||||||
|
Block 的前 12 个 partial-state RMS 是:
|
||||||
|
|
||||||
|
```text
|
||||||
|
0.0334 0.0598 0.0967 0.1181
|
||||||
|
0.0509 0.0569 0.0745 0.0815
|
||||||
|
0.0532 0.0581 0.1079 0.1158
|
||||||
|
```
|
||||||
|
|
||||||
|
每四个值形成一个局部块:
|
||||||
|
|
||||||
|
```text
|
||||||
|
块内:逐层累积,RMS 通常上升
|
||||||
|
块间:重新从历史块状态混合,partial stream 被重置
|
||||||
|
```
|
||||||
|
|
||||||
|
所以曲线不是训练不稳定造成的随机锯齿,而是 Block 拓扑的直接几何痕迹。完整 32 点向量、
|
||||||
|
三个 seed 的 min / mean / max 均进入公开 JSON。
|
||||||
|
|
||||||
|
Full 的 layer-input RMS 则从 `0.0544` 降到 `0.00866`。这不等于信息“消失”:
|
||||||
|
每层输入是多个经过 RMSNorm 的历史 states 的学习加权和,混合可以通过方向抵消改变
|
||||||
|
合成向量的 RMS。只看单个标量不能判断信息保留量。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 8. mixer 权重:一个事后但有解释力的观察
|
||||||
|
|
||||||
|
Full 在第 31 个 residual sublayer 的 branch-output RMS 平均达到 `1.4964`,是 32 层中
|
||||||
|
最大值。但最终 output mixer 给这个 source 的平均权重只有:
|
||||||
|
|
||||||
|
```text
|
||||||
|
observed = 0.002794
|
||||||
|
uniform = 1 / 33 = 0.030303
|
||||||
|
ratio = 0.0922× uniform
|
||||||
|
```
|
||||||
|
|
||||||
|
一个直观解释是:输出混合器学会了压低这个幅值突增的 source,而不是被迫把它以单位
|
||||||
|
residual 权重传到输出。
|
||||||
|
|
||||||
|
必须同时保留两个限制:
|
||||||
|
|
||||||
|
1. “最大 spike 对应低权重”是看完完整 trace 后挑出的描述;
|
||||||
|
2. 它不是预注册 endpoint,不能作为独立确认性证据。
|
||||||
|
|
||||||
|
网站会明确标注 **post-hoc descriptive callout**,并展示完整深度权重图,让读者看到它
|
||||||
|
不是从被隐藏的其他 source 中挑出的孤立数字。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 9. 梯度结果没有复现论文叙述
|
||||||
|
|
||||||
|
预注册诊断对每个 Transformer block 的公共 core 参数计算 gradient RMS,再求 16 个
|
||||||
|
block 间的 coefficient of variation:
|
||||||
|
|
||||||
|
| 结构 | seed 1 | seed 2 | seed 3 | mean CV |
|
||||||
|
|---|---:|---:|---:|---:|
|
||||||
|
| Baseline | 0.3537 | 0.3409 | 0.3396 | **0.3447** |
|
||||||
|
| Full | 0.4890 | 0.5100 | 0.5272 | **0.5087** |
|
||||||
|
| Block | 0.6622 | 0.6849 | 0.5448 | **0.6306** |
|
||||||
|
|
||||||
|
CV 越低,按这个特定定义才越均匀。因此本轮观察是:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Baseline < Full < Block
|
||||||
|
```
|
||||||
|
|
||||||
|
这和 AttnRes 论文在大模型训练中报告的、更平坦的跨深度梯度幅值叙述不是同一个结果。
|
||||||
|
合理边界包括:
|
||||||
|
|
||||||
|
- 本实验只有 width 192、16 blocks、2,000 steps;
|
||||||
|
- 本指标是“按 block 汇总的核心参数 gradient RMS”;
|
||||||
|
- 论文图可能观察 activation / residual-output gradients,聚合对象并不相同;
|
||||||
|
- byte-level WikiText-2 与论文的大规模训练数据、优化器状态和训练阶段不同。
|
||||||
|
|
||||||
|
正确表述是:
|
||||||
|
|
||||||
|
> 本缩小实验的主 BPC 对比支持 AttnRes 的方向,但预注册的核心参数梯度均匀性指标不支持
|
||||||
|
> 论文式叙述;这提示该解释可能依赖尺度、指标定义或训练阶段,需要后续专门实验。
|
||||||
|
|
||||||
|
不正确的做法是改换一个看起来更漂亮的梯度统计后,只展示新指标。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 10. 复现链
|
||||||
|
|
||||||
|
### 10.1 smoke
|
||||||
|
|
||||||
|
三个结构各执行两次独立的 20-step smoke。以下字段对每个结构都 exact:
|
||||||
|
|
||||||
|
```text
|
||||||
|
manifest
|
||||||
|
model
|
||||||
|
optimizer
|
||||||
|
hashes
|
||||||
|
evaluations
|
||||||
|
training_history
|
||||||
|
diagnostic
|
||||||
|
environment
|
||||||
|
```
|
||||||
|
|
||||||
|
### 10.2 正式独立进程 replay
|
||||||
|
|
||||||
|
预先指定:
|
||||||
|
|
||||||
|
```text
|
||||||
|
architecture = block
|
||||||
|
seed = 2026073001
|
||||||
|
steps = 2000
|
||||||
|
```
|
||||||
|
|
||||||
|
正式格与 fresh-process replay 的最终 BPC 都是:
|
||||||
|
|
||||||
|
```text
|
||||||
|
1.947877975922777
|
||||||
|
```
|
||||||
|
|
||||||
|
上面的八组冻结字段全部 exact。计时不要求 exact,实际也不相等,因为 wall time 受系统
|
||||||
|
调度影响。
|
||||||
|
|
||||||
|
| 文件 | SHA-256 |
|
||||||
|
|---|---|
|
||||||
|
| formal block / seed 1 | `5df870369d9a86ccb4ba4191fbd1d6f3642893dd47a60f8f6d1143006bdfbdaf` |
|
||||||
|
| fresh replay | `e74d3323e5fe31378bb8aad7a8efa2fb91995cd7224c158cf03006466cdea2a7` |
|
||||||
|
|
||||||
|
### 10.3 公开产物
|
||||||
|
|
||||||
|
| 产物 | 内容 | SHA-256 |
|
||||||
|
|---|---|---|
|
||||||
|
| `src/data/k3-attnres-reduced.json` | 9 个完整 run + 聚合 + 复现记录 | `44f8622654d32485f8d6e698c02ba1365ddffb10cbd73db0294136d0bd93ce88` |
|
||||||
|
| `src/data/k3-attnres-reduced-compact.json` | 网站所需完整曲线与诊断 | `44864d48eddb2ae5887fba4b74f63b5a3d6a23497886ee307decf5b4f45d9faf` |
|
||||||
|
| `experiments/k3/attnres/reproduction.json` | smoke、初始化与 replay audit | `545543b7e4a970ca3bc0e6246610a32fb53ec3d9546a98e0f17f38d7121918a2` |
|
||||||
|
|
||||||
|
聚合器在同一批只读 run 文件上再次运行后,三个文件 SHA-256 全部不变。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 11. 证据等级
|
||||||
|
|
||||||
|
### A. 本轮可直接主张
|
||||||
|
|
||||||
|
- 冻结协议下 9 个训练格的最终 BPC 与完整验证曲线;
|
||||||
|
- Full / Block 相对 Baseline 的三 seed 配对方向;
|
||||||
|
- 当前实现的参数量、实测 step time 与 peak allocated memory;
|
||||||
|
- 固定诊断窗口上的 residual RMS、mixer 权重与参数梯度统计;
|
||||||
|
- smoke 与指定正式格的独立进程 exact replay;
|
||||||
|
- 数据、窗口、初始化和产物 SHA-256。
|
||||||
|
|
||||||
|
### B. 只能作为机制解释
|
||||||
|
|
||||||
|
- Block 的四层锯齿与块边界重混合一致;
|
||||||
|
- Full mixer 可能通过降低权重抑制高 RMS source;
|
||||||
|
- Full / Block 的短预算优势可能来自更灵活的深度路由。
|
||||||
|
|
||||||
|
这些解释与观测相容,但不是唯一因果解释。
|
||||||
|
|
||||||
|
### C. 本轮明确不主张
|
||||||
|
|
||||||
|
- K3 checkpoint 已成功 forward 或训练;
|
||||||
|
- 论文表格、Figure 4–8 或 paper-scale scaling 已复现;
|
||||||
|
- AttnRes 在任意模型、数据和预算上都降低 loss;
|
||||||
|
- Block 一般优于 Full;
|
||||||
|
- 梯度在 AttnRes 中更均匀;
|
||||||
|
- 同 FLOPs、同 wall time 或生产系统的性价比优势;
|
||||||
|
- 三个 seed 支持总体统计显著性。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 12. 下一步
|
||||||
|
|
||||||
|
这个实验把“能运行的独立机制 probe”完成了,但真实 K3 仍有两道门:
|
||||||
|
|
||||||
|
1. `A_log [128]` 的官方转换或权重修订;
|
||||||
|
2. 能加载完整或官方切分 K3 的受支持执行环境。
|
||||||
|
|
||||||
|
AttnRes 本身的下一轮也不应只增加 seed。优先级更高的是:
|
||||||
|
|
||||||
|
- 对齐论文实际使用的 activation / output-gradient 诊断定义;
|
||||||
|
- 增加 depth 与训练预算,检验梯度结论是否随尺度翻转;
|
||||||
|
- 做 mixer 计算的优化实现,再讨论同 wall-time 或近似同-FLOP 对比;
|
||||||
|
- 冻结一个更强 tokenizer / corpus 后检查 byte-level 结论是否保持;
|
||||||
|
- 将 Block size 作为预注册变量,而不是看完结果后挑 4。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 13. 一手来源
|
||||||
|
|
||||||
|
- [Kimi K3 Technical Report](https://arxiv.org/abs/2607.24653)
|
||||||
|
- [Kimi K3 official checkpoint](https://huggingface.co/moonshotai/Kimi-K3)
|
||||||
|
- [Kimi K3 official code repository](https://github.com/MoonshotAI/Kimi-K3)
|
||||||
|
- [Attention Residuals](https://arxiv.org/abs/2603.15031)
|
||||||
|
- [Official Attention Residuals implementation](https://github.com/MoonshotAI/Attention-Residuals)
|
||||||
|
- [WikiText dataset repository](https://huggingface.co/datasets/Salesforce/wikitext)
|
||||||
|
- [vLLM Kimi K3 implementation](https://github.com/vllm-project/vllm)
|
||||||
|
- [SGLang Kimi K3 implementation](https://github.com/sgl-project/sglang)
|
||||||
|
|
||||||
|
Grok CLI 在协议冻结前只承担一次对抗式方法审阅:它提出锁定参数容量、残差拓扑、数据顺序、
|
||||||
|
指标定义和复现合同的检查项。所有论文事实和实验结论仍由一手来源、冻结代码与本地运行产物
|
||||||
|
支持;Grok 输出不作为证据来源。
|
||||||
@@ -0,0 +1,276 @@
|
|||||||
|
# Kimi K3 第四轮:Attention Residuals 独立小模型复现协议
|
||||||
|
|
||||||
|
> 协议 ID:`llm-atlas-k3-attnres-reduced-v1`
|
||||||
|
> 冻结日期:2026-07-30(Asia/Shanghai)
|
||||||
|
> 状态:正式输出前预注册
|
||||||
|
> 目标:用可在单张 RTX 5090 上完整训练、复跑和检查的小模型,验证 Attention
|
||||||
|
> Residuals 的运算合同与早期训练动力学;不冒充 K3 checkpoint forward 或原论文规模复现。
|
||||||
|
|
||||||
|
## 1. 为什么本轮不直接“跑 K3 第一层”
|
||||||
|
|
||||||
|
截至本协议冻结时,官方开放工件仍是:
|
||||||
|
|
||||||
|
- `moonshotai/Kimi-K3@9f62e4e9fffbd0a83ddd60e1c209d828994b3569`;
|
||||||
|
- K3 GitHub `MoonshotAI/Kimi-K3@7c5be9599120d7993748de66a76128614f15f210`;
|
||||||
|
- Hugging Face remote code 把 KDA `A_log` 初始化为 `[num_heads]=[96]`;
|
||||||
|
- checkpoint header 中每个 KDA `A_log` 仍为 `[128]`;
|
||||||
|
- 当前 vLLM `fa2a2589bd2a1fce0851df7fd42ffb54b6195f04` 与 SGLang
|
||||||
|
`3c1717d9b6355e48855be7cc079db3ef9958f36d` 都把参数构造成 head 轴 96,并沿该轴
|
||||||
|
sharding;没有公开的 128→96 转换合同。
|
||||||
|
|
||||||
|
因此,裁剪、重复、平均或把 `[128]` 改解释成 channel 参数都会引入未公开假设。本轮不做。
|
||||||
|
官方也没有发布可加载的 K3 reduced checkpoint;Attention Residuals 论文所述 48B/3B 模型权重
|
||||||
|
仍未公开。
|
||||||
|
|
||||||
|
## 2. 一手来源
|
||||||
|
|
||||||
|
| 工件 | 固定 revision / checksum | 本轮用途 |
|
||||||
|
|---|---|---|
|
||||||
|
| Kimi K3 HF | `9f62e4e9…b3569` | 说明完整 checkpoint 的执行边界 |
|
||||||
|
| Kimi K3 GitHub | `7c5be959…f210` | 报告与部署入口 |
|
||||||
|
| Attention Residuals GitHub | `85e22310fe5ee860b4a023de312d791de8a5a5e6` | 官方论文与公式 |
|
||||||
|
| `Attention_Residuals.pdf` | SHA-256 `e5831b0d…a26b2f` | Full / Block AttnRes 运算合同 |
|
||||||
|
| WikiText-2 raw | `Salesforce/wikitext@b08601e04326c79dfdd32d625aee71d232d685c3` | 固定公开语料 |
|
||||||
|
|
||||||
|
Grok Headless 只承担正式输出前的对抗式方法检查,不是事实来源,也不参与结果解释。
|
||||||
|
|
||||||
|
## 3. 研究问题与声明边界
|
||||||
|
|
||||||
|
本轮只问:
|
||||||
|
|
||||||
|
1. 在核心 Transformer 权重、训练 Token、输入窗口与 optimizer 合同相同的缩小系统中,
|
||||||
|
Full / Block AttnRes 的验证 bits-per-byte 相对 PreNorm 方向是否跨三个 seed 一致?
|
||||||
|
2. 三种残差图的输入、分支输出和累计状态 RMS 怎样随深度变化?
|
||||||
|
3. 固定诊断 batch 上,每个 Transformer block 的参数梯度 RMS 怎样分布?
|
||||||
|
4. zero-init pseudo-query 经过训练后,是否出现邻近来源、embedding 和远层来源的可见分工?
|
||||||
|
5. 额外残差运算带来多少实际 step time 与 peak allocated memory?
|
||||||
|
|
||||||
|
本轮不能回答:
|
||||||
|
|
||||||
|
- K3 2.8T checkpoint 的真实 hidden state、router load 或 cache trace;
|
||||||
|
- 原论文 194M–528M activated / 38.7B–119B Token scaling law;
|
||||||
|
- AttnRes 的 benchmark 能力、长上下文质量或生产吞吐;
|
||||||
|
- KDA、MLA、MoE 与 AttnRes 的联合因果贡献;
|
||||||
|
- 任意总体显著性、p-value 或跨数据集普适性。
|
||||||
|
|
||||||
|
## 4. 数据合同
|
||||||
|
|
||||||
|
下载并校验:
|
||||||
|
|
||||||
|
```text
|
||||||
|
wikitext-2-raw-v1/train-00000-of-00001.parquet
|
||||||
|
wikitext-2-raw-v1/validation-00000-of-00001.parquet
|
||||||
|
wikitext-2-raw-v1/test-00000-of-00001.parquet
|
||||||
|
```
|
||||||
|
|
||||||
|
预处理固定为:
|
||||||
|
|
||||||
|
1. 按 parquet 行序读取 `text`;
|
||||||
|
2. 每行原文后追加一个 `\n`;
|
||||||
|
3. UTF-8 编码,不做 Unicode normalization、去空行、大小写或空白改写;
|
||||||
|
4. 词表固定为 256 个原始 byte;
|
||||||
|
5. 每个样本取连续 `context+1=257` bytes,前 256 预测后 256。
|
||||||
|
|
||||||
|
训练第 `step`、第 `row` 的起点:
|
||||||
|
|
||||||
|
```text
|
||||||
|
z = first 8 bytes of SHA256(
|
||||||
|
protocol_id + "\0train-window\0" + seed + "\0" + step + "\0" + row
|
||||||
|
)
|
||||||
|
start = uint64_be(z) mod (len(train_bytes) - 257)
|
||||||
|
```
|
||||||
|
|
||||||
|
因此同一 seed 的三种架构逐 step、逐 row 使用完全相同的 token tensor,不依赖 Python、NumPy
|
||||||
|
或 CUDA RNG 的消费顺序。
|
||||||
|
|
||||||
|
验证窗口固定 64 条,诊断窗口固定 16 条,分别用标签 `validation-window` 与
|
||||||
|
`diagnostic-window`、固定 index 取 SHA-256 起点;它们对全部 seed / 架构相同。
|
||||||
|
|
||||||
|
manifest 必须记录:
|
||||||
|
|
||||||
|
- dataset revision、三个 parquet SHA-256;
|
||||||
|
- 拼接后 split byte length 与 SHA-256;
|
||||||
|
- 训练 seed×step×row 的总 window-schedule hash;
|
||||||
|
- validation / diagnostic tensor hash。
|
||||||
|
|
||||||
|
## 5. 模型合同
|
||||||
|
|
||||||
|
所有模型:
|
||||||
|
|
||||||
|
| 项 | 固定值 |
|
||||||
|
|---|---:|
|
||||||
|
| vocabulary | 256 bytes |
|
||||||
|
| context | 256 |
|
||||||
|
| Transformer blocks | 16 |
|
||||||
|
| residual sublayers | 32(每块 attention + MLP) |
|
||||||
|
| `d_model` | 192 |
|
||||||
|
| heads | 6 |
|
||||||
|
| head dimension | 32 |
|
||||||
|
| `d_ff` | 768 |
|
||||||
|
| dropout | 0 |
|
||||||
|
| positional embedding | learned absolute, 256 × 192 |
|
||||||
|
| norm | RMSNorm, `eps=1e-6` |
|
||||||
|
| attention | causal multi-head softmax,score 用 FP32 softmax |
|
||||||
|
| MLP | bias-free SwiGLU,two `192→768` projections + one `768→192` projection |
|
||||||
|
| input/output embedding | tied |
|
||||||
|
| final readout | RMSNorm 后乘 tied token embedding |
|
||||||
|
|
||||||
|
三种 residual graph:
|
||||||
|
|
||||||
|
1. **PreNorm baseline**:`h ← h + f(RMSNorm(h))`。
|
||||||
|
2. **Full AttnRes**:每个 attention / MLP 子层从 embedding 与所有早期子层输出中,
|
||||||
|
以 `softmax(q_l^T RMSNorm(source))` 选出输入;当前分支输出成为下一个独立 source;
|
||||||
|
32 个子层结束后用同型 output mixer 聚合 embedding + 32 个输出。
|
||||||
|
3. **Block AttnRes**:32 个子层按顺序冻结为 8 块、每块 4 个子层;跨块保存 8 个 block
|
||||||
|
sums,块内使用 partial sum,embedding 永远是 source 0;最后用同型 output mixer 聚合
|
||||||
|
embedding + 8 个完整 block sums。
|
||||||
|
|
||||||
|
AttnRes 每个子层增加:
|
||||||
|
|
||||||
|
- 一个 `d_model` pseudo-query,初始化严格为 0;
|
||||||
|
- 一个 `d_model` RMSNorm key weight,初始化严格为 1。
|
||||||
|
|
||||||
|
Full / Block 各自再增加一组相同结构的 output mixer。所有 bias-free linear 与 embedding 使用
|
||||||
|
`N(0, 0.02)`;attention output projection 与 MLP down projection 按
|
||||||
|
`0.02 / sqrt(2 × 16)` 缩放初始化;普通 RMSNorm 为 1。
|
||||||
|
|
||||||
|
核心 token / position embedding、attention、MLP、输入 norm 与 tied output weights 在同一 seed
|
||||||
|
的三种架构中必须逐 tensor SHA-256 exact。AttnRes 额外参数与 mixer 运算如实报告,不通过
|
||||||
|
无作用 dummy 参数伪造“完全等容量”。
|
||||||
|
|
||||||
|
本实验匹配:
|
||||||
|
|
||||||
|
- 核心 Transformer 参数;
|
||||||
|
- optimizer steps;
|
||||||
|
- 每步训练 Token;
|
||||||
|
- 逐 Token 数据顺序。
|
||||||
|
|
||||||
|
本实验**不匹配**:
|
||||||
|
|
||||||
|
- residual mixer FLOPs;
|
||||||
|
- step wall time;
|
||||||
|
- peak activation memory。
|
||||||
|
|
||||||
|
后二者正是次要观测指标,不能被用于支持“同算力下更好”。
|
||||||
|
|
||||||
|
## 6. 优化与运行合同
|
||||||
|
|
||||||
|
| 项 | 固定值 |
|
||||||
|
|---|---:|
|
||||||
|
| seeds | `2026073001, 2026073002, 2026073003` |
|
||||||
|
| formal steps | 2,000 |
|
||||||
|
| batch | 32 |
|
||||||
|
| tokens / run | 16,384,000 target bytes |
|
||||||
|
| optimizer | AdamW |
|
||||||
|
| betas | `(0.9, 0.95)` |
|
||||||
|
| epsilon | `1e-8` |
|
||||||
|
| peak LR | `3e-4` |
|
||||||
|
| min LR | `3e-5` |
|
||||||
|
| warmup | 100 steps,linear |
|
||||||
|
| decay | cosine,step 100→2,000 |
|
||||||
|
| weight decay | `0.1` for parameters with `ndim >= 2`; otherwise `0` |
|
||||||
|
| grad clip | global norm `1.0` |
|
||||||
|
| compute | BF16 autocast,FP32 optimizer state |
|
||||||
|
| device | one RTX 5090 |
|
||||||
|
| compile | off / eager |
|
||||||
|
| RNG | deterministic algorithms,`CUBLAS_WORKSPACE_CONFIG=:4096:8` |
|
||||||
|
|
||||||
|
验证发生在 step `0, 100, 250, 500, 1000, 1500, 2000`。每次使用固定 64 条窗口;
|
||||||
|
以 8 条一个 eval batch,报告 token-mean cross entropy(nats)与:
|
||||||
|
|
||||||
|
```text
|
||||||
|
bits_per_byte = cross_entropy_nats / ln(2)
|
||||||
|
```
|
||||||
|
|
||||||
|
计时:
|
||||||
|
|
||||||
|
- 前 20 个训练 step 不进入 wall-time 统计;
|
||||||
|
- step 21–2,000 每步前后 CUDA synchronize;
|
||||||
|
- step 20 后 reset peak memory stats;
|
||||||
|
- 同报 mean / median / p95 step ms、peak allocated 与 peak reserved。
|
||||||
|
|
||||||
|
## 7. 预注册指标
|
||||||
|
|
||||||
|
### 7.1 主指标
|
||||||
|
|
||||||
|
每个 seed 在 step 2,000 的验证 `bits_per_byte`:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Δ_full = Full AttnRes − PreNorm
|
||||||
|
Δ_block = Block AttnRes − PreNorm
|
||||||
|
```
|
||||||
|
|
||||||
|
只报告三个 paired delta、mean、min–max。
|
||||||
|
|
||||||
|
预注册解释规则:
|
||||||
|
|
||||||
|
- 三个 seed 全同为负,且 mean delta ≤ `−0.010 BPC`:**directional support in this reduced protocol**;
|
||||||
|
- 三个 seed 全同为正,且 mean delta ≥ `+0.010 BPC`:**directional concern in this reduced protocol**;
|
||||||
|
- 其他情况:**inconclusive at this budget**。
|
||||||
|
|
||||||
|
不报告 p-value、population CI 或“复现了论文提升”。
|
||||||
|
|
||||||
|
### 7.2 次要指标与精确定义
|
||||||
|
|
||||||
|
- `branch_output_rms[l]`:第 l 个 attention / MLP 分支输出在 batch×time×channel 上的 RMS;
|
||||||
|
- `layer_input_rms[l]`:进入第 l 个分支 norm 之前的 mixture / residual state RMS;
|
||||||
|
- `stream_state_rms[l]`:baseline 加法后的 state;Full 为新 source 输出集合的整体 RMS;
|
||||||
|
Block 为当前 partial sum 的 RMS;
|
||||||
|
- `parameter_grad_rms[block]`:固定 diagnostic batch 上、clip 前,该 block 所有核心参数梯度
|
||||||
|
拼接后的 `sqrt(sum(g²)/numel)`;不含 embedding、LM head 与 AttnRes mixer 参数;
|
||||||
|
- `depth_weights[l, source]`:固定 diagnostic batch 上 softmax 权重对 batch×time 求均值;
|
||||||
|
- `source_entropy[l]`:同一权重先逐 token 计算 entropy,再对 batch×time 求均值;
|
||||||
|
- `step_ms` 与 CUDA memory:按 §6 固定协议。
|
||||||
|
|
||||||
|
这些指标是描述性机制账,不进入主判定。
|
||||||
|
|
||||||
|
## 8. Smoke、正式运行与复现
|
||||||
|
|
||||||
|
正式输出前先跑:
|
||||||
|
|
||||||
|
- 三种架构 × seed 1;
|
||||||
|
- 20 steps;
|
||||||
|
- batch 4;
|
||||||
|
- 同一 window schedule;
|
||||||
|
- 断言无 NaN、loss finite、common-weight hashes exact;
|
||||||
|
- 在全新进程重跑相同 smoke,比较数据 hash、初始 common hash、逐 eval loss 和最终 common
|
||||||
|
checkpoint hash。
|
||||||
|
|
||||||
|
smoke 只决定实现是否可运行,不用于改变 formal 超参数或挑选架构。
|
||||||
|
|
||||||
|
正式运行顺序冻结为:
|
||||||
|
|
||||||
|
```text
|
||||||
|
seed 2026073001: baseline → full → block
|
||||||
|
seed 2026073002: baseline → full → block
|
||||||
|
seed 2026073003: baseline → full → block
|
||||||
|
```
|
||||||
|
|
||||||
|
全部 9 个 run 完成后,在全新进程复跑 `seed 2026073001 / block / 2,000 steps`,比较:
|
||||||
|
|
||||||
|
- manifest / dataset / schedule hashes;
|
||||||
|
- common initial weight hash;
|
||||||
|
- step 0–2,000 eval history;
|
||||||
|
- final common parameter hash;
|
||||||
|
- final mixer parameter hash;
|
||||||
|
- diagnostic tensors与 depth-weight hashes。
|
||||||
|
|
||||||
|
计时不要求 exact;数值字段要求 exact,若底层确定性限制导致非 exact,必须报告最大差异,
|
||||||
|
不能降低字段范围后宣称复现。
|
||||||
|
|
||||||
|
## 9. 冻结产物
|
||||||
|
|
||||||
|
```text
|
||||||
|
research/K3_ATTNRES_REDUCED_PROTOCOL.md
|
||||||
|
research/K3_ATTNRES_REDUCED_AUDIT.md
|
||||||
|
experiments/k3/attnres/build_dataset.py
|
||||||
|
experiments/k3/attnres/train.py
|
||||||
|
experiments/k3/attnres/analyze.py
|
||||||
|
experiments/k3/attnres/README.md
|
||||||
|
experiments/k3/attnres/manifest.json
|
||||||
|
src/data/k3-attnres-reduced.json
|
||||||
|
src/data/k3-attnres-reduced-compact.json
|
||||||
|
```
|
||||||
|
|
||||||
|
原始 parquet 与训练 checkpoint 留在本机 cache,不进入公开仓库;manifest、原始指标 JSON、
|
||||||
|
分析结果、代码、环境、checksum 和确定性复现账进入开源树。
|
||||||
@@ -0,0 +1,200 @@
|
|||||||
|
import { writeFileSync } from "node:fs";
|
||||||
|
|
||||||
|
const cdpPort = process.env.CDP_PORT ?? "9227";
|
||||||
|
const baseUrl = process.env.SITE_URL ?? "http://127.0.0.1:4327";
|
||||||
|
const pages = await fetch(`http://127.0.0.1:${cdpPort}/json/list`).then((response) => response.json());
|
||||||
|
const page = pages.find((entry) => entry.type === "page");
|
||||||
|
if (!page) throw new Error(`CDP ${cdpPort} 没有可用页面`);
|
||||||
|
|
||||||
|
const socket = new WebSocket(page.webSocketDebuggerUrl);
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
socket.addEventListener("open", resolve, { once: true });
|
||||||
|
socket.addEventListener("error", reject, { once: true });
|
||||||
|
});
|
||||||
|
|
||||||
|
let nextId = 0;
|
||||||
|
const pending = new Map();
|
||||||
|
const exceptions = [];
|
||||||
|
socket.addEventListener("message", (event) => {
|
||||||
|
const message = JSON.parse(event.data);
|
||||||
|
if (message.id && pending.has(message.id)) {
|
||||||
|
const { resolve, reject } = pending.get(message.id);
|
||||||
|
pending.delete(message.id);
|
||||||
|
if (message.error) reject(new Error(message.error.message));
|
||||||
|
else resolve(message.result);
|
||||||
|
}
|
||||||
|
if (message.method === "Runtime.exceptionThrown") {
|
||||||
|
exceptions.push(message.params.exceptionDetails.exception?.description ?? message.params.exceptionDetails.text);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const command = (method, params = {}) => new Promise((resolve, reject) => {
|
||||||
|
const id = ++nextId;
|
||||||
|
pending.set(id, { resolve, reject });
|
||||||
|
socket.send(JSON.stringify({ id, method, params }));
|
||||||
|
});
|
||||||
|
const pause = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
|
||||||
|
const evaluate = async (expression) => {
|
||||||
|
const result = await command("Runtime.evaluate", { expression, returnByValue: true, awaitPromise: true });
|
||||||
|
if (result.exceptionDetails) throw new Error(result.exceptionDetails.exception?.description ?? result.exceptionDetails.text);
|
||||||
|
return result.result.value;
|
||||||
|
};
|
||||||
|
const navigate = async (path) => {
|
||||||
|
await command("Page.navigate", { url: `${baseUrl}${path}` });
|
||||||
|
for (let attempt = 0; attempt < 80; attempt += 1) {
|
||||||
|
await pause(100);
|
||||||
|
if (await evaluate("document.readyState === 'complete'")) return;
|
||||||
|
}
|
||||||
|
throw new Error(`${path} 加载超时`);
|
||||||
|
};
|
||||||
|
const screenshot = async (path) => {
|
||||||
|
const result = await command("Page.captureScreenshot", { format: "png", captureBeyondViewport: false });
|
||||||
|
writeFileSync(path, Buffer.from(result.data, "base64"));
|
||||||
|
};
|
||||||
|
|
||||||
|
await command("Page.enable");
|
||||||
|
await command("Runtime.enable");
|
||||||
|
await command("Emulation.setDeviceMetricsOverride", {
|
||||||
|
width: 1440,
|
||||||
|
height: 1100,
|
||||||
|
deviceScaleFactor: 1,
|
||||||
|
mobile: false,
|
||||||
|
});
|
||||||
|
await navigate("/k3/");
|
||||||
|
|
||||||
|
const desktop = await evaluate(`(() => {
|
||||||
|
const root = document.querySelector("[data-attnres-lab]");
|
||||||
|
root.scrollIntoView({ block: "start", behavior: "instant" });
|
||||||
|
window.scrollBy(0, -78);
|
||||||
|
const text = (selector) => root.querySelector(selector)?.textContent.trim();
|
||||||
|
const panel = () => root.querySelector("[data-attnres-panel]:not([hidden])")?.dataset.attnresPanel;
|
||||||
|
const line = (architecture) => root.querySelector(\`[data-curve-series="\${architecture}"] [data-curve-line]\`)?.getAttribute("points");
|
||||||
|
|
||||||
|
const initial = {
|
||||||
|
panel: panel(),
|
||||||
|
tabs: root.querySelectorAll("[data-attnres-tab]").length,
|
||||||
|
panels: root.querySelectorAll("[data-attnres-panel]").length,
|
||||||
|
baseline: text('[data-curve-final="baseline"]'),
|
||||||
|
full: text('[data-curve-final="full"]'),
|
||||||
|
block: text('[data-curve-final="block"]'),
|
||||||
|
baselineLine: line("baseline"),
|
||||||
|
textBoundary: root.textContent.includes("不是 K3 checkpoint forward") &&
|
||||||
|
root.textContent.includes("不能写成论文梯度结果复现"),
|
||||||
|
};
|
||||||
|
|
||||||
|
root.querySelector('[data-curve-seed="0"]').click();
|
||||||
|
const seed = {
|
||||||
|
baseline: text('[data-curve-final="baseline"]'),
|
||||||
|
full: text('[data-curve-final="full"]'),
|
||||||
|
block: text('[data-curve-final="block"]'),
|
||||||
|
baselineLine: line("baseline"),
|
||||||
|
};
|
||||||
|
|
||||||
|
root.querySelector('[data-attnres-tab="rms"]').click();
|
||||||
|
const rmsInitial = {
|
||||||
|
panel: panel(),
|
||||||
|
title: text("[data-rms-title]"),
|
||||||
|
blockLine: root.querySelector('[data-rms-series="block"]').getAttribute("points"),
|
||||||
|
rhythm: root.querySelectorAll(".block-rhythm i").length,
|
||||||
|
};
|
||||||
|
root.querySelector('[data-rms-metric="branch_output_rms"]').click();
|
||||||
|
const rmsChanged = {
|
||||||
|
title: text("[data-rms-title]"),
|
||||||
|
blockLine: root.querySelector('[data-rms-series="block"]').getAttribute("points"),
|
||||||
|
};
|
||||||
|
|
||||||
|
root.querySelector('[data-attnres-tab="mixer"]').click();
|
||||||
|
const mixerInitial = {
|
||||||
|
panel: panel(),
|
||||||
|
fullVisible: !root.querySelector('[data-mixer-view="full"]').hidden,
|
||||||
|
fullRows: root.querySelectorAll('[data-mixer-view="full"] .heat-row').length,
|
||||||
|
spike: root.querySelectorAll(".spikeSource").length,
|
||||||
|
};
|
||||||
|
root.querySelector('[data-mixer-arch="block"]').click();
|
||||||
|
const mixerChanged = {
|
||||||
|
blockVisible: !root.querySelector('[data-mixer-view="block"]').hidden,
|
||||||
|
blockRows: root.querySelectorAll('[data-mixer-view="block"] .heat-row').length,
|
||||||
|
};
|
||||||
|
|
||||||
|
root.querySelector('[data-attnres-tab="gradient"]').click();
|
||||||
|
const gradient = {
|
||||||
|
panel: panel(),
|
||||||
|
cards: root.querySelectorAll(".gradient-cv article").length,
|
||||||
|
blocks: root.querySelectorAll(".gradient-grid article").length,
|
||||||
|
boundary: root.textContent.includes("BASE < FULL < BLOCK") &&
|
||||||
|
root.textContent.includes("不能写成论文梯度结果复现"),
|
||||||
|
};
|
||||||
|
|
||||||
|
root.querySelector('[data-attnres-tab="audit"]').click();
|
||||||
|
const audit = {
|
||||||
|
panel: panel(),
|
||||||
|
costs: root.querySelectorAll(".cost-grid article").length,
|
||||||
|
hashes: root.querySelectorAll(".hash-ledger code").length,
|
||||||
|
exact: root.textContent.includes("2,000 steps · 8 / 8 exact"),
|
||||||
|
claims: root.querySelectorAll(".claim-grid li").length,
|
||||||
|
};
|
||||||
|
|
||||||
|
const first = root.querySelector('[data-attnres-tab="outcome"]');
|
||||||
|
first.focus();
|
||||||
|
first.dispatchEvent(new KeyboardEvent("keydown", { key: "ArrowRight", bubbles: true }));
|
||||||
|
const keyboard = {
|
||||||
|
selected: root.querySelector('[data-attnres-tab][aria-selected="true"]').dataset.attnresTab,
|
||||||
|
panel: panel(),
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
initial, seed, rmsInitial, rmsChanged, mixerInitial, mixerChanged, gradient, audit, keyboard,
|
||||||
|
documentOverflow: document.documentElement.scrollWidth - document.documentElement.clientWidth,
|
||||||
|
};
|
||||||
|
})()`);
|
||||||
|
await pause(180);
|
||||||
|
await screenshot("/tmp/llm-atlas-k3-attnres-desktop.png");
|
||||||
|
|
||||||
|
await command("Emulation.setDeviceMetricsOverride", {
|
||||||
|
width: 390,
|
||||||
|
height: 844,
|
||||||
|
deviceScaleFactor: 1,
|
||||||
|
mobile: true,
|
||||||
|
});
|
||||||
|
await navigate("/k3/");
|
||||||
|
const mobile = await evaluate(`(() => {
|
||||||
|
const root = document.querySelector("[data-attnres-lab]");
|
||||||
|
root.scrollIntoView({ block: "start", behavior: "instant" });
|
||||||
|
window.scrollBy(0, -64);
|
||||||
|
return {
|
||||||
|
tabs: root.querySelectorAll("[data-attnres-tab]").length,
|
||||||
|
ledger: root.querySelectorAll(".trace-ledger article").length,
|
||||||
|
documentOverflow: document.documentElement.scrollWidth - document.documentElement.clientWidth,
|
||||||
|
rootOverflow: root.scrollWidth - root.clientWidth,
|
||||||
|
visiblePanel: root.querySelector("[data-attnres-panel]:not([hidden])")?.dataset.attnresPanel,
|
||||||
|
};
|
||||||
|
})()`);
|
||||||
|
await pause(180);
|
||||||
|
await screenshot("/tmp/llm-atlas-k3-attnres-mobile.png");
|
||||||
|
|
||||||
|
const report = { desktop, mobile, exceptions };
|
||||||
|
console.log(JSON.stringify(report, null, 2));
|
||||||
|
|
||||||
|
const numeric = (text) => Number.parseFloat(text.replace("−", "-"));
|
||||||
|
const failures = [];
|
||||||
|
if (desktop.initial.panel !== "outcome" || desktop.initial.tabs !== 5 || desktop.initial.panels !== 5) failures.push("五视图初始结构异常");
|
||||||
|
if (Math.abs(numeric(desktop.initial.baseline) - 1.99913) > 1e-5 || Math.abs(numeric(desktop.initial.full) - 1.98457) > 1e-5 || Math.abs(numeric(desktop.initial.block) - 1.95667) > 1e-5) failures.push("三 seed 均值 BPC 异常");
|
||||||
|
if (Math.abs(numeric(desktop.seed.baseline) - 2.00054) > 1e-5 || desktop.seed.baselineLine === desktop.initial.baselineLine) failures.push("seed 切换未更新训练曲线");
|
||||||
|
if (!desktop.initial.textBoundary) failures.push("主视区缺少 K3 forward 或梯度反证边界");
|
||||||
|
if (desktop.rmsInitial.panel !== "rms" || desktop.rmsInitial.rhythm !== 32 || desktop.rmsInitial.title === desktop.rmsChanged.title || desktop.rmsInitial.blockLine === desktop.rmsChanged.blockLine) failures.push("RMS 指标切换或 32 层节律异常");
|
||||||
|
if (desktop.mixerInitial.panel !== "mixer" || !desktop.mixerInitial.fullVisible || desktop.mixerInitial.fullRows !== 32 || desktop.mixerInitial.spike !== 1 || !desktop.mixerChanged.blockVisible || desktop.mixerChanged.blockRows !== 32) failures.push("Full/Block mixer heatmap 异常");
|
||||||
|
if (desktop.gradient.panel !== "gradient" || desktop.gradient.cards !== 4 || desktop.gradient.blocks !== 16 || !desktop.gradient.boundary) failures.push("梯度反证视图异常");
|
||||||
|
if (desktop.audit.panel !== "audit" || desktop.audit.costs !== 3 || desktop.audit.hashes !== 4 || !desktop.audit.exact || desktop.audit.claims !== 6) failures.push("成本、重放或 claim boundary 异常");
|
||||||
|
if (desktop.keyboard.selected !== "rms" || desktop.keyboard.panel !== "rms") failures.push("键盘 tab 导航异常");
|
||||||
|
if (desktop.documentOverflow > 1 || mobile.documentOverflow > 1 || mobile.rootOverflow > 1) failures.push("桌面或移动端出现文档级横向溢出");
|
||||||
|
if (mobile.tabs !== 5 || mobile.ledger !== 6 || mobile.visiblePanel !== "outcome") failures.push("移动端初始结构异常");
|
||||||
|
if (exceptions.length) failures.push(`浏览器异常:${exceptions.join(" | ")}`);
|
||||||
|
|
||||||
|
if (failures.length) {
|
||||||
|
console.error(`\nFAIL\n- ${failures.join("\n- ")}`);
|
||||||
|
process.exitCode = 1;
|
||||||
|
} else {
|
||||||
|
console.log("\nPASS K3 AttnRes browser regression");
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.close();
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import { createHash } from "node:crypto";
|
||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
|
||||||
|
const read = (path) => {
|
||||||
|
const bytes = readFileSync(new URL(path, import.meta.url));
|
||||||
|
return {
|
||||||
|
bytes,
|
||||||
|
json: JSON.parse(bytes),
|
||||||
|
sha256: createHash("sha256").update(bytes).digest("hex"),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const raw = read("../src/data/k3-attnres-reduced.json");
|
||||||
|
const compact = read("../src/data/k3-attnres-reduced-compact.json");
|
||||||
|
const reproduction = read("../experiments/k3/attnres/reproduction.json");
|
||||||
|
const failures = [];
|
||||||
|
|
||||||
|
const expect = (condition, message) => {
|
||||||
|
if (!condition) failures.push(message);
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(raw.sha256 === "44f8622654d32485f8d6e698c02ba1365ddffb10cbd73db0294136d0bd93ce88", "raw payload SHA-256 changed");
|
||||||
|
expect(compact.sha256 === "44864d48eddb2ae5887fba4b74f63b5a3d6a23497886ee307decf5b4f45d9faf", "compact payload SHA-256 changed");
|
||||||
|
expect(reproduction.sha256 === "545543b7e4a970ca3bc0e6246610a32fb53ec3d9546a98e0f17f38d7121918a2", "reproduction payload SHA-256 changed");
|
||||||
|
expect(compact.json.protocol_id === "llm-atlas-k3-attnres-reduced-v1", "protocol identity mismatch");
|
||||||
|
expect(compact.json.grid.runs === 9, "formal grid is not 9 cells");
|
||||||
|
expect(compact.json.grid.target_bytes_total === 147_456_000, "formal target-byte budget mismatch");
|
||||||
|
expect(raw.json.formal_runs.length === 9, "raw formal run count mismatch");
|
||||||
|
expect(Object.values(reproduction.json.common_initial_parameters).every((row) => row.exact), "common initial parameters are not exact within seed");
|
||||||
|
expect(Object.values(reproduction.json.smoke).every((row) => row.all_exact), "paired smoke replay mismatch");
|
||||||
|
expect(reproduction.json.formal_replay.all_numeric_and_hash_fields_exact, "formal fresh-process replay mismatch");
|
||||||
|
expect(!reproduction.json.formal_replay.timing_exact_required, "timing must not be an exact replay requirement");
|
||||||
|
|
||||||
|
const full = compact.json.final_validation.full_contrast;
|
||||||
|
const block = compact.json.final_validation.block_contrast;
|
||||||
|
expect(full.paired_deltas_bpc.length === 3 && full.paired_deltas_bpc.every((value) => value < 0), "Full paired direction mismatch");
|
||||||
|
expect(block.paired_deltas_bpc.length === 3 && block.paired_deltas_bpc.every((value) => value < 0), "Block paired direction mismatch");
|
||||||
|
expect(Math.abs(full.mean_delta_bpc - (-0.014567152672337214)) < 1e-15, "Full mean delta changed");
|
||||||
|
expect(Math.abs(block.mean_delta_bpc - (-0.04246557635602392)) < 1e-15, "Block mean delta changed");
|
||||||
|
expect(compact.json.gradients.baseline.mean_cv < compact.json.gradients.full.mean_cv, "gradient counterevidence order baseline/full changed");
|
||||||
|
expect(compact.json.gradients.full.mean_cv < compact.json.gradients.block.mean_cv, "gradient counterevidence order full/block changed");
|
||||||
|
expect(compact.json.posthoc.label.startsWith("post-hoc"), "post-hoc callout lost its evidence label");
|
||||||
|
|
||||||
|
if (failures.length) {
|
||||||
|
console.error(`FAIL K3 AttnRes data\n- ${failures.join("\n- ")}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(JSON.stringify({
|
||||||
|
protocol: compact.json.protocol_id,
|
||||||
|
formalRuns: compact.json.grid.runs,
|
||||||
|
fullMeanDeltaBpc: full.mean_delta_bpc,
|
||||||
|
blockMeanDeltaBpc: block.mean_delta_bpc,
|
||||||
|
formalReplayExact: reproduction.json.formal_replay.all_numeric_and_hash_fields_exact,
|
||||||
|
hashes: {
|
||||||
|
raw: raw.sha256,
|
||||||
|
compact: compact.sha256,
|
||||||
|
reproduction: reproduction.sha256,
|
||||||
|
},
|
||||||
|
}, null, 2));
|
||||||
|
console.log("PASS K3 AttnRes frozen data");
|
||||||
@@ -79,6 +79,8 @@ const overview = await evaluate(`(() => ({
|
|||||||
artifactPanels: document.querySelectorAll("[data-artifact-panel]").length,
|
artifactPanels: document.querySelectorAll("[data-artifact-panel]").length,
|
||||||
artifactLayers: document.querySelectorAll("[data-layer-cell]").length,
|
artifactLayers: document.querySelectorAll("[data-layer-cell]").length,
|
||||||
artifactMismatch: document.querySelector("#artifacts")?.textContent.includes("A_log [128] ≠ expected [96]"),
|
artifactMismatch: document.querySelector("#artifacts")?.textContent.includes("A_log [128] ≠ expected [96]"),
|
||||||
|
attnresTabs: document.querySelectorAll("[data-attnres-tab]").length,
|
||||||
|
attnresPanels: document.querySelectorAll("[data-attnres-panel]").length,
|
||||||
nativeVisionCorrected: document.body.textContent.includes("MoonViT‑V2 从头训练") &&
|
nativeVisionCorrected: document.body.textContent.includes("MoonViT‑V2 从头训练") &&
|
||||||
document.body.textContent.includes("同一个 next-token prediction objective"),
|
document.body.textContent.includes("同一个 next-token prediction objective"),
|
||||||
staleVisionClaim: document.body.textContent.includes("先固定语言模型训练视觉组件"),
|
staleVisionClaim: document.body.textContent.includes("先固定语言模型训练视觉组件"),
|
||||||
@@ -287,8 +289,9 @@ const mobile = await evaluate(`(() => {
|
|||||||
tabs: root.querySelectorAll("[data-k3-tab]").length,
|
tabs: root.querySelectorAll("[data-k3-tab]").length,
|
||||||
artifactTabs: document.querySelectorAll("[data-artifact-tab]").length,
|
artifactTabs: document.querySelectorAll("[data-artifact-tab]").length,
|
||||||
artifactLayers: document.querySelectorAll("[data-layer-cell]").length,
|
artifactLayers: document.querySelectorAll("[data-layer-cell]").length,
|
||||||
|
attnresTabs: document.querySelectorAll("[data-attnres-tab]").length,
|
||||||
offenders: [...document.querySelectorAll("body *")]
|
offenders: [...document.querySelectorAll("body *")]
|
||||||
.filter((node) => !node.closest(".paper-chain, .spec-table-wrap, .cache-strip, .architecture-explorer, [data-k3-lab], [data-k3-artifact-lab]"))
|
.filter((node) => !node.closest(".paper-chain, .spec-table-wrap, .cache-strip, .architecture-explorer, [data-k3-lab], [data-k3-artifact-lab], [data-attnres-lab]"))
|
||||||
.filter((node) => node.getBoundingClientRect().right > document.documentElement.clientWidth + 1)
|
.filter((node) => node.getBoundingClientRect().right > document.documentElement.clientWidth + 1)
|
||||||
.slice(0, 15)
|
.slice(0, 15)
|
||||||
.map((node) => ({
|
.map((node) => ({
|
||||||
@@ -319,11 +322,12 @@ console.log(JSON.stringify(report, null, 2));
|
|||||||
const numeric = (text) => Number.parseFloat(text.replaceAll(",", "").replace("−", "-"));
|
const numeric = (text) => Number.parseFloat(text.replaceAll(",", "").replace("−", "-"));
|
||||||
const failures = [];
|
const failures = [];
|
||||||
if (!overview.title.includes("因果环节")) failures.push("K3 二轮标题异常");
|
if (!overview.title.includes("因果环节")) failures.push("K3 二轮标题异常");
|
||||||
if (overview.sections !== 32 || overview.tocLinks !== 32) failures.push("31 个编号专题加阅读链的目录结构异常");
|
if (overview.sections !== 33 || overview.tocLinks !== 33) failures.push("32 个编号专题加阅读链的目录结构异常");
|
||||||
if (overview.ledgers !== 32 || overview.reportMap !== 9) failures.push("32 张问题账或报告地图异常");
|
if (overview.ledgers !== 32 || overview.reportMap !== 9) failures.push("32 张问题账或报告地图异常");
|
||||||
if (overview.figureAtlas !== 21 || overview.paperLinks !== 100 || overview.paperGroups < 12) failures.push("图表审计或 100 节点阅读链异常");
|
if (overview.figureAtlas !== 21 || overview.paperLinks !== 100 || overview.paperGroups < 12) failures.push("图表审计或 100 节点阅读链异常");
|
||||||
if (overview.labTabs !== 8 || overview.labPanels !== 8) failures.push("八联实验结构异常");
|
if (overview.labTabs !== 8 || overview.labPanels !== 8) failures.push("八联实验结构异常");
|
||||||
if (overview.artifactTabs !== 4 || overview.artifactPanels !== 4 || overview.artifactLayers !== 93 || !overview.artifactMismatch) failures.push("开放工件四视图、93 层条带或形状冲突异常");
|
if (overview.artifactTabs !== 4 || overview.artifactPanels !== 4 || overview.artifactLayers !== 93 || !overview.artifactMismatch) failures.push("开放工件四视图、93 层条带或形状冲突异常");
|
||||||
|
if (overview.attnresTabs !== 5 || overview.attnresPanels !== 5) failures.push("AttnRes 独立实验五视图异常");
|
||||||
if (!overview.nativeVisionCorrected || overview.staleVisionClaim) failures.push("原生多模态纠错未生效或旧错误残留");
|
if (!overview.nativeVisionCorrected || overview.staleVisionClaim) failures.push("原生多模态纠错未生效或旧错误残留");
|
||||||
if (overview.documentOverflow > 1 || mobile.documentOverflow > 1) failures.push("桌面或移动端存在文档级横向溢出");
|
if (overview.documentOverflow > 1 || mobile.documentOverflow > 1) failures.push("桌面或移动端存在文档级横向溢出");
|
||||||
if (labs.memoryInitial.panel !== "memory" || numeric(labs.memoryInitial.additiveError) <= numeric(labs.memoryInitial.deltaError)) failures.push("Delta memory 初始递推异常");
|
if (labs.memoryInitial.panel !== "memory" || numeric(labs.memoryInitial.additiveError) <= numeric(labs.memoryInitial.deltaError)) failures.push("Delta memory 初始递推异常");
|
||||||
@@ -348,7 +352,7 @@ if (artifacts.parameterChanged.shape !== "[96,128] F32" || !artifacts.parameterC
|
|||||||
if (artifacts.reproductionInitial.panel !== "reproduction" || numeric(artifacts.reproductionInitial.speedup) !== 1.85 || numeric(artifacts.reproductionInitial.localMean) < 2.6 || !artifacts.reproductionInitial.exactSuite || numeric(artifacts.reproductionInitial.cv) < 2) failures.push("FlashKDA H20、本机 exact suite 或 router 初始探针异常");
|
if (artifacts.reproductionInitial.panel !== "reproduction" || numeric(artifacts.reproductionInitial.speedup) !== 1.85 || numeric(artifacts.reproductionInitial.localMean) < 2.6 || !artifacts.reproductionInitial.exactSuite || numeric(artifacts.reproductionInitial.cv) < 2) failures.push("FlashKDA H20、本机 exact suite 或 router 初始探针异常");
|
||||||
if (numeric(artifacts.reproductionChanged.speedup) !== 3.27 || numeric(artifacts.reproductionChanged.flash) !== 0.7064 || numeric(artifacts.reproductionChanged.localMean) >= numeric(artifacts.reproductionInitial.localMean) || !artifacts.reproductionChanged.localMode.includes("FP32 state") || numeric(artifacts.reproductionChanged.cv) <= numeric(artifacts.reproductionInitial.cv) || numeric(artifacts.reproductionChanged.zero) <= numeric(artifacts.reproductionInitial.zero)) failures.push("GB200 benchmark、本机 varlen/state 或 synthetic router counterexample 未更新");
|
if (numeric(artifacts.reproductionChanged.speedup) !== 3.27 || numeric(artifacts.reproductionChanged.flash) !== 0.7064 || numeric(artifacts.reproductionChanged.localMean) >= numeric(artifacts.reproductionInitial.localMean) || !artifacts.reproductionChanged.localMode.includes("FP32 state") || numeric(artifacts.reproductionChanged.cv) <= numeric(artifacts.reproductionInitial.cv) || numeric(artifacts.reproductionChanged.zero) <= numeric(artifacts.reproductionInitial.zero)) failures.push("GB200 benchmark、本机 varlen/state 或 synthetic router counterexample 未更新");
|
||||||
if (artifacts.keyboardSelected !== "tensors" || artifacts.keyboardVisible !== "tensors") failures.push("开放工件键盘 tab 导航异常");
|
if (artifacts.keyboardSelected !== "tensors" || artifacts.keyboardVisible !== "tensors") failures.push("开放工件键盘 tab 导航异常");
|
||||||
if (!mobile.menuVisible || mobile.menuOpen !== "true" || mobile.tabs !== 8 || mobile.artifactTabs !== 4 || mobile.artifactLayers !== 93) failures.push("移动端导航或实验异常");
|
if (!mobile.menuVisible || mobile.menuOpen !== "true" || mobile.tabs !== 8 || mobile.artifactTabs !== 4 || mobile.artifactLayers !== 93 || mobile.attnresTabs !== 5) failures.push("移动端导航或实验异常");
|
||||||
if (mobile.offenders.length) failures.push(`移动端越界元素:${JSON.stringify(mobile.offenders)}`);
|
if (mobile.offenders.length) failures.push(`移动端越界元素:${JSON.stringify(mobile.offenders)}`);
|
||||||
if (exceptions.length) failures.push(`浏览器异常:${exceptions.join(" | ")}`);
|
if (exceptions.length) failures.push(`浏览器异常:${exceptions.join(" | ")}`);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,717 @@
|
|||||||
|
---
|
||||||
|
import rawLab from "@/data/k3-attnres-reduced-compact.json";
|
||||||
|
|
||||||
|
const lab = rawLab as any;
|
||||||
|
const json = JSON.stringify(lab).replaceAll("<", "\\u003c");
|
||||||
|
const architectures = ["baseline", "full", "block"];
|
||||||
|
const labels: Record<string, string> = {
|
||||||
|
baseline: "Baseline",
|
||||||
|
full: "Full AttnRes",
|
||||||
|
block: "Block AttnRes",
|
||||||
|
};
|
||||||
|
const colors: Record<string, string> = {
|
||||||
|
baseline: "#79746b",
|
||||||
|
full: "#ba603b",
|
||||||
|
block: "#163f3b",
|
||||||
|
};
|
||||||
|
const final = lab.final_validation;
|
||||||
|
const reproduction = lab.reproduction;
|
||||||
|
const formatSigned = (value: number, digits = 5) =>
|
||||||
|
`${value < 0 ? "−" : value > 0 ? "+" : ""}${Math.abs(value).toFixed(digits)}`;
|
||||||
|
const gib = (value: number) => value / 2 ** 30;
|
||||||
|
const heatOpacity = (weight: number, sources: number) =>
|
||||||
|
Math.min(1, 0.12 + Math.min(2.2, weight * sources) / 2.2 * 0.88);
|
||||||
|
const gradientMax = Math.max(
|
||||||
|
...architectures.flatMap((architecture) => lab.gradients[architecture].by_block.mean),
|
||||||
|
);
|
||||||
|
---
|
||||||
|
|
||||||
|
<figure class="attnres-trace" data-attnres-lab>
|
||||||
|
<header class="trace-head">
|
||||||
|
<div>
|
||||||
|
<p>ROUND 04 / REDUCED INDEPENDENT MECHANISM PROBE</p>
|
||||||
|
<h3>不裁剪 K3 的冲突权重:从零训练一个可以完整审计的深度路由实验</h3>
|
||||||
|
</div>
|
||||||
|
<p>
|
||||||
|
WikiText-2 byte LM · 16 blocks / 32 residual sublayers · 3 structures × 3 seeds。
|
||||||
|
这是缩小机制探针,不是 K3 checkpoint forward,也不是论文规模复现。
|
||||||
|
</p>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="trace-ledger">
|
||||||
|
<article><span>FORMAL GRID</span><b>3 × 3</b><p>9 个 2,000-step runs</p></article>
|
||||||
|
<article><span>TARGET BYTES</span><b>147.456M</b><p>每格 16,384,000</p></article>
|
||||||
|
<article><span>SHARED CORE</span><b>9.542M</b><p>同 seed 公共初始化 exact</p></article>
|
||||||
|
<article class="pass"><span>FULL Δ BPC</span><b>{formatSigned(final.full_contrast.mean_delta_bpc)}</b><p>3 / 3 paired negative</p></article>
|
||||||
|
<article class="pass"><span>BLOCK Δ BPC</span><b>{formatSigned(final.block_contrast.mean_delta_bpc)}</b><p>3 / 3 paired negative</p></article>
|
||||||
|
<article class="pass"><span>FRESH REPLAY</span><b>8 / 8 exact</b><p>timing 明确不要求 exact</p></article>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="trace-tabs" role="tablist" aria-label="选择 Attention Residuals 缩小实验视图">
|
||||||
|
<button type="button" role="tab" data-attnres-tab="outcome" aria-selected="true">
|
||||||
|
<span>01</span><b>训练曲线与配对结果</b><small>three seeds · final BPC</small>
|
||||||
|
</button>
|
||||||
|
<button type="button" role="tab" data-attnres-tab="rms" aria-selected="false" tabindex="-1">
|
||||||
|
<span>02</span><b>残差流怎样改变</b><small>RMS · block sawtooth</small>
|
||||||
|
</button>
|
||||||
|
<button type="button" role="tab" data-attnres-tab="mixer" aria-selected="false" tabindex="-1">
|
||||||
|
<span>03</span><b>深度权重读了谁</b><small>mixer heatmap · output</small>
|
||||||
|
</button>
|
||||||
|
<button type="button" role="tab" data-attnres-tab="gradient" aria-selected="false" tabindex="-1">
|
||||||
|
<span>04</span><b>没有复现的梯度故事</b><small>counterevidence · metric boundary</small>
|
||||||
|
</button>
|
||||||
|
<button type="button" role="tab" data-attnres-tab="audit" aria-selected="false" tabindex="-1">
|
||||||
|
<span>05</span><b>成本、重放与边界</b><small>compute · hashes · claims</small>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<section class="trace-panel" data-attnres-panel="outcome">
|
||||||
|
<div class="panel-lead">
|
||||||
|
<div><span>I / PREREGISTERED PRIMARY ENDPOINT</span><h4>先看三条完整曲线,再放大最后一个配对点</h4></div>
|
||||||
|
<p>
|
||||||
|
BPC 越低越好。主判据只读 step 2000:三个 seed 必须同方向,且 mean paired
|
||||||
|
delta 至少达到 −0.010;中途曲线不用于改终点。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="curve-controls" role="group" aria-label="选择训练曲线 seed">
|
||||||
|
<button type="button" data-curve-seed="mean" aria-pressed="true">3-SEED MEAN</button>
|
||||||
|
{lab.grid.seeds.map((seed: number, index: number) => (
|
||||||
|
<button type="button" data-curve-seed={String(index)} aria-pressed="false">SEED {String(seed).slice(-2)}</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="curve-layout">
|
||||||
|
<div class="curve-chart">
|
||||||
|
<header><span>VALIDATION BPC</span><b>0 → 2,000 TRAINING STEPS</b></header>
|
||||||
|
<svg viewBox="0 0 840 330" role="img" aria-label="三种结构的验证 BPC 训练曲线">
|
||||||
|
<g class="chart-grid">
|
||||||
|
{[2, 3, 4, 6, 8].map((tick) => {
|
||||||
|
const y = 20 + (8.2 - tick) / 6.4 * 260;
|
||||||
|
return <g><line x1="62" x2="818" y1={y} y2={y}></line><text x="50" y={y + 4}>{tick}</text></g>;
|
||||||
|
})}
|
||||||
|
{[0, 500, 1000, 1500, 2000].map((tick) => {
|
||||||
|
const x = 62 + tick / 2000 * 756;
|
||||||
|
return <g><line x1={x} x2={x} y1="20" y2="280"></line><text x={x} y="308">{tick}</text></g>;
|
||||||
|
})}
|
||||||
|
</g>
|
||||||
|
{architectures.map((architecture) => (
|
||||||
|
<g data-curve-series={architecture}>
|
||||||
|
<polyline
|
||||||
|
data-curve-line
|
||||||
|
fill="none"
|
||||||
|
stroke={colors[architecture]}
|
||||||
|
stroke-width={architecture === "block" ? "4" : "3"}
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
></polyline>
|
||||||
|
<g data-curve-points></g>
|
||||||
|
</g>
|
||||||
|
))}
|
||||||
|
</svg>
|
||||||
|
<div class="chart-legend">
|
||||||
|
{architectures.map((architecture) => <span style={`--legend:${colors[architecture]}`}><i></i>{labels[architecture]}</span>)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="curve-readout">
|
||||||
|
<span>STEP 2000 / SELECTED VIEW</span>
|
||||||
|
{architectures.map((architecture) => (
|
||||||
|
<article>
|
||||||
|
<i style={`--series:${colors[architecture]}`}></i>
|
||||||
|
<b>{labels[architecture]}</b>
|
||||||
|
<strong data-curve-final={architecture}>{final.means[architecture].toFixed(5)}</strong>
|
||||||
|
</article>
|
||||||
|
))}
|
||||||
|
<p data-curve-copy>三 seed 均值;正式判据使用逐 seed paired delta,不把三次运行当成 benchmark 样本总体。</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="seed-pairs">
|
||||||
|
{final.by_seed.map((row: any) => (
|
||||||
|
<article>
|
||||||
|
<header><span>SEED {String(row.seed).slice(-2)}</span><b>BASE {row.final_bpc.baseline.toFixed(5)}</b></header>
|
||||||
|
<div><span>FULL − BASE</span><strong>{formatSigned(row.full_minus_baseline, 5)}</strong></div>
|
||||||
|
<div><span>BLOCK − BASE</span><strong>{formatSigned(row.block_minus_baseline, 5)}</strong></div>
|
||||||
|
</article>
|
||||||
|
))}
|
||||||
|
<article class="verdict">
|
||||||
|
<header><span>FROZEN RULE</span><b>3 / 3 + |MEAN| ≥ .010</b></header>
|
||||||
|
<strong>DIRECTIONAL SUPPORT</strong>
|
||||||
|
<p>只在这个 reduced protocol 内;不是总体显著性,也不外推 paper scale。</p>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="trace-panel" data-attnres-panel="rms" hidden>
|
||||||
|
<div class="panel-lead">
|
||||||
|
<div><span>II / FIXED DIAGNOSTIC WINDOWS</span><h4>普通 residual 一路累加;Block 每四层重新混合</h4></div>
|
||||||
|
<p>
|
||||||
|
下面是三个 seed 在固定 16 个诊断窗口上的均值。RMS 只描述幅值,不等于信息量、有效秩或因果重要性。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="rms-controls" role="group" aria-label="选择 residual RMS 指标">
|
||||||
|
<button type="button" data-rms-metric="stream_state_rms" aria-pressed="true">STREAM / PARTIAL STATE</button>
|
||||||
|
<button type="button" data-rms-metric="layer_input_rms" aria-pressed="false">LAYER INPUT</button>
|
||||||
|
<button type="button" data-rms-metric="branch_output_rms" aria-pressed="false">BRANCH OUTPUT</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="rms-chart">
|
||||||
|
<header><span data-rms-title>STREAM / PARTIAL STATE RMS</span><b>32 RESIDUAL SUBLAYERS</b></header>
|
||||||
|
<svg viewBox="0 0 840 330" role="img" aria-label="三种结构沿 32 个残差子层的 RMS 曲线">
|
||||||
|
<g class="chart-grid">
|
||||||
|
{[0, 8, 16, 24, 32].map((tick) => {
|
||||||
|
const x = 62 + tick / 32 * 756;
|
||||||
|
return <g><line x1={x} x2={x} y1="20" y2="280"></line><text x={x} y="308">{tick}</text></g>;
|
||||||
|
})}
|
||||||
|
{[0, 0.25, 0.5, 0.75, 1].map((part) => {
|
||||||
|
const y = 20 + (1 - part) * 260;
|
||||||
|
return <g><line x1="62" x2="818" y1={y} y2={y}></line><text data-rms-tick={String(part)} x="50" y={y + 4}>—</text></g>;
|
||||||
|
})}
|
||||||
|
</g>
|
||||||
|
{architectures.map((architecture) => (
|
||||||
|
<polyline
|
||||||
|
data-rms-series={architecture}
|
||||||
|
fill="none"
|
||||||
|
stroke={colors[architecture]}
|
||||||
|
stroke-width={architecture === "block" ? "4" : "3"}
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
></polyline>
|
||||||
|
))}
|
||||||
|
</svg>
|
||||||
|
<div class="chart-legend">
|
||||||
|
{architectures.map((architecture) => <span style={`--legend:${colors[architecture]}`}><i></i>{labels[architecture]}</span>)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="block-rhythm">
|
||||||
|
<header><span>BLOCK / STREAM STATE</span><b>每四格是一个局部 residual block</b></header>
|
||||||
|
<div>
|
||||||
|
{lab.traces.block.stream_state_rms.mean.map((value: number, index: number) => (
|
||||||
|
<i
|
||||||
|
class:list={{ boundary: (index + 1) % 4 === 0 }}
|
||||||
|
style={`--height:${Math.max(8, value / 0.12 * 100)}%`}
|
||||||
|
title={`sublayer ${index + 1}: ${value.toFixed(5)}`}
|
||||||
|
><span>{index + 1}</span></i>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<p>块内通常向上累积;下一块重新读取历史 block sources 后,partial state 出现重置。锯齿是拓扑痕迹,不是自动等价于“更稳定”。</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="trace-panel" data-attnres-panel="mixer" hidden>
|
||||||
|
<div class="panel-lead">
|
||||||
|
<div><span>III / LEARNED DEPTH ROUTING</span><h4>横轴是历史 source,纵轴是当前 residual sublayer</h4></div>
|
||||||
|
<p>
|
||||||
|
每格颜色按“实际权重 ÷ 均匀权重”归一:深色代表比该行均匀读取更强。灰格表示那一层尚看不到该 source。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mixer-controls" role="group" aria-label="选择 depth mixer 结构">
|
||||||
|
<button type="button" data-mixer-arch="full" aria-pressed="true">FULL · 32 SUBLAYER SOURCES</button>
|
||||||
|
<button type="button" data-mixer-arch="block" aria-pressed="false">BLOCK · 8 BLOCK SOURCES</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{(["full", "block"] as const).map((architecture, architectureIndex) => (
|
||||||
|
<div class="mixer-view" data-mixer-view={architecture} hidden={architectureIndex !== 0}>
|
||||||
|
<div class="heatmap-scroll">
|
||||||
|
<div
|
||||||
|
class="depth-heatmap"
|
||||||
|
style={`--columns:${lab.mixers[architecture].max_sources}`}
|
||||||
|
aria-label={`${labels[architecture]} depth weight heatmap`}
|
||||||
|
>
|
||||||
|
{lab.mixers[architecture].rows.map((row: any) => (
|
||||||
|
<div class="heat-row">
|
||||||
|
<span>{String(row.sublayer).padStart(2, "0")}</span>
|
||||||
|
<div style={`--columns:${lab.mixers[architecture].max_sources}`}>
|
||||||
|
{Array.from({ length: lab.mixers[architecture].max_sources }, (_, source) =>
|
||||||
|
source < row.sources
|
||||||
|
? <i
|
||||||
|
style={`--heat:${heatOpacity(row.mean_weights[source], row.sources)}`}
|
||||||
|
title={`L${row.sublayer} ← source ${source}: ${row.mean_weights[source].toFixed(6)}`}
|
||||||
|
></i>
|
||||||
|
: <i class="empty"></i>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="output-weights">
|
||||||
|
<header><span>FINAL OUTPUT MIXER</span><b>{lab.mixers[architecture].output.sources} SOURCES · 3-SEED MEAN</b></header>
|
||||||
|
<div>
|
||||||
|
{lab.mixers[architecture].output.mean_weights.map((weight: number, source: number) => (
|
||||||
|
<i
|
||||||
|
class:list={{ spikeSource: architecture === "full" && source === 31 }}
|
||||||
|
style={`--weight:${weight / Math.max(...lab.mixers[architecture].output.mean_weights) * 100}%`}
|
||||||
|
title={`source ${source}: ${weight.toFixed(6)}`}
|
||||||
|
><span>{source}</span></i>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
|
||||||
|
<aside class="posthoc-callout">
|
||||||
|
<span>POST-HOC DESCRIPTIVE CALLOUT</span>
|
||||||
|
<div><b>SUBLAYER 31 BRANCH RMS</b><strong>{lab.posthoc.largest_full_branch_rms.toFixed(4)}</strong></div>
|
||||||
|
<i>→</i>
|
||||||
|
<div><b>FINAL MIXER WEIGHT</b><strong>{lab.posthoc.corresponding_final_output_weight.toFixed(6)}</strong></div>
|
||||||
|
<i>→</i>
|
||||||
|
<div><b>RELATIVE TO UNIFORM</b><strong>{lab.posthoc.weight_over_uniform.toFixed(3)}×</strong></div>
|
||||||
|
<p>高幅值 source 同时被最终 mixer 强烈降权,与“学习抑制异常 source”相容;这是事后观察,不是预注册证据。</p>
|
||||||
|
</aside>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="trace-panel" data-attnres-panel="gradient" hidden>
|
||||||
|
<div class="panel-lead">
|
||||||
|
<div><span>IV / PREREGISTERED COUNTEREVIDENCE</span><h4>BPC 支持,不代表每一种机制解释都同时得到支持</h4></div>
|
||||||
|
<p>
|
||||||
|
指标是每个 Transformer block 的公共核心参数 gradient RMS,再看 16 个 block 的变异系数。
|
||||||
|
CV 越低,按这一定义才越均匀。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="gradient-cv">
|
||||||
|
{architectures.map((architecture) => (
|
||||||
|
<article class:list={{ warning: architecture !== "baseline" }}>
|
||||||
|
<span>{labels[architecture]}</span>
|
||||||
|
<b>{lab.gradients[architecture].mean_cv.toFixed(4)}</b>
|
||||||
|
<p>seed CV · {lab.gradients[architecture].cv_by_seed.map((value: number) => value.toFixed(3)).join(" / ")}</p>
|
||||||
|
</article>
|
||||||
|
))}
|
||||||
|
<article class="verdict">
|
||||||
|
<span>OBSERVED ORDER</span>
|
||||||
|
<b>BASE < FULL < BLOCK</b>
|
||||||
|
<p>本指标下 AttnRes 更不均匀,不能写成论文梯度结果复现。</p>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="gradient-depth">
|
||||||
|
<header><span>CORE-PARAMETER GRADIENT RMS</span><b>3-SEED MEAN BY TRANSFORMER BLOCK</b></header>
|
||||||
|
<div class="gradient-grid">
|
||||||
|
{Array.from({ length: 16 }, (_, block) => (
|
||||||
|
<article>
|
||||||
|
<span>B{String(block + 1).padStart(2, "0")}</span>
|
||||||
|
<div>
|
||||||
|
{architectures.map((architecture) => {
|
||||||
|
const value = lab.gradients[architecture].by_block.mean[block];
|
||||||
|
return <i
|
||||||
|
style={`--bar:${value / gradientMax * 100}%;--series:${colors[architecture]}`}
|
||||||
|
title={`${labels[architecture]}: ${value.toExponential(4)}`}
|
||||||
|
></i>;
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="metric-boundary">
|
||||||
|
<article><span>THIS PROBE</span><b>core parameter gradients</b><p>16 blocks · fixed diagnostic batch · reduced model</p></article>
|
||||||
|
<i>≠</i>
|
||||||
|
<article><span>PAPER NARRATIVE</span><b>large-model depth gradients</b><p>尺度、训练阶段与聚合对象都可能不同</p></article>
|
||||||
|
<p>下一步应先对齐论文实际 activation / residual-output gradient 定义,再增加 depth 与训练预算;不能先换指标再只展示好看的图。</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="trace-panel" data-attnres-panel="audit" hidden>
|
||||||
|
<div class="panel-lead">
|
||||||
|
<div><span>V / COST + REPRODUCTION + CLAIM BOUNDARY</span><h4>近似同参数,不是同计算;数值 exact,不要求计时 exact</h4></div>
|
||||||
|
<p>
|
||||||
|
Full / Block 只增加 12,672 个 mixer 参数,但教学实现必须保存、归一化并混合历史 states,
|
||||||
|
所以参数开销小不等于执行开销小。
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="cost-grid">
|
||||||
|
{architectures.map((architecture) => (
|
||||||
|
<article>
|
||||||
|
<header><span>{labels[architecture]}</span><b>{lab.parameters[architecture].total.toLocaleString("en-US")} PARAMS</b></header>
|
||||||
|
<div><span>MEAN STEP</span><strong>{lab.timing[architecture].mean_step_ms.toFixed(2)} ms</strong></div>
|
||||||
|
<div><span>PEAK ALLOCATED</span><strong>{gib(lab.timing[architecture].mean_peak_allocated_bytes).toFixed(2)} GiB</strong></div>
|
||||||
|
<p>{architecture === "baseline"
|
||||||
|
? "1.00× time · 1.00× memory"
|
||||||
|
: `${lab.timing.relative_to_baseline[architecture].step_time_ratio.toFixed(2)}× time · ${lab.timing.relative_to_baseline[architecture].allocated_memory_ratio.toFixed(2)}× memory`}</p>
|
||||||
|
</article>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="replay-chain">
|
||||||
|
<article><span>FREEZE</span><b>protocol + manifest</b><p>{lab.dataset.schedule_sha256.slice(0, 12)}… schedule</p></article>
|
||||||
|
<i>→</i>
|
||||||
|
<article><span>SMOKE</span><b>3 × two processes</b><p>eight frozen fields exact</p></article>
|
||||||
|
<i>→</i>
|
||||||
|
<article><span>FORMAL</span><b>9 / 9 complete</b><p>budget · init · finite checks</p></article>
|
||||||
|
<i>→</i>
|
||||||
|
<article class="pass"><span>REPLAY</span><b>Block / seed 01</b><p>2,000 steps · 8 / 8 exact</p></article>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="hash-ledger">
|
||||||
|
<article><span>MANIFEST</span><code>{reproduction.manifest_sha256}</code></article>
|
||||||
|
<article><span>FORMAL REPLAY SOURCE</span><code>{reproduction.formal_replay.formal_file_sha256}</code></article>
|
||||||
|
<article><span>FRESH REPLAY</span><code>{reproduction.formal_replay.replay_file_sha256}</code></article>
|
||||||
|
<article><span>COMPACT PAYLOAD</span><code>{lab.canonical_sha256_without_self}</code></article>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="claim-grid">
|
||||||
|
<article class="yes">
|
||||||
|
<span>可以说</span>
|
||||||
|
<ul>
|
||||||
|
<li>冻结的缩小协议中,两种 AttnRes 的 BPC 配对方向都为负。</li>
|
||||||
|
<li>Block partial-state RMS 每四层出现与拓扑一致的重置。</li>
|
||||||
|
<li>指定 2,000-step run 在全新进程中数值与哈希字段 exact。</li>
|
||||||
|
</ul>
|
||||||
|
</article>
|
||||||
|
<article class="no">
|
||||||
|
<span>不可以说</span>
|
||||||
|
<ul>
|
||||||
|
<li>K3 checkpoint 已 forward,或论文规模收益已经复现。</li>
|
||||||
|
<li>这是同 FLOPs / 同 wall-time 优势,或 Block 普遍优于 Full。</li>
|
||||||
|
<li>AttnRes 梯度更均匀;本轮预注册指标恰好给出相反结果。</li>
|
||||||
|
</ul>
|
||||||
|
</article>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<script is:inline type="application/json" data-attnres-data set:html={json}></script>
|
||||||
|
</figure>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
type AttnResArchitecture = "baseline" | "full" | "block";
|
||||||
|
type AttnResRmsMetric = "stream_state_rms" | "layer_input_rms" | "branch_output_rms";
|
||||||
|
|
||||||
|
const initializeAttnRes = (root: HTMLElement) => {
|
||||||
|
if (root.dataset.ready === "true") return;
|
||||||
|
root.dataset.ready = "true";
|
||||||
|
const dataNode = root.querySelector("[data-attnres-data]");
|
||||||
|
const data: any = JSON.parse(dataNode?.textContent || "{}");
|
||||||
|
const architectures: AttnResArchitecture[] = ["baseline", "full", "block"];
|
||||||
|
const labels: Record<AttnResArchitecture, string> = { baseline: "Baseline", full: "Full AttnRes", block: "Block AttnRes" };
|
||||||
|
const colors: Record<AttnResArchitecture, string> = { baseline: "#79746b", full: "#ba603b", block: "#163f3b" };
|
||||||
|
|
||||||
|
const tabs = [...root.querySelectorAll<HTMLButtonElement>("[data-attnres-tab]")];
|
||||||
|
const panels = [...root.querySelectorAll<HTMLElement>("[data-attnres-panel]")];
|
||||||
|
const selectTab = (id: string | undefined) => {
|
||||||
|
tabs.forEach((tab) => {
|
||||||
|
const selected = tab.dataset.attnresTab === id;
|
||||||
|
tab.setAttribute("aria-selected", String(selected));
|
||||||
|
tab.tabIndex = selected ? 0 : -1;
|
||||||
|
});
|
||||||
|
panels.forEach((panel) => { panel.hidden = panel.dataset.attnresPanel !== id; });
|
||||||
|
};
|
||||||
|
tabs.forEach((tab, index) => {
|
||||||
|
tab.addEventListener("click", () => selectTab(tab.dataset.attnresTab));
|
||||||
|
tab.addEventListener("keydown", (event: KeyboardEvent) => {
|
||||||
|
if (!["ArrowRight", "ArrowLeft", "Home", "End"].includes(event.key)) return;
|
||||||
|
event.preventDefault();
|
||||||
|
let next = index;
|
||||||
|
if (event.key === "ArrowRight") next = (index + 1) % tabs.length;
|
||||||
|
if (event.key === "ArrowLeft") next = (index - 1 + tabs.length) % tabs.length;
|
||||||
|
if (event.key === "Home") next = 0;
|
||||||
|
if (event.key === "End") next = tabs.length - 1;
|
||||||
|
selectTab(tabs[next].dataset.attnresTab);
|
||||||
|
tabs[next].focus();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const curveButtons = [...root.querySelectorAll<HTMLButtonElement>("[data-curve-seed]")];
|
||||||
|
const curvePoint = (step: number, value: number) => {
|
||||||
|
const x = 62 + step / 2000 * 756;
|
||||||
|
const y = 20 + (8.2 - value) / 6.4 * 260;
|
||||||
|
return [x, y];
|
||||||
|
};
|
||||||
|
const updateCurve = (seedKey: string | undefined) => {
|
||||||
|
const seedIndex = seedKey === "mean" ? -1 : Number(seedKey);
|
||||||
|
architectures.forEach((architecture) => {
|
||||||
|
const values: { step: number; value: number }[] = data.evaluation_curves[architecture].map((row: any) => ({
|
||||||
|
step: row.step,
|
||||||
|
value: seedIndex < 0 ? row.mean_bpc : row.by_seed[seedIndex],
|
||||||
|
}));
|
||||||
|
const group = root.querySelector(`[data-curve-series="${architecture}"]`);
|
||||||
|
const polyline = group?.querySelector("[data-curve-line]");
|
||||||
|
polyline?.setAttribute("points", values.map((row) => curvePoint(row.step, row.value).join(",")).join(" "));
|
||||||
|
const points = group?.querySelector("[data-curve-points]");
|
||||||
|
if (points) {
|
||||||
|
points.innerHTML = values.map((row: { step: number; value: number }) => {
|
||||||
|
const [x, y] = curvePoint(row.step, row.value);
|
||||||
|
return `<circle cx="${x}" cy="${y}" r="4.2" fill="${colors[architecture]}"><title>${labels[architecture]} · step ${row.step}: ${row.value.toFixed(5)} BPC</title></circle>`;
|
||||||
|
}).join("");
|
||||||
|
}
|
||||||
|
const finalNode = root.querySelector<HTMLElement>(`[data-curve-final="${architecture}"]`);
|
||||||
|
const finalValue = values[values.length - 1]?.value;
|
||||||
|
if (finalNode && Number.isFinite(finalValue)) finalNode.textContent = finalValue.toFixed(5);
|
||||||
|
});
|
||||||
|
const copy = root.querySelector<HTMLElement>("[data-curve-copy]");
|
||||||
|
if (copy) copy.textContent = seedIndex < 0
|
||||||
|
? "三 seed 均值;正式判据使用逐 seed paired delta,不把三次运行当成 benchmark 样本总体。"
|
||||||
|
: `初始化 seed ${data.grid.seeds[seedIndex]};三种结构共享这一 seed 的公共参数与全部训练窗口。`;
|
||||||
|
curveButtons.forEach((button) => button.setAttribute("aria-pressed", String(button.dataset.curveSeed === seedKey)));
|
||||||
|
};
|
||||||
|
curveButtons.forEach((button) => button.addEventListener("click", () => updateCurve(button.dataset.curveSeed)));
|
||||||
|
updateCurve("mean");
|
||||||
|
|
||||||
|
const rmsButtons = [...root.querySelectorAll<HTMLButtonElement>("[data-rms-metric]")];
|
||||||
|
const rmsTitles: Record<AttnResRmsMetric, string> = {
|
||||||
|
stream_state_rms: "STREAM / PARTIAL STATE RMS",
|
||||||
|
layer_input_rms: "LAYER INPUT RMS",
|
||||||
|
branch_output_rms: "BRANCH OUTPUT RMS",
|
||||||
|
};
|
||||||
|
const updateRms = (metric: AttnResRmsMetric) => {
|
||||||
|
const all: number[] = architectures.flatMap((architecture) => data.traces[architecture][metric].mean);
|
||||||
|
const maximum = Math.max(...all) * 1.06;
|
||||||
|
architectures.forEach((architecture) => {
|
||||||
|
const values: number[] = data.traces[architecture][metric].mean;
|
||||||
|
const points = values.map((value: number, index: number) => {
|
||||||
|
const x = 62 + (index + 1) / 32 * 756;
|
||||||
|
const y = 20 + (1 - value / maximum) * 260;
|
||||||
|
return `${x},${y}`;
|
||||||
|
}).join(" ");
|
||||||
|
root.querySelector(`[data-rms-series="${architecture}"]`)?.setAttribute("points", points);
|
||||||
|
});
|
||||||
|
root.querySelectorAll<HTMLElement>("[data-rms-tick]").forEach((node) => {
|
||||||
|
node.textContent = (Number(node.dataset.rmsTick) * maximum).toFixed(maximum >= 1 ? 2 : 3);
|
||||||
|
});
|
||||||
|
const title = root.querySelector<HTMLElement>("[data-rms-title]");
|
||||||
|
if (title) title.textContent = rmsTitles[metric];
|
||||||
|
rmsButtons.forEach((button) => button.setAttribute("aria-pressed", String(button.dataset.rmsMetric === metric)));
|
||||||
|
};
|
||||||
|
rmsButtons.forEach((button) => button.addEventListener("click", () => updateRms(button.dataset.rmsMetric as AttnResRmsMetric)));
|
||||||
|
updateRms("stream_state_rms");
|
||||||
|
|
||||||
|
const mixerButtons = [...root.querySelectorAll<HTMLButtonElement>("[data-mixer-arch]")];
|
||||||
|
const mixerViews = [...root.querySelectorAll<HTMLElement>("[data-mixer-view]")];
|
||||||
|
const updateMixer = (architecture: "full" | "block") => {
|
||||||
|
mixerButtons.forEach((button) => button.setAttribute("aria-pressed", String(button.dataset.mixerArch === architecture)));
|
||||||
|
mixerViews.forEach((view) => { view.hidden = view.dataset.mixerView !== architecture; });
|
||||||
|
};
|
||||||
|
mixerButtons.forEach((button) => button.addEventListener("click", () => updateMixer(button.dataset.mixerArch as "full" | "block")));
|
||||||
|
};
|
||||||
|
|
||||||
|
document.querySelectorAll<HTMLElement>("[data-attnres-lab]").forEach(initializeAttnRes);
|
||||||
|
document.addEventListener("astro:page-load", () => {
|
||||||
|
document.querySelectorAll<HTMLElement>("[data-attnres-lab]").forEach(initializeAttnRes);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.attnres-trace {
|
||||||
|
--trace-ink: #1c201e;
|
||||||
|
--trace-muted: #77746b;
|
||||||
|
--trace-line: rgba(28, 32, 30, .16);
|
||||||
|
--trace-paper: #f4f0e7;
|
||||||
|
--trace-raised: #faf7ef;
|
||||||
|
--trace-copper: #ba603b;
|
||||||
|
--trace-green: #163f3b;
|
||||||
|
width: min(1120px, 100%);
|
||||||
|
margin: 42px 0;
|
||||||
|
color: var(--trace-ink);
|
||||||
|
border: 1px solid var(--trace-line);
|
||||||
|
background: var(--trace-paper);
|
||||||
|
box-shadow: 0 30px 80px rgba(28, 32, 30, .09);
|
||||||
|
}
|
||||||
|
.trace-head {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(0, 1.45fr) minmax(260px, .7fr);
|
||||||
|
gap: 44px;
|
||||||
|
padding: 30px;
|
||||||
|
color: #f5efe4;
|
||||||
|
background: var(--trace-green);
|
||||||
|
}
|
||||||
|
.trace-head p { margin: 0; color: rgba(245, 239, 228, .7); font: .65rem/1.7 var(--mono); }
|
||||||
|
.trace-head div > p { color: #d58a68; letter-spacing: .08em; }
|
||||||
|
.trace-head h3 { max-width: 720px; margin: 14px 0 0; color: inherit; font-size: clamp(1.15rem, 2.2vw, 1.75rem); line-height: 1.35; }
|
||||||
|
.trace-ledger {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(6, 1fr);
|
||||||
|
border-bottom: 1px solid var(--trace-line);
|
||||||
|
}
|
||||||
|
.trace-ledger article { min-height: 126px; padding: 18px 15px; border-right: 1px solid var(--trace-line); }
|
||||||
|
.trace-ledger article:last-child { border-right: 0; }
|
||||||
|
.trace-ledger span, .panel-lead span, .output-weights span, .gradient-depth header span {
|
||||||
|
color: var(--trace-muted); font: .56rem/1.2 var(--mono); letter-spacing: .08em;
|
||||||
|
}
|
||||||
|
.trace-ledger b { display: block; margin-top: 23px; font: 700 1rem/1 var(--mono); }
|
||||||
|
.trace-ledger p { margin: 8px 0 0; color: var(--trace-muted); font-size: .6rem; line-height: 1.45; }
|
||||||
|
.trace-ledger .pass { color: #f7f0e6; background: var(--trace-copper); }
|
||||||
|
.trace-ledger .pass span, .trace-ledger .pass p { color: rgba(247, 240, 230, .74); }
|
||||||
|
.trace-tabs {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(5, 1fr);
|
||||||
|
border-bottom: 1px solid var(--trace-line);
|
||||||
|
background: #e9e4da;
|
||||||
|
}
|
||||||
|
.trace-tabs button {
|
||||||
|
min-height: 112px;
|
||||||
|
padding: 16px;
|
||||||
|
text-align: left;
|
||||||
|
color: inherit;
|
||||||
|
border: 0;
|
||||||
|
border-right: 1px solid var(--trace-line);
|
||||||
|
background: transparent;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.trace-tabs button:last-child { border-right: 0; }
|
||||||
|
.trace-tabs button[aria-selected="true"] { color: #f7f0e6; background: var(--trace-copper); }
|
||||||
|
.trace-tabs span, .trace-tabs small { display: block; color: var(--trace-muted); font: .55rem/1.2 var(--mono); }
|
||||||
|
.trace-tabs b { display: block; margin: 15px 0 8px; font-size: .71rem; }
|
||||||
|
.trace-tabs button[aria-selected="true"] span, .trace-tabs button[aria-selected="true"] small { color: rgba(247, 240, 230, .72); }
|
||||||
|
.trace-panel { padding: 30px; }
|
||||||
|
.panel-lead { display: grid; grid-template-columns: 1.05fr .95fr; gap: 48px; align-items: end; margin-bottom: 28px; }
|
||||||
|
.panel-lead h4 { max-width: 680px; margin: 10px 0 0; font-size: 1.2rem; line-height: 1.4; }
|
||||||
|
.panel-lead p { margin: 0; color: var(--trace-muted); font-size: .7rem; line-height: 1.7; }
|
||||||
|
.curve-controls, .rms-controls, .mixer-controls {
|
||||||
|
display: flex; flex-wrap: wrap; gap: 0; margin: 12px 0 20px;
|
||||||
|
}
|
||||||
|
.curve-controls button, .rms-controls button, .mixer-controls button {
|
||||||
|
padding: 11px 14px;
|
||||||
|
color: var(--trace-muted);
|
||||||
|
font: 700 .58rem/1 var(--mono);
|
||||||
|
border: 1px solid var(--trace-line);
|
||||||
|
background: var(--trace-raised);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.curve-controls button + button, .rms-controls button + button, .mixer-controls button + button { border-left: 0; }
|
||||||
|
.curve-controls button[aria-pressed="true"], .rms-controls button[aria-pressed="true"], .mixer-controls button[aria-pressed="true"] {
|
||||||
|
color: #fff9ef; background: var(--trace-green);
|
||||||
|
}
|
||||||
|
.curve-layout { display: grid; grid-template-columns: minmax(0, 1fr) 235px; border: 1px solid var(--trace-line); background: var(--trace-raised); }
|
||||||
|
.curve-chart { min-width: 0; padding: 18px; border-right: 1px solid var(--trace-line); }
|
||||||
|
.curve-chart header, .rms-chart header, .output-weights header, .gradient-depth header {
|
||||||
|
display: flex; justify-content: space-between; color: var(--trace-muted); font: .56rem/1 var(--mono);
|
||||||
|
}
|
||||||
|
.curve-chart svg, .rms-chart svg { display: block; width: 100%; height: auto; margin-top: 12px; overflow: visible; }
|
||||||
|
.chart-grid line { stroke: rgba(28, 32, 30, .1); stroke-width: 1; }
|
||||||
|
.chart-grid text { fill: #8b867c; font: 12px var(--mono); text-anchor: end; }
|
||||||
|
.chart-grid g:has(line[x1="62"]) text { text-anchor: end; }
|
||||||
|
.chart-grid g:not(:has(line[x1="62"])) text { text-anchor: middle; }
|
||||||
|
.chart-legend { display: flex; flex-wrap: wrap; gap: 18px; padding: 7px 4px 2px; color: var(--trace-muted); font: .58rem/1 var(--mono); }
|
||||||
|
.chart-legend span { display: inline-flex; gap: 7px; align-items: center; }
|
||||||
|
.chart-legend i { width: 22px; height: 3px; background: var(--legend); }
|
||||||
|
.curve-readout { padding: 22px 18px; }
|
||||||
|
.curve-readout > span { color: var(--trace-copper); font: .56rem/1 var(--mono); }
|
||||||
|
.curve-readout article { display: grid; grid-template-columns: 6px 1fr auto; gap: 10px; align-items: center; padding: 18px 0; border-bottom: 1px solid var(--trace-line); }
|
||||||
|
.curve-readout article i { width: 4px; height: 34px; background: var(--series); }
|
||||||
|
.curve-readout article b { font-size: .68rem; }
|
||||||
|
.curve-readout article strong { font: 700 .9rem/1 var(--mono); }
|
||||||
|
.curve-readout p { color: var(--trace-muted); font-size: .62rem; line-height: 1.55; }
|
||||||
|
.seed-pairs { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 20px; border-top: 1px solid var(--trace-line); border-left: 1px solid var(--trace-line); }
|
||||||
|
.seed-pairs article { min-height: 165px; padding: 17px; border-right: 1px solid var(--trace-line); border-bottom: 1px solid var(--trace-line); background: var(--trace-raised); }
|
||||||
|
.seed-pairs header { display: flex; justify-content: space-between; color: var(--trace-muted); font: .53rem/1 var(--mono); }
|
||||||
|
.seed-pairs article > div { display: flex; justify-content: space-between; margin-top: 24px; }
|
||||||
|
.seed-pairs article > div span { color: var(--trace-muted); font: .54rem/1 var(--mono); }
|
||||||
|
.seed-pairs article > div strong { color: var(--trace-green); font: 700 .72rem/1 var(--mono); }
|
||||||
|
.seed-pairs .verdict { color: #f7f0e6; background: var(--trace-green); }
|
||||||
|
.seed-pairs .verdict header { color: rgba(247, 240, 230, .65); }
|
||||||
|
.seed-pairs .verdict > strong { display: block; margin-top: 26px; font: 700 .8rem/1.2 var(--mono); }
|
||||||
|
.seed-pairs .verdict p { color: rgba(247, 240, 230, .7); font-size: .61rem; line-height: 1.5; }
|
||||||
|
.rms-chart { padding: 18px; border: 1px solid var(--trace-line); background: var(--trace-raised); }
|
||||||
|
.block-rhythm { margin-top: 20px; padding: 20px; color: #f7f0e6; background: var(--trace-green); }
|
||||||
|
.block-rhythm header { display: flex; justify-content: space-between; color: rgba(247, 240, 230, .68); font: .56rem/1 var(--mono); }
|
||||||
|
.block-rhythm > div { display: grid; grid-template-columns: repeat(32, 1fr); align-items: end; height: 160px; margin-top: 18px; border-bottom: 1px solid rgba(255,255,255,.3); }
|
||||||
|
.block-rhythm i { position: relative; display: block; min-height: 8px; height: min(100%, var(--height)); margin-right: 2px; background: #d4835d; }
|
||||||
|
.block-rhythm i.boundary { margin-right: 7px; }
|
||||||
|
.block-rhythm i span { position: absolute; bottom: -18px; left: 50%; color: rgba(255,255,255,.55); font: .46rem/1 var(--mono); transform: translateX(-50%); }
|
||||||
|
.block-rhythm p { margin: 35px 0 0; color: rgba(247, 240, 230, .72); font-size: .65rem; line-height: 1.6; }
|
||||||
|
.heatmap-scroll { overflow-x: auto; padding-bottom: 8px; }
|
||||||
|
.depth-heatmap { min-width: 760px; padding: 15px; border: 1px solid var(--trace-line); background: var(--trace-raised); }
|
||||||
|
.heat-row { display: grid; grid-template-columns: 28px 1fr; gap: 7px; margin-bottom: 3px; }
|
||||||
|
.heat-row > span { color: var(--trace-muted); font: .48rem/11px var(--mono); }
|
||||||
|
.heat-row > div { display: grid; grid-template-columns: repeat(var(--columns), 1fr); gap: 2px; }
|
||||||
|
.heat-row i { display: block; height: 11px; background: rgba(186, 96, 59, var(--heat)); }
|
||||||
|
.heat-row i.empty { background: rgba(28, 32, 30, .055); }
|
||||||
|
.output-weights { margin-top: 18px; padding: 18px; border: 1px solid var(--trace-line); background: var(--trace-raised); }
|
||||||
|
.output-weights > div { display: grid; grid-template-columns: repeat(auto-fit, minmax(10px, 1fr)); align-items: end; height: 170px; gap: 3px; margin-top: 15px; border-bottom: 1px solid var(--trace-line); }
|
||||||
|
.output-weights i { position: relative; display: block; height: max(3px, var(--weight)); background: var(--trace-green); }
|
||||||
|
.output-weights i.spikeSource { background: #d24e3f; }
|
||||||
|
.output-weights i span { position: absolute; bottom: -17px; left: 50%; color: var(--trace-muted); font: .43rem/1 var(--mono); transform: translateX(-50%); }
|
||||||
|
.posthoc-callout { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 16px; align-items: center; margin: 35px 0 0; padding: 22px; border-left: 5px solid var(--trace-copper); background: #ebe2d5; }
|
||||||
|
.posthoc-callout > span { grid-column: 1 / -1; color: var(--trace-copper); font: .57rem/1 var(--mono); }
|
||||||
|
.posthoc-callout div b { display: block; color: var(--trace-muted); font: .53rem/1 var(--mono); }
|
||||||
|
.posthoc-callout div strong { display: block; margin-top: 12px; font: 700 .95rem/1 var(--mono); }
|
||||||
|
.posthoc-callout > i { color: var(--trace-copper); }
|
||||||
|
.posthoc-callout > p { grid-column: 1 / -1; margin: 3px 0 0; color: var(--trace-muted); font-size: .64rem; line-height: 1.6; }
|
||||||
|
.gradient-cv { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--trace-line); border-left: 1px solid var(--trace-line); }
|
||||||
|
.gradient-cv article { min-height: 145px; padding: 18px; border-right: 1px solid var(--trace-line); border-bottom: 1px solid var(--trace-line); background: var(--trace-raised); }
|
||||||
|
.gradient-cv span { color: var(--trace-muted); font: .55rem/1 var(--mono); }
|
||||||
|
.gradient-cv b { display: block; margin-top: 25px; font: 700 1.1rem/1 var(--mono); }
|
||||||
|
.gradient-cv p { color: var(--trace-muted); font-size: .59rem; line-height: 1.5; }
|
||||||
|
.gradient-cv .warning { border-top: 4px solid var(--trace-copper); }
|
||||||
|
.gradient-cv .verdict { color: #f7f0e6; background: var(--trace-green); }
|
||||||
|
.gradient-cv .verdict span, .gradient-cv .verdict p { color: rgba(247, 240, 230, .68); }
|
||||||
|
.gradient-depth { margin-top: 20px; padding: 18px; border: 1px solid var(--trace-line); background: var(--trace-raised); }
|
||||||
|
.gradient-grid { display: grid; grid-template-columns: repeat(16, 1fr); gap: 5px; align-items: end; height: 250px; margin-top: 17px; }
|
||||||
|
.gradient-grid article { display: grid; grid-template-rows: 1fr auto; height: 100%; }
|
||||||
|
.gradient-grid article > span { grid-row: 2; margin-top: 6px; color: var(--trace-muted); font: .45rem/1 var(--mono); text-align: center; }
|
||||||
|
.gradient-grid article > div { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; align-items: end; }
|
||||||
|
.gradient-grid i { display: block; height: max(2px, var(--bar)); background: var(--series); }
|
||||||
|
.metric-boundary { display: grid; grid-template-columns: 1fr 40px 1fr; gap: 12px; align-items: center; margin-top: 20px; padding: 20px; background: #ebe2d5; }
|
||||||
|
.metric-boundary article { padding: 12px; }
|
||||||
|
.metric-boundary article span { color: var(--trace-copper); font: .55rem/1 var(--mono); }
|
||||||
|
.metric-boundary article b { display: block; margin-top: 13px; font-size: .8rem; }
|
||||||
|
.metric-boundary article p { color: var(--trace-muted); font-size: .61rem; }
|
||||||
|
.metric-boundary > i { color: var(--trace-copper); font-size: 1.2rem; text-align: center; }
|
||||||
|
.metric-boundary > p { grid-column: 1 / -1; margin: 0; padding-top: 16px; border-top: 1px solid var(--trace-line); color: var(--trace-muted); font-size: .65rem; line-height: 1.6; }
|
||||||
|
.cost-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--trace-line); border-left: 1px solid var(--trace-line); }
|
||||||
|
.cost-grid article { padding: 20px; border-right: 1px solid var(--trace-line); border-bottom: 1px solid var(--trace-line); background: var(--trace-raised); }
|
||||||
|
.cost-grid header { display: flex; justify-content: space-between; color: var(--trace-muted); font: .54rem/1 var(--mono); }
|
||||||
|
.cost-grid article > div { display: flex; justify-content: space-between; margin-top: 28px; }
|
||||||
|
.cost-grid article > div span { color: var(--trace-muted); font: .53rem/1 var(--mono); }
|
||||||
|
.cost-grid article > div strong { font: 700 .7rem/1 var(--mono); }
|
||||||
|
.cost-grid article > p { margin: 20px 0 0; padding-top: 13px; border-top: 1px solid var(--trace-line); color: var(--trace-copper); font: .58rem/1 var(--mono); }
|
||||||
|
.replay-chain { display: flex; gap: 10px; align-items: stretch; margin-top: 20px; }
|
||||||
|
.replay-chain article { flex: 1; padding: 18px; border: 1px solid var(--trace-line); background: var(--trace-raised); }
|
||||||
|
.replay-chain article.pass { color: #f7f0e6; background: var(--trace-green); }
|
||||||
|
.replay-chain span { color: var(--trace-muted); font: .54rem/1 var(--mono); }
|
||||||
|
.replay-chain article.pass span, .replay-chain article.pass p { color: rgba(247, 240, 230, .66); }
|
||||||
|
.replay-chain b { display: block; margin-top: 20px; font-size: .7rem; }
|
||||||
|
.replay-chain p { color: var(--trace-muted); font-size: .57rem; line-height: 1.5; }
|
||||||
|
.replay-chain > i { align-self: center; color: var(--trace-copper); }
|
||||||
|
.hash-ledger { display: grid; grid-template-columns: repeat(2, 1fr); margin-top: 20px; border-top: 1px solid var(--trace-line); border-left: 1px solid var(--trace-line); }
|
||||||
|
.hash-ledger article { min-width: 0; padding: 16px; border-right: 1px solid var(--trace-line); border-bottom: 1px solid var(--trace-line); background: #e9e4da; }
|
||||||
|
.hash-ledger span { display: block; color: var(--trace-muted); font: .52rem/1 var(--mono); }
|
||||||
|
.hash-ledger code { display: block; margin-top: 11px; overflow: hidden; color: var(--trace-green); font: .55rem/1.3 var(--mono); text-overflow: ellipsis; }
|
||||||
|
.claim-grid { display: grid; grid-template-columns: repeat(2, 1fr); margin-top: 20px; }
|
||||||
|
.claim-grid article { padding: 22px; }
|
||||||
|
.claim-grid .yes { color: #f7f0e6; background: var(--trace-green); }
|
||||||
|
.claim-grid .no { background: #e7d8ca; }
|
||||||
|
.claim-grid span { font: .58rem/1 var(--mono); letter-spacing: .07em; }
|
||||||
|
.claim-grid ul { margin: 18px 0 0; padding-left: 17px; }
|
||||||
|
.claim-grid li { margin-top: 10px; font-size: .65rem; line-height: 1.55; }
|
||||||
|
.claim-grid .yes span, .claim-grid .yes li { color: rgba(247, 240, 230, .78); }
|
||||||
|
@media (max-width: 920px) {
|
||||||
|
.trace-ledger { grid-template-columns: repeat(3, 1fr); }
|
||||||
|
.trace-ledger article:nth-child(3) { border-right: 0; }
|
||||||
|
.trace-tabs { grid-template-columns: repeat(3, 1fr); }
|
||||||
|
.curve-layout { grid-template-columns: 1fr; }
|
||||||
|
.curve-chart { border-right: 0; border-bottom: 1px solid var(--trace-line); }
|
||||||
|
.seed-pairs, .gradient-cv { grid-template-columns: repeat(2, 1fr); }
|
||||||
|
.gradient-grid { grid-template-columns: repeat(8, 1fr); height: 440px; }
|
||||||
|
.gradient-grid article { height: 210px; }
|
||||||
|
}
|
||||||
|
@media (max-width: 680px) {
|
||||||
|
.trace-head, .panel-lead { grid-template-columns: 1fr; gap: 20px; }
|
||||||
|
.trace-head, .trace-panel { padding: 20px; }
|
||||||
|
.trace-ledger { grid-template-columns: repeat(2, 1fr); }
|
||||||
|
.trace-ledger article:nth-child(3) { border-right: 1px solid var(--trace-line); }
|
||||||
|
.trace-ledger article:nth-child(even) { border-right: 0; }
|
||||||
|
.trace-tabs { display: flex; overflow-x: auto; }
|
||||||
|
.trace-tabs button { flex: 0 0 190px; }
|
||||||
|
.seed-pairs, .gradient-cv, .cost-grid, .hash-ledger, .claim-grid { grid-template-columns: 1fr; }
|
||||||
|
.rms-controls button, .mixer-controls button { flex: 1 0 100%; border-left: 1px solid var(--trace-line) !important; }
|
||||||
|
.block-rhythm > div { min-width: 680px; }
|
||||||
|
.block-rhythm { overflow-x: auto; }
|
||||||
|
.posthoc-callout { grid-template-columns: 1fr; }
|
||||||
|
.posthoc-callout > i { transform: rotate(90deg); text-align: center; }
|
||||||
|
.posthoc-callout > p { grid-column: 1; }
|
||||||
|
.gradient-grid { grid-template-columns: repeat(4, 1fr); height: 850px; }
|
||||||
|
.metric-boundary { grid-template-columns: 1fr; }
|
||||||
|
.metric-boundary > i { transform: rotate(90deg); }
|
||||||
|
.metric-boundary > p { grid-column: 1; }
|
||||||
|
.replay-chain { flex-direction: column; }
|
||||||
|
.replay-chain > i { transform: rotate(90deg); }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -107,7 +107,7 @@ const paths = [
|
|||||||
</div>
|
</div>
|
||||||
<aside class="hero-aside" aria-label="项目统计">
|
<aside class="hero-aside" aria-label="项目统计">
|
||||||
<span>RESEARCH CUTOFF</span>
|
<span>RESEARCH CUTOFF</span>
|
||||||
<strong>29 · 07 · 2026</strong>
|
<strong>30 · 07 · 2026</strong>
|
||||||
<p>首版持续建设中,所有动态结论带日期</p>
|
<p>首版持续建设中,所有动态结论带日期</p>
|
||||||
<div class="hero-stats">
|
<div class="hero-stats">
|
||||||
<div><b>17</b><span>核心专题</span></div>
|
<div><b>17</b><span>核心专题</span></div>
|
||||||
@@ -128,20 +128,20 @@ const paths = [
|
|||||||
<div class="release-grid">
|
<div class="release-grid">
|
||||||
<a class="release-card k3-release" href="/k3/">
|
<a class="release-card k3-release" href="/k3/">
|
||||||
<div>
|
<div>
|
||||||
<p class="eyebrow"><span>NEW / K3 ROUND 03</span> REPORT · CHECKPOINT · KERNEL · BOUNDARY</p>
|
<p class="eyebrow"><span>NEW / K3 ROUND 04</span> ATTENTION RESIDUALS · PREREGISTERED PROBE</p>
|
||||||
<h2>47 页不再压成摘要:再把 1.56 TB 开放工件接回报告</h2>
|
<h2>真实 K3 权重仍有冲突:先把一个可证伪的深度路由问题完整做完</h2>
|
||||||
<p>
|
<p>
|
||||||
在三十二张报告问题账之外,继续审计 96 个 safetensors 分片、497,220 个 tensor entries、
|
不裁剪 <code>A_log [128]</code> 冒充 96-head K3 forward;冻结相同主干、初始化、数据窗口和预算,
|
||||||
真实 KDA / MLA / MoE / MoonViT shape、小范围权重统计,并把 FlashKDA 推进到 RTX 5090
|
从零训练 Baseline / Full / Block 共 9 个 2,000-step 格。两种 AttnRes 的三 seed BPC
|
||||||
6/6 exact-match、K3 fixed / varlen 计时与未决 checkpoint 形状矛盾。
|
配对方向都为负,但梯度均匀性指标没有复现论文叙述;支持与反证在同一实验室展示。
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<dl>
|
<dl>
|
||||||
<div><dt>REPORT</dt><dd>16 Figures · 5 Tables</dd></div>
|
<div><dt>REPORT</dt><dd>16 Figures · 5 Tables</dd></div>
|
||||||
<div><dt>ARTIFACTS</dt><dd>96 shards · 497,220 entries</dd></div>
|
<div><dt>GRID</dt><dd>3 structures × 3 seeds</dd></div>
|
||||||
<div><dt>KERNEL</dt><dd>sm_120a · exact 6/6</dd></div>
|
<div><dt>REPLAY</dt><dd>2,000 steps · 8/8 exact</dd></div>
|
||||||
</dl>
|
</dl>
|
||||||
<span class="release-arrow" aria-hidden="true">从报告目录进入开放工件证据链 →</span>
|
<span class="release-arrow" aria-hidden="true">进入训练曲线、深度权重与梯度反证 →</span>
|
||||||
</a>
|
</a>
|
||||||
<a class="release-card deepseek-release" href="/deepseek/">
|
<a class="release-card deepseek-release" href="/deepseek/">
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||||
import ArchitectureExplorer from "@/components/ArchitectureExplorer.astro";
|
import ArchitectureExplorer from "@/components/ArchitectureExplorer.astro";
|
||||||
import K3ArtifactLab from "@/components/K3ArtifactLab.astro";
|
import K3ArtifactLab from "@/components/K3ArtifactLab.astro";
|
||||||
|
import K3AttnResTraceLab from "@/components/K3AttnResTraceLab.astro";
|
||||||
import K3ReportLab from "@/components/K3ReportLab.astro";
|
import K3ReportLab from "@/components/K3ReportLab.astro";
|
||||||
import { k3FigureAtlas, k3Ledgers, k3PaperChain, k3ReportMap } from "@/data/k3";
|
import { k3FigureAtlas, k3Ledgers, k3PaperChain, k3ReportMap } from "@/data/k3";
|
||||||
|
|
||||||
@@ -36,7 +37,8 @@ const toc = [
|
|||||||
["27", "xtml", "XTML 协议"],
|
["27", "xtml", "XTML 协议"],
|
||||||
["28", "lab", "八联交互实验"],
|
["28", "lab", "八联交互实验"],
|
||||||
["29", "artifacts", "开放权重工件审计"],
|
["29", "artifacts", "开放权重工件审计"],
|
||||||
["30", "audit", "21 张图表审计"],
|
["30", "attnres-reduced", "AttnRes 缩小机制实验"],
|
||||||
|
["31", "audit", "21 张图表审计"],
|
||||||
["↳", "papers", "100 节点阅读链"],
|
["↳", "papers", "100 节点阅读链"],
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -105,13 +107,13 @@ const paperGroups = [
|
|||||||
|
|
||||||
<BaseLayout
|
<BaseLayout
|
||||||
title="Kimi K3 技术报告完整深读:架构、训练、RL、系统与评测"
|
title="Kimi K3 技术报告完整深读:架构、训练、RL、系统与评测"
|
||||||
description="用三十二张问题账、二十一张图表审计、八个机制实验、四个开放工件视图与一百个一手阅读节点,逐节读懂 Kimi K3。"
|
description="用三十二张问题账、二十一张图表审计、八个机制实验、四个开放工件视图、五个 AttnRes 独立实验视图与一百个一手阅读节点,逐节读懂 Kimi K3。"
|
||||||
section="k3"
|
section="k3"
|
||||||
>
|
>
|
||||||
<header class="page-hero k3-hero">
|
<header class="page-hero k3-hero">
|
||||||
<div class="page-hero-inner">
|
<div class="page-hero-inner">
|
||||||
<div>
|
<div>
|
||||||
<p class="eyebrow"><span>ANCHOR REPORT / ROUND 03</span> KIMI K3 · REPORT → OPEN ARTIFACTS</p>
|
<p class="eyebrow"><span>ANCHOR REPORT / ROUND 04</span> KIMI K3 · REPORT → ARTIFACTS → INDEPENDENT PROBE</p>
|
||||||
<h1>不把报告压成摘要<br />把每个因果环节<br />重新展开</h1>
|
<h1>不把报告压成摘要<br />把每个因果环节<br />重新展开</h1>
|
||||||
<p class="lead">
|
<p class="lead">
|
||||||
K3 同时扩展序列、深度、宽度、视觉与 Agent 轨迹。真正值得读的不是 2.8T 这个最大数字,
|
K3 同时扩展序列、深度、宽度、视觉与 Agent 轨迹。真正值得读的不是 2.8T 这个最大数字,
|
||||||
@@ -121,11 +123,11 @@ const paperGroups = [
|
|||||||
<dl class="page-facts">
|
<dl class="page-facts">
|
||||||
<div><dt>QUESTIONS</dt><dd>32 张问题账</dd></div>
|
<div><dt>QUESTIONS</dt><dd>32 张问题账</dd></div>
|
||||||
<div><dt>REPORT</dt><dd>16 Figures · 5 Tables</dd></div>
|
<div><dt>REPORT</dt><dd>16 Figures · 5 Tables</dd></div>
|
||||||
<div><dt>LABS</dt><dd>8 个机制实验 + 4 个工件视图</dd></div>
|
<div><dt>LABS</dt><dd>8 + 4 + 5 个交互视图</dd></div>
|
||||||
<div><dt>READING</dt><dd>100 个一手 / 官方节点</dd></div>
|
<div><dt>READING</dt><dd>100 个一手 / 官方节点</dd></div>
|
||||||
<div><dt>MODEL</dt><dd>2.78T total / 104.2B active</dd></div>
|
<div><dt>MODEL</dt><dd>2.78T total / 104.2B active</dd></div>
|
||||||
<div><dt>ARTIFACTS</dt><dd>96 shards · 497,220 tensors</dd></div>
|
<div><dt>ARTIFACTS</dt><dd>96 shards · 497,220 tensors</dd></div>
|
||||||
<div><dt>STATUS</dt><dd>K3 三轮进行中</dd></div>
|
<div><dt>STATUS</dt><dd>K3 四轮 · AttnRes 实验</dd></div>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
@@ -871,8 +873,31 @@ const paperGroups = [
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section class="article-section" id="attnres-reduced">
|
||||||
|
<p class="eyebrow"><span>30</span> REDUCED ATTENTION RESIDUALS STUDY</p>
|
||||||
|
<h2>真实 K3 权重还不能诚实 forward;先把一个可证伪的 AttnRes 问题完整做完</h2>
|
||||||
|
<p class="lede">
|
||||||
|
checkpoint 的 <code>A_log [128]</code> 与 config、remote code、FlashKDA、vLLM 和 SGLang
|
||||||
|
期望的 96 heads 仍没有公开转换合同。本轮不裁剪权重冒充 K3,而是预注册一个从零训练的缩小实验:
|
||||||
|
相同 16-block Transformer、相同数据窗口与相同初始化,只改变 residual source 的读取拓扑。
|
||||||
|
</p>
|
||||||
|
<div class="artifact-callout">
|
||||||
|
<article><span>F / FROZEN</span><b>3 structures × 3 seeds</b><p>9 格各 2,000 steps;每格 16,384,000 target bytes。</p></article>
|
||||||
|
<article><span>X / OBSERVED</span><b>Full −0.01457 BPC</b><p>三个 paired seed 同为负,达到预注册 −0.010 判据。</p></article>
|
||||||
|
<article><span>X / OBSERVED</span><b>Block −0.04247 BPC</b><p>同样满足本 reduced protocol 内的方向支持规则。</p></article>
|
||||||
|
<article class="warning"><span>B / BOUNDARY</span><b>gradient CV 未复现</b><p>Baseline 0.3447;Full 0.5087;Block 0.6306。</p></article>
|
||||||
|
</div>
|
||||||
|
<K3AttnResTraceLab />
|
||||||
|
<div class="hero-actions">
|
||||||
|
<a class="button primary" href="https://git.k1412.top/wuyang/llm-atlas/src/branch/main/research/K3_ATTNRES_REDUCED_AUDIT.md">阅读完整研究审计</a>
|
||||||
|
<a class="button" href="https://git.k1412.top/wuyang/llm-atlas/src/branch/main/experiments/k3/attnres">复跑公开实验代码</a>
|
||||||
|
<a class="button" href="https://arxiv.org/abs/2603.15031">Attention Residuals 原论文</a>
|
||||||
|
<a class="button" href="https://github.com/MoonshotAI/Attention-Residuals">官方实现</a>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section class="article-section" id="audit">
|
<section class="article-section" id="audit">
|
||||||
<p class="eyebrow"><span>30</span> FIGURE & TABLE AUDIT</p>
|
<p class="eyebrow"><span>31</span> FIGURE & TABLE AUDIT</p>
|
||||||
<h2>Figure 1–16、Table 1–5:每张图究竟支持什么,不能支持什么</h2>
|
<h2>Figure 1–16、Table 1–5:每张图究竟支持什么,不能支持什么</h2>
|
||||||
<div class="figure-atlas">
|
<div class="figure-atlas">
|
||||||
{k3FigureAtlas.map(([id, report, title, contract]) => (
|
{k3FigureAtlas.map(([id, report, title, contract]) => (
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const researching = chapters.filter((chapter) => ["researching", "drafting"].inc
|
|||||||
const workstreams = [
|
const workstreams = [
|
||||||
{ label: "研究框架与规范", value: 83, next: "给 Scaling 与推理专题补逐篇图表/实验精读层级" },
|
{ label: "研究框架与规范", value: 83, next: "给 Scaling 与推理专题补逐篇图表/实验精读层级" },
|
||||||
{ label: "网站设计系统", value: 89, next: "打印样式与更多通用可视化组件" },
|
{ label: "网站设计系统", value: 89, next: "打印样式与更多通用可视化组件" },
|
||||||
{ label: "Kimi K3 深读", value: 94, next: "接入真实 hidden-state / expert-load / cache traces,并重绘报告数值图" },
|
{ label: "Kimi K3 深读", value: 96, next: "对齐 AttnRes 梯度定义并扩展深度/预算;等待 A_log 官方转换合同" },
|
||||||
{ label: "语言模型前史", value: 78, next: "逐图精读 Kneser–Ney、LSTM 与 Bahdanau,并加入真实小语料复现" },
|
{ label: "语言模型前史", value: 78, next: "逐图精读 Kneser–Ney、LSTM 与 Bahdanau,并加入真实小语料复现" },
|
||||||
{ label: "Transformer 基础", value: 79, next: "逐图精读多头电路、Pre/Post-LN 与真实 kernel / KV 配置" },
|
{ label: "Transformer 基础", value: 79, next: "逐图精读多头电路、Pre/Post-LN 与真实 kernel / KV 配置" },
|
||||||
{ label: "表示、位置与残差高速公路", value: 81, next: "加入真实 hidden-state / norm traces、长上下文位置外推复现与更多深层稳定性消融" },
|
{ label: "表示、位置与残差高速公路", value: 81, next: "加入真实 hidden-state / norm traces、长上下文位置外推复现与更多深层稳定性消融" },
|
||||||
@@ -50,7 +50,7 @@ const workstreams = [
|
|||||||
<div><dt>OVERALL</dt><dd>专题平均 {average}%</dd></div>
|
<div><dt>OVERALL</dt><dd>专题平均 {average}%</dd></div>
|
||||||
<div><dt>READABLE</dt><dd>{published} 个首版可读专题</dd></div>
|
<div><dt>READABLE</dt><dd>{published} 个首版可读专题</dd></div>
|
||||||
<div><dt>ACTIVE</dt><dd>{researching} 个研究/写作中</dd></div>
|
<div><dt>ACTIVE</dt><dd>{researching} 个研究/写作中</dd></div>
|
||||||
<div><dt>UPDATED</dt><dd>2026-07-30 04:00 CST</dd></div>
|
<div><dt>UPDATED</dt><dd>2026-07-30 07:30 CST</dd></div>
|
||||||
<div><dt>MODE</dt><dd>持续迭代,不锁死版本</dd></div>
|
<div><dt>MODE</dt><dd>持续迭代,不锁死版本</dd></div>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
@@ -97,7 +97,7 @@ const workstreams = [
|
|||||||
<article><span>✓</span><h3>K3 报告已结构化拆解</h3><p>47 页报告目录、151 条参考来源和架构/后训练/系统主线已经提取。</p></article>
|
<article><span>✓</span><h3>K3 报告已结构化拆解</h3><p>47 页报告目录、151 条参考来源和架构/后训练/系统主线已经提取。</p></article>
|
||||||
<article><span>✓</span><h3>17 专题知识图</h3><p>从语言模型基础到评测安全,包含先修依赖和三条贯穿案例。</p></article>
|
<article><span>✓</span><h3>17 专题知识图</h3><p>从语言模型基础到评测安全,包含先修依赖和三条贯穿案例。</p></article>
|
||||||
<article><span>✓</span><h3>编辑式网站系统</h3><p>响应式导航、章节模板、侧栏、进度、论文链和证据提示组件。</p></article>
|
<article><span>✓</span><h3>编辑式网站系统</h3><p>响应式导航、章节模板、侧栏、进度、论文链和证据提示组件。</p></article>
|
||||||
<article><span>✓</span><h3>八十九个原创交互视图</h3><p>K3 三轴图、八联报告实验与四联开放工件实验,DeepSeek 四联公式实验、十三联 Base 工件实验、Chat 行为、completion/full-depth、multi-seed、cross-source 与 task-bootstrap CRN 五轮实验,以及语言模型前史、Transformer、表示深度、长上下文、MoE、推理、Agent、多模态、训练系统、推理服务、Scaling、数据工程、数值、Alignment 与评测安全专题。</p></article>
|
<article><span>✓</span><h3>九十四个原创交互视图</h3><p>K3 三轴图、八联报告实验、四联开放工件实验与五联 AttnRes 独立实验,DeepSeek 四联公式实验、十三联 Base 工件实验、Chat 行为、completion/full-depth、multi-seed、cross-source 与 task-bootstrap CRN 五轮实验,以及语言模型前史、Transformer、表示深度、长上下文、MoE、推理、Agent、多模态、训练系统、推理服务、Scaling、数据工程、数值、Alignment 与评测安全专题。</p></article>
|
||||||
<article><span>✓</span><h3>十七篇首版长文</h3><p>K3、语言模型前史、Transformer、表示/位置/残差、DeepSeek、Scaling、数据工程、长上下文、MoE、后训练、推理、Agent、原生多模态、训练系统、推理服务、数值优化与评测安全专题。</p></article>
|
<article><span>✓</span><h3>十七篇首版长文</h3><p>K3、语言模型前史、Transformer、表示/位置/残差、DeepSeek、Scaling、数据工程、长上下文、MoE、后训练、推理、Agent、原生多模态、训练系统、推理服务、数值优化与评测安全专题。</p></article>
|
||||||
<article><span>✓</span><h3>语言模型前史深度专题</h3><p>八张独立问题账、33 个正式节点、20 段长文与概率—向量—记忆—对齐四联实验。</p></article>
|
<article><span>✓</span><h3>语言模型前史深度专题</h3><p>八张独立问题账、33 个正式节点、20 段长文与概率—向量—记忆—对齐四联实验。</p></article>
|
||||||
<article><span>✓</span><h3>Transformer 深度专题</h3><p>十张独立问题账、40 个正式节点、21 段正文与 QKV—Mask—多头位置—Block 成本四联实验。</p></article>
|
<article><span>✓</span><h3>Transformer 深度专题</h3><p>十张独立问题账、40 个正式节点、21 段正文与 QKV—Mask—多头位置—Block 成本四联实验。</p></article>
|
||||||
@@ -105,6 +105,7 @@ const workstreams = [
|
|||||||
<article><span>✓</span><h3>DeepSeek 八轮真实权重里程碑</h3><p>把覆盖扩到 HumanEval / GSM8K 各 32 条冻结任务,用显式 SHA-256 uniform tape 驱动四个条件的共同随机数采样:352 条正式输出中 343 条 natural EOS、320 个 unique trajectories;10,000 次选定任务配对 bootstrap 的正确性区间均跨零,长度则揭示 Code 与 Math 的相反方向。新进程十二字段重放 64 / 64 exact。</p></article>
|
<article><span>✓</span><h3>DeepSeek 八轮真实权重里程碑</h3><p>把覆盖扩到 HumanEval / GSM8K 各 32 条冻结任务,用显式 SHA-256 uniform tape 驱动四个条件的共同随机数采样:352 条正式输出中 343 条 natural EOS、320 个 unique trajectories;10,000 次选定任务配对 bootstrap 的正确性区间均跨零,长度则揭示 Code 与 Math 的相反方向。新进程十二字段重放 64 / 64 exact。</p></article>
|
||||||
<article><span>✓</span><h3>Kimi K3 技术报告二轮深读</h3><p>三十二张问题账、Figure 1–16 / Table 1–5 审计、100 节点阅读链,以及 Delta—Decay—AttnRes—LatentMoE—SiTU—QB—MOPD—Cache 八联实验。</p></article>
|
<article><span>✓</span><h3>Kimi K3 技术报告二轮深读</h3><p>三十二张问题账、Figure 1–16 / Table 1–5 审计、100 节点阅读链,以及 Delta—Decay—AttnRes—LatentMoE—SiTU—QB—MOPD—Cache 八联实验。</p></article>
|
||||||
<article><span>✓</span><h3>Kimi K3 三轮开放工件里程碑</h3><p>固定官方 revisions,审计 96 个 shards、497,220 个 tensor entries 与真实 KDA / MLA / MoE / MoonViT shapes;四联实验分开显示层型、tensor anatomy、参数范围和复现边界。</p></article>
|
<article><span>✓</span><h3>Kimi K3 三轮开放工件里程碑</h3><p>固定官方 revisions,审计 96 个 shards、497,220 个 tensor entries 与真实 KDA / MLA / MoE / MoonViT shapes;四联实验分开显示层型、tensor anatomy、参数范围和复现边界。</p></article>
|
||||||
|
<article><span>✓</span><h3>Kimi K3 四轮 AttnRes 独立实验</h3><p>冻结三结构 × 三 seed 的 9 个 2,000-step 格;Full / Block 相对 Baseline 的平均 paired delta 为 −0.01457 / −0.04247 BPC,但核心参数梯度 CV 没有复现论文叙述。指定正式格全新进程八字段 exact,五视图同时展示结果、反证、成本与 claim boundary。</p></article>
|
||||||
<article><span>✓</span><h3>FlashKDA RTX 5090 执行闸门</h3><p>隔离 CUDA 13.0 / glibc 2.39 编译 sm_120a wheel;6/6 官方参考逐元素相等,并完成 fixed / varlen、三种 state mode 的 1,800 个 CUDA Event samples。</p></article>
|
<article><span>✓</span><h3>FlashKDA RTX 5090 执行闸门</h3><p>隔离 CUDA 13.0 / glibc 2.39 编译 sm_120a wheel;6/6 官方参考逐元素相等,并完成 fixed / varlen、三种 state mode 的 1,800 个 CUDA Event samples。</p></article>
|
||||||
<article><span>✓</span><h3>Scaling Laws 深度专题</h3><p>九张账、29 个一手节点、DeepSeek/Kimi 双谱系与曲面—部署—复用—涌现四联实验。</p></article>
|
<article><span>✓</span><h3>Scaling Laws 深度专题</h3><p>九张账、29 个一手节点、DeepSeek/Kimi 双谱系与曲面—部署—复用—涌现四联实验。</p></article>
|
||||||
<article><span>✓</span><h3>数据工程深度专题</h3><p>十二张账、31 个一手节点、DeepSeek/Kimi 双谱系与流水线—去重—混合—改写四联实验。</p></article>
|
<article><span>✓</span><h3>数据工程深度专题</h3><p>十二张账、31 个一手节点、DeepSeek/Kimi 双谱系与流水线—去重—混合—改写四联实验。</p></article>
|
||||||
@@ -133,7 +134,7 @@ const workstreams = [
|
|||||||
</div>
|
</div>
|
||||||
<div class="queue-table">
|
<div class="queue-table">
|
||||||
<div class="head"><b>优先级</b><b>专题</b><b>本轮交付</b><b>完成闸门</b></div>
|
<div class="head"><b>优先级</b><b>专题</b><b>本轮交付</b><b>完成闸门</b></div>
|
||||||
<div><span>P0</span><strong>K3 三轮</strong><p>开放权重 traces → FlashKDA / AttnRes / MoE 真实行为 → Figure 1–16 数值重绘与独立复现</p><em>运行证据 + 逐图复现</em></div>
|
<div><span>P0</span><strong>K3 四轮后续</strong><p>对齐论文梯度定义 → 增加 depth / budget → 等待 A_log 官方合同后进入真实 checkpoint forward</p><em>尺度复查 + 工件边界</em></div>
|
||||||
<div><span>P0</span><strong>DeepSeek 八轮后续</strong><p>干预式 mediation → SM90 FlashMLA / FP8 / pipeline traces → R1-like RL 小模型复现</p><em>运行证据 + 独立复现</em></div>
|
<div><span>P0</span><strong>DeepSeek 八轮后续</strong><p>干预式 mediation → SM90 FlashMLA / FP8 / pipeline traces → R1-like RL 小模型复现</p><em>运行证据 + 独立复现</em></div>
|
||||||
<div><span>P0</span><strong>Transformer 二轮</strong><p>多头电路逐图 → Pre/Post-LN 真实 traces → Flash/KV 配置与 kernel 对照</p><em>逐图笔记 + 实测边界</em></div>
|
<div><span>P0</span><strong>Transformer 二轮</strong><p>多头电路逐图 → Pre/Post-LN 真实 traces → Flash/KV 配置与 kernel 对照</p><em>逐图笔记 + 实测边界</em></div>
|
||||||
<div><span>P0</span><strong>表示、位置与残差二轮</strong><p>真实 hidden-state / norm traces → 长上下文位置外推 → mHC / AttnRes 深层稳定性消融</p><em>可复现实验 + 逐图笔记</em></div>
|
<div><span>P0</span><strong>表示、位置与残差二轮</strong><p>真实 hidden-state / norm traces → 长上下文位置外推 → mHC / AttnRes 深层稳定性消融</p><em>可复现实验 + 逐图笔记</em></div>
|
||||||
@@ -215,6 +216,10 @@ const workstreams = [
|
|||||||
<div><time>2026-07-29</time><b>A_log 形状冲突保持未决</b><p>checkpoint 的 [128] 与 config / remote code / FlashKDA API 期待的 [96] 并列展示;不宣布权重损坏,也不把 channel-wise 假设写成真实 forward。</p></div>
|
<div><time>2026-07-29</time><b>A_log 形状冲突保持未决</b><p>checkpoint 的 [128] 与 config / remote code / FlashKDA API 期待的 [96] 并列展示;不宣布权重损坏,也不把 channel-wise 假设写成真实 forward。</p></div>
|
||||||
<div><time>2026-07-29</time><b>FlashKDA 编译与执行永久分两道闸门</b><p>容器产出 sm_120a wheel 只证明可编译;RTX 5090 的 6/6 official-reference exact suite 通过后,才把证据升级为本机执行 X。</p></div>
|
<div><time>2026-07-29</time><b>FlashKDA 编译与执行永久分两道闸门</b><p>容器产出 sm_120a wheel 只证明可编译;RTX 5090 的 6/6 official-reference exact suite 通过后,才把证据升级为本机执行 X。</p></div>
|
||||||
<div><time>2026-07-29</time><b>作者表与 RTX 5090 表永久分账</b><p>H20 / GB200 保持 O;本站只报告独立环境、协议、300 samples/mode 和延迟分布,未跑本机 FLA 就不写本机 speedup。</p></div>
|
<div><time>2026-07-29</time><b>作者表与 RTX 5090 表永久分账</b><p>H20 / GB200 保持 O;本站只报告独立环境、协议、300 samples/mode 和延迟分布,未跑本机 FLA 就不写本机 speedup。</p></div>
|
||||||
|
<div><time>2026-07-30</time><b>K3 权重冲突不靠裁剪“解决”</b><p>HF / FlashKDA / vLLM / SGLang 仍没有公开 A_log 128→96 转换;真实 K3 forward 继续标为未决。</p></div>
|
||||||
|
<div><time>2026-07-30</time><b>AttnRes 缩小实验先冻结、后运行</b><p>三结构共享公共主干、初始化、窗口与优化器;只按三个 paired seed 和预注册 −0.010 BPC 阈值给出本协议内方向判断。</p></div>
|
||||||
|
<div><time>2026-07-30</time><b>支持结果与梯度反结果同时进入主视区</b><p>Full / Block 的最终 BPC 同向改善;核心参数 gradient RMS CV 却高于 Baseline,不换指标掩盖。</p></div>
|
||||||
|
<div><time>2026-07-30</time><b>正式重放不把 wall time 纳入 exact</b><p>Block / seed-1 的模型、优化器、曲线、历史、诊断和环境八字段 exact;计时受调度影响,单独报告。</p></div>
|
||||||
<div><time>2026-07-29</time><b>32-token 对照改为同源 16→24</b><p>TNEWS 只有 105/10,000 条达到 32 tokens,强行统一会落入约 1% 极端长尾;24-token eligibility 仍保留 1,609 条中文候选。</p></div>
|
<div><time>2026-07-29</time><b>32-token 对照改为同源 16→24</b><p>TNEWS 只有 105/10,000 条达到 32 tokens,强行统一会落入约 1% 极端长尾;24-token eligibility 仍保留 1,609 条中文候选。</p></div>
|
||||||
<div><time>2026-07-29</time><b>长度敏感性必须成对重采样</b><p>16-token 输入严格是 24-token 输入前缀,2,000 次 bootstrap 共用 prompt indices;结果只描述固定 cohort 的长度敏感性。</p></div>
|
<div><time>2026-07-29</time><b>长度敏感性必须成对重采样</b><p>16-token 输入严格是 24-token 输入前缀,2,000 次 bootstrap 共用 prompt indices;结果只描述固定 cohort 的长度敏感性。</p></div>
|
||||||
<div><time>2026-07-29</time><b>三类 cohort 永久分身份</b><p>自然长度回答本批样本如何路由;matched-16 / 24 回答同一 prompt 多看 8 tokens 后如何变化,不把二者混成内容因果。</p></div>
|
<div><time>2026-07-29</time><b>三类 cohort 永久分身份</b><p>自然长度回答本批样本如何路由;matched-16 / 24 回答同一 prompt 多看 8 tokens 后如何变化,不把二者混成内容因果。</p></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user