From 04a58682de217acd48bb986ea45cf5522a81054c Mon Sep 17 00:00:00 2001 From: Codex Bot Date: Wed, 2 Dec 2026 16:21:21 +0800 Subject: [PATCH] Verify both score-path replay endpoints against archived lookup answers --- crossqkv/lisa_score_paths_audit.py | 48 ++- docs/LISA_SCORE_PATHS_RESULTS.md | 7 + .../replay-19-baseline-old.json | 306 ++++++++++++++++++ .../lisa-score-paths/replay-19-both-old.json | 306 ++++++++++++++++++ results/lisa-score-paths/replay-verified.json | 17 + 5 files changed, 671 insertions(+), 13 deletions(-) create mode 100644 docs/LISA_SCORE_PATHS_RESULTS.md create mode 100644 results/lisa-score-paths/replay-19-baseline-old.json create mode 100644 results/lisa-score-paths/replay-19-both-old.json create mode 100644 results/lisa-score-paths/replay-verified.json diff --git a/crossqkv/lisa_score_paths_audit.py b/crossqkv/lisa_score_paths_audit.py index 63a1650..6f519ac 100644 --- a/crossqkv/lisa_score_paths_audit.py +++ b/crossqkv/lisa_score_paths_audit.py @@ -45,6 +45,23 @@ def interval(values, resamples): upper95=estimates[math.ceil(len(estimates)*.975)-1]) +def summarize_arms(arms, contrasts, samples): + first = next(iter(arms.values())) + fields = first[0].keys() + count = len(first) + assert all(len(arm) == count for arm in arms.values()) + means = {m: {k: mean(row[k] for row in arm) for k in fields} + for m, arm in arms.items()} + comparisons = {} + for name, coefficients in contrasts.items(): + comparisons[name] = {} + for field in fields: + differences = [sum(c * arms[m][i][field] for m, c in coefficients.items()) + for i in range(count)] + comparisons[name][field] = interval(differences, samples) + return dict(means=means, paired_contrasts=comparisons) + + def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('directory', type=Path) @@ -93,7 +110,6 @@ def main(): mode: [{k: (s[k]+q[k])/2 for k in fields} for s, q in zip(tables['swap'][mode], tables['query'][mode])] for mode in modes} for kind, arms in tables.items(): - estimates = {mode: {k: mean(row[k] for row in arms[mode]) for k in fields} for mode in modes} contrasts = {mode+'-baseline': {mode: 1, 'baseline': -1} for mode in modes if mode != 'baseline'} contrasts['interaction'] = {'both': 1, 'baseline': 1, 'read': -1, 'send': -1} if 'send-permuted' in modes: @@ -103,13 +119,9 @@ def main(): other = next(m for m in modes if m.startswith('read-group-') and m != selected) contrasts['selected-other'] = {selected: 1, other: -1} contrasts['selected-full-read'] = {selected: 1, 'read': -1} - comparisons = {} - for name, coefficients in contrasts.items(): - comparisons[name] = {k: interval([ - sum(c*arms[m][i][k] for m, c in coefficients.items()) for i in range(n) - ], resamples) for k in fields} - summary[kind] = dict(means=estimates, paired_contrasts=comparisons) + summary[kind] = summarize_arms(arms, contrasts, resamples) isolation = {} + layer_comparison = {} for kind, prompts in plan['diagnostic'].items(): arms = {} for mode in ('native', 'only-15', 'only-19', 'both-15-19'): @@ -123,14 +135,24 @@ def main(): 'only-15-minus-native': {'only-15': 1, 'native': -1}, 'only-19-minus-native': {'only-19': 1, 'native': -1}, 'joint-interaction': {'both-15-19': 1, 'only-19': -1, 'only-15': -1, 'native': 1}} - isolation[kind] = { - 'means': {m: {k: mean(row[k] for row in arm) for k in fields} for m, arm in arms.items()}, - 'contrasts': {name: {k: interval([ - sum(c*arms[m][i][k] for m,c in coefficients.items()) for i in range(count) - ], samples) for k in fields} for name, coefficients in combinations.items()}} + isolation[kind] = summarize_arms(arms, combinations, samples) + arms = {} + for site, mode in [(19, 'baseline')] + [(s, m) for s in (15, 19) + for m in ('both', 'read', 'send')]: + rows = read(f'diagnostic-{site}-{mode}-{kind}.json') + verify(tokenizer, protocol, prompts, rows, (mode,)) + label = 'baseline' if mode == 'baseline' else f'{site}-{mode}' + arms[label], _ = table_metrics(prompts, rows, mode) + comparisons = {f'19-minus-15-{m}': {f'19-{m}': 1, f'15-{m}': -1} + for m in ('read', 'send', 'both')} + for site in (15, 19): + comparisons[f'{site}-interaction'] = { + f'{site}-both': 1, 'baseline': 1, f'{site}-read': -1, f'{site}-send': -1} + layer_comparison[kind] = summarize_arms(arms, comparisons, samples) write_json(args.directory/'audit.json', dict( tables=n, bootstrap_seed=120204, bootstrap_replicates=len(resamples), - summary=summary, answers=detail, costs=costs, diagnostic_isolation=isolation)) + summary=summary, answers=detail, costs=costs, diagnostic_isolation=isolation, + diagnostic_site_comparison=layer_comparison)) if __name__ == '__main__': diff --git a/docs/LISA_SCORE_PATHS_RESULTS.md b/docs/LISA_SCORE_PATHS_RESULTS.md new file mode 100644 index 0000000..d951dc3 --- /dev/null +++ b/docs/LISA_SCORE_PATHS_RESULTS.md @@ -0,0 +1,7 @@ +# LiSA 查表分数路径实验结果 + +## 旧诊断题端点重放 + +同一份 Qwen3.5-2B 和同一份冻结 LiSA 在旧诊断集上重放 8 对题。原 LiSA 的 16 份答卷逐 token 与归档相同,完整答案全错。只在第 19 层同时恢复本层读取与向第 23 层传递的原生分数,另 16 份答卷也逐 token 与旧恢复组相同,完整答案全对。两组正确首位数字的概率相对既有全词表评分,最大绝对差分别为 0.00000136 和 0.00000241。核验还比较了题号、金标、终止原因及整数解析。[基线答卷](../results/lisa-score-paths/replay-19-baseline-old.json) · [恢复组答卷](../results/lisa-score-paths/replay-19-both-old.json) · [哈希与核验结果](../results/lisa-score-paths/replay-verified.json) + +这批题曾用于选层,重放检验的是实现一致性。区分本层读取、分数传递和单层共享损伤的实验采用另外生成的表。[实验协议](LISA_SCORE_PATHS.md) diff --git a/results/lisa-score-paths/replay-19-baseline-old.json b/results/lisa-score-paths/replay-19-baseline-old.json new file mode 100644 index 0000000..32499b8 --- /dev/null +++ b/results/lisa-score-paths/replay-19-baseline-old.json @@ -0,0 +1,306 @@ +[ + { + "id": "diagnostic-000-0", + "task": "lookup", + "gold": 76, + "first_digit_probability": 0.043660085648298264, + "arms": { + "baseline": { + "tokens": [ + 24, + 19, + 248046 + ], + "response": "94<|im_end|>", + "stop": "eos", + "answer": 94, + "correct": false + } + } + }, + { + "id": "diagnostic-000-1", + "task": "lookup", + "gold": 75, + "first_digit_probability": 0.049357522279024124, + "arms": { + "baseline": { + "tokens": [ + 24, + 19, + 248046 + ], + "response": "94<|im_end|>", + "stop": "eos", + "answer": 94, + "correct": false + } + } + }, + { + "id": "diagnostic-001-0", + "task": "lookup", + "gold": 39, + "first_digit_probability": 0.1423700600862503, + "arms": { + "baseline": { + "tokens": [ + 22, + 18, + 248046 + ], + "response": "73<|im_end|>", + "stop": "eos", + "answer": 73, + "correct": false + } + } + }, + { + "id": "diagnostic-001-1", + "task": "lookup", + "gold": 76, + "first_digit_probability": 0.7241368293762207, + "arms": { + "baseline": { + "tokens": [ + 22, + 18, + 248046 + ], + "response": "73<|im_end|>", + "stop": "eos", + "answer": 73, + "correct": false + } + } + }, + { + "id": "diagnostic-002-0", + "task": "lookup", + "gold": 49, + "first_digit_probability": 0.1303817480802536, + "arms": { + "baseline": { + "tokens": [ + 20, + 17, + 248046 + ], + "response": "52<|im_end|>", + "stop": "eos", + "answer": 52, + "correct": false + } + } + }, + { + "id": "diagnostic-002-1", + "task": "lookup", + "gold": 22, + "first_digit_probability": 0.019029637798666954, + "arms": { + "baseline": { + "tokens": [ + 20, + 17, + 248046 + ], + "response": "52<|im_end|>", + "stop": "eos", + "answer": 52, + "correct": false + } + } + }, + { + "id": "diagnostic-003-0", + "task": "lookup", + "gold": 63, + "first_digit_probability": 0.03255172818899155, + "arms": { + "baseline": { + "tokens": [ + 24, + 15, + 248046 + ], + "response": "90<|im_end|>", + "stop": "eos", + "answer": 90, + "correct": false + } + } + }, + { + "id": "diagnostic-003-1", + "task": "lookup", + "gold": 21, + "first_digit_probability": 0.005789129063487053, + "arms": { + "baseline": { + "tokens": [ + 24, + 15, + 248046 + ], + "response": "90<|im_end|>", + "stop": "eos", + "answer": 90, + "correct": false + } + } + }, + { + "id": "diagnostic-004-0", + "task": "lookup", + "gold": 74, + "first_digit_probability": 0.058539994060993195, + "arms": { + "baseline": { + "tokens": [ + 24, + 24, + 248046 + ], + "response": "99<|im_end|>", + "stop": "eos", + "answer": 99, + "correct": false + } + } + }, + { + "id": "diagnostic-004-1", + "task": "lookup", + "gold": 29, + "first_digit_probability": 0.006509687285870314, + "arms": { + "baseline": { + "tokens": [ + 24, + 24, + 248046 + ], + "response": "99<|im_end|>", + "stop": "eos", + "answer": 99, + "correct": false + } + } + }, + { + "id": "diagnostic-005-0", + "task": "lookup", + "gold": 39, + "first_digit_probability": 0.0035035305190831423, + "arms": { + "baseline": { + "tokens": [ + 21, + 16, + 248046 + ], + "response": "61<|im_end|>", + "stop": "eos", + "answer": 61, + "correct": false + } + } + }, + { + "id": "diagnostic-005-1", + "task": "lookup", + "gold": 77, + "first_digit_probability": 0.1008690670132637, + "arms": { + "baseline": { + "tokens": [ + 21, + 16, + 248046 + ], + "response": "61<|im_end|>", + "stop": "eos", + "answer": 61, + "correct": false + } + } + }, + { + "id": "diagnostic-006-0", + "task": "lookup", + "gold": 40, + "first_digit_probability": 0.22315144538879395, + "arms": { + "baseline": { + "tokens": [ + 20, + 15, + 248046 + ], + "response": "50<|im_end|>", + "stop": "eos", + "answer": 50, + "correct": false + } + } + }, + { + "id": "diagnostic-006-1", + "task": "lookup", + "gold": 67, + "first_digit_probability": 0.06879249960184097, + "arms": { + "baseline": { + "tokens": [ + 20, + 15, + 248046 + ], + "response": "50<|im_end|>", + "stop": "eos", + "answer": 50, + "correct": false + } + } + }, + { + "id": "diagnostic-007-0", + "task": "lookup", + "gold": 89, + "first_digit_probability": 0.015698770061135292, + "arms": { + "baseline": { + "tokens": [ + 19, + 18, + 248046 + ], + "response": "43<|im_end|>", + "stop": "eos", + "answer": 43, + "correct": false + } + } + }, + { + "id": "diagnostic-007-1", + "task": "lookup", + "gold": 61, + "first_digit_probability": 0.011921032331883907, + "arms": { + "baseline": { + "tokens": [ + 19, + 18, + 248046 + ], + "response": "43<|im_end|>", + "stop": "eos", + "answer": 43, + "correct": false + } + } + } +] diff --git a/results/lisa-score-paths/replay-19-both-old.json b/results/lisa-score-paths/replay-19-both-old.json new file mode 100644 index 0000000..dc18b26 --- /dev/null +++ b/results/lisa-score-paths/replay-19-both-old.json @@ -0,0 +1,306 @@ +[ + { + "id": "diagnostic-000-0", + "task": "lookup", + "gold": 76, + "first_digit_probability": 0.49160245060920715, + "arms": { + "both": { + "tokens": [ + 22, + 21, + 248046 + ], + "response": "76<|im_end|>", + "stop": "eos", + "answer": 76, + "correct": true + } + } + }, + { + "id": "diagnostic-000-1", + "task": "lookup", + "gold": 75, + "first_digit_probability": 0.533911406993866, + "arms": { + "both": { + "tokens": [ + 22, + 20, + 248046 + ], + "response": "75<|im_end|>", + "stop": "eos", + "answer": 75, + "correct": true + } + } + }, + { + "id": "diagnostic-001-0", + "task": "lookup", + "gold": 39, + "first_digit_probability": 0.9007320404052734, + "arms": { + "both": { + "tokens": [ + 18, + 24, + 248046 + ], + "response": "39<|im_end|>", + "stop": "eos", + "answer": 39, + "correct": true + } + } + }, + { + "id": "diagnostic-001-1", + "task": "lookup", + "gold": 76, + "first_digit_probability": 0.9933711290359497, + "arms": { + "both": { + "tokens": [ + 22, + 21, + 248046 + ], + "response": "76<|im_end|>", + "stop": "eos", + "answer": 76, + "correct": true + } + } + }, + { + "id": "diagnostic-002-0", + "task": "lookup", + "gold": 49, + "first_digit_probability": 0.784931480884552, + "arms": { + "both": { + "tokens": [ + 19, + 24, + 248046 + ], + "response": "49<|im_end|>", + "stop": "eos", + "answer": 49, + "correct": true + } + } + }, + { + "id": "diagnostic-002-1", + "task": "lookup", + "gold": 22, + "first_digit_probability": 0.6501032710075378, + "arms": { + "both": { + "tokens": [ + 17, + 17, + 248046 + ], + "response": "22<|im_end|>", + "stop": "eos", + "answer": 22, + "correct": true + } + } + }, + { + "id": "diagnostic-003-0", + "task": "lookup", + "gold": 63, + "first_digit_probability": 0.9689449071884155, + "arms": { + "both": { + "tokens": [ + 21, + 18, + 248046 + ], + "response": "63<|im_end|>", + "stop": "eos", + "answer": 63, + "correct": true + } + } + }, + { + "id": "diagnostic-003-1", + "task": "lookup", + "gold": 21, + "first_digit_probability": 0.9367953538894653, + "arms": { + "both": { + "tokens": [ + 17, + 16, + 248046 + ], + "response": "21<|im_end|>", + "stop": "eos", + "answer": 21, + "correct": true + } + } + }, + { + "id": "diagnostic-004-0", + "task": "lookup", + "gold": 74, + "first_digit_probability": 0.9645876288414001, + "arms": { + "both": { + "tokens": [ + 22, + 19, + 248046 + ], + "response": "74<|im_end|>", + "stop": "eos", + "answer": 74, + "correct": true + } + } + }, + { + "id": "diagnostic-004-1", + "task": "lookup", + "gold": 29, + "first_digit_probability": 0.788325309753418, + "arms": { + "both": { + "tokens": [ + 17, + 24, + 248046 + ], + "response": "29<|im_end|>", + "stop": "eos", + "answer": 29, + "correct": true + } + } + }, + { + "id": "diagnostic-005-0", + "task": "lookup", + "gold": 39, + "first_digit_probability": 0.6246046423912048, + "arms": { + "both": { + "tokens": [ + 18, + 24, + 248046 + ], + "response": "39<|im_end|>", + "stop": "eos", + "answer": 39, + "correct": true + } + } + }, + { + "id": "diagnostic-005-1", + "task": "lookup", + "gold": 77, + "first_digit_probability": 0.7460411787033081, + "arms": { + "both": { + "tokens": [ + 22, + 22, + 248046 + ], + "response": "77<|im_end|>", + "stop": "eos", + "answer": 77, + "correct": true + } + } + }, + { + "id": "diagnostic-006-0", + "task": "lookup", + "gold": 40, + "first_digit_probability": 0.9425035715103149, + "arms": { + "both": { + "tokens": [ + 19, + 15, + 248046 + ], + "response": "40<|im_end|>", + "stop": "eos", + "answer": 40, + "correct": true + } + } + }, + { + "id": "diagnostic-006-1", + "task": "lookup", + "gold": 67, + "first_digit_probability": 0.8656787872314453, + "arms": { + "both": { + "tokens": [ + 21, + 22, + 248046 + ], + "response": "67<|im_end|>", + "stop": "eos", + "answer": 67, + "correct": true + } + } + }, + { + "id": "diagnostic-007-0", + "task": "lookup", + "gold": 89, + "first_digit_probability": 0.8434507846832275, + "arms": { + "both": { + "tokens": [ + 23, + 24, + 248046 + ], + "response": "89<|im_end|>", + "stop": "eos", + "answer": 89, + "correct": true + } + } + }, + { + "id": "diagnostic-007-1", + "task": "lookup", + "gold": 61, + "first_digit_probability": 0.49588829278945923, + "arms": { + "both": { + "tokens": [ + 21, + 16, + 248046 + ], + "response": "61<|im_end|>", + "stop": "eos", + "answer": 61, + "correct": true + } + } + } +] diff --git a/results/lisa-score-paths/replay-verified.json b/results/lisa-score-paths/replay-verified.json new file mode 100644 index 0000000..b87cfb9 --- /dev/null +++ b/results/lisa-score-paths/replay-verified.json @@ -0,0 +1,17 @@ +{ + "baseline": { + "replay_sha256": "b69bdd1aa5bc91447a6b8f600b597f5a2d61c9ecd16aa1f29815b3dc0414afba", + "reference_sha256": "8f3fb8773fa790de01604db9a313365bab25a55c86b363eaf0269f94df020e8f", + "token_identical": 16, + "correct": 0, + "maximum_first_digit_probability_difference": 1.361978284930565e-06 + }, + "both": { + "replay_sha256": "f74d4d4ab6af9c92188f5a4d9e34195c67d187f6a72586f2d60710f5ea456152", + "reference_sha256": "c1b158e61eaa98b1c24ead81363ef3193b392d36947f3199e7930fe199e5163a", + "token_identical": 16, + "correct": 16, + "maximum_first_digit_probability_difference": 2.4037814841948446e-06 + }, + "reference_probabilities_sha256": "7fb33eca323ab3ec45ceae8be77609e388fe88b2b77eb59c43726cc0c39b69e3" +}