diff --git a/experiments/k3/attnres_local_path/README.md b/experiments/k3/attnres_local_path/README.md new file mode 100644 index 0000000..82b0a64 --- /dev/null +++ b/experiments/k3/attnres_local_path/README.md @@ -0,0 +1,22 @@ +# Attention Residuals local mixer-path diagnostics + +This directory implements preregistered protocol +`llm-atlas-k3-attnres-local-path-v1`. + +It is a targeted follow-up to Round 06. It exact-replays the same depth-32 +Block training and keeps the learned forward unchanged while switching source +value-gradient coefficients only at frozen mixer scopes. It is not a Kimi K3 +checkpoint run, a trainable variant, an additive attribution, or a reproduction +of unpublished Figure 5 telemetry. + +## Frozen environment + +```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 +``` + +The runner and exact commands will be added after this preregistration +manifest is committed. No result file may precede that commit. diff --git a/experiments/k3/attnres_local_path/manifest.json b/experiments/k3/attnres_local_path/manifest.json new file mode 100644 index 0000000..f2a24e3 --- /dev/null +++ b/experiments/k3/attnres_local_path/manifest.json @@ -0,0 +1,540 @@ +{ + "schema_version": 1, + "protocol_id": "llm-atlas-k3-attnres-local-path-v1", + "parent_protocol_id": "llm-atlas-k3-attnres-spike-path-v1", + "study_identity": "targeted local-path follow-up informed by Round 05 and Round 06; not blind discovery", + "architecture": "block", + "depth": 32, + "aggregation_groups": 8, + "blocks_per_group": 4, + "depth_mixers": 64, + "output_mixers": 1, + "formal_seeds": [ + 2026073001, + 2026073002, + 2026073003 + ], + "replay": { + "architecture": "block", + "depth": 32, + "seed": 2026073001, + "environment_scope": "same host, GPU, Python, PyTorch, CUDA and CUBLAS_WORKSPACE_CONFIG" + }, + "training": { + "steps": 8000, + "batch_size": 32, + "context": 256, + "target_bytes_per_cell": 65536000, + "parent_diagnostic_steps": [ + 0, + 100, + 500, + 2000, + 4000, + 8000 + ], + "local_matrix_steps": [ + 0, + 8000 + ], + "matrix_used_during_training": false + }, + "primary_object": { + "position": "post_mlp_state", + "reduction": "element_rms", + "spike_layers_one_based": [ + 21, + 22, + 23, + 24, + 25 + ], + "metrics": [ + "spike_contrast", + "peak_normalized" + ] + }, + "matrix_modes": [ + "detached_learned", + "uniform_group_6_only", + "uniform_group_7_only", + "uniform_groups_6_7_only", + "uniform_group_6_attention_only", + "uniform_group_6_mlp_only", + "uniform_group_7_attention_only", + "uniform_group_7_mlp_only", + "uniform_output_only", + "uniform_depth_all", + "uniform_all", + "uniform_except_group_6", + "uniform_except_group_7", + "uniform_except_groups_6_7" + ], + "selector": { + "coefficient_choices": [ + "detached_learned", + "uniform" + ], + "full_autograd_learned_in_matrix": false, + "depth_identity": "kind=depth,index=0..63; layer=floor(index/2)+1; attention iff index even", + "output_identity": "kind=output,index=64; parallel-schema alias only; parent mixer_index remains null", + "uniform_depth_indices": { + "detached_learned": [], + "uniform_group_6_only": [ + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47 + ], + "uniform_group_7_only": [ + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55 + ], + "uniform_groups_6_7_only": [ + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55 + ], + "uniform_group_6_attention_only": [ + 40, + 42, + 44, + 46 + ], + "uniform_group_6_mlp_only": [ + 41, + 43, + 45, + 47 + ], + "uniform_group_7_attention_only": [ + 48, + 50, + 52, + 54 + ], + "uniform_group_7_mlp_only": [ + 49, + 51, + 53, + 55 + ], + "uniform_output_only": [], + "uniform_depth_all": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63 + ], + "uniform_all": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63 + ], + "uniform_except_group_6": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 48, + 49, + 50, + 51, + 52, + 53, + 54, + 55, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63 + ], + "uniform_except_group_7": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 40, + 41, + 42, + 43, + 44, + 45, + 46, + 47, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63 + ], + "uniform_except_groups_6_7": [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + 24, + 25, + 26, + 27, + 28, + 29, + 30, + 31, + 32, + 33, + 34, + 35, + 36, + 37, + 38, + 39, + 56, + 57, + 58, + 59, + 60, + 61, + 62, + 63 + ] + }, + "uniform_output": { + "detached_learned": false, + "uniform_group_6_only": false, + "uniform_group_7_only": false, + "uniform_groups_6_7_only": false, + "uniform_group_6_attention_only": false, + "uniform_group_6_mlp_only": false, + "uniform_group_7_attention_only": false, + "uniform_group_7_mlp_only": false, + "uniform_output_only": true, + "uniform_depth_all": false, + "uniform_all": true, + "uniform_except_group_6": true, + "uniform_except_group_7": true, + "uniform_except_groups_6_7": true + }, + "expected_uniform_counts": { + "detached_learned": 0, + "uniform_group_6_only": 8, + "uniform_group_7_only": 8, + "uniform_groups_6_7_only": 16, + "uniform_group_6_attention_only": 4, + "uniform_group_6_mlp_only": 4, + "uniform_group_7_attention_only": 4, + "uniform_group_7_mlp_only": 4, + "uniform_output_only": 1, + "uniform_depth_all": 64, + "uniform_all": 65, + "uniform_except_group_6": 57, + "uniform_except_group_7": 57, + "uniform_except_groups_6_7": 49 + } + }, + "thresholds": { + "positive_denominator_epsilon": 1e-30, + "step0_spectrum_tolerance": 1e-6, + "loss_scale_tolerance": 1e-5, + "global_relative_drop_minimum": 0.2, + "groups_6_7_sufficiency_minimum": 0.5, + "groups_6_7_restoration_minimum": 0.5, + "single_group_material_minimum": 0.2, + "branch_material_minimum": 0.2, + "branch_dominance_margin": 0.15, + "output_half_gap_minimum": 0.5, + "formal_seed_gate": "3/3 independently for both metrics; means are display-only" + }, + "formulas": { + "global_log_gap": "G_X = ln(X_ref / X_uniform_all)", + "global_relative_drop": "(X_ref - X_uniform_all) / X_ref", + "sufficiency": "S_X(m) = ln(X_ref / X_m) / G_X", + "restoration": "R_X(r) = ln(X_r / X_uniform_all) / G_X", + "score_clipping": false + }, + "parent_artifacts": { + "manifest_path": "experiments/k3/attnres_spike/manifest.json", + "manifest_sha256": "d5302a249249a07d362819134763d14e7d32307f22cff416c665ed9606142fef", + "runner_path": "experiments/k3/attnres_spike/train.py", + "runner_sha256": "77298081d3c491d2e88e4705995174b9879ef377f520eb5fe5ea107e7a1da084", + "protocol_path": "research/K3_ATTNRES_SPIKE_PROTOCOL.md", + "protocol_sha256": "6cb101b8760d9f1c81caeb2f16880b16152da103867224a06761a75a12984a16", + "scoping_path": "research/K3_ATTNRES_SPIKE_SCOPING.md", + "scoping_sha256": "590166bd62580bb8238293823cfcc39bc0a465fec4c697025343f3f1138abd27", + "formal_schedule_sha256": "5041e09b167f229248d2462324e8c254b8f5938975f135dcd8192b00a54a4f4e", + "validation_tensor_sha256": "f459316f13078a163b47c133511bb7181e05170ab89516e196490113893ce338", + "diagnostic_tensor_sha256": "21117e31db302b10d67b63f035665dc8f220b879d216ccd12b7d2ba86e7b1716" + }, + "current_artifacts": { + "protocol_path": "research/K3_ATTNRES_LOCAL_PATH_PROTOCOL.md", + "protocol_sha256": "5ecc7ca92314ddb50aecf0cb50e115814c8983aa8bffb30e3634f7b3ce6dca1d", + "scoping_path": "research/K3_ATTNRES_LOCAL_PATH_SCOPING.md", + "scoping_sha256": "670ca4edf31a4be1f54937d9c7a760dba7a96e1e820c38c6b10405e22b078fc8", + "grok_review_path": "research/K3_ATTNRES_LOCAL_PATH_GROK_REVIEW.md", + "grok_review_sha256": "2da1b6bf1f455c4121a7a2c5cfe40e102327dabafc7e24dccc23ed0d00ac6d71", + "grok_session": "019fb151-9627-76c1-b7d7-53012874f85c" + }, + "round06_expected": { + "2026073001": { + "raw_file_sha256": "e39e93b7a7fce3c56f5f14f95cfdc04afdce53628affee1202fe62bd1bdb7f71", + "canonical_sha256": "76b0ccfb55c38baef50c395788ac4b351cbe0d58de70064b50702acb5c93f515", + "final_model_state": "3f0b97ece3a15571ba3d656f589f512ca0bb9e20083c9f58a42ccaee14892f59", + "final_optimizer_state": "ed03e6fbd4a12d8b063dcb22e0437754285f54d585374cd52fbd534f05d24637" + }, + "2026073002": { + "raw_file_sha256": "1c6f6c731030ec0adb2a8e7a4d586e0c4005cc3319568a7ac83c08c2a4b8eaf8", + "canonical_sha256": "5352c74eca853b375c0e85933dafd7c5916c39fc59052e742ca14ffd6d68bc78", + "final_model_state": "bd2556388aeaa211b798c283c7cbd8ccd29edf166a2922fa13d172e8dfdc38d1", + "final_optimizer_state": "0b101eab3bc7d8d654be2ea335c86fc25563ce19912d721844ee4e639c569e77" + }, + "2026073003": { + "raw_file_sha256": "115f8245577ece6dfaaa8ada68445c186e6523a7f3b26efcc3eb4c0c4ce82406", + "canonical_sha256": "7e764c07e90b78c4cd0acc2e99600225f16428cbb25d5188a0a5a8fe797f8766", + "final_model_state": "638568aede21890773b6932a19ec4e112f5ac0a4770ba3402fcd82980a9ecf76", + "final_optimizer_state": "83947fd743ec8e3e31ca7788fd201981846f0f1c7e9e38c88afcef95cfc6ec4e" + } + } +} diff --git a/research/K3_ATTNRES_LOCAL_PATH_GROK_REVIEW.md b/research/K3_ATTNRES_LOCAL_PATH_GROK_REVIEW.md new file mode 100644 index 0000000..12ea825 --- /dev/null +++ b/research/K3_ATTNRES_LOCAL_PATH_GROK_REVIEW.md @@ -0,0 +1,64 @@ +# Round 07 Grok Headless 对抗审阅与处置 + +审阅日期:2026-07-30 +审阅会话:`019fb151-9627-76c1-b7d7-53012874f85c` +身份:**外部模型的只读方法学审稿,不是论文证据源** + +## 1. 调用边界 + +Grok CLI 使用 single/headless 方式读取: + +- `research/K3_ATTNRES_LOCAL_PATH_SCOPING.md` +- `research/K3_ATTNRES_LOCAL_PATH_PROTOCOL.md` +- `experiments/k3/attnres_spike/train.py` + +关闭 web search、禁止 subagents、使用 plan permission;它没有修改文件。审稿任务是找 +selector、公式、endpoint exactness、negative control、replay 与父 runner API 的冲突。 + +## 2. Blocking findings 与处置 + +| finding | 风险 | 处置 | +|---|---|---| +| 父 runner 只有 global mode,局部 selector 尚不可实现 | 不同实现可能选错 indices 或混入 full autograd | **采纳**:协议冻结 14 个 exact identity sets;所有矩阵 mode 只用同一个 `RoutedSourceBackward` | +| 新 output `index=64` 与父 summary 的 `mixer_index=null` 冲突 | 改 schema 会破坏 Round 06 summary hash | **采纳**:父 `trace.mixers` 不动;新建平行 `selector_visits`,64 只作为新 schema alias | +| “restore to learned” 会被误解成恢复 query/key/softmax autograd | 分母是 detached learned,实验会回答不同问题 | **采纳**:统一改为 “restore to detached-learned value coefficients” | +| 14-mode 合同没明确保留六个 parent `learned` diagnostics | 可能削弱或破坏 Round 06 exactness | **采纳**:六 checkpoints 跑 parent learned;0/8000 追加 14-mode matrix | +| 20% raw drop 没写明确分母 | gap gate 可能用不同公式 | **采纳**:冻结 `(X_ref-X_all)/X_ref`,并定义缺失格如何使 3×2 主 gate 失败 | +| step-0 只做 custom-mode 互比不够 | 同一种 surrogate 错误可全体一致 | **采纳**:双 endpoint exact、learned-vs-detached 负控制、detached `×1/×2` loss-scale gate | + +## 3. Non-blocking findings 与处置 + +全部采纳: + +- 统一符号为 `X_ref = X_detached_learned`; +- 在 protocol 正文列出 exact indices,而不只依赖 scoping 公式; +- branch dominance 标为 sufficiency-only 次级探索; +- interaction residual 明确“不预期为 0、不是检验”; +- 明示 group 7 包含固定 `S` 外的 layers 26–28; +- 精确定义 `mixed`; +- replay 限定 same-host environment; +- 所有 score / gate 只由单一 `analyze.py` 生成。 + +“单 group 20% 与 joint 50% 不按 mixer 数量成比例”保留为预注册决策;协议已禁止把它解释为 +per-mixer rate。 + +## 4. 复核结论 + +Grok 复核 14-mode arithmetic: + +```text +1 reference + 10 sufficiency + 3 restoration = 14 +``` + +uniform census `0 / 1 / 4 / 8 / 16 / 49 / 57 / 64 / 65` 与 64 depth + 1 output +拓扑一致。真正风险是 identity/schema,不是计数;本轮修订已把两者写成独立 exact gate。 + +最终公式被审阅为内部自洽: + +```text +G_X = ln(X_ref / X_all) +S_X(m) = ln(X_ref / X_m) / G_X +R_X(r) = ln(X_r / X_all) / G_X +``` + +审稿意见不会进入实验结果、论文事实或官网证据等级;它只用于在结果出现前强化协议。 diff --git a/research/K3_ATTNRES_LOCAL_PATH_PROTOCOL.md b/research/K3_ATTNRES_LOCAL_PATH_PROTOCOL.md new file mode 100644 index 0000000..a05e119 --- /dev/null +++ b/research/K3_ATTNRES_LOCAL_PATH_PROTOCOL.md @@ -0,0 +1,539 @@ +# K3 Attention Residuals 局部 mixer 路径干预协议 + +协议 ID:`llm-atlas-k3-attnres-local-path-v1` +冻结日期:2026-07-30 +协议状态:**结果前预注册 frozen;任何语义变更必须更换 protocol ID** +父协议:`llm-atlas-k3-attnres-spike-path-v1` + +## 0. 研究身份 + +本轮是 Round 06 结果后的**定向机制追踪**,不是盲发现。 + +已知: + +- depth-32 / Block 的固定尖峰集合是 layers 21–25; +- 全部 65 个 mixer 的 source value backward coefficients 从 learned 改成 uniform, + 在三 seed 上 material 地降低最终 `post_mlp_state` 的 spike contrast 和 peak; +- 该全局干预保持 forward exact; +- group 6 覆盖 layers 21–24,group 7 覆盖 layers 25–28。 + +未知: + +- 全局下降是否主要集中在 group 6 / 7 的 16 个 depth mixers; +- group 6 与 group 7 是否各自有稳定 effect; +- attention 与 MLP mixer 是否能在预注册阈值下区分; +- output mixer 是否解释了大量全局 effect; +- 局部 sufficiency 与反向 restoration 是否给出一致证据。 + +前置证据、拓扑和同期 artifact audit 固定在 +`research/K3_ATTNRES_LOCAL_PATH_SCOPING.md`。任何结果不得倒写成事前未知。 + +## 1. 允许回答的问题 + +1. 在相同模型、batch、loss、activation 与 learned forward weights 下,只改变某个固定 + mixer scope 的 source-gradient coefficients,能复现多少全局 log gap? +2. 从 all-uniform 背景只恢复 group 6 / 7 的 learned coefficients,能恢复多少 + global log gap? +3. groups 6+7 是否在 sufficiency 与 restoration 两个方向、两个 spike 指标、三 seed + 同时通过 50% 阈值? +4. 单独 group 6 或 group 7 是否在两个指标、三 seed 通过 20% 阈值? +5. attention-only 与 MLP-only 是否达到预注册的 branch dominance 规则? +6. output-only 与 all-depth 控制是否显示 effect 主要来自最终 output mixer? + +## 2. 明确不回答的问题 + +- Kimi K3 2.8T checkpoint 的真实训练梯度; +- 论文 Figure 5(c) 未公开 telemetry 的精确定义; +- 哪个 layer、source 或 operator “产生”尖峰; +- learned source weight 的语义归因; +- 重新训练局部 uniform variant 的最终能力; +- intervention effect 的可加性、Shapley value 或方差分解; +- 三 seed 外的总体显著性、置信区间或 p-value; +- K3 `A_log` 两个社区修复中哪个已经得到官方认可; +- checkpoint conversion、推理正确性或部署可用性。 + +## 3. 冻结训练与数据合同 + +完整复用 Round 06: + +| 字段 | 固定值 | +|---|---| +| architecture | Block AttnRes | +| Transformer depth | 32 | +| aggregation groups | 8 | +| blocks / group | 4 | +| depth mixers / output mixers | 64 / 1 | +| width / heads / FFN | 192 / 6 / 768 | +| context / vocabulary | 256 / byte-256 | +| seeds | 2026073001 / 2026073002 / 2026073003 | +| steps / batch | 8,000 / 32 | +| target bytes / formal cell | 65,536,000 | +| optimizer | AdamW | +| peak / min LR | 3e-4 / 3e-5 | +| warmup | 400 | +| weight decay | 0.1 for ndim ≥ 2 | +| betas / epsilon | 0.9, 0.95 / 1e-8 | +| clip | global norm 1.0 | +| forward | CUDA BF16 autocast | +| residual accumulation | explicit FP32 | +| diagnostic CE | fixed 16 × 256 token-mean FP32 CE | +| parent diagnostic steps | 0 / 100 / 500 / 2,000 / 4,000 / 8,000 | +| local matrix steps | 0 / 8,000 | + +训练路径必须逐调用父 runner 原始 forward;局部 custom autograd 只能存在于 optimizer +step 外的 diagnostic。数据 bytes、schedule、validation tensor、diagnostic tensor 与三 +seed 的每个 optimizer input 都必须与 Round 06 exact。 + +诊断调度明确分成两条: + +- 六个 parent diagnostic steps 都运行原始 `learned` mode,用于 Round 06 等价; +- step 0 / 8,000 另外运行下述 14-mode local matrix; +- localization 公式只读取 14-mode matrix,绝不把 full-autograd `learned` 混入分母。 + +## 4. 正式矩阵与 replay + +正式运行: + +```text +depth-32 / block / seed-2026073001 +depth-32 / block / seed-2026073002 +depth-32 / block / seed-2026073003 +``` + +另从初始化完整重跑: + +```text +replay / depth-32 / block / seed-2026073001 +``` + +正式三格处理 196,608,000 target bytes;含 replay 共 262,144,000 bytes。每格使用 +全新 Python 进程。最多并行两个进程;不能共享 model、optimizer、RNG 或 CUDA graph。 +wall-time 不进入数值复现合同。 + +## 5. 固定主对象与指标 + +主对象固定为最终 step 8,000: + +```text +position = post_mlp_state +reduction = element_rms +S = layers 21, 22, 23, 24, 25 +R = other 27 layers +``` + +对 mode `m`: + +```text +C_m = mean(metric[S]) / mean(metric[R]) # spike contrast +P_m = max(metric) / mean(metric) # peak normalized +``` + +`C_m` 与 `P_m` 必须 finite 且严格大于 `1e-30`。后文统一用 `X_ref` 表示 +`X_detached_learned`;不用 `detached_reference` 等其他别名。不允许用其他位置、reduction、layer +集合或 metric 替换主对象。32-layer raw spectrum、normalized spectrum、peak layer 和 +top-five layers 全量报告,但不参与主阈值。 + +## 6. 14 种冻结模式 + +所有模式调用同一个 parent learned forward。custom Function 的 forward 直接返回 +parent output,只有 backward 对 source tensors 使用选定 coefficients。 + +14-mode matrix **全部**使用 `RoutedSourceBackward`:每个 mixer 只在 +`stopgrad(w)` 与 `1/N` 两种 source value coefficients 中选择。完整 +query / key / softmax autograd 的 `learned` 不属于这 14 种模式,只用于训练和父诊断 +等价。实现不得把某个 restoration scope 切回 full-autograd `learned`。 + +### 6.1 reference + +`detached_learned` + +- 65 个 mixer 全部使用 learned `w` 作为 source value backward coefficients; +- `w` detach,不走 query / key / softmax derivative path; +- 必须 exact reproduce Round 06 的同名 mode。 + +### 6.2 learned 背景上的局部 uniform:sufficiency family + +未选 mixer 使用 detached learned coefficients;选中 mixer 使用 `1/N`: + +1. `uniform_group_6_only` +2. `uniform_group_7_only` +3. `uniform_groups_6_7_only` +4. `uniform_group_6_attention_only` +5. `uniform_group_6_mlp_only` +6. `uniform_group_7_attention_only` +7. `uniform_group_7_mlp_only` +8. `uniform_output_only` +9. `uniform_depth_all` +10. `uniform_all` + +`uniform_all` 必须 exact reproduce Round 06 的 `uniform_value_backward`。 + +### 6.3 all-uniform 背景上的 detached-learned restoration family + +选中 scope 恢复 detached learned coefficients,其余保持 uniform: + +1. `uniform_except_group_6` +2. `uniform_except_group_7` +3. `uniform_except_groups_6_7` + +名字中的 `except` 表示该 scope **不是 uniform**。报告和网站必须同时展示人话标签 +“restore ... to detached-learned value coefficients”,避免误读。 + +## 7. selector 的唯一合同 + +为了同时满足新 selector audit 和 Round 06 endpoint exactness,保留两个互不混写的 +schema: + +1. 父 `trace.mixers` summary **逐字段不变**;output 仍使用父 schema 的 + `mixer_index=null`,并继续参与父 `mixer_summary_sha256`; +2. 新增平行 `selector_visits`,只用于 local mask audit,不写入父 summary。 + +`selector_visits` 的 depth mixer identity 用: + +```text +(kind="depth", index=0..63, layer=1..32, + group=1..8, branch in {"attention","mlp"}) +``` + +`selector_visits` 的 output mixer identity 用: + +```text +(kind="output", index=64, layer=null, group=null, branch="output") +``` + +这里 `index=64` 只是新 selector schema 的稳定别名,不得回写父 summary。 + +令 `D_i` 表示 `kind=depth,index=i`,`O` 表示 output。14 种 mode 的 uniform identity +集合冻结如下: + +| mode | exact uniform set | +|---|---| +| `detached_learned` | `∅` | +| `uniform_group_6_only` | `{D40,…,D47}` | +| `uniform_group_7_only` | `{D48,…,D55}` | +| `uniform_groups_6_7_only` | `{D40,…,D55}` | +| `uniform_group_6_attention_only` | `{D40,D42,D44,D46}` | +| `uniform_group_6_mlp_only` | `{D41,D43,D45,D47}` | +| `uniform_group_7_attention_only` | `{D48,D50,D52,D54}` | +| `uniform_group_7_mlp_only` | `{D49,D51,D53,D55}` | +| `uniform_output_only` | `{O}` | +| `uniform_depth_all` | `{D0,…,D63}` | +| `uniform_all` | `{D0,…,D63,O}` | +| `uniform_except_group_6` | `{D0,…,D39,D48,…,D63,O}` | +| `uniform_except_group_7` | `{D0,…,D47,D56,…,D63,O}` | +| `uniform_except_groups_6_7` | `{D0,…,D39,D56,…,D63,O}` | + +runner 必须把这些 set 编码为一个 frozen selector 函数;不能散落在 mode-specific +if/else 中。manifest 同时保存 machine-readable exact index lists。runner 通过 +override `_mix` 或等价 hook 做 set lookup,并替换父 runner 中只接受三种 global mode +的 mode validation、bundle loop 和相关 gate;训练 forward 继续直接调用父路径。 + +每次 forward 必须验证: + +- exactly 65 个 mixer visits; +- identity 不重复; +- identity 顺序与 reference exact; +- 父 `trace.mixers` schema 与 hash 路径没有新字段; +- uniform census 与 manifest exact; +- selected identity list 与 selector rule exact; +- reference 的 uniform count 为 0; +- branch-only 4,group-only 8,groups 6+7 为 16; +- output-only 1,all-depth 64,all 65; +- except-one-group 57,except-two-groups 49。 + +任一 gate 失败,cell invalid;不得只改结果 JSON。 + +## 8. forward identity 与 parent exactness + +### 8.1 所有 14 模式的 forward identity + +同 seed / step 相对 `detached_learned` 必须满足: + +- logits tensor SHA-256 exact; +- loss FP32 value exact; +- 六位置 activation tensor hashes exact; +- 65 个 mixer forward summaries exact。 + +任一 mode 失败,整格 invalid。 + +### 8.2 Round 06 endpoint exactness + +对 step 0 / 8,000: + +- `detached_learned` 的 logits、loss、六位置 activation、未改 schema 的 mixer + summaries 和六位置 gradient reductions 必须与对应 Round 06 + raw output exact; +- `uniform_all` 的同一组字段和六位置 gradient reductions必须与对应 Round 06 + `uniform_value_backward` exact; +- 正式训练的 final model hash、optimizer hash、六个 validation BPC、training + history 与六个 parent `learned` diagnostics 必须与 Round 06 exact; +- 新 `selector_visits` 不参与旧 `mixer_summary_sha256`,而由独立 canonical hash + 和 exact-set gate 管理。 + +runner / protocol / scoping / manifest 物理 hash 在运行前冻结。父 raw 文件同时检查 physical +SHA-256、canonical SHA-256、final model hash 和 final optimizer hash。 + +## 9. 初始化负控制 + +step 0 的 mixer query 为零,learned `w` 是 uniform。14 模式在六个位置的 +`element_rms` 必须: + +- 32 个 raw values 全部 finite、strictly positive; +- 相对 reference 的逐层 raw relative error `≤1e-6`; +- normalized absolute error `≤1e-6`。 + +此外: + +- `detached_learned` 与 `uniform_all` 必须分别与 Round 06 step-0 endpoint exact; +- parent full-autograd `learned` 与 `detached_learned` 必须按 Round 06 负控制在 + `1e-6` tolerance 内一致; +- `detached_learned` 另执行同一 loss 的 `×1 / ×2` backward,六位置、七 reductions + 都必须通过父协议相同的 scale 与 normalized-spectrum gate。 + +失败表示 selector 或 surrogate 没有隔离预期路径;正式结果无效。 + +## 10. global log gap + +对每个 seed 和每个指标 `X ∈ {C,P}`: + +```text +G_X = ln(X_ref / X_uniform_all) +relative_drop_X = (X_ref - X_uniform_all) / X_ref +``` + +只有同时满足以下条件才允许解释局部比例: + +1. `G_C > 0` 且 `G_P > 0`; +2. 上式 `relative_drop_X ≥0.20`; +3. Round 06 endpoint exactness 通过。 + +seed `s` 的 metric `X` 任一条件不满足,则该 `(s,X)` 称为 +`global gap not established`,不计算该格 `S_X / R_X`。groups 6+7 的主 gate 要求 +3 seed × 2 metrics 全部存在,因此任一 required cell 缺失都会使主 localization +判定失败;仍公开 raw matrix,不使用事后替代分母。 + +log ratio 用于让相同的乘法变化在两个方向可比。所有归一化值按原值报告,**不裁剪到 +[0,1]**;负值表示反方向,超过 1 表示局部 intervention 超过 all-uniform endpoint。 + +## 11. sufficiency score + +对 sufficiency mode `m`: + +```text +S_X(m) = ln(X_ref / X_m) / G_X +``` + +### 11.1 groups 6+7 主判定 + +只有 `uniform_groups_6_7_only` 对 `C` 和 `P` 都满足: + +```text +S_X(m) ≥ 0.50 +``` + +且三个 formal seed 6 / 6 全部达标,才记为: + +> groups 6+7 的 16 个 depth mixers 在本 diagnostic 中,足以复现至少一半 +> all-65 uniform intervention 的预注册 log-gap reduction。 + +任一失败记为 `not sufficient at the preregistered 50% threshold`。`mixed` 精确定义为: +seed 通过/失败不一致、`C/P` 通过/失败不一致,或 score 的正负号跨 seed 不一致;可同时 +附加多个原因,不得降低阈值。 + +### 11.2 单 group + +group 6 / group 7 分别对 `C` 和 `P`、三 seed 全部满足: + +```text +S_X(m) ≥ 0.20 +``` + +才称为 `material local sufficiency at the 20% threshold`。没过阈值不等于 effect 为零。 + +## 12. restoration score + +对 restoration mode `r`: + +```text +R_X(r) = ln(X_r / X_uniform_all) / G_X +``` + +### 12.1 groups 6+7 主判定 + +只有 `uniform_except_groups_6_7` 对 `C` 和 `P`、三 seed全部满足: + +```text +R_X(r) ≥ 0.50 +``` + +才称为: + +> 从 all-uniform 背景只恢复 groups 6+7 的 learned coefficients,恢复了至少一半 +> 预注册 global log gap。 + +这仍是同前向 backward-rule restoration sensitivity,不是严格 causal necessity。 + +### 12.2 单 group + +`uniform_except_group_6` / `uniform_except_group_7` 分别以 `≥0.20`、两个指标、三 seed +作为 material restoration threshold。 + +## 13. localization 总闸门 + +只有以下两项同时通过: + +1. groups 6+7 sufficiency:`S_C,S_P ≥0.50`,3 / 3 seeds; +2. groups 6+7 restoration:`R_C,R_P ≥0.50`,3 / 3 seeds; + +才允许写: + +> 在本缩小模型、固定训练状态和 diagnostic backward 下,全局 value-coefficient +> sensitivity 的主要部分 localization 到 group 6 / 7 mixer path。 + +即使通过,也必须紧邻注明: + +- “主要部分”由 50% 双向阈值定义; +- effect non-additive; +- 不是唯一来源或 layer-origin; +- 不是真实 K3 checkpoint 结论。 + +一侧通过一侧失败,统一写成 `one-sided evidence, localization not established`。 + +## 14. attention vs MLP branch 判定 + +每个 group 独立比较 attention-only 与 MLP-only sufficiency score。只有某 branch: + +1. `S_C ≥0.20` 且 `S_P ≥0.20`; +2. 在 `C` 与 `P` 上都比 sibling 高至少 `0.15`; +3. 三 seed 全部满足前两项; + +才称为 `branch-dominant at the preregistered margin`。 + +若 group-level sufficiency 未通过 20% 阈值,不允许宣称其内部 branch dominance。 +branch-only scores 可能交互、超加或相互抵消,不能相加成 group score。 +本节只有 sufficiency 方向,没有 branch-level restoration,属于预注册的次级探索性 +判定,证据层级低于 §13 双向 localization。 + +## 15. output 与 depth 控制 + +`uniform_output_only` 和 `uniform_depth_all` 不进入 group localization 主判定。 + +探索性报告: + +```text +S_X(output) +S_X(depth_all) +interaction_residual_X = + 1 - S_X(output) - S_X(depth_all) +``` + +`interaction_residual` 只是 log-gap bookkeeping,不是统计交互估计或贡献分解。 +它不预期接近 0,也不是 hypothesis test。 + +只有 output-only 对两个指标、三 seed 都 `≥0.50`,才标记 +`output mixer alone captures at least half the global gap`。即使如此,也不否定 +groups 6+7;两者可能重叠、串联或超加。 + +## 16. 报告顺序与反 cherry-picking + +固定报告顺序: + +1. input / parent / endpoint exactness; +2. step-0 negative control; +3. 每 seed 的 raw `C` / `P` 矩阵; +4. global gaps; +5. groups 6+7 sufficiency; +6. groups 6+7 restoration; +7. localization gate; +8. single-group scores; +9. branch scores; +10. output / depth controls; +11. full 32-layer spectra; +12. replay; +13. limitations。 + +所有 14 modes、两个指标、三个 seed 都公开。不得只展示通过阈值的 scope。不得用跨 seed +均值替代 3 / 3 gate;均值只用于视觉摘要。 + +## 17. replay 与复现闸门 + +seed 2026073001 从初始化独立 replay,比较去除以下字段后的 canonical content: + +- `run_kind`; +- wall-clock timing; +- output path; +- self canonical hash。 + +至少以下字段必须 exact: + +- input tensor hashes; +- initial/final model 与 optimizer hashes; +- evaluations / training history; +- parent diagnostics; +- 14-mode step-0 / step-8,000 forward hashes; +- selector census / identities; +- 六位置 raw gradient reductions; +- global gaps / local scores / gates。 + +若正式 seed1 与 replay 不 exact,Round 07 数值结论无效。 +replay 固定在与 formal 相同 host、GPU、Python、PyTorch、CUDA 和 +`CUBLAS_WORKSPACE_CONFIG` 环境;本协议不声称跨硬件 bit exact。 + +## 18. 预期失败与停止规则 + +以下任一项使 cell invalid: + +- CUDA deterministic contract 未开启; +- parent manifest / runner / protocol / scoping / raw hash 不匹配; +- 训练等价失败; +- diagnostic 改变 optimizer state; +- forward identity 失败; +- selector identity / census 失败; +- Round 06 endpoint exactness 失败; +- step-0 negative control 失败; +- raw gradient missing、non-finite 或 non-positive; +- global gap denominator 不成立。 + +程序错误修复必须: + +1. 保存失败日志; +2. 修改 runner; +3. 更新 runner hash; +4. 明确判断协议语义是否改变; +5. 若改变 selector、mode、metric、threshold 或 aggregation,创建新 protocol ID; +6. 全部受影响 cell 从初始化重跑。 + +## 19. 结果语言边界 + +允许: + +- “在同前向 diagnostic backward 下,uniformizing scope X 改变了固定尖峰指标”; +- “groups 6+7 在预注册 50% 双向阈值下建立 / 未建立 localization”; +- “branch effect mixed / below threshold”; +- “这是一项 reduced-model mechanism probe”。 + +禁止: + +- “证明 K3 的尖峰来自第 6 组”; +- “这些 mixer 贡献了 X% 梯度”; +- “group effect 加总为 100%”; +- “uniform mixer 更适合训练”; +- “复现了 Figure 5(c)”; +- “验证了 K3 2.8T checkpoint”; +- “社区 PR #144 或 #150 已成为官方修复”。 + +## 20. 冻结清单 + +在任何 formal 结果产生前必须完成: + +- [x] scoping 文件完成; +- [x] protocol 状态改为 frozen; +- [ ] 14 modes 与 selector census 写入 manifest; +- [ ] thresholds / formulas 写入 manifest; +- [ ] Round 06 父 artifact physical / canonical hashes 写入 manifest; +- [ ] runner、protocol、scoping、manifest hashes 固定; +- [x] Grok Headless 对抗审阅完成,采纳/拒绝理由留档; +- [ ] step-0 smoke 全门通过; +- [ ] formal 命令与环境写入 README; +- [ ] 单一 `analyze.py` 实现所有 score / gate,网站只消费其冻结输出; +- [ ] protocol commit 早于 formal result commit。 diff --git a/research/K3_ATTNRES_LOCAL_PATH_SCOPING.md b/research/K3_ATTNRES_LOCAL_PATH_SCOPING.md new file mode 100644 index 0000000..8459ebc --- /dev/null +++ b/research/K3_ATTNRES_LOCAL_PATH_SCOPING.md @@ -0,0 +1,197 @@ +# K3 Attention Residuals 局部 mixer 路径:Round 07 前置定位 + +研究日期:2026-07-30 +阶段身份:**定向 scoping,不是 Round 07 预注册结果** +上游协议:`llm-atlas-k3-attnres-spike-path-v1` + +## 1. 已知到什么程度 + +Round 06 在同一个 depth-32 / Block AttnRes 缩小模型上,把前向保持为 learned +weights,只改写 mixer 的反向规则。三 seed 的最终 `post_mlp_state / element_rms` +结果为: + +| backward rule | spike contrast(3-seed mean) | 相对 detached learned | peak normalized(3-seed mean) | 相对 detached learned | +|---|---:|---:|---:|---:| +| learned | 2.754 | — | 4.803 | — | +| detached learned | 2.812 | reference | 4.956 | reference | +| uniform value / all 65 mixers | 0.837 | **−70.2%** | 3.122 | **−37.0%** | + +其中: + +- `learned → detached learned` 没有降低尖峰,contrast 反而平均增加约 2.0%; +- `detached learned → uniform value backward` 在 contrast 和 peak 上都 3 / 3 seed + 超过预注册的 20% material threshold; +- 三种模式的 logits、loss、六位置 activation 和 mixer forward 摘要全部 exact; +- 这证明的是**全局 backward-rule sensitivity**,不是训练变体,也不是局部归因。 + +因此 Round 07 不再重复问“learned value coefficients 是否重要”,而是问: + +> 65 个 mixer 全局改写带来的下降,主要能否由尖峰邻近的 group 6 / 7 +> depth mixers 复现,并能否从反方向恢复? + +## 2. 固定拓扑,而不是结果后挑层 + +depth 32 的 Block AttnRes 有 8 个 aggregation groups,每组 4 个 Transformer +blocks。每层有 attention 和 MLP 两个 depth mixers,合计 64 个;模型末尾还有一个 +独立 output mixer,合计 65 个 intervention nodes。 + +对 1-based layer `l`: + +```text +group = floor((l - 1) / 4) + 1 +attention mixer index = 2 × (l - 1) # 0-based +MLP mixer index = 2 × (l - 1) + 1 # 0-based +``` + +所以: + +| scope | layers | 0-based depth mixer indices | mixer count | +|---|---:|---:|---:| +| group 6 | 21–24 | 40–47 | 8 | +| group 7 | 25–28 | 48–55 | 8 | +| groups 6+7 | 21–28 | 40–55 | 16 | +| output | — | separate node | 1 | + +Round 05 已在看过数据后冻结尖峰集合 `S = layers 21–25`。它覆盖完整 group 6 和 +group 7 的首层。因此 Round 07 明确是**定向邻域追踪**,不能称为盲发现;group 6 / 7 +也不能结果后替换成更好看的范围。 + +## 3. 为什么需要两个方向 + +只在 learned 背景把 group 6 / 7 改成 uniform,回答的是: + +> 只改这段是否足以复现全局干预的一大部分下降? + +但 mixer 路径有串联、分流和 nonlinear interaction,单侧结果可能被其他 learned +路径补偿。反过来,在 all-uniform 背景只把 group 6 / 7 恢复为 learned,回答的是: + +> 只恢复这段是否足以让尖峰朝 reference 回升? + +两种值都不是“贡献百分比”,也不要求相加为 100%。Round 07 用相同的 global log gap +归一化两种方向,只把双向、跨 seed 稳定的结果称为 localization evidence。 + +## 4. 冻结候选范围 + +从 `detached_learned` 背景出发的 sufficiency scopes: + +1. group 6; +2. group 7; +3. groups 6+7; +4. group 6 attention-only; +5. group 6 MLP-only; +6. group 7 attention-only; +7. group 7 MLP-only; +8. output-only; +9. all 64 depth mixers; +10. all 65 mixers。 + +从 all-uniform 背景出发的 restoration scopes: + +1. restore group 6 to detached-learned value coefficients; +2. restore group 7 to detached-learned value coefficients; +3. restore groups 6+7 to detached-learned value coefficients。 + +加上 `detached_learned` reference,共 14 种模式。预期 uniform selector census 为: + +| mode | uniform mixers | +|---|---:| +| detached reference | 0 | +| group branch only | 4 | +| group only | 8 | +| groups 6+7 | 16 | +| output only | 1 | +| all depth | 64 | +| all | 65 | +| uniform except group 6 / 7 | 57 | +| uniform except groups 6+7 | 49 | + +每次 diagnostic 都必须保存实际选中的 mixer identity;不能只信 mode 名称。 +group 7 的 scope 包含 layers 26–28,它们不在固定尖峰集合 `S=21–25` 中,所以 +group 7 是预先定义的**完整邻接 group intervention**,不是 spike-layer-only +intervention。 + +## 5. 不把局部 intervention 误译成什么 + +即使 groups 6+7 双向通过,结论也只限于: + +- 固定训练状态; +- 固定 diagnostic batch 与 loss; +- 固定 `S = 21–25` 指标; +- 同前向、替代 source-gradient coefficient 的 diagnostic backward。 + +它不等于: + +- 这些层“产生”了尖峰; +- group 6 / 7 是唯一原因; +- 真实 K3 checkpoint 有相同梯度路径; +- 把 mixer 训练成 uniform 会有同样结果; +- 局部 effect 可加,或可解释成方差分解; +- 论文 Figure 5(c) 的未公开 telemetry 已被复现。 + +保留 output-only 和 all-depth 两个控制,是为了看清最终 readout 与 depth path 的关系; +它们不进入 group 6 / 7 localization 的主判定。 + +## 6. 同期 artifact 状态审计:`A_log` + +这一问题与缩小实验的局部梯度机制**相互独立**,但会限制任何真实 K3 checkpoint +验证,因此在冻结 Round 07 前重新检查官方模型仓库。 + +截至 **2026-07-30 12:35 CST**: + +- 官方 Hugging Face main commit 仍为 + `9f62e4e9fffbd0a83ddd60e1c209d828994b3569`; +- main 的 `modeling_kimi_linear.py` 仍以 `num_heads=96` 初始化 `A_log`; +- 已发布 checkpoint 中该张量的公开 shape 是 `[128]`,与 main 存在加载不匹配; +- 官方 main 尚未合并修复或给出 conversion contract。 + +同时出现了两个**未合并、互相竞争的社区 PR**: + +### PR #144:把参数改成 128 + +- 一行把初始化从 `self.num_heads` 改为 `self.head_dim`; +- 提交者报告所有 shards 能加载; +- 提交者明确说没有独立验证 forward; +- 它把 checkpoint shape 当作权威语义。 + +### PR #150:保留 96,加载时验证并裁零尾 + +- 保持模型参数为 `[num_heads]=[96]`; +- `_load_from_state_dict` 检查 `[96:128]` 全为零后再裁掉; +- 提交者报告检查了 69 个 KDA 层,所有 32 项尾部都 exact zero; +- 提交者还报告经过 disk-offloaded MoE 的完整生成; +- 这些 checkpoint 全量扫描和生成是**提交者报告**,本项目没有下载约 1.56 TB + 权重独立复核;本项目只核对了 PR diff、main 代码路径和 PR 状态。 + +PR #150 进一步指出,forward 中 `v` 被 reshape 为 96 heads,kernel 随后接收 +`A_log`;若直接采用 #144 的 128 元素参数,现有 `view(H, 1)` 路径会在 96 heads 下 +失败。这个论证比单看 checkpoint shape 更完整,但在官方合并或独立复核前,仍必须标成 +高可信社区解释,而不是 Kimi 官方结论。 + +当前准确状态应写成: + +> official main 仍然不匹配;社区已有两个竞争性候选修复,其中 #150 提供了更完整的 +> checkpoint-tail 与 end-to-end 证据,但尚无官方裁决。 + +来源: + +- [Kimi-K3 official main](https://huggingface.co/moonshotai/Kimi-K3/tree/main) +- [main `modeling_kimi_linear.py`](https://huggingface.co/moonshotai/Kimi-K3/blob/main/modeling_kimi_linear.py) +- [community PR #144](https://huggingface.co/moonshotai/Kimi-K3/discussions/144) +- [community PR #150](https://huggingface.co/moonshotai/Kimi-K3/discussions/150) + +## 7. Round 07 的可证伪问题 + +Round 07 将: + +1. exact replay Round 06 的三 seed 训练; +2. exact reproduce Round 06 的 `detached_learned` 与 `uniform_all` 两个端点; +3. 在 step 0 对 14 种模式做负控制,在 step 8,000 做正式矩阵; +4. 同时测 `spike_contrast` 与 `peak_normalized`; +5. 用 groups 6+7 的 sufficiency 与 restoration 两个方向预注册 50% log-gap + localization threshold; +6. 用单 group 的 20% 阈值和 attention-vs-MLP 的 15 percentage-point margin + 作更细分的层级判定; +7. 从初始化完整 replay seed 2026073001。 + +完整模式、公式、失败规则和复现合同见 +`research/K3_ATTNRES_LOCAL_PATH_PROTOCOL.md`。