Verify LiSA full-vocabulary results and report scope

This commit is contained in:
2026-11-24 01:39:44 +08:00
parent c2aa23f32f
commit 78f3869060
6 changed files with 2197 additions and 2 deletions
+20 -2
View File
@@ -1,6 +1,6 @@
# Qwen3.5-2B 双层 LiSA 复现实验
在固定的 32 道查找题上,原模型、直接共享、线性修正和两版 LiSA 都答对 32 道。原版 LiSA 降低了接收层 K/V 缓存,并在投影权重常驻内存时缩短了两个接收层的单步解码时间。按本次 CPU 权重流式读取方式测量,第 19 层单步解码更快,第 23 层略慢,双层共享的预填充更慢。全词表答案复核正在运行。
在冻结的 32 道查找题上,原模型、直接共享、线性修正和两版 LiSA 的四选一准确率均为 32/32。全词表首 token 命中率从双层直接共享的 27/32 升到两版 LiSA 的 32/32。五道变化题都涉及首 token 从 `<think>` 变成正确选项。两个接收层各自的 K/V 缓存减少 42.2%。耗时随权重是否驻留及测量阶段而异。
## 四选一任务表现
@@ -14,7 +14,23 @@
| 双层 LiSA | 32/32 | 0.1846 |
| 双层 LiSA,答案损失加权 | 32/32 | 0.1260 |
直接共享在留出集上丢失 0 道原模型答对的题,因此无法估计 LiSA 对这类错题的恢复率。答案加权把 LiSA 的四选一 NLL 降低了 0.0586,仍高于直接共享。三种训练方法各用 12 道拟合题跑两轮,并由另外 12 道验证题选择检查点。所选检查点都是第 2 轮。逐题 logits、训练轨迹及检查点哈希随结果归档。
直接共享在留出集上丢失 0 道原模型答对的题,因此无法估计 LiSA 对这类错题的恢复率。答案加权把 LiSA 的四选一 NLL 降低了 0.0586,仍高于直接共享。相比直接共享,原版 LiSA 的 NLL 增加 0.1118,按题配对 bootstrap 95% 区间为 [0.0968, 0.1282]。答案加权 LiSA 的差为 0.0532,区间为 [0.0327, 0.0749]。三种训练方法各用 12 道拟合题跑两轮,并由另外 12 道验证题选择检查点。所选检查点都是第 2 轮。
## 全词表首 token
| 方法 | 正确选项为首 token | 全词表答案 NLL ↓ |
| --- | ---: | ---: |
| 原模型 | 27/32 | 0.5633 |
| 单层直接共享,第 23 层 | 32/32 | 0.3124 |
| 单层 LiSA,第 23 层,使用双层训练的适配器 | 32/32 | 0.2554 |
| 双层直接共享 | 27/32 | 0.5579 |
| 双层线性修正 | 27/32 | 0.5574 |
| 双层 LiSA | 32/32 | 0.4706 |
| 双层 LiSA,答案损失加权 | 32/32 | 0.1545 |
两版 LiSA 对双层直接共享的首 token 净改善均为 5/32,另有 0 道从正确变成错误,McNemar 精确双侧 p = 0.0625。双层直接共享比单层直接共享少答对的五道,恰好也是原模型和线性修正先输出 `<think>` 的五道。它们的正确选项都是 `4`,四选一口径在全部方法上均答对。输出符合格式是这里观察到的改善,后续生成内容没有记录。
原版 LiSA 相对双层直接共享的全词表 NLL 差为 −0.0872,按题配对 bootstrap 95% 区间为 [−0.1498, −0.0305]。答案加权版的差为 −0.4033,区间为 [−0.4796, −0.3344]。原版和加权版的首 token 命中数一致,加权版的平均答案 NLL 更低。由于五道变化集中于同一选项和同一个替代 token,推广到其它任务或输出格式还需要独立证据。
## CPU 计时和缓存
@@ -29,3 +45,5 @@
每个接收层的 FP32 K/V 实际分配从 643,072 降到 371,776 字节,下降 42.2%。计入该层所用的 5,024 字节上游分数行后,单层合计下降 41.4%。V 缓存为 321,536 字节。解码计时的单位是单个接收层的一步,计时范围从接收现成分数行开始,至该层注意力输出结束。预填充用 3 次计时的中位数,单层解码每个配置用 9 步计时的中位数。
论文表 2 的 96.44% 衡量 LLaMA2-13B 在共享 22 层时多个基准上的平均性能保留率。这里每轮只有 1,874 个训练目标 token,测到的是单一查找任务的表现和 CPU 组件耗时。 [论文表 2、表 3 和附录 C.1](https://aclanthology.org/2026.tacl-1.30.pdf)
训练轨迹、两种答案口径的逐题记录、配对统计、缓存和时延原始结果均在 [实验结果目录](../results/lisa-effect-reproduction/)。[复跑协议](LISA_EFFECT_PROTOCOL.md)
@@ -0,0 +1,104 @@
{
"tokenizer_sha256": "5f9e4d4901a92b997e463c1f46055088b6cca5ca61a6522d1b9f64c4bb81cb42",
"source_sha256": "b3a113d5ea1e4d11e9fdd2ff5e066a50ad3e75b3c20b109e2add05179c7e3eb4",
"decoded_tokens": {
"16": "1",
"17": "2",
"18": "3",
"19": "4",
"248068": "<think>"
},
"target_counts": {
"1": 8,
"4": 8,
"2": 8,
"3": 8
},
"wrong_first_tokens": {
"native": [
{
"item": "test-lookup16-012",
"expected": "4",
"produced": "<think>"
},
{
"item": "test-lookup16-017",
"expected": "4",
"produced": "<think>"
},
{
"item": "test-lookup16-022",
"expected": "4",
"produced": "<think>"
},
{
"item": "test-lookup16-024",
"expected": "4",
"produced": "<think>"
},
{
"item": "test-lookup16-029",
"expected": "4",
"produced": "<think>"
}
],
"direct_23": [],
"lisa_23_ablation": [],
"direct_chain": [
{
"item": "test-lookup16-012",
"expected": "4",
"produced": "<think>"
},
{
"item": "test-lookup16-017",
"expected": "4",
"produced": "<think>"
},
{
"item": "test-lookup16-022",
"expected": "4",
"produced": "<think>"
},
{
"item": "test-lookup16-024",
"expected": "4",
"produced": "<think>"
},
{
"item": "test-lookup16-029",
"expected": "4",
"produced": "<think>"
}
],
"lisa_chain": [],
"linear": [
{
"item": "test-lookup16-012",
"expected": "4",
"produced": "<think>"
},
{
"item": "test-lookup16-017",
"expected": "4",
"produced": "<think>"
},
{
"item": "test-lookup16-022",
"expected": "4",
"produced": "<think>"
},
{
"item": "test-lookup16-024",
"expected": "4",
"produced": "<think>"
},
{
"item": "test-lookup16-029",
"expected": "4",
"produced": "<think>"
}
],
"lisa_answer_weighted": []
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,123 @@
{
"selected_task": "lookup16",
"sites": [
19,
23
],
"n": 32,
"arms": {
"native": {
"correct": 32,
"answer_nll_4": 0.1341308259358034,
"native_correct_lost_by_direct": 0,
"rescued": 0,
"newly_lost_among_native_and_direct_correct": 0,
"candidate_correct_direct_wrong": 0,
"direct_correct_candidate_wrong": 0,
"accuracy_delta_vs_direct": 0.0,
"paired_prompt_bootstrap_95": [
0.0,
0.0
],
"mcnemar_exact_p": 1.0
},
"direct": {
"correct": 32,
"answer_nll_4": 0.07281379044277814,
"native_correct_lost_by_direct": 0,
"rescued": 0,
"newly_lost_among_native_and_direct_correct": 0,
"candidate_correct_direct_wrong": 0,
"direct_correct_candidate_wrong": 0,
"accuracy_delta_vs_direct": 0.0,
"paired_prompt_bootstrap_95": [
0.0,
0.0
],
"mcnemar_exact_p": 1.0
},
"linear": {
"correct": 32,
"answer_nll_4": 0.07204867493801925,
"native_correct_lost_by_direct": 0,
"rescued": 0,
"newly_lost_among_native_and_direct_correct": 0,
"candidate_correct_direct_wrong": 0,
"direct_correct_candidate_wrong": 0,
"accuracy_delta_vs_direct": 0.0,
"paired_prompt_bootstrap_95": [
0.0,
0.0
],
"mcnemar_exact_p": 1.0
},
"lisa": {
"correct": 32,
"answer_nll_4": 0.1846203565157959,
"native_correct_lost_by_direct": 0,
"rescued": 0,
"newly_lost_among_native_and_direct_correct": 0,
"candidate_correct_direct_wrong": 0,
"direct_correct_candidate_wrong": 0,
"accuracy_delta_vs_direct": 0.0,
"paired_prompt_bootstrap_95": [
0.0,
0.0
],
"mcnemar_exact_p": 1.0
},
"lisa_answer_weighted": {
"correct": 32,
"answer_nll_4": 0.12601824456448818,
"native_correct_lost_by_direct": 0,
"rescued": 0,
"newly_lost_among_native_and_direct_correct": 0,
"candidate_correct_direct_wrong": 0,
"direct_correct_candidate_wrong": 0,
"accuracy_delta_vs_direct": 0.0,
"paired_prompt_bootstrap_95": [
0.0,
0.0
],
"mcnemar_exact_p": 1.0
}
},
"prefill": {
"scope": "cached-prefix last layers, prefill",
"median_s": {
"native": 12.369724708609283,
"direct": 11.017615622840822,
"lisa": 16.311319678090513
},
"lisa_median_ratio_to_native": 1.3186485602818545
},
"decode": {
"scope": "isolated full-attention recipient, FP32, frozen true activations; excludes donor generation and full-model decode",
"sites": {
"19": {
"median_s_per_token": {
"native": 0.1361464262008667,
"lisa": 0.0963163236156106
},
"measured_kv_bytes": {
"native": 643072,
"lisa": 371776
},
"lisa_upstream_score_row_bytes": 5024,
"recipient_bytes_delta": -266272
},
"23": {
"median_s_per_token": {
"native": 0.13638535235077143,
"lisa": 0.1387955490499735
},
"measured_kv_bytes": {
"native": 643072,
"lisa": 371776
},
"lisa_upstream_score_row_bytes": 5024,
"recipient_bytes_delta": -266272
}
}
}
}
@@ -36,6 +36,26 @@
"lisa.pt": {"epoch": 2, "sha256": "358272c5eb90cea9e3ed006b2c75a4bcd7f5db4f857982e078dd7f71c6c46c5b"},
"lisa_answer_weighted.pt": {"epoch": 2, "sha256": "2b384d5618c190b29bdbb1bc0151c1eb64e1699e209a50ed8171a2d"}
},
"final_remote_verification": {
"pipeline_exit_code": 0,
"unittest_modules": [
"tests.test_lisa_train",
"tests.test_lisa_tail",
"tests.test_lisa_effect_screen",
"tests.test_lisa_effect_resume",
"tests.test_lisa_effect_audit"
],
"passed": 13,
"sha256": {
"test-items.json": "e978b482479deec2d78f8b19d75a5f708bd383111a4c360aad41384e572d48af",
"full-vocab-answers.json": "b3a113d5ea1e4d11e9fdd2ff5e066a50ad3e75b3c20b109e2add05179c7e3eb4",
"paired-audit.json": "f66e60b229cdeaaf6c295382b3bf617332e28f95d6610c11be571edd937e4570",
"verified-audit.json": "a5d496bb5f6d5518a5da2fd6ca3007934558860397a7678c8af8ee23a8d9b92d",
"decode.json": "36b84fbba56bd609f24f550124cd1417e67781eaa6a2401f152fb9f86641370b",
"performance.json": "5f806f713f00b794592899feb3b8188b352fb73052daf304d9026a1294801e17",
"train-protocol.json": "98c71cde7f8ab1bcdb9e05a814fd2c303a046cca51a0d8dfdc936c699da62cce"
}
},
"main_code_sha256": {
"lisa_effect.py": "8a3ecad71f23e3e8b8faf4a7c21c0c93f00fd0bffe14bdee6117921b548dce8a",
"lisa_tail.py": "4bd2c3c8690a8ae30cc1a9573ec17b7bbe25edf43a33507482719dc03cfeb9af",
@@ -0,0 +1,297 @@
{
"selected_task": "lookup16",
"sites": [
19,
23
],
"n": 32,
"arms": {
"native": {
"correct": 32,
"answer_nll_4": 0.1341308259358034,
"answer_nll_4_vs_direct": {
"mean_delta": 0.06131703549302525,
"paired_prompt_bootstrap_95": [
0.04199299138593708,
0.07944046845013401
]
},
"native_correct_lost_by_direct": 0,
"rescued": 0,
"newly_lost_among_native_and_direct_correct": 0,
"candidate_correct_direct_wrong": 0,
"direct_correct_candidate_wrong": 0,
"accuracy_delta_vs_direct": 0.0,
"paired_prompt_bootstrap_95": [
0.0,
0.0
],
"mcnemar_exact_p": 1.0
},
"direct": {
"correct": 32,
"answer_nll_4": 0.07281379044277814,
"answer_nll_4_vs_direct": {
"mean_delta": 0.0,
"paired_prompt_bootstrap_95": [
0.0,
0.0
]
},
"native_correct_lost_by_direct": 0,
"rescued": 0,
"newly_lost_among_native_and_direct_correct": 0,
"candidate_correct_direct_wrong": 0,
"direct_correct_candidate_wrong": 0,
"accuracy_delta_vs_direct": 0.0,
"paired_prompt_bootstrap_95": [
0.0,
0.0
],
"mcnemar_exact_p": 1.0
},
"linear": {
"correct": 32,
"answer_nll_4": 0.07204867493801925,
"answer_nll_4_vs_direct": {
"mean_delta": -0.0007651155047588842,
"paired_prompt_bootstrap_95": [
-0.0011749581537977532,
-0.00035981557985461103
]
},
"native_correct_lost_by_direct": 0,
"rescued": 0,
"newly_lost_among_native_and_direct_correct": 0,
"candidate_correct_direct_wrong": 0,
"direct_correct_candidate_wrong": 0,
"accuracy_delta_vs_direct": 0.0,
"paired_prompt_bootstrap_95": [
0.0,
0.0
],
"mcnemar_exact_p": 1.0
},
"lisa": {
"correct": 32,
"answer_nll_4": 0.1846203565157959,
"answer_nll_4_vs_direct": {
"mean_delta": 0.11180656607301775,
"paired_prompt_bootstrap_95": [
0.09675488440532508,
0.12821407122333472
]
},
"native_correct_lost_by_direct": 0,
"rescued": 0,
"newly_lost_among_native_and_direct_correct": 0,
"candidate_correct_direct_wrong": 0,
"direct_correct_candidate_wrong": 0,
"accuracy_delta_vs_direct": 0.0,
"paired_prompt_bootstrap_95": [
0.0,
0.0
],
"mcnemar_exact_p": 1.0
},
"lisa_answer_weighted": {
"correct": 32,
"answer_nll_4": 0.12601824456448818,
"answer_nll_4_vs_direct": {
"mean_delta": 0.05320445412171004,
"paired_prompt_bootstrap_95": [
0.03266015039585242,
0.07493446492664697
]
},
"native_correct_lost_by_direct": 0,
"rescued": 0,
"newly_lost_among_native_and_direct_correct": 0,
"candidate_correct_direct_wrong": 0,
"direct_correct_candidate_wrong": 0,
"accuracy_delta_vs_direct": 0.0,
"paired_prompt_bootstrap_95": [
0.0,
0.0
],
"mcnemar_exact_p": 1.0
}
},
"prefill": {
"scope": "cached-prefix last layers, prefill",
"median_s": {
"native": 12.369724708609283,
"direct": 11.017615622840822,
"lisa": 16.311319678090513
},
"lisa_median_ratio_to_native": 1.3186485602818545
},
"decode": {
"scope": "isolated full-attention recipient, FP32, frozen true activations; excludes donor generation and full-model decode",
"sites": {
"19": {
"median_s_per_token": {
"native": 0.1361464262008667,
"lisa": 0.0963163236156106
},
"measured_kv_bytes": {
"native": 643072,
"lisa": 371776
},
"lisa_upstream_score_row_bytes": 5024,
"recipient_bytes_delta": -266272
},
"23": {
"median_s_per_token": {
"native": 0.13638535235077143,
"lisa": 0.1387955490499735
},
"measured_kv_bytes": {
"native": 643072,
"lisa": 371776
},
"lisa_upstream_score_row_bytes": 5024,
"recipient_bytes_delta": -266272
}
}
},
"full_vocab": {
"arms": {
"native": {
"correct": 27,
"answer_nll": 0.5633379220962524
},
"direct_23": {
"correct": 32,
"answer_nll": 0.31241124868392944
},
"lisa_23_ablation": {
"correct": 32,
"answer_nll": 0.2554302215576172
},
"direct_chain": {
"correct": 27,
"answer_nll": 0.5578678846359253
},
"lisa_chain": {
"correct": 32,
"answer_nll": 0.4706266522407532
},
"linear": {
"correct": 27,
"answer_nll": 0.5574188828468323
},
"lisa_answer_weighted": {
"correct": 32,
"answer_nll": 0.15454155206680298
}
},
"matched_direct_comparisons": {
"lisa_23_ablation": {
"baseline": "direct_23",
"answer_nll_delta": {
"mean_delta": -0.056981027126312256,
"paired_prompt_bootstrap_95": [
-0.0759883001446724,
-0.03968979567289353
]
},
"native_correct_lost_by_direct": 0,
"rescued": 0,
"newly_lost_among_native_and_direct_correct": 0,
"candidate_correct_direct_wrong": 0,
"direct_correct_candidate_wrong": 0,
"accuracy_delta_vs_direct": 0.0,
"paired_prompt_bootstrap_95": [
0.0,
0.0
],
"mcnemar_exact_p": 1.0
},
"native": {
"baseline": "direct_chain",
"answer_nll_delta": {
"mean_delta": 0.0054700374603271484,
"paired_prompt_bootstrap_95": [
-0.04259051829576492,
0.05237825959920882
]
},
"native_correct_lost_by_direct": 0,
"rescued": 0,
"newly_lost_among_native_and_direct_correct": 0,
"candidate_correct_direct_wrong": 0,
"direct_correct_candidate_wrong": 0,
"accuracy_delta_vs_direct": 0.0,
"paired_prompt_bootstrap_95": [
0.0,
0.0
],
"mcnemar_exact_p": 1.0
},
"linear": {
"baseline": "direct_chain",
"answer_nll_delta": {
"mean_delta": -0.0004490017890930176,
"paired_prompt_bootstrap_95": [
-0.002629266679286957,
0.0016906306147575377
]
},
"native_correct_lost_by_direct": 0,
"rescued": 0,
"newly_lost_among_native_and_direct_correct": 0,
"candidate_correct_direct_wrong": 0,
"direct_correct_candidate_wrong": 0,
"accuracy_delta_vs_direct": 0.0,
"paired_prompt_bootstrap_95": [
0.0,
0.0
],
"mcnemar_exact_p": 1.0
},
"lisa_answer_weighted": {
"baseline": "direct_chain",
"answer_nll_delta": {
"mean_delta": -0.4033263325691223,
"paired_prompt_bootstrap_95": [
-0.47958737164735793,
-0.33443659693002703
]
},
"native_correct_lost_by_direct": 0,
"rescued": 0,
"newly_lost_among_native_and_direct_correct": 0,
"candidate_correct_direct_wrong": 5,
"direct_correct_candidate_wrong": 0,
"accuracy_delta_vs_direct": 0.15625,
"paired_prompt_bootstrap_95": [
0.03125,
0.28125
],
"mcnemar_exact_p": 0.0625
},
"lisa_chain": {
"baseline": "direct_chain",
"answer_nll_delta": {
"mean_delta": -0.08724123239517212,
"paired_prompt_bootstrap_95": [
-0.14977428913116456,
-0.030542241036891984
]
},
"native_correct_lost_by_direct": 0,
"rescued": 0,
"newly_lost_among_native_and_direct_correct": 0,
"candidate_correct_direct_wrong": 5,
"direct_correct_candidate_wrong": 0,
"accuracy_delta_vs_direct": 0.15625,
"paired_prompt_bootstrap_95": [
0.03125,
0.28125
],
"mcnemar_exact_p": 0.0625
}
}
}
}