import os, json, glob, math, collectionsimport numpy as npimport torch
print("Model tensors:", len(NAMES))print("Representative names:", [ n for n in NAMES if ("layers.0." in n or "layers.17." in n)][:24])print("Work files:", sorted(os.listdir("/work"))[:30])with open("/work/eval_prompt_format.txt") as f: prompt_format = f.read()print("Prompt format:", repr(prompt_format))
practice = {}practice_by_source = {}for source in ["gsm8k_train", "math_train"]: with open("/practice/" + source + ".jsonl") as f: rows = [json.loads(line) for line in f] practice_by_source[source] = rows for row in rows: practice[row["id"]] = row print(source, "count:", len(rows), "fields:", sorted(rows[0].keys())) if source == "math_train": print("Levels:", dict(collections.Counter(str(r.get("level")) for r in rows))) print("Subjects:", dict(collections.Counter(str(r.get("subject")) for r in rows)))
print("Tokenizer interface:", type(tok).__name__)print("Existing edits:", edited())print("No weights changed.")Model tensors: 236Representative names: ['model.layers.0.input_layernorm.weight', 'model.layers.0.mlp.down_proj.weight', 'model.layers.0.mlp.gate_proj.weight', 'model.layers.0.mlp.up_proj.weight', 'model.layers.0.post_attention_layernorm.weight', 'model.layers.0.post_feedforward_layernorm.weight', 'model.layers.0.pre_feedforward_layernorm.weight', 'model.layers.0.self_attn.k_norm.weight', 'model.layers.0.self_attn.k_proj.weight', 'model.layers.0.self_attn.o_proj.weight', 'model.layers.0.self_attn.q_norm.weight', 'model.layers.0.self_attn.q_proj.weight', 'model.layers.0.self_attn.v_proj.weight', 'model.layers.17.input_layernorm.weight', 'model.layers.17.mlp.down_proj.weight', 'model.layers.17.mlp.gate_proj.weight', 'model.layers.17.mlp.up_proj.weight', 'model.layers.17.post_attention_layernorm.weight', 'model.layers.17.post_feedforward_layernorm.weight', 'model.layers.17.pre_feedforward_layernorm.weight', 'model.layers.17.self_attn.k_norm.weight', 'model.layers.17.self_attn.k_proj.weight', 'model.layers.17.self_attn.o_proj.weight', 'model.layers.17.self_attn.q_norm.weight']Work files: ['eval_prompt_format.txt']Prompt format: 'The evaluation prompt, exactly as the model sees it (thinking off), for a problem P:\nPREFIX + P + SUFFIX, with\nPREFIX = \'<bos><start_of_turn>user\\n\'\nSUFFIX = \'\\nPlease reason step by step, and put your final answer within \\\\boxed{}.<end_of_turn>\\n<start_of_turn>model\\n\'\nThe model\'s answer follows SUFFIX directly. To score a text with a teacher-forced pass, send PREFIX + P + SUFFIX + answer as one raw text in "texts".\n'gsm8k_train count: 7469 fields: ['answer', 'id', 'problem', 'solution', 'source']math_train count: 7275 fields: ['answer', 'id', 'level', 'problem', 'solution', 'source', 'subject']Levels: {'Level 5': 2187, 'Level 3': 1558, 'Level 4': 1652, 'Level 1': 556, 'Level 2': 1320, 'Level ?': 2}Subjects: {'algebra': 1726, 'counting_and_probability': 737, 'geometry': 799, 'intermediate_algebra': 1270, 'number_theory': 859, 'prealgebra': 1196, 'precalculus': 688}Tokenizer interface: TokenizerExisting edits: []No weights changed.rng = np.random.default_rng(20261025)math_rows = practice_by_source["math_train"]gsm_rows = practice_by_source["gsm8k_train"]
holdout_ids = []for level, count in [(1,26), (2,26), (3,26), (4,25), (5,25)]: pool = sorted([r["id"] for r in math_rows if r["level"] == f"Level {level}"]) holdout_ids.extend(rng.choice(pool, count, replace=False).tolist())holdout_set = set(holdout_ids)
diagnostic_ids = []for level, count in [(1,32), (2,32), (3,24), (4,16), (5,8)]: pool = sorted([ r["id"] for r in math_rows if r["level"] == f"Level {level}" and r["id"] not in holdout_set ]) diagnostic_ids.extend(rng.choice(pool, count, replace=False).tolist())diagnostic_ids.extend(rng.choice( sorted(r["id"] for r in gsm_rows), 16, replace=False).tolist())assert len(diagnostic_ids) == 128assert not set(diagnostic_ids) & holdout_set
os.makedirs("/work", exist_ok=True)for filename, ids in [ ("HOLDOUT_ids.json", holdout_ids), ("diagnostic_ids.json", diagnostic_ids),]: with open("/work/" + filename, "w") as f: json.dump(ids, f)
notes = """# Math weight-edit experiment
## Fixed design- Seed: 20261025.- HOLDOUT: 128 MATH problems, stratified by level; ids in HOLDOUT_ids.json. No holdout generations or scores will be inspected until the candidate is frozen.- Diagnostic pool: 112 separate MATH problems plus 16 GSM8K problems; ids in diagnostic_ids.json.- DEV will be fixed from diagnostic problems with both correct and incorrect baseline samples, before any weight edit.- Planned passes: baseline generation; original teacher-forced localization; paired DEV at two edit strengths; frozen paired HOLDOUT.- All generation comparisons use the specified sampling and 8192-token limit.
## Pass 1: baseline diagnosis- Exact edit: none; original weights.- Problems: diagnostic_ids.json, 128 problems, 16 samples each (2048 answers).- Collect residual layers 0..18 and all available MLP down-projection inputs.- Inspect accuracy, missing answers, token-limit failures, and failing text."""with open("/work/notes.md", "w") as f: f.write(notes)
print("Holdout reserved:", len(holdout_ids))print("Diagnostic problem IDs:")print(json.dumps(diagnostic_ids))Holdout reserved: 128Diagnostic problem IDs:["math_train_algebra_1519", "math_train_prealgebra_327", "math_train_prealgebra_158", "math_train_intermediate_algebra_239", "math_train_prealgebra_55", "math_train_intermediate_algebra_785", "math_train_algebra_1500", "math_train_counting_and_probability_501", "math_train_algebra_1152", "math_train_prealgebra_774", "math_train_prealgebra_741", "math_train_prealgebra_940", "math_train_counting_and_probability_111", "math_train_algebra_573", "math_train_algebra_1114", "math_train_counting_and_probability_621", "math_train_algebra_549", "math_train_geometry_743", "math_train_geometry_236", "math_train_intermediate_algebra_1043", "math_train_algebra_636", "math_train_algebra_1497", "math_train_prealgebra_585", "math_train_counting_and_probability_626", "math_train_algebra_1573", "math_train_geometry_856", "math_train_precalculus_220", "math_train_intermediate_algebra_80", "math_train_prealgebra_590", "math_train_algebra_182", "math_train_prealgebra_793", "math_train_algebra_1566", "math_train_geometry_119", "math_train_algebra_958", "math_train_number_theory_540", "math_train_prealgebra_839", "math_train_prealgebra_780", "math_train_prealgebra_593", "math_train_intermediate_algebra_633", "math_train_prealgebra_1195", "math_train_precalculus_245", "math_train_algebra_495", "math_train_algebra_731", "math_train_intermediate_algebra_1156", "math_train_algebra_1574", "math_train_prealgebra_1065", "math_train_algebra_656", "math_train_prealgebra_314", "math_train_prealgebra_1182", "math_train_algebra_1707", "math_train_counting_and_probability_606", "math_train_prealgebra_502", "math_train_intermediate_algebra_1080", "math_train_prealgebra_1007", "math_train_geometry_88", "math_train_algebra_56", "math_train_algebra_1461", "math_train_algebra_939", "math_train_algebra_1523", "math_train_intermediate_algebra_1053", "math_train_intermediate_algebra_954", "math_train_precalculus_614", "math_train_prealgebra_318", "math_train_geometry_769", "math_train_number_theory_696", "math_train_number_theory_542", "math_train_precalculus_8", "math_train_algebra_43", "math_train_intermediate_algebra_1074", "math_train_intermediate_algebra_686", "math_train_prealgebra_207", "math_train_algebra_963", "math_train_precalculus_483", "math_train_number_theory_773", "math_train_precalculus_112", "math_train_algebra_361", "math_train_intermediate_algebra_36", "math_train_intermediate_algebra_486", "math_train_algebra_144", "math_train_precalculus_97", "math_train_counting_and_probability_740", "math_train_number_theory_839", "math_train_intermediate_algebra_933", "math_train_algebra_1423", "math_train_intermediate_algebra_925", "math_train_precalculus_209", "math_train_counting_and_probability_148", "math_train_algebra_32", "math_train_intermediate_algebra_34", "math_train_number_theory_496", "math_train_intermediate_algebra_643", "math_train_algebra_1657", "math_train_algebra_1115", "math_train_number_theory_538", "math_train_algebra_498", "math_train_prealgebra_523", "math_train_precalculus_94", "math_train_number_theory_479", "math_train_geometry_86", "math_train_number_theory_722", "math_train_geometry_158", "math_train_precalculus_81", "math_train_algebra_1102", "math_train_prealgebra_1113", "math_train_precalculus_502", "math_train_counting_and_probability_757", "math_train_prealgebra_202", "math_train_algebra_1486", "math_train_geometry_774", "math_train_counting_and_probability_674", "math_train_intermediate_algebra_1131", "math_train_counting_and_probability_323", "gsm8k_train_4686", "gsm8k_train_455", "gsm8k_train_4449", "gsm8k_train_4236", "gsm8k_train_1792", "gsm8k_train_6299", "gsm8k_train_3211", "gsm8k_train_6931", "gsm8k_train_6481", "gsm8k_train_2062", "gsm8k_train_6691", "gsm8k_train_7053", "gsm8k_train_4344", "gsm8k_train_1620", "gsm8k_train_3545", "gsm8k_train_2606"]{"type":"generate","model":"original","problems":["math_train_algebra_1519","math_train_prealgebra_327","math_train_prealgebra_158","math_train_intermediate_algebra_239","math_train_prealgebra_55","math_train_intermediate_algebra_785","math_train_algebra_1500","math_train_counting_and_probability_501","math_train_algebra_1152","math_train_prealgebra_774","math_train_prealgebra_741","math_train_prealgebra_940","math_train_counting_and_probability_111","math_train_algebra_573","math_train_algebra_1114","math_train_counting_and_probability_621","math_train_algebra_549","math_train_geometry_743","math_train_geometry_236","math_train_intermediate_algebra_1043","math_train_algebra_636","math_train_algebra_1497","math_train_prealgebra_585","math_train_counting_and_probability_626","math_train_algebra_1573","math_train_geometry_856","math_train_precalculus_220","math_train_intermediate_algebra_80","math_train_prealgebra_590","math_train_algebra_182","math_train_prealgebra_793","math_train_algebra_1566","math_train_geometry_119","math_train_algebra_958","math_train_number_theory_540","math_train_prealgebra_839","math_train_prealgebra_780","math_train_prealgebra_593","math_train_intermediate_algebra_633","math_train_prealgebra_1195","math_train_precalculus_245","math_train_algebra_495","math_train_algebra_731","math_train_intermediate_algebra_1156","math_train_algebra_1574","math_train_prealgebra_1065","math_train_algebra_656","math_train_prealgebra_314","math_train_prealgebra_1182","math_train_algebra_1707","math_train_counting_and_probability_606","math_train_prealgebra_502","math_train_intermediate_algebra_1080","math_train_prealgebra_1007","math_train_geometry_88","math_train_algebra_56","math_train_algebra_1461","math_train_algebra_939","math_train_algebra_1523","math_train_intermediate_algebra_1053","math_train_intermediate_algebra_954","math_train_precalculus_614","math_train_prealgebra_318","math_train_geometry_769","math_train_number_theory_696","math_train_number_theory_542","math_train_precalculus_8","math_train_algebra_43","math_train_intermediate_algebra_1074","math_train_intermediate_algebra_686","math_train_prealgebra_207","math_train_algebra_963","math_train_precalculus_483","math_train_number_theory_773","math_train_precalculus_112","math_train_algebra_361","math_train_intermediate_algebra_36","math_train_intermediate_algebra_486","math_train_algebra_144","math_train_precalculus_97","math_train_counting_and_probability_740","math_train_number_theory_839","math_train_intermediate_algebra_933","math_train_algebra_1423","math_train_intermediate_algebra_925","math_train_precalculus_209","math_train_counting_and_probability_148","math_train_algebra_32","math_train_intermediate_algebra_34","math_train_number_theory_496","math_train_intermediate_algebra_643","math_train_algebra_1657","math_train_algebra_1115","math_train_number_theory_538","math_train_algebra_498","math_train_prealgebra_523","math_train_precalculus_94","math_train_number_theory_479","math_train_geometry_86","math_train_number_theory_722","math_train_geometry_158","math_train_precalculus_81","math_train_algebra_1102","math_train_prealgebra_1113","math_train_precalculus_502","math_train_counting_and_probability_757","math_train_prealgebra_202","math_train_algebra_1486","math_train_geometry_774","math_train_counting_and_probability_674","math_train_intermediate_algebra_1131","math_train_counting_and_probability_323","gsm8k_train_4686","gsm8k_train_455","gsm8k_train_4449","gsm8k_train_4236","gsm8k_train_1792","gsm8k_train_6299","gsm8k_train_3211","gsm8k_train_6931","gsm8k_train_6481","gsm8k_train_2062","gsm8k_train_6691","gsm8k_train_7053","gsm8k_train_4344","gsm8k_train_1620","gsm8k_train_3545","gsm8k_train_2606"],"n":16,"max_tokens":8192,"activations":{"layers":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18],"mlp":true}}{ "activations": { "dir": "/work/gen_1_acts/", "files": { "hidden_last_prompt.npy": [ 2048, 19, 640 ], "hidden_mean_answer.npy": [ 2048, 19, 640 ], "mlp_last_prompt.npy": [ 2048, 18, 2048 ], "mlp_mean_answer.npy": [ 2048, 18, 2048 ] } }, "ok": true, "type": "generate", "model": "original", "file": "/work/gen_1.jsonl", "generations": 2048, "graded": 2048, "accuracy": 0.16455078125, "accuracy_by_source": { "math": 0.1747, "gsm8k": 0.0938 }, "mean_tokens": 1399, "cut_share": 0.0791, "failures": { "wrong_answer": 853, "no_answer_finished": 708, "cut_at_max_tokens": 150 }, "s": 319.7}with open("/work/gen_1.jsonl") as f: baseline = [json.loads(line) for line in f]
print("Record schema:")for k, v in baseline[0].items(): if isinstance(v, str): print(k, "str", repr(v[:100])) elif isinstance(v, (int, float, bool)) or v is None: print(k, type(v).__name__, v) elif isinstance(v, dict): print(k, "dict keys", sorted(v.keys())) else: print(k, type(v).__name__)
print("Activation directory files:", sorted(os.listdir("/work/gen_1_acts")))for filename in sorted(glob.glob("/work/gen_1_acts/*.json")): with open(filename) as f: metadata = json.load(f) print(os.path.basename(filename), str(metadata)[:1000])
text_key = next( (k for k in ["text", "response", "answer", "completion", "generated_text"] if isinstance(baseline[0].get(k), str)), None)print("Detected response field:", text_key)if text_key: for i in [0, 1, 16, 32, 128, 256, 512, 1024, 1536, 1792]: r = baseline[i] s = r[text_key] excerpt = s[:170] + (" ... " + s[-100:] if len(s) > 170 else "") print("Example", i, ascii(excerpt))Record schema:id str 'math_train_algebra_1519'source str 'math'answer str '162x^4'samples listActivation directory files: ['hidden_last_prompt.npy', 'hidden_mean_answer.npy', 'index.json', 'mlp_last_prompt.npy', 'mlp_mean_answer.npy']index.json {'layers': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], 'mlp_layers': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], 'samples': [{'item': 'math_train_algebra_1519', 'sample': 0, 'correct': False, 'tokens': 707}, {'item': 'math_train_algebra_1519', 'sample': 1, 'correct': False, 'tokens': 8192}, {'item': 'math_train_algebra_1519', 'sample': 2, 'correct': False, 'tokens': 1838}, {'item': 'math_train_algebra_1519', 'sample': 3, 'correct': False, 'tokens': 1540}, {'item': 'math_train_algebra_1519', 'sample': 4, 'correct': False, 'tokens': 1480}, {'item': 'math_train_algebra_1519', 'sample': 5, 'correct': False, 'tokens': 2495}, {'item': 'math_train_algebra_1519', 'sample': 6, 'correct': False, 'tokens': 2175}, {'item': 'math_train_algebra_1519', 'sample': 7, 'correct': False, 'tokens': 1616}, {'item': 'math_train_algebra_1519', 'sample': 8, 'correct': False, 'tokens': 1276}, {'item': 'math_train_algebra_1519', 'sample': 9, 'correct': False, 'tokens':Detected response field: answerExample 0 '162x^4'Example 1 '20'Example 16 '15'Example 32 '\\dfrac{1}{2}'Traceback (most recent call last): File "<string>", line 17, in <module> File "<run>", line 29, in <module>IndexError: list index out of rangebaseline_groups = baselineprint("Problems:", len(baseline_groups))print("Sample schema:")for k, v in baseline_groups[0]["samples"][0].items(): if isinstance(v, str): print(k, "str", ascii(v[:100])) elif isinstance(v, (int, float, bool)) or v is None: print(k, type(v).__name__, v) else: print(k, type(v).__name__)
records = []for group in baseline_groups: for j, sample in enumerate(group["samples"]): records.append({ **sample, "problem_id": group["id"], "sample_index": j, "reference": group["answer"], "source": group["source"], })with open("/work/gen_1_acts/index.json") as f: act_index = json.load(f)assert len(records) == len(act_index["samples"]) == 2048assert all( r["problem_id"] == a["item"] and r["sample_index"] == a["sample"] for r, a in zip(records, act_index["samples"]))print("Verified activation/sample alignment:", len(records))
sample_text_key = next( (k for k in ["text", "response", "completion", "generated_text", "answer"] if isinstance(records[0].get(k), str)), None)print("Generated text field:", sample_text_key)counts = { g["id"]: sum(bool(s["correct"]) for s in g["samples"]) for g in baseline_groups}print("Success-count histogram:", dict(sorted(collections.Counter(counts.values()).items())))print("Mixed-success MATH problems:", sum(0 < counts[g["id"]] < 16 for g in baseline_groups if g["source"] == "math"))
for i in [0, 2, 16, 32, 128, 256, 512, 1024, 1536, 1792]: r = records[i] s = r[sample_text_key] excerpt = s[:160] + (" ... " + s[-120:] if len(s) > 160 else "") print("Example", i, r["problem_id"], "correct:", r["correct"], "tokens:", r.get("tokens"), ascii(excerpt))Problems: 128Sample schema:text str 'Let the given sequence be denoted by $a_n = 2 \\cdot x^{n-1}$.\nWe want to find the next term in the s'pred NoneType Nonecorrect bool Falsetokens int 639cut bool FalseVerified activation/sample alignment: 2048Generated text field: textSuccess-count histogram: {0: 70, 1: 11, 2: 7, 3: 8, 4: 5, 5: 2, 6: 5, 7: 3, 8: 2, 9: 1, 11: 4, 12: 3, 13: 2, 14: 1, 15: 2, 16: 2}Mixed-success MATH problems: 49Example 0 math_train_algebra_1519 correct: False tokens: 639 'Let the given sequence be denoted by $a_n = 2 \\cdot x^{n-1}$.\nWe want to find the next term in the sequence, which is $a_{n+1}$.\nWe have $a_1 = 2$, $a_2 = 6x$, ... We are asked to express the answer in terms of $x$.\nThe next term in the sequence is $a_5 = 2x^4$.\n\nFinal Answer: $2x^4$'Example 2 math_train_algebra_1519 correct: False tokens: 1770 'Let the geometric sequence be denoted by $a_1, a_2, a_3, \\ldots$.\nWe are given that $a_1 = 2$, $a_2 = 6x$, $a_3 = 18x^2$, and $a_4 = 54x^3$.\nThe sequence is giv ... t term is $54x^3$.\nSo we should let $a_5 = 54x^3$.\nThen $a_5 = 2x^4$.\n\nFinal Answer: The final answer is $\\boxed{54x^3}$'Example 16 math_train_prealgebra_327 correct: False tokens: 586 'Let $n$ be the number of oranges Jimmy has.\nLet $a$ be the number of apples Jimmy has.\nWe are given that $n = 28$ oranges.\nWe are also given that Jimmy has $a = ... 8\n\nThe number of apples Jimmy needs to equal the weight of his $28$ oranges is $28$.\n\nFinal Answer: 28\nFinal Answer: 28\n'Example 32 math_train_prealgebra_158 correct: True tokens: 175 'Let the given expression be $x = 3 \\times (7 - 5) - 5$.\nWe have\n$$ x = 3 \\times (7 - 5) - 5 $$\n$$ x = 3 \\times 2 - 5 $$\n$$ x = 6 - 5 $$\n$$ x = 1 $$\nTherefore, t ... times (7 - 5) - 5 = 3 \\times 2 - 5 = 6 - 5 = 1 $$\nThe value of $3 \\times (7 - 5) - 5$ is $1$.\n\nFinal Answer: $\\boxed{1}$'Example 128 math_train_algebra_1152 correct: False tokens: 244 'Let $n$ be the number of bowling balls.\nLet $c_1$ and $c_2$ be the number of canoes.\nWe are given that $n = 7$.\nWe are also given that the weight of each bowlin ... 2$, where $c_1 = 8$ and $c_2 = 1$.\nTherefore, the weight of one bowling ball is $8 \\cdot 1 = 8$ pounds.\n\nFinal Answer: 8'Example 256 math_train_algebra_549 correct: False tokens: 509 'Okay, I\'ve analyzed the given function, "machine", and it\'s a bit tricky to directly solve without a visual representation. I\'ll try to explain the steps and th ... ween the input points `x` and `y` as:\n\n`distance = 20 / 2 = 10`\n\n**Answer**\n\nThe output of the function `machine` is 10.'Example 512 math_train_geometry_119 correct: True tokens: 545 'Let $a = 5$, $b = 12$, and $c = 13$.\nThe area of triangle $ABC$ is given by\n$$A_1 = \\frac{1}{2} \\cdot 5 \\cdot 12 = \\frac{60}{2} = 30.$$\nThe area of triangle $DE ... Since $\\frac{1}{2} = \\frac{1}{2}$, the ratio is $\\frac{1}{2}$.\n\nFinal Answer: $\\frac{1}{2}$\n\nFinal Answer: $\\frac{1}{2}$'Example 1024 math_train_number_theory_696 correct: False tokens: 2068 'Let $A$ be the product of the divisors of $42$.\nWe are looking for the number of distinct prime factors of $A$.\nThe prime factors of $42$ are $2, 3, 3, 3$.\nThe ... \nFinal Answer: 4\nThe distinct prime factors of $42$ are $2, 3, 3, 3$. The number of distinct prime factors of $A$ is 4.\n'Example 1536 math_train_precalculus_94 correct: False tokens: 943 'Let $z$ be a complex number with $|z|=1$. We are given that $z^{6!}-z^{5!}$ is a real number.\nWe want to find the number of different complex numbers $z$ with $ ... Final Answer: The number of complex numbers with $|z|=1$ that satisfy the given condition is infinite.\n\nFinal Answer: 0\n'Example 1792 gsm8k_train_4686 correct: False tokens: 169 'Let $S$ be the number of shirts Darcy has.\nLet $H$ be the number of shorts Darcy has.\nDarcy washes and dries 20 shirts and 8 pairs of shorts.\nSo, the total numb ... Darcy has is $28 - 7 = 21$.\nTherefore, Darcy has 21 more pieces of clothing to fold.\n\nFinal Answer: 21\n\nFinal Answer: 21'import remixed_math = [ g["id"] for g in baseline_groups if g["source"] == "math" and 0 < counts[g["id"]] < 16]dev_ids = sorted( mixed_math, key=lambda pid: (-counts[pid] * (16 - counts[pid]), pid))[:32]dev_set = set(dev_ids)assert len(dev_ids) == 32 and not dev_set & holdout_setwith open("/work/DEV_ids.json", "w") as f: json.dump(dev_ids, f)with open("/work/notes.md", "a") as f: f.write("\n## DEV fixed before edits\n" "- DEV_ids.json: 32 mixed-success MATH problems, selected by highest " "baseline Bernoulli variance, ties by id.\n" "- HOLDOUT remains untouched. No weights edited.\n")
for r in records: t = r["text"] words = re.findall(r"\S+", t) grams = list(zip(words, words[1:], words[2:], words[3:])) r["repeat4"] = 1 - len(set(grams)) / max(1, len(grams)) r["final_markers"] = len(re.findall(r"final answer", t, re.I)) r["failure_type"] = ( "correct" if r["correct"] else "cut" if r["cut"] else "no_extracted_answer" if r.get("pred") is None else "wrong_extracted_answer" )print("Recounted outcomes:", dict(collections.Counter(r["failure_type"] for r in records)))print("DEV success counts:", dict(sorted(collections.Counter(counts[p] for p in dev_ids).items())))print("DEV levels:", dict(collections.Counter(practice[p]["level"] for p in dev_ids)))print("DEV sources: MATH only")
for correct in [True, False]: rr = [r for r in records if r["problem_id"] in dev_set and r["correct"] == correct] print("DEV baseline", "correct" if correct else "failed", "n", len(rr), "median tokens", round(float(np.median([r["tokens"] for r in rr]))), "mean repetition", round(float(np.mean([r["repeat4"] for r in rr])), 3), "mean final markers", round(float(np.mean([r["final_markers"] for r in rr])), 2))
dev_indices = np.array([i for i,r in enumerate(records) if r["problem_id"] in dev_set])dev_records = [records[i] for i in dev_indices]groups_dev = np.array([dev_ids.index(r["problem_id"]) for r in dev_records])def within_problem(x): x = np.asarray(x, dtype=np.float64).copy() for g in np.unique(groups_dev): m = groups_dev == g x[m] -= x[m].mean(axis=0) return x
failure = within_problem(np.array([not r["correct"] for r in dev_records], dtype=float))loglen = within_problem(np.log1p([r["tokens"] for r in dev_records]))failure_len = failure - loglen * (loglen @ failure) / (loglen @ loglen)repeat = within_problem(np.array([r["repeat4"] for r in dev_records]))repeat_len = repeat - loglen * (loglen @ repeat) / (loglen @ loglen)
mlp_mean = np.load("/work/gen_1_acts/mlp_mean_answer.npy", mmap_mode="r")hidden_mean = np.load("/work/gen_1_acts/hidden_mean_answer.npy", mmap_mode="r")neuron_screen = []for layer in range(18): X = np.asarray(mlp_mean[dev_indices, layer, :], dtype=np.float64) Xc = within_problem(X) Xl = Xc - np.outer(loglen, loglen @ Xc / (loglen @ loglen)) sd = np.sqrt(np.sum(Xl * Xl, axis=0) + 1e-20) corr = (failure_len @ Xl) / (np.linalg.norm(failure_len) * sd) rawcorr = (failure @ Xc) / ( np.linalg.norm(failure) * np.sqrt(np.sum(Xc*Xc, axis=0) + 1e-20) ) repcorr = (repeat_len @ Xl) / (np.linalg.norm(repeat_len) * sd + 1e-20) D = load_original(f"model.layers.{layer}.mlp.down_proj.weight").numpy() energy = np.sqrt(np.mean(X * X, axis=0)) * np.linalg.norm(D, axis=0) for j in range(2048): neuron_screen.append({ "layer": layer, "neuron": j, "failure_corr": float(corr[j]), "raw_failure_corr": float(rawcorr[j]), "repeat_corr": float(repcorr[j]), "energy": float(energy[j]), "mean": float(X[:, j].mean()), "sd": float(X[:, j].std()) }) top = int(np.argmax(corr)) print("Layer", layer, "top failure neuron", top, "length-controlled corr", round(float(corr[top]), 3), "raw corr", round(float(rawcorr[top]), 3), "repeat corr", round(float(repcorr[top]), 3))
neuron_screen.sort(key=lambda x: x["failure_corr"], reverse=True)print("Top 16 neurons:")for s in neuron_screen[:16]: print({k: round(v, 4) if isinstance(v, float) else v for k,v in s.items()})
print("Short excerpts from DEV failures with no extracted answer:")shown = 0for r in dev_records: if r["failure_type"] == "no_extracted_answer": print(r["problem_id"], "tokens", r["tokens"], ascii(r["text"][:140] + " ... " + r["text"][-140:])) shown += 1 if shown == 6: break
print("DEV IDs:", json.dumps(dev_ids))Recounted outcomes: {'no_extracted_answer': 708, 'cut': 150, 'wrong_extracted_answer': 853, 'correct': 337}DEV success counts: {2: 1, 3: 7, 4: 4, 5: 1, 6: 5, 7: 3, 8: 2, 11: 4, 12: 3, 13: 2}DEV levels: {'Level 2': 13, 'Level 1': 10, 'Level 3': 5, 'Level 4': 3, 'Level 5': 1}DEV sources: MATH onlyDEV baseline correct n 217 median tokens 440 mean repetition 0.361 mean final markers 15.42DEV baseline failed n 295 median tokens 589 mean repetition 0.413 mean final markers 30.74Layer 0 top failure neuron 1869 length-controlled corr 0.202 raw corr 0.211 repeat corr 0.062Layer 1 top failure neuron 483 length-controlled corr 0.172 raw corr 0.185 repeat corr 0.117Layer 2 top failure neuron 1029 length-controlled corr 0.167 raw corr 0.186 repeat corr 0.022Layer 3 top failure neuron 1049 length-controlled corr 0.157 raw corr 0.197 repeat corr 0.068Layer 4 top failure neuron 193 length-controlled corr 0.193 raw corr 0.219 repeat corr 0.018Layer 5 top failure neuron 1427 length-controlled corr 0.167 raw corr 0.164 repeat corr 0.039Layer 6 top failure neuron 2027 length-controlled corr 0.144 raw corr 0.13 repeat corr -0.081Layer 7 top failure neuron 906 length-controlled corr 0.162 raw corr 0.15 repeat corr 0.155Layer 8 top failure neuron 1777 length-controlled corr 0.18 raw corr 0.152 repeat corr -0.169Layer 9 top failure neuron 1006 length-controlled corr 0.152 raw corr 0.138 repeat corr -0.032Layer 10 top failure neuron 482 length-controlled corr 0.159 raw corr 0.186 repeat corr 0.18Layer 11 top failure neuron 401 length-controlled corr 0.213 raw corr 0.236 repeat corr -0.079Layer 12 top failure neuron 1184 length-controlled corr 0.17 raw corr 0.149 repeat corr 0.001Layer 13 top failure neuron 1226 length-controlled corr 0.216 raw corr 0.248 repeat corr -0.026Layer 14 top failure neuron 1497 length-controlled corr 0.182 raw corr 0.149 repeat corr 0.131Layer 15 top failure neuron 1839 length-controlled corr 0.173 raw corr 0.215 repeat corr 0.058Layer 16 top failure neuron 624 length-controlled corr 0.188 raw corr 0.223 repeat corr 0.186Layer 17 top failure neuron 793 length-controlled corr 0.218 raw corr 0.162 repeat corr -0.042Top 16 neurons:{'layer': 17, 'neuron': 793, 'failure_corr': 0.2185, 'raw_failure_corr': 0.1621, 'repeat_corr': -0.0417, 'energy': 0.0035, 'mean': 0.0066, 'sd': 0.006}{'layer': 13, 'neuron': 1226, 'failure_corr': 0.2165, 'raw_failure_corr': 0.248, 'repeat_corr': -0.0262, 'energy': 0.0106, 'mean': 0.0276, 'sd': 0.0113}{'layer': 11, 'neuron': 401, 'failure_corr': 0.2126, 'raw_failure_corr': 0.2361, 'repeat_corr': -0.0788, 'energy': 0.006, 'mean': -0.0078, 'sd': 0.0106}{'layer': 0, 'neuron': 1869, 'failure_corr': 0.2024, 'raw_failure_corr': 0.2113, 'repeat_corr': 0.0622, 'energy': 0.0293, 'mean': 0.0473, 'sd': 0.028}{'layer': 4, 'neuron': 193, 'failure_corr': 0.193, 'raw_failure_corr': 0.2191, 'repeat_corr': 0.0177, 'energy': 0.011, 'mean': 0.0275, 'sd': 0.0181}{'layer': 17, 'neuron': 271, 'failure_corr': 0.1888, 'raw_failure_corr': 0.1946, 'repeat_corr': -0.0406, 'energy': 0.0057, 'mean': -0.0018, 'sd': 0.0125}{'layer': 16, 'neuron': 624, 'failure_corr': 0.1879, 'raw_failure_corr': 0.2233, 'repeat_corr': 0.1856, 'energy': 0.0034, 'mean': -0.0048, 'sd': 0.0061}{'layer': 13, 'neuron': 1540, 'failure_corr': 0.1867, 'raw_failure_corr': 0.1788, 'repeat_corr': 0.1371, 'energy': 0.0057, 'mean': 0.0148, 'sd': 0.0088}{'layer': 14, 'neuron': 1497, 'failure_corr': 0.1817, 'raw_failure_corr': 0.1495, 'repeat_corr': 0.1306, 'energy': 0.0065, 'mean': 0.0133, 'sd': 0.012}{'layer': 13, 'neuron': 223, 'failure_corr': 0.1815, 'raw_failure_corr': 0.184, 'repeat_corr': 0.072, 'energy': 0.0094, 'mean': -0.0072, 'sd': 0.0231}{'layer': 8, 'neuron': 1777, 'failure_corr': 0.1801, 'raw_failure_corr': 0.1522, 'repeat_corr': -0.1692, 'energy': 0.0037, 'mean': 0.0027, 'sd': 0.0107}{'layer': 0, 'neuron': 445, 'failure_corr': 0.1774, 'raw_failure_corr': 0.1913, 'repeat_corr': 0.1654, 'energy': 0.1163, 'mean': 0.0934, 'sd': 0.2129}{'layer': 14, 'neuron': 1202, 'failure_corr': 0.1765, 'raw_failure_corr': 0.2095, 'repeat_corr': 0.0188, 'energy': 0.0068, 'mean': 0.013, 'sd': 0.0141}{'layer': 17, 'neuron': 653, 'failure_corr': 0.1748, 'raw_failure_corr': 0.1051, 'repeat_corr': 0.1539, 'energy': 0.0163, 'mean': 0.0375, 'sd': 0.0095}{'layer': 16, 'neuron': 250, 'failure_corr': 0.1747, 'raw_failure_corr': 0.1778, 'repeat_corr': 0.1508, 'energy': 0.0033, 'mean': -0.004, 'sd': 0.0056}{'layer': 15, 'neuron': 1839, 'failure_corr': 0.1732, 'raw_failure_corr': 0.2145, 'repeat_corr': 0.0579, 'energy': 0.0037, 'mean': -0.0098, 'sd': 0.0087}Short excerpts from DEV failures with no extracted answer:math_train_prealgebra_55 tokens 386 'Let $x = 5^2 - 4^2 = 5^2 - 4^2 = 25 - 16 = 9$.\nThen,\n$\\left(5^2 - 4^2\\right)^3 = (5^2 - 4^2)^3 = (5^2 - 4^2)^3 = (5^2 - 4^2)^3 = (5^2 - 4^2) ... d $9 = 9$, we can say that the value of the expression is 9.\n\nFinal Answer: 9\n\nTherefore, the value of the expression is 9.\n\nFinal Answer: 9'math_train_prealgebra_55 tokens 245 'Let $a = 5^2 - 4^2$.\nWe have $a = 5^2 - 4^2 = 25 - 16 = 9$.\nWe are asked to find the value of $\\left(5^2 - 4^2\\right)^3$.\nWe have\n$$ \\left(5 ... ession as $5^2 - 4^2$.\nThen, we have $5^2 - 4^2 = 25 - 16 = 9$.\nSo the value of the expression is $9$.\n\nFinal Answer: $9$\n\nFinal Answer: $9$'math_train_prealgebra_55 tokens 7964 'Let $x = 5^2 - 4^2$.\nWe have $x = 5^2 - 4^2 = 25 - 16 = 9$.\nWe want to find the value of the expression $\\left(5^2 - 4^2\\right)^3$.\nWe have ... = 9 \\cdot 9^3.\n\nFinal Answer: 9 \\cdot 9^3 = 9 \\cdot 9^3.\n\nFinal Answer: 9 \\cdot 9^3 = 9 \\cdot 9^3.\n\nFinal Answer: 9 \\cdot 9^3 = 9 \\cdot 9^3.'math_train_prealgebra_55 tokens 549 'Let $a = 5^2 - 4^2 = 5^2 - 4^2 = 25 - 16 = 9$.\nThen we have\n$$ \\left(5^2-4^2\\right)^3 = (9)^3 = 9 \\cdot 9^3 = 9 \\cdot 9^3 = 9 \\cdot 9^6 = 9 ... 9^6$.\nThe expression is $9^6 = 9^6$.\n\nFinal Answer: 9^6\n\n$9^6 = 9^6 = 9^6$\n\nThe value of the expression is $9^6$.\n\nFinal Answer: $9^6 = 9^6$'math_train_prealgebra_55 tokens 94 'To find the value of the expression $(5^2-4^2)^3$, we first evaluate the expression:\n$$ (5^2-4^2)^3 = (5^2-4^2)^3 = (5^2-4^2)^3 = (5-4)^3 = ... expression:\n$$ (5^2-4^2)^3 = (5^2-4^2)^3 = (5^2-4^2)^3 = (5-4)^3 = 1^3 = 1 $$\nTherefore, the value of the expression is 1.\n\nFinal Answer: 1\n'math_train_prealgebra_774 tokens 157 'Let $a = 5^2 - 3(4) + 3^2$.\n$a = 5^2 - 3(4) + 3^2 = 25 - 12 + 9 = 25 - 3 + 9 = 22 + 9 = 31$.\nTherefore, $5^2-3(4)+3^2 = 31$.\n\nSo the answer ... -3(4)+3^2 = 31$.\n\nSo the answer is 31.\n\nWe can also write the expression as $5^2-3(4)+3^2 = 25-12+9 = 25-3+9 = 22+9 = 31$.\n\nFinal Answer: 31'DEV IDs: ["math_train_counting_and_probability_606", "math_train_prealgebra_593", "math_train_algebra_1707", "math_train_prealgebra_55", "math_train_prealgebra_940", "math_train_algebra_1114", "math_train_intermediate_algebra_633", "math_train_prealgebra_207", "math_train_prealgebra_502", "math_train_precalculus_220", "math_train_algebra_498", "math_train_algebra_636", "math_train_counting_and_probability_148", "math_train_prealgebra_318", "math_train_prealgebra_780", "math_train_algebra_1497", "math_train_algebra_182", "math_train_intermediate_algebra_643", "math_train_intermediate_algebra_933", "math_train_number_theory_540", "math_train_number_theory_696", "math_train_prealgebra_774", "math_train_algebra_1461", "math_train_algebra_1523", "math_train_algebra_731", "math_train_algebra_958", "math_train_geometry_158", "math_train_intermediate_algebra_80", "math_train_prealgebra_202", "math_train_prealgebra_590", "math_train_prealgebra_839", "math_train_algebra_1423"]def normalized_answer(s): if s is None: return None return re.sub(r"[\s$]", "", str(s)).replace(r"\dfrac", r"\frac")
def boxed_contents(text): out = [] for m in re.finditer(r"\\boxed\s*\{", text): start, depth, j = m.end(), 1, m.end() while j < len(text) and depth: depth += (text[j] == "{") - (text[j] == "}") j += 1 if depth == 0: out.append(text[start:j-1]) return out
box_stats = collections.Counter()for r in dev_records: boxes = boxed_contents(r["text"]) ref = normalized_answer(r["reference"]) matches = [normalized_answer(b) == ref for b in boxes] box_stats["responses_with_box"] += bool(boxes) box_stats["multiple_boxes"] += len(boxes) > 1 box_stats["correct_box_then_wrong_last_box"] += ( bool(matches) and any(matches[:-1]) and not matches[-1] ) box_stats["failed_despite_earlier_matching_box"] += ( not r["correct"] and any(matches[:-1]) )print("DEV box diagnostics:", dict(box_stats))
# Stability across disjoint halves of the DEV problems.for layer in range(18): X = np.asarray(mlp_mean[dev_indices, layer, :], dtype=np.float64) Xc = within_problem(X) for half in [0, 1]: mask = groups_dev % 2 == half z = loglen[mask] Y = Xc[mask] - np.outer(z, z @ Xc[mask] / (z @ z)) f = failure[mask] - z * (z @ failure[mask]) / (z @ z) rr = (f @ Y) / ( np.linalg.norm(f) * np.sqrt(np.sum(Y*Y, axis=0) + 1e-20) ) for s in neuron_screen: if s["layer"] == layer: s[f"half{half}_corr"] = float(rr[s["neuron"]])
stable = [ s for s in neuron_screen if s["half0_corr"] > .06 and s["half1_corr"] > .06 and s["failure_corr"] > .10 and s["mean"] > 0]for s in stable: s["robust_score"] = min(s["half0_corr"], s["half1_corr"]) * math.sqrt(s["energy"])stable.sort(key=lambda s: s["robust_score"], reverse=True)
print("Stable, positive-mean failure-associated components:")for s in stable[:18]: print({k: round(s[k], 4) if isinstance(s[k], float) else s[k] for k in ["layer","neuron","failure_corr","half0_corr","half1_corr", "repeat_corr","energy","mean"]})
print("Strongest length-controlled repetition associations:")for s in sorted(neuron_screen, key=lambda s: s["repeat_corr"], reverse=True)[:12]: print({k: round(s[k], 4) if isinstance(s[k], float) else s[k] for k in ["layer","neuron","repeat_corr","failure_corr","energy","mean"]})
print("Matched failing DEV excerpts:")for pid in dev_ids[:6]: rr = [r for r in dev_records if r["problem_id"] == pid and not r["correct"]] r = min(rr, key=lambda x: abs(x["tokens"] - 500)) print(pid, "reference", ascii(str(practice[pid]["answer"])[:60]), "response", ascii(r["text"][:140] + " ... " + r["text"][-140:]))
with open("/work/neuron_screen.json", "w") as f: json.dump(neuron_screen, f)print("No edits; holdout remains untouched.")DEV box diagnostics: {'responses_with_box': 229, 'multiple_boxes': 8, 'correct_box_then_wrong_last_box': 0, 'failed_despite_earlier_matching_box': 0}Stable, positive-mean failure-associated components:{'layer': 0, 'neuron': 1405, 'failure_corr': 0.1013, 'half0_corr': 0.1063, 'half1_corr': 0.0906, 'repeat_corr': 0.2692, 'energy': 4.2313, 'mean': 13.3728}{'layer': 0, 'neuron': 149, 'failure_corr': 0.105, 'half0_corr': 0.1122, 'half1_corr': 0.0964, 'repeat_corr': 0.2817, 'energy': 0.7672, 'mean': 1.5894}{'layer': 0, 'neuron': 1309, 'failure_corr': 0.1658, 'half0_corr': 0.1908, 'half1_corr': 0.1287, 'repeat_corr': -0.0447, 'energy': 0.2515, 'mean': 0.4785}{'layer': 0, 'neuron': 2032, 'failure_corr': 0.1402, 'half0_corr': 0.1364, 'half1_corr': 0.1399, 'repeat_corr': 0.0226, 'energy': 0.1355, 'mean': 0.1692}{'layer': 0, 'neuron': 761, 'failure_corr': 0.1136, 'half0_corr': 0.1126, 'half1_corr': 0.0989, 'repeat_corr': -0.007, 'energy': 0.2207, 'mean': 0.3206}{'layer': 0, 'neuron': 1479, 'failure_corr': 0.1131, 'half0_corr': 0.1111, 'half1_corr': 0.1212, 'repeat_corr': -0.0276, 'energy': 0.1453, 'mean': 0.1645}{'layer': 0, 'neuron': 1658, 'failure_corr': 0.1098, 'half0_corr': 0.0837, 'half1_corr': 0.1307, 'repeat_corr': -0.0128, 'energy': 0.2551, 'mean': 0.4254}{'layer': 0, 'neuron': 445, 'failure_corr': 0.1774, 'half0_corr': 0.1238, 'half1_corr': 0.2154, 'repeat_corr': 0.1654, 'energy': 0.1163, 'mean': 0.0934}{'layer': 0, 'neuron': 898, 'failure_corr': 0.1156, 'half0_corr': 0.1303, 'half1_corr': 0.1058, 'repeat_corr': 0.1001, 'energy': 0.1486, 'mean': 0.0638}{'layer': 0, 'neuron': 845, 'failure_corr': 0.1108, 'half0_corr': 0.1269, 'half1_corr': 0.0809, 'repeat_corr': 0.062, 'energy': 0.2212, 'mean': 0.2508}{'layer': 1, 'neuron': 483, 'failure_corr': 0.1725, 'half0_corr': 0.2164, 'half1_corr': 0.1222, 'repeat_corr': 0.1173, 'energy': 0.0796, 'mean': 0.1955}{'layer': 1, 'neuron': 1899, 'failure_corr': 0.131, 'half0_corr': 0.0978, 'half1_corr': 0.1538, 'repeat_corr': 0.0744, 'energy': 0.123, 'mean': 0.2215}{'layer': 0, 'neuron': 607, 'failure_corr': 0.1116, 'half0_corr': 0.1151, 'half1_corr': 0.0902, 'repeat_corr': 0.1704, 'energy': 0.1334, 'mean': 0.0462}{'layer': 0, 'neuron': 798, 'failure_corr': 0.1318, 'half0_corr': 0.1282, 'half1_corr': 0.1358, 'repeat_corr': -0.0088, 'energy': 0.0623, 'mean': 0.0027}{'layer': 0, 'neuron': 1632, 'failure_corr': 0.1463, 'half0_corr': 0.1321, 'half1_corr': 0.1547, 'repeat_corr': 0.0959, 'energy': 0.0533, 'mean': 0.0196}{'layer': 0, 'neuron': 1915, 'failure_corr': 0.1299, 'half0_corr': 0.1667, 'half1_corr': 0.1072, 'repeat_corr': 0.2637, 'energy': 0.0808, 'mean': 0.0971}{'layer': 0, 'neuron': 1028, 'failure_corr': 0.1095, 'half0_corr': 0.1097, 'half1_corr': 0.0948, 'repeat_corr': -0.0809, 'energy': 0.1002, 'mean': 0.1064}{'layer': 1, 'neuron': 553, 'failure_corr': 0.1144, 'half0_corr': 0.1015, 'half1_corr': 0.1195, 'repeat_corr': 0.063, 'energy': 0.087, 'mean': 0.1896}Strongest length-controlled repetition associations:{'layer': 5, 'neuron': 1574, 'repeat_corr': 0.445, 'failure_corr': 0.0374, 'energy': 0.0268, 'mean': 0.0608}{'layer': 10, 'neuron': 175, 'repeat_corr': 0.4343, 'failure_corr': 0.0493, 'energy': 0.0189, 'mean': 0.0586}{'layer': 5, 'neuron': 1586, 'repeat_corr': 0.432, 'failure_corr': 0.0061, 'energy': 0.0371, 'mean': -0.0436}{'layer': 5, 'neuron': 1777, 'repeat_corr': 0.4079, 'failure_corr': 0.0377, 'energy': 0.0614, 'mean': 0.1245}{'layer': 16, 'neuron': 452, 'repeat_corr': 0.3941, 'failure_corr': 0.0504, 'energy': 0.0045, 'mean': 0.0013}{'layer': 6, 'neuron': 1142, 'repeat_corr': 0.3879, 'failure_corr': 0.038, 'energy': 0.0257, 'mean': -0.0543}{'layer': 8, 'neuron': 716, 'repeat_corr': 0.3603, 'failure_corr': 0.0521, 'energy': 0.024, 'mean': 0.0765}{'layer': 17, 'neuron': 17, 'repeat_corr': 0.3487, 'failure_corr': -0.0001, 'energy': 0.0093, 'mean': -0.0191}{'layer': 15, 'neuron': 1254, 'repeat_corr': 0.3458, 'failure_corr': -0.0136, 'energy': 0.0084, 'mean': -0.0165}{'layer': 10, 'neuron': 1413, 'repeat_corr': 0.3451, 'failure_corr': -0.0137, 'energy': 0.0119, 'mean': 0.0025}{'layer': 0, 'neuron': 1808, 'repeat_corr': 0.3424, 'failure_corr': 0.0614, 'energy': 0.6438, 'mean': -0.975}{'layer': 8, 'neuron': 916, 'repeat_corr': 0.3389, 'failure_corr': 0.0018, 'energy': 0.017, 'mean': -0.033}Matched failing DEV excerpts:math_train_counting_and_probability_606 reference '35' response 'Let the 7 distinct points be denoted by $P_1, P_2, P_3, P_4, P_5, P_6, P_7$.\nWe want to find the number of different triangles that can be f ... ent triangles that can be formed is 245.\n\nFinal Answer: 245\n\nThe number of different triangles that can be formed is 245.\n\nFinal Answer: 245'math_train_prealgebra_593 reference '250' response 'Let $A=(0,0)$, $B=(25,0)$, and $C=(0,20)$. The area of triangle $ABC$ is given by the formula\n$$Area = \\frac{1}{2} \\cdot AC \\cdot AB = \\frac ... ot 20 \\cdot 25 = \\frac{2500}{2} = 1250.$$\nThus, the area of triangle $ABC$ is 1250 cm$^2$.\n\nFinal Answer: The final answer is $\\boxed{1250}$'math_train_algebra_1707 reference '\\frac{63}{64}' response 'Let the geometric sequence be denoted by $a_1, a_2, a_3, \\dots$.\nThe first term is $a_1 = \\frac12$.\nThe common ratio is $r = \\frac{1}{2}$.\nT ... c{1}{12} + \\frac{1}{16}$.\n\nFinal Answer: The final answer is $\\boxed{\\frac{1}{2} + \\frac{1}{4} + \\frac{1}{8} + \\frac{1}{12} + \\frac{1}{16}}$'math_train_prealgebra_55 reference '729' response 'Let $a = 5^2 - 4^2 = 5^2 - 4^2 = 25 - 16 = 9$.\nThen we have\n$$ \\left(5^2-4^2\\right)^3 = (9)^3 = 9 \\cdot 9^3 = 9 \\cdot 9^3 = 9 \\cdot 9^6 = 9 ... 9^6$.\nThe expression is $9^6 = 9^6$.\n\nFinal Answer: 9^6\n\n$9^6 = 9^6 = 9^6$\n\nThe value of the expression is $9^6$.\n\nFinal Answer: $9^6 = 9^6$'math_train_prealgebra_940 reference '8' response 'Let $n$ be the number of cards Jasmine wants to buy.\nThe cost of the cards is $0.85 per card.\nThe total cost of the cards is $7.50.\nThe tota ... r of cards she can buy is $n = \\frac{75}{85}$.\nThus, the most number of cards she can buy is $\\frac{75}{85}$.\n\nFinal Answer: $\\frac{75}{85}$'math_train_algebra_1114 reference '100' response 'The first 10 odd positive integers are 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21.\nThe sum of the first 10 odd positive integers is\n1 + 3 + 5 + 7 ... irst 10 odd positive integers are 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21.\nTheir sum is $1+3+5+7+9+11+13+15+17+19+21 = 55$.\n\nFinal Answer: 55\n'No edits; holdout remains untouched.PREFIX = "<bos><start_of_turn>user\n"SUFFIX = ( "\nPlease reason step by step, and put your final answer within \\boxed{}." "<end_of_turn>\n<start_of_turn>model\n")
teacher_sources = []for i in dev_indices: r = records[int(i)] teacher_sources.append({ "kind": "generated", "record_index": int(i), "problem_id": r["problem_id"], "correct": bool(r["correct"]), "prompt": PREFIX + practice[r["problem_id"]]["problem"] + SUFFIX, "answer": r["text"], })for pid in dev_ids: teacher_sources.append({ "kind": "reference", "record_index": None, "problem_id": pid, "correct": True, "prompt": PREFIX + practice[pid]["problem"] + SUFFIX, "answer": practice[pid]["solution"], })
encoded_sources = [ tok.encode(s["prompt"] + s["answer"], add_special_tokens=[REDACTED] for s in teacher_sources]cap = 2048while sum(min(len(e.ids), cap) for e in encoded_sources) > 520000: cap -= 64
teacher_texts, teacher_manifest = [], []for source, enc in zip(teacher_sources, encoded_sources): raw = source["prompt"] + source["answer"] if len(enc.ids) > cap: raw = raw[:enc.offsets[cap-1][1]] actual = tok.encode(raw, add_special_tokens=[REDACTED] assert len(actual.ids) <= cap teacher_texts.append(raw) teacher_manifest.append({ k: v for k,v in source.items() if k not in ["prompt", "answer"] } | { "prompt_chars": len(source["prompt"]), "prompt_tokens": len(tok.encode(source["prompt"], add_special_tokens=[REDACTED] "tokens": len(actual.ids), "truncated": len(enc.ids) > cap, })
teacher_return = { "token_logprobs": True, "topk": 8, "hidden_states": [0,1,6,14,18], "mlp_act": [0,1,5,13,17],}teacher_request = { "type": "teacher_forced", "model": "original", "texts": teacher_texts, "return": teacher_return,}with open("/work/dev_teacher_texts.json", "w") as f: json.dump(teacher_texts, f)with open("/work/dev_teacher_manifest.json", "w") as f: json.dump(teacher_manifest, f)with open("/work/dev_teacher_request.json", "w") as f: json.dump(teacher_request, f)
with open("/work/notes.md", "a") as f: f.write( "\n## Baseline localization findings\n" "- 337/2048 correct overall. DEV: 217/512 correct.\n" "- Wrong quantity binding, invalid arithmetic/algebra, and repeated " "non-progressing equalities occur in inspected failures.\n" "- No DEV correct-box-to-wrong-box overwrite cases found.\n" "- Pure repetition correlations are not strong accuracy evidence.\n" "- Length-controlled, within-problem failure correlations are modest.\n" "- Early MLP neurons 1405,149,1309,2032 and others in layer 0 " "have stable associations across disjoint DEV halves; not yet causal.\n" "\n## Pass 2: original teacher-forced localization\n" "- Exact edit: none; original weights.\n" "- Dataset: all 512 DEV sampled responses plus 32 DEV reference " "solutions, truncated only for the forward token budget.\n" "- Full request: dev_teacher_request.json; text list: dev_teacher_texts.json; " "alignment: dev_teacher_manifest.json.\n" f"- Texts: {len(teacher_texts)}; tokens: " f"{sum(m['tokens'] for m in teacher_manifest)}; cap: {cap}.\n" "- Examine token-local arithmetic progress versus copied/repeated " "expressions and component specificity before selecting an edit.\n" )print("Teacher-forced texts:", len(teacher_texts))print("Total tokens:", sum(m["tokens"] for m in teacher_manifest))print("Maximum tokens:", max(m["tokens"] for m in teacher_manifest))print("Truncated trajectories:", sum(m["truncated"] for m in teacher_manifest))print("Request saved to /work/dev_teacher_request.json.")print("Weights unchanged.")Teacher-forced texts: 544Total tokens: 427720Maximum tokens: 2048Truncated trajectories: 62Request saved to /work/dev_teacher_request.json.Weights unchanged.{"type":"teacher_forced","model":"original","texts_file":"/work/dev_teacher_texts.json","return":{"token_logprobs":true,"topk":8,"hidden_states":[0,1,6,14,18],"mlp_act":[0,1,5,13,17]}}{"type":"teacher_forced","model":"original","texts":"/work/dev_teacher_texts.json","return":{"token_logprobs":true,"topk":8,"hidden_states":[0,1,6,14,18],"mlp_act":[0,1,5,13,17]}}{ "ok": true, "lengths": [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], "files": { "input_ids": [ 28, 1 ], "token_logprobs": [ 28, 0 ], "topk_logprobs": [ 28, 1, 8 ], "topk_ids": [ 28, 1, 8 ], "hidden_0": [ 28, 1, 640 ], "hidden_1": [ 28, 1, 640 ], "hidden_6": [ 28, 1, 640 ], "hidden_14": [ 28, 1, 640 ], "hidden_18": [ 28, 1, 640 ], "mlp_act_0": [ 28, 1, 2048 ], "mlp_act_1": [ 28, 1, 2048 ], "mlp_act_5": [ 28, 1, 2048 ], "mlp_act_13": [ 28, 1, 2048 ], "mlp_act_17": [ 28, 1, 2048 ] }, "edited_tensors": 0, "mean_token_logprob": [ null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null ], "type": "teacher_forced", "s": 0.6}import astfrom fractions import Fraction
with open("/work/notes.md", "a") as f: f.write( "\n## Pass 2 input-format failure (consumed)\n" "- texts_file was rejected without cost. Passing a path in texts was " "incorrectly interpreted as 28 one-character texts, consuming pass 2.\n" "- Intended 544-text localization batch was NOT run.\n" "- No token-local math claims will be made from fwd_2 outputs.\n" "- Remaining plan: two full paired DEV tests at different strengths, " "then freeze and test HOLDOUT.\n" )
def safe_number(expr): expr = expr.strip().rstrip(".,") if not expr or len(expr) > 180 or not re.fullmatch(r"[0-9\s.+*/()\-]+", expr): return None try: tree = ast.parse(expr, mode="eval") def rec(node, depth=0): if depth > 18: raise ValueError() if isinstance(node, ast.Expression): return rec(node.body, depth+1) if isinstance(node, ast.Constant) and type(node.value) in (int, float): if abs(node.value) > 1e10: raise ValueError() return Fraction(str(node.value)) if isinstance(node, ast.UnaryOp) and isinstance(node.op, (ast.UAdd, ast.USub)): val = rec(node.operand, depth+1) return -val if isinstance(node.op, ast.USub) else val if isinstance(node, ast.BinOp): a, b = rec(node.left, depth+1), rec(node.right, depth+1) if isinstance(node.op, ast.Add): v = a+b elif isinstance(node.op, ast.Sub): v = a-b elif isinstance(node.op, ast.Mult): v = a*b elif isinstance(node.op, ast.Div): v = a/b elif isinstance(node.op, ast.Pow): if b.denominator != 1 or abs(b) > 8: raise ValueError() v = a ** int(b) else: raise ValueError() if abs(v.numerator) > 10**30 or v.denominator > 10**30: raise ValueError() return v raise ValueError() return rec(tree) except Exception: return None
def numeric_equalities(text): spans = re.findall(r"\$\$([\s\S]*?)\$\$|\$([^$\n]+)\$", text) checked = [] for pair in spans: s = pair[0] or pair[1] s = re.sub(r"\\(?:left|right|displaystyle|,|!|;)", "", s) s = s.replace(r"\times", "*").replace(r"\cdot", "*").replace(r"\div", "/") for _ in range(5): s2 = re.sub(r"\\(?:dfrac|frac)\{([^{}]*)\}\{([^{}]*)\}", r"((\1)/(\2))", s) if s2 == s: break s = s2 s = s.replace("^", "**").replace("{", "(").replace("}", ")") parts = s.split("=") for a, b in zip(parts, parts[1:]): av, bv = safe_number(a), safe_number(b) if av is not None and bv is not None: identical = re.sub(r"\s", "", a) == re.sub(r"\s", "", b) checked.append((av == bv, identical, a.strip()[:70], b.strip()[:70])) return checked
feature_rows = []for r in dev_records: t = r["text"] eqs = numeric_equalities(t) bad = sum(not e[0] for e in eqs) progress = sum(e[0] and not e[1] for e in eqs) identities = sum(e[1] for e in eqs) L = max(1, len(t)) feature_rows.append({ "arithmetic_error": bad / max(1, bad + progress), "arithmetic_error_count": math.log1p(bad), "arithmetic_progress": progress / max(1, bad + progress + identities), "identity_fraction": identities / max(1, len(eqs)), "repetition": r["repeat4"], "equality_density": t.count("=") / L, "digit_density": sum(c.isdigit() for c in t) / L, "latex_density": t.count("\\") / L, "final_density": r["final_markers"] / max(1, r["tokens"]), "let_density": len(re.findall(r"\b[Ll]et\b", t)) / max(1, r["tokens"]), "therefore_density": len(re.findall(r"\b[Tt]herefore\b", t)) / max(1, r["tokens"]), })feature_names = list(feature_rows[0])F = np.array([[r[k] for k in feature_names] for r in feature_rows])Fc = within_problem(F)Fl = Fc - np.outer(loglen, loglen @ Fc / (loglen @ loglen))Fnorm = np.sqrt(np.sum(Fl * Fl, axis=0) + 1e-20)
print("Mechanical arithmetic checks:", sum(len(numeric_equalities(r["text"])) for r in dev_records), "adjacent literal-number equalities")for good in [True, False]: mask = np.array([r["correct"] == good for r in dev_records]) print("Correct" if good else "Failed", "responses with checked arithmetic error:", int(np.sum(F[mask, feature_names.index("arithmetic_error_count")] > 0)), "/", int(mask.sum()))
component_profiles = {}for layer in [0,1,5,13,17]: X = np.asarray(mlp_mean[dev_indices, layer, :], dtype=np.float64) Xc = within_problem(X) Xl = Xc - np.outer(loglen, loglen @ Xc / (loglen @ loglen)) corrs = Xl.T @ Fl / ( np.sqrt(np.sum(Xl*Xl, axis=0) + 1e-20)[:,None] * Fnorm[None,:] ) for s in neuron_screen: if s["layer"] == layer: s["feature_corrs"] = dict(zip(feature_names, map(float, corrs[s["neuron"]]))) candidates = sorted( [s for s in stable if s["layer"] == layer], key=lambda s: s["robust_score"], reverse=True )[:6] for s in candidates: j = s["neuron"] profile = sorted( s["feature_corrs"].items(), key=lambda x: abs(x[1]), reverse=True )[:4] print("L", layer, "N", j, "mean/sd", round(s["mean"],3), round(s["sd"],3), "top feature correlations", [(k,round(v,3)) for k,v in profile])
arith_candidates = [ s for s in stable if "feature_corrs" in s and s["feature_corrs"]["arithmetic_error"] > .06]arith_candidates.sort( key=lambda s: s["robust_score"] * s["feature_corrs"]["arithmetic_error"], reverse=True)print("Stable failure + arithmetic-error candidates:")for s in arith_candidates[:16]: print("L", s["layer"], "N", s["neuron"], "failure", round(s["failure_corr"],3), "arith-error", round(s["feature_corrs"]["arithmetic_error"],3), "energy", round(s["energy"],4), "mean/sd", round(s["mean"],3), round(s["sd"],3))print("Weights remain unchanged.")Mechanical arithmetic checks: 3270 adjacent literal-number equalitiesCorrect responses with checked arithmetic error: 27 / 217Failed responses with checked arithmetic error: 82 / 295L 0 N 1405 mean/sd 13.373 6.971 top feature correlations [('digit_density', 0.318), ('repetition', 0.269), ('final_density', 0.132), ('latex_density', -0.126)]L 0 N 149 mean/sd 1.589 0.596 top feature correlations [('final_density', 0.329), ('repetition', 0.282), ('equality_density', -0.203), ('latex_density', -0.202)]L 0 N 1309 mean/sd 0.479 0.24 top feature correlations [('digit_density', 0.561), ('let_density', -0.144), ('arithmetic_error_count', 0.121), ('final_density', -0.094)]L 0 N 2032 mean/sd 0.169 0.193 top feature correlations [('digit_density', 0.4), ('final_density', -0.27), ('equality_density', 0.166), ('arithmetic_progress', -0.157)]L 0 N 761 mean/sd 0.321 0.277 top feature correlations [('digit_density', 0.59), ('arithmetic_error_count', 0.196), ('latex_density', -0.153), ('let_density', -0.122)]L 0 N 1479 mean/sd 0.165 0.201 top feature correlations [('digit_density', 0.487), ('identity_fraction', 0.177), ('arithmetic_error_count', 0.171), ('final_density', -0.121)]L 1 N 483 mean/sd 0.195 0.114 top feature correlations [('digit_density', 0.664), ('equality_density', 0.192), ('let_density', -0.157), ('arithmetic_error_count', 0.144)]L 1 N 1899 mean/sd 0.222 0.253 top feature correlations [('digit_density', 0.635), ('latex_density', -0.484), ('equality_density', 0.217), ('final_density', 0.141)]L 1 N 553 mean/sd 0.19 0.149 top feature correlations [('digit_density', 0.643), ('arithmetic_progress', -0.139), ('therefore_density', -0.133), ('final_density', -0.129)]L 1 N 421 mean/sd 0.198 0.107 top feature correlations [('digit_density', 0.42), ('equality_density', 0.226), ('latex_density', 0.171), ('arithmetic_error_count', 0.1)]L 1 N 1851 mean/sd 0.132 0.085 top feature correlations [('digit_density', 0.369), ('final_density', 0.316), ('equality_density', 0.134), ('therefore_density', -0.126)]L 1 N 1066 mean/sd 0.053 0.06 top feature correlations [('final_density', 0.442), ('arithmetic_error_count', 0.169), ('identity_fraction', 0.152), ('let_density', -0.109)]L 5 N 1111 mean/sd 0.004 0.018 top feature correlations [('final_density', 0.522), ('equality_density', -0.486), ('latex_density', -0.197), ('repetition', 0.119)]L 5 N 1244 mean/sd 0.052 0.046 top feature correlations [('digit_density', 0.492), ('final_density', -0.254), ('latex_density', 0.181), ('arithmetic_error_count', 0.136)]L 5 N 970 mean/sd 0.037 0.015 top feature correlations [('digit_density', 0.63), ('final_density', -0.23), ('equality_density', 0.167), ('therefore_density', -0.161)]L 5 N 207 mean/sd 0.014 0.013 top feature correlations [('final_density', 0.451), ('digit_density', 0.395), ('latex_density', -0.336), ('equality_density', -0.171)]L 5 N 473 mean/sd 0.022 0.01 top feature correlations [('final_density', 0.345), ('equality_density', -0.236), ('arithmetic_error', -0.141), ('arithmetic_progress', 0.097)]L 5 N 1493 mean/sd 0.013 0.014 top feature correlations [('equality_density', -0.522), ('final_density', 0.502), ('latex_density', -0.264), ('arithmetic_error_count', 0.092)]L 13 N 1226 mean/sd 0.028 0.011 top feature correlations [('digit_density', 0.343), ('equality_density', 0.149), ('arithmetic_progress', -0.128), ('final_density', -0.127)]L 13 N 231 mean/sd 0.035 0.016 top feature correlations [('digit_density', 0.607), ('equality_density', 0.268), ('final_density', -0.221), ('identity_fraction', 0.149)]L 13 N 1881 mean/sd 0.023 0.009 top feature correlations [('digit_density', 0.427), ('equality_density', 0.329), ('final_density', -0.179), ('arithmetic_progress', -0.17)]L 13 N 570 mean/sd 0.033 0.012 top feature correlations [('digit_density', 0.423), ('final_density', -0.304), ('identity_fraction', 0.248), ('latex_density', 0.152)]L 13 N 39 mean/sd 0.053 0.023 top feature correlations [('digit_density', 0.397), ('final_density', -0.38), ('arithmetic_error_count', 0.21), ('latex_density', 0.195)]L 13 N 1059 mean/sd 0.033 0.019 top feature correlations [('equality_density', 0.538), ('digit_density', 0.504), ('final_density', -0.242), ('latex_density', 0.235)]L 17 N 1451 mean/sd 0.183 0.06 top feature correlations [('digit_density', 0.375), ('equality_density', 0.272), ('identity_fraction', 0.264), ('repetition', 0.233)]L 17 N 653 mean/sd 0.037 0.009 top feature correlations [('digit_density', 0.289), ('equality_density', 0.259), ('final_density', -0.22), ('repetition', 0.154)]L 17 N 547 mean/sd 0.083 0.051 top feature correlations [('final_density', 0.375), ('latex_density', -0.373), ('digit_density', 0.275), ('equality_density', 0.264)]L 17 N 942 mean/sd 0.033 0.01 top feature correlations [('final_density', -0.491), ('digit_density', 0.464), ('equality_density', 0.259), ('therefore_density', -0.147)]L 17 N 211 mean/sd 0.067 0.044 top feature correlations [('final_density', 0.341), ('latex_density', -0.294), ('equality_density', -0.208), ('digit_density', -0.19)]L 17 N 1475 mean/sd 0.015 0.015 top feature correlations [('digit_density', 0.184), ('let_density', -0.167), ('identity_fraction', 0.113), ('final_density', -0.105)]Stable failure + arithmetic-error candidates:L 0 N 1028 failure 0.11 arith-error 0.154 energy 0.1002 mean/sd 0.106 0.126L 0 N 2032 failure 0.14 arith-error 0.092 energy 0.1355 mean/sd 0.169 0.193L 0 N 761 failure 0.114 arith-error 0.075 energy 0.2207 mean/sd 0.321 0.277L 0 N 1479 failure 0.113 arith-error 0.063 energy 0.1453 mean/sd 0.165 0.201L 0 N 845 failure 0.111 arith-error 0.066 energy 0.2212 mean/sd 0.251 0.262L 0 N 1450 failure 0.128 arith-error 0.082 energy 0.0428 mean/sd 0.023 0.064L 0 N 1013 failure 0.109 arith-error 0.08 energy 0.0683 mean/sd 0.047 0.116L 13 N 1881 failure 0.168 arith-error 0.117 energy 0.0101 mean/sd 0.023 0.009L 17 N 1554 failure 0.135 arith-error 0.165 energy 0.007 mean/sd 0.013 0.009L 13 N 39 failure 0.127 arith-error 0.104 energy 0.0212 mean/sd 0.053 0.023L 13 N 1540 failure 0.187 arith-error 0.117 energy 0.0057 mean/sd 0.015 0.009L 17 N 942 failure 0.162 arith-error 0.089 energy 0.015 mean/sd 0.033 0.01L 17 N 793 failure 0.218 arith-error 0.106 energy 0.0035 mean/sd 0.007 0.006L 17 N 1475 failure 0.149 arith-error 0.066 energy 0.0091 mean/sd 0.015 0.015L 17 N 124 failure 0.102 arith-error 0.119 energy 0.0083 mean/sd 0.016 0.011L 17 N 1484 failure 0.129 arith-error 0.126 energy 0.005 mean/sd 0.009 0.007Weights remain unchanged.# Statistical residualization only: this does not train or run the model.control_names = [ "digit_density", "latex_density", "equality_density", "final_density", "let_density", "therefore_density"]C = np.column_stack( [loglen] + [Fc[:, feature_names.index(k)] for k in control_names])Q, _ = np.linalg.qr(C, mode="reduced")def remove_controls(x, mask=None): if mask is None: return x - Q @ (Q.T @ x) c = C[mask] q, _ = np.linalg.qr(c, mode="reduced") z = x[mask] return z - q @ (q.T @ z)
f_adj = remove_controls(failure)a_adj = remove_controls(Fc[:, feature_names.index("arithmetic_error")])p_adj = remove_controls(Fc[:, feature_names.index("arithmetic_progress")])i_adj = remove_controls(Fc[:, feature_names.index("identity_fraction")])r_adj = remove_controls(repeat)controlled_screen = []
for layer in range(18): Xc = within_problem(np.asarray(mlp_mean[dev_indices, layer, :], dtype=np.float64)) Xa = remove_controls(Xc) normx = np.sqrt(np.sum(Xa * Xa, axis=0) + 1e-20) def correlations(y): return y @ Xa / (np.linalg.norm(y) * normx + 1e-20) cf, ca, cp, ci, cr = [correlations(y) for y in [f_adj,a_adj,p_adj,i_adj,r_adj]] ch = [] for half in [0,1]: mask = groups_dev % 2 == half xx = remove_controls(Xc, mask) yy = remove_controls(failure, mask) ch.append(yy @ xx / ( np.linalg.norm(yy) * np.sqrt(np.sum(xx*xx, axis=0) + 1e-20) )) prior = {s["neuron"]:s for s in neuron_screen if s["layer"] == layer} for j in range(2048): controlled_screen.append({ **prior[j], "adjusted_failure": float(cf[j]), "adjusted_arithmetic_error": float(ca[j]), "adjusted_progress": float(cp[j]), "adjusted_identity": float(ci[j]), "adjusted_repeat": float(cr[j]), "adjusted_half0": float(ch[0][j]), "adjusted_half1": float(ch[1][j]), })
controlled_candidates = [ s for s in controlled_screen if s["layer"] >= 6 and s["mean"] > 0 and s["adjusted_failure"] > .10 and min(s["adjusted_half0"], s["adjusted_half1"]) > .045 and s["adjusted_arithmetic_error"] > .04]controlled_candidates.sort( key=lambda s: ( min(s["adjusted_half0"], s["adjusted_half1"]) * math.sqrt(max(0, s["adjusted_arithmetic_error"])) ), reverse=True)print("Late-layer candidates after surface-form controls:", len(controlled_candidates))for s in controlled_candidates[:24]: print({ k: round(s[k], 3) if isinstance(s[k], float) else s[k] for k in [ "layer","neuron","adjusted_failure","adjusted_arithmetic_error", "adjusted_half0","adjusted_half1","adjusted_progress", "adjusted_identity","energy" ] })
print("Top adjusted failure correlations by layer:")for layer in range(18): ss = [s for s in controlled_screen if s["layer"] == layer] s = max(ss, key=lambda s:s["adjusted_failure"]) print(layer, s["neuron"], round(s["adjusted_failure"],3), "halves", round(s["adjusted_half0"],3), round(s["adjusted_half1"],3), "arith", round(s["adjusted_arithmetic_error"],3))
with open("/work/controlled_neuron_screen.json", "w") as f: json.dump(controlled_screen, f)print("No edit yet.")Late-layer candidates after surface-form controls: 166{'layer': 17, 'neuron': 793, 'adjusted_failure': 0.208, 'adjusted_arithmetic_error': 0.117, 'adjusted_half0': 0.224, 'adjusted_half1': 0.213, 'adjusted_progress': -0.063, 'adjusted_identity': -0.087, 'energy': 0.004}{'layer': 16, 'neuron': 128, 'adjusted_failure': 0.149, 'adjusted_arithmetic_error': 0.173, 'adjusted_half0': 0.155, 'adjusted_half1': 0.153, 'adjusted_progress': -0.177, 'adjusted_identity': 0.065, 'energy': 0.006}{'layer': 11, 'neuron': 587, 'adjusted_failure': 0.172, 'adjusted_arithmetic_error': 0.135, 'adjusted_half0': 0.155, 'adjusted_half1': 0.182, 'adjusted_progress': -0.138, 'adjusted_identity': 0.14, 'energy': 0.036}{'layer': 14, 'neuron': 11, 'adjusted_failure': 0.157, 'adjusted_arithmetic_error': 0.128, 'adjusted_half0': 0.156, 'adjusted_half1': 0.174, 'adjusted_progress': -0.077, 'adjusted_identity': -0.024, 'energy': 0.002}{'layer': 13, 'neuron': 1881, 'adjusted_failure': 0.177, 'adjusted_arithmetic_error': 0.14, 'adjusted_half0': 0.187, 'adjusted_half1': 0.148, 'adjusted_progress': -0.127, 'adjusted_identity': 0.124, 'energy': 0.01}{'layer': 15, 'neuron': 1036, 'adjusted_failure': 0.142, 'adjusted_arithmetic_error': 0.129, 'adjusted_half0': 0.174, 'adjusted_half1': 0.148, 'adjusted_progress': -0.072, 'adjusted_identity': 0.093, 'energy': 0.007}{'layer': 12, 'neuron': 1797, 'adjusted_failure': 0.147, 'adjusted_arithmetic_error': 0.148, 'adjusted_half0': 0.136, 'adjusted_half1': 0.143, 'adjusted_progress': 0.014, 'adjusted_identity': -0.054, 'energy': 0.011}{'layer': 14, 'neuron': 1157, 'adjusted_failure': 0.137, 'adjusted_arithmetic_error': 0.193, 'adjusted_half0': 0.112, 'adjusted_half1': 0.159, 'adjusted_progress': -0.209, 'adjusted_identity': -0.018, 'energy': 0.004}{'layer': 13, 'neuron': 1540, 'adjusted_failure': 0.176, 'adjusted_arithmetic_error': 0.158, 'adjusted_half0': 0.211, 'adjusted_half1': 0.124, 'adjusted_progress': -0.075, 'adjusted_identity': -0.075, 'energy': 0.006}{'layer': 6, 'neuron': 1157, 'adjusted_failure': 0.136, 'adjusted_arithmetic_error': 0.125, 'adjusted_half0': 0.133, 'adjusted_half1': 0.135, 'adjusted_progress': -0.038, 'adjusted_identity': -0.018, 'energy': 0.012}{'layer': 17, 'neuron': 942, 'adjusted_failure': 0.175, 'adjusted_arithmetic_error': 0.097, 'adjusted_half0': 0.15, 'adjusted_half1': 0.202, 'adjusted_progress': -0.015, 'adjusted_identity': -0.138, 'energy': 0.015}{'layer': 13, 'neuron': 1098, 'adjusted_failure': 0.156, 'adjusted_arithmetic_error': 0.101, 'adjusted_half0': 0.194, 'adjusted_half1': 0.148, 'adjusted_progress': -0.06, 'adjusted_identity': -0.055, 'energy': 0.004}{'layer': 9, 'neuron': 1493, 'adjusted_failure': 0.15, 'adjusted_arithmetic_error': 0.12, 'adjusted_half0': 0.187, 'adjusted_half1': 0.135, 'adjusted_progress': -0.056, 'adjusted_identity': -0.066, 'energy': 0.005}{'layer': 17, 'neuron': 1554, 'adjusted_failure': 0.151, 'adjusted_arithmetic_error': 0.156, 'adjusted_half0': 0.203, 'adjusted_half1': 0.116, 'adjusted_progress': -0.141, 'adjusted_identity': 0.033, 'energy': 0.007}{'layer': 17, 'neuron': 1378, 'adjusted_failure': 0.115, 'adjusted_arithmetic_error': 0.152, 'adjusted_half0': 0.112, 'adjusted_half1': 0.132, 'adjusted_progress': -0.058, 'adjusted_identity': 0.084, 'energy': 0.006}{'layer': 16, 'neuron': 1315, 'adjusted_failure': 0.172, 'adjusted_arithmetic_error': 0.137, 'adjusted_half0': 0.118, 'adjusted_half1': 0.21, 'adjusted_progress': -0.003, 'adjusted_identity': -0.074, 'energy': 0.012}{'layer': 11, 'neuron': 1551, 'adjusted_failure': 0.122, 'adjusted_arithmetic_error': 0.129, 'adjusted_half0': 0.135, 'adjusted_half1': 0.121, 'adjusted_progress': -0.031, 'adjusted_identity': -0.2, 'energy': 0.007}{'layer': 8, 'neuron': 1777, 'adjusted_failure': 0.165, 'adjusted_arithmetic_error': 0.122, 'adjusted_half0': 0.12, 'adjusted_half1': 0.217, 'adjusted_progress': -0.067, 'adjusted_identity': -0.016, 'energy': 0.004}{'layer': 16, 'neuron': 1766, 'adjusted_failure': 0.19, 'adjusted_arithmetic_error': 0.091, 'adjusted_half0': 0.138, 'adjusted_half1': 0.242, 'adjusted_progress': -0.166, 'adjusted_identity': 0.014, 'energy': 0.004}{'layer': 9, 'neuron': 580, 'adjusted_failure': 0.142, 'adjusted_arithmetic_error': 0.119, 'adjusted_half0': 0.12, 'adjusted_half1': 0.139, 'adjusted_progress': -0.146, 'adjusted_identity': 0.04, 'energy': 0.021}{'layer': 8, 'neuron': 1185, 'adjusted_failure': 0.145, 'adjusted_arithmetic_error': 0.11, 'adjusted_half0': 0.123, 'adjusted_half1': 0.213, 'adjusted_progress': -0.047, 'adjusted_identity': 0.01, 'energy': 0.088}{'layer': 10, 'neuron': 1798, 'adjusted_failure': 0.139, 'adjusted_arithmetic_error': 0.091, 'adjusted_half0': 0.157, 'adjusted_half1': 0.135, 'adjusted_progress': -0.026, 'adjusted_identity': -0.116, 'energy': 0.005}{'layer': 17, 'neuron': 75, 'adjusted_failure': 0.115, 'adjusted_arithmetic_error': 0.122, 'adjusted_half0': 0.118, 'adjusted_half1': 0.114, 'adjusted_progress': -0.05, 'adjusted_identity': -0.083, 'energy': 0.018}{'layer': 17, 'neuron': 1484, 'adjusted_failure': 0.146, 'adjusted_arithmetic_error': 0.147, 'adjusted_half0': 0.101, 'adjusted_half1': 0.211, 'adjusted_progress': -0.154, 'adjusted_identity': 0.025, 'energy': 0.005}Top adjusted failure correlations by layer:0 1869 0.194 halves 0.257 0.139 arith 0.0211 694 0.18 halves 0.152 0.227 arith -0.0732 1616 0.145 halves 0.203 0.052 arith -0.0083 1628 0.158 halves 0.169 0.139 arith 0.0614 193 0.193 halves 0.244 0.111 arith 0.0465 1111 0.151 halves 0.128 0.159 arith -0.0046 1850 0.163 halves 0.171 0.166 arith 0.0337 796 0.171 halves 0.145 0.228 arith 0.0118 1751 0.188 halves 0.172 0.213 arith 0.0349 175 0.164 halves 0.126 0.243 arith 0.07710 779 0.154 halves 0.232 0.076 arith 0.02711 401 0.21 halves 0.203 0.227 arith 0.11112 467 0.164 halves 0.133 0.185 arith -0.02513 1226 0.216 halves 0.188 0.265 arith 0.00414 1202 0.228 halves 0.13 0.315 arith 0.07815 1839 0.17 halves 0.139 0.205 arith 0.08416 250 0.191 halves 0.123 0.257 arith 0.09717 793 0.208 halves 0.224 0.213 arith 0.117No edit yet.torch.set_grad_enabled(False)
# Geometry of existing weights and recorded activations, not a forward simulation.for layer in range(6,18): delta = ( np.asarray(hidden_mean[dev_indices, layer+1, :], dtype=np.float64) - np.asarray(hidden_mean[dev_indices, layer, :], dtype=np.float64) ) delta_adj = remove_controls(within_problem(delta)) direction = f_adj @ delta_adj / (f_adj @ f_adj) D = load_original(f"model.layers.{layer}.mlp.down_proj.weight").numpy().astype(np.float64) gamma = 1 + load_original( f"model.layers.{layer}.post_feedforward_layernorm.weight" ).numpy().astype(np.float64) columns = gamma[:,None] * D align = direction @ columns / ( np.linalg.norm(direction) * np.linalg.norm(columns, axis=0) + 1e-20 ) for s in controlled_candidates: if s["layer"] == layer: s["failure_update_alignment"] = float(align[s["neuron"]])
reinforcing = [ s for s in controlled_candidates if s["failure_update_alignment"] > 0]selected_components = reinforcing[:64]assert len(selected_components) >= 16selected_by_layer = collections.defaultdict(list)for s in selected_components: selected_by_layer[s["layer"]].append(s["neuron"])selected_by_layer = {l: sorted(js) for l,js in sorted(selected_by_layer.items())}
selection_manifest = { "hypothesis": "Sparse late MLP outputs reinforce invalid numerical transformations.", "selection": ( "Within-DEV-problem correlations, controlling log length and six surface " "features; positive-mean neurons in layers 6-17; adjusted failure>.10; " "both DEV-half failure correlations>.045; adjusted arithmetic-error>.04; " "positive output alignment with the observed failure-associated block update. " "Rank by min half correlation times sqrt arithmetic-error correlation; top64." ), "neurons": {str(l):js for l,js in selected_by_layer.items()}, "evidence": selected_components, "planned_strengths": [0.5,1.0], "primary_outcome": "paired final-answer accuracy", "secondary_outcomes": [ "responses containing mechanically checked false numeric equalities", "arithmetic-check coverage", "failure types", "repetition" ],}with open("/work/candidate_manifest.json", "w") as f: json.dump(selection_manifest, f, indent=2)
def apply_candidate(strength): summaries = [] for layer, js in selected_by_layer.items(): name = f"model.layers.{layer}.mlp.down_proj.weight" original = load_original(name) new = original.clone() new[:, js] = original[:, js] * (1-strength) save_edit(name, new) summaries.append({ "layer": layer, "neurons": len(js), "relative_frobenius_change": float(torch.linalg.vector_norm(new-original) / torch.linalg.vector_norm(original)) }) return summaries
strength = 0.5edit_summary = apply_candidate(strength)with open("/work/notes.md", "a") as f: f.write( "\n## Candidate fixed before causal tests\n" "- Selection and complete neuron evidence: candidate_manifest.json.\n" "- Sparse down_proj column suppression only; no embeddings, output matrix, " "norms, attention, gate_proj or up_proj edited.\n" f"- Exact selected columns by layer: {json.dumps(selected_by_layer)}.\n" "- Hypothesis: these outputs reinforce invalid numerical transformations. " "Association and output geometry alone are not causal proof.\n" "\n## Pass 3: paired DEV, half suppression\n" "- Exact edit: for each selected layer/column above, " "down_proj[:,j] = 0.5 * original[:,j]; all other values unchanged.\n" "- Problems: DEV_ids.json; 32 problems x 32 samples/model = 1024/model.\n" "- Both models, temperature/top-k/top-p fixed by evaluator; max_tokens=[REDACTED] "- Accuracy is primary; arithmetic errors and coverage are secondary.\n" "- Next planned dose: full removal of exactly the same columns.\n" )
import shutilshutil.copytree("/work/edited", "/work/candidate_half", dirs_exist_ok=True)print("Selected neurons:", sum(map(len,selected_by_layer.values())))print("Selected columns by layer:", json.dumps(selected_by_layer))print("Geometry-screen survivors:", len(reinforcing))print("Per-tensor changes:", edit_summary)print("Edited tensor count:", len(edited()))print("Half-strength candidate backed up; HOLDOUT untouched.")Selected neurons: 64Selected columns by layer: {"6": [640, 678, 1157], "7": [637, 1621], "8": [477, 792, 1777, 1865], "9": [884, 1493], "10": [1621, 1798], "11": [1, 587, 672, 1551, 1890], "12": [1123, 1184, 1278, 1797, 1894], "13": [39, 759, 1059, 1260, 1540, 1881], "14": [11, 23, 238, 640, 1157, 1202, 1497, 1935], "15": [661, 968, 1304, 1507, 1818], "16": [128, 255, 322, 513, 663, 1315, 1486, 1548, 1598, 1649, 1876, 2004], "17": [124, 942, 1115, 1222, 1326, 1475, 1484, 1554, 1688, 1741]}Geometry-screen survivors: 106Per-tensor changes: [{'layer': 6, 'neurons': 3, 'relative_frobenius_change': 0.020754922181367874}, {'layer': 7, 'neurons': 2, 'relative_frobenius_change': 0.014555721543729305}, {'layer': 8, 'neurons': 4, 'relative_frobenius_change': 0.02329275943338871}, {'layer': 9, 'neurons': 2, 'relative_frobenius_change': 0.014009480364620686}, {'layer': 10, 'neurons': 2, 'relative_frobenius_change': 0.012839410454034805}, {'layer': 11, 'neurons': 5, 'relative_frobenius_change': 0.02441495656967163}, {'layer': 12, 'neurons': 5, 'relative_frobenius_change': 0.026036622002720833}, {'layer': 13, 'neurons': 6, 'relative_frobenius_change': 0.028796641156077385}, {'layer': 14, 'neurons': 8, 'relative_frobenius_change': 0.0321677103638649}, {'layer': 15, 'neurons': 5, 'relative_frobenius_change': 0.025061622262001038}, {'layer': 16, 'neurons': 12, 'relative_frobenius_change': 0.038654133677482605}, {'layer': 17, 'neurons': 10, 'relative_frobenius_change': 0.037476081401109695}]Edited tensor count: 12Half-strength candidate backed up; HOLDOUT untouched.{"type":"generate","model":"both","problems":["math_train_counting_and_probability_606","math_train_prealgebra_593","math_train_algebra_1707","math_train_prealgebra_55","math_train_prealgebra_940","math_train_algebra_1114","math_train_intermediate_algebra_633","math_train_prealgebra_207","math_train_prealgebra_502","math_train_precalculus_220","math_train_algebra_498","math_train_algebra_636","math_train_counting_and_probability_148","math_train_prealgebra_318","math_train_prealgebra_780","math_train_algebra_1497","math_train_algebra_182","math_train_intermediate_algebra_643","math_train_intermediate_algebra_933","math_train_number_theory_540","math_train_number_theory_696","math_train_prealgebra_774","math_train_algebra_1461","math_train_algebra_1523","math_train_algebra_731","math_train_algebra_958","math_train_geometry_158","math_train_intermediate_algebra_80","math_train_prealgebra_202","math_train_prealgebra_590","math_train_prealgebra_839","math_train_algebra_1423"],"n":32,"max_tokens":8192}{ "ok": true, "type": "generate", "model": "both", "files": { "original": "/work/gen_3_original.jsonl", "edited": "/work/gen_3_edited.jsonl" }, "activations": null, "original": { "generations": 1024, "graded": 1024, "accuracy": 0.39453125, "accuracy_by_source": { "math": 0.3945 }, "mean_tokens": 1327, "cut_share": 0.0791, "failures": { "wrong_answer": 276, "no_answer_finished": 279, "cut_at_max_tokens": 65 } }, "edited": { "generations": 1024, "graded": 1024, "accuracy": 0.3896484375, "accuracy_by_source": { "math": 0.3896 }, "mean_tokens": 1138, "cut_share": 0.0566, "failures": { "wrong_answer": 310, "no_answer_finished": 273, "cut_at_max_tokens": 42 } }, "paired": { "items": 32, "accuracy_difference": -0.0049, "standard_error": 0.0157, "samples_wrong_to_right": 143, "samples_right_to_wrong": 148 }, "s": 643.2}def load_generation_file(path): with open(path) as f: grouped = [json.loads(line) for line in f] flat = [] for group in grouped: for j, s in enumerate(group["samples"]): flat.append({ **s, "problem_id": group["id"], "sample_index": j, "reference": group["answer"], }) return flat
def mechanism_summary(rr): eq_lists = [numeric_equalities(r["text"]) for r in rr] checked = np.array([len(e)>0 for e in eq_lists]) bad = np.array([any(not v[0] for v in e) for e in eq_lists]) n_bad = sum(sum(not v[0] for v in e) for e in eq_lists) n_valid_progress = sum(sum(v[0] and not v[1] for v in e) for e in eq_lists) n_identity = sum(sum(v[1] for v in e) for e in eq_lists) result = { "answers": len(rr), "correct": sum(r["correct"] for r in rr), "checked_response_share": float(checked.mean()), "response_with_checked_error_share": float(bad.mean()), "error_share_among_checked_responses": float(bad.sum()/max(1,checked.sum())), "checked_false_equalities": int(n_bad), "checked_valid_progress_equalities": int(n_valid_progress), "checked_identity_equalities": int(n_identity), "median_tokens": float(np.median([r["tokens"] for r in rr])), "cut_responses": sum(r["cut"] for r in rr), } return result, bad, checked
dev_half_original = load_generation_file("/work/gen_3_original.jsonl")dev_half_edited = load_generation_file("/work/gen_3_edited.jsonl")assert [ (r["problem_id"],r["sample_index"]) for r in dev_half_original] == [(r["problem_id"],r["sample_index"]) for r in dev_half_edited]
half_mechanisms = {}for label, rr in [("original",dev_half_original), ("half_suppression",dev_half_edited)]: summary, bad, checked = mechanism_summary(rr) half_mechanisms[label] = summary print(label, summary)with open("/work/dev_half_mechanisms.json", "w") as f: json.dump(half_mechanisms, f, indent=2)
for lo, hi in [(0,256),(256,512),(512,1024),(1024,2048),(2048,9000)]: row = {"token_range": [lo,hi]} for label, rr in [("original",dev_half_original), ("edited",dev_half_edited)]: subset = [r for r in rr if lo <= r["tokens"] < hi] if subset: s,_,_ = mechanism_summary(subset) row[label] = { "n":len(subset), "accuracy":round(s["correct"]/s["answers"],3), "checked_error_share":round(s["response_with_checked_error_share"],3) } print(row)
strength = 1.0full_summary = apply_candidate(strength)shutil.copytree("/work/edited", "/work/candidate_full", dirs_exist_ok=True)with open("/work/notes.md", "a") as f: f.write( "\n## Pass 3 results\n" "- Original: 404/1024 (39.4531%); half suppression: 399/1024 (38.9648%).\n" "- Paired difference: -0.49 percentage points; tool-reported SE 1.57 points.\n" "- Wrong-to-right 143; right-to-wrong 148. No accuracy benefit demonstrated.\n" "- Cut share fell from 7.91% to 5.66%; not treated as success.\n" "- Arithmetic diagnostics: dev_half_mechanisms.json.\n" "\n## Pass 4: paired DEV, full suppression\n" "- Exact edit: same 64 columns in candidate_manifest.json, " "down_proj[:,j] = 0; all other tensor values unchanged.\n" "- Same 32 DEV problems, 32 samples/model = 1024/model, " "max_tokens=[REDACTED] both original and edited.\n" "- Half and full candidates are backed up separately. " "Select by within-pass accuracy difference, not response length.\n" "- HOLDOUT still untouched; freeze the better tested non-original " "candidate before pass 5.\n" )print("Full-removal edit saved:", len(edited()), "tensors.")print("Relative changes:", [ (s["layer"], round(s["relative_frobenius_change"],4)) for s in full_summary])original {'answers': 1024, 'correct': 404, 'checked_response_share': 0.689453125, 'response_with_checked_error_share': 0.1904296875, 'error_share_among_checked_responses': 0.2762039660056657, 'checked_false_equalities': 573, 'checked_valid_progress_equalities': 3779, 'checked_identity_equalities': 1933, 'median_tokens': 539.0, 'cut_responses': 81}half_suppression {'answers': 1024, 'correct': 399, 'checked_response_share': 0.69921875, 'response_with_checked_error_share': 0.1845703125, 'error_share_among_checked_responses': 0.2639664804469274, 'checked_false_equalities': 598, 'checked_valid_progress_equalities': 2992, 'checked_identity_equalities': 1667, 'median_tokens': 509.5, 'cut_responses': 58}{'token_range': [0, 256], 'original': {'n': 235, 'accuracy': 0.472, 'checked_error_share': 0.106}, 'edited': {'n': 257, 'accuracy': 0.447, 'checked_error_share': 0.16}}{'token_range': [256, 512], 'original': {'n': 262, 'accuracy': 0.466, 'checked_error_share': 0.183}, 'edited': {'n': 258, 'accuracy': 0.434, 'checked_error_share': 0.167}}{'token_range': [512, 1024], 'original': {'n': 244, 'accuracy': 0.381, 'checked_error_share': 0.303}, 'edited': {'n': 254, 'accuracy': 0.386, 'checked_error_share': 0.252}}{'token_range': [1024, 2048], 'original': {'n': 150, 'accuracy': 0.293, 'checked_error_share': 0.173}, 'edited': {'n': 150, 'accuracy': 0.3, 'checked_error_share': 0.18}}{'token_range': [2048, 9000], 'original': {'n': 133, 'accuracy': 0.256, 'checked_error_share': 0.165}, 'edited': {'n': 105, 'accuracy': 0.276, 'checked_error_share': 0.133}}Full-removal edit saved: 12 tensors.Relative changes: [(6, 0.0415), (7, 0.0291), (8, 0.0466), (9, 0.028), (10, 0.0257), (11, 0.0488), (12, 0.0521), (13, 0.0576), (14, 0.0643), (15, 0.0501), (16, 0.0773), (17, 0.075)]{"type":"generate","model":"both","problems":["math_train_counting_and_probability_606","math_train_prealgebra_593","math_train_algebra_1707","math_train_prealgebra_55","math_train_prealgebra_940","math_train_algebra_1114","math_train_intermediate_algebra_633","math_train_prealgebra_207","math_train_prealgebra_502","math_train_precalculus_220","math_train_algebra_498","math_train_algebra_636","math_train_counting_and_probability_148","math_train_prealgebra_318","math_train_prealgebra_780","math_train_algebra_1497","math_train_algebra_182","math_train_intermediate_algebra_643","math_train_intermediate_algebra_933","math_train_number_theory_540","math_train_number_theory_696","math_train_prealgebra_774","math_train_algebra_1461","math_train_algebra_1523","math_train_algebra_731","math_train_algebra_958","math_train_geometry_158","math_train_intermediate_algebra_80","math_train_prealgebra_202","math_train_prealgebra_590","math_train_prealgebra_839","math_train_algebra_1423"],"n":32,"max_tokens":8192}{ "ok": true, "type": "generate", "model": "both", "files": { "original": "/work/gen_4_original.jsonl", "edited": "/work/gen_4_edited.jsonl" }, "activations": null, "original": { "generations": 1024, "graded": 1024, "accuracy": 0.3955078125, "accuracy_by_source": { "math": 0.3955 }, "mean_tokens": 1380, "cut_share": 0.082, "failures": { "wrong_answer": 259, "no_answer_finished": 303, "cut_at_max_tokens": 57 } }, "edited": { "generations": 1024, "graded": 1024, "accuracy": 0.349609375, "accuracy_by_source": { "math": 0.3496 }, "mean_tokens": 1058, "cut_share": 0.0508, "failures": { "wrong_answer": 359, "no_answer_finished": 263, "cut_at_max_tokens": 44 } }, "paired": { "items": 32, "accuracy_difference": -0.0459, "standard_error": 0.017, "samples_wrong_to_right": 155, "samples_right_to_wrong": 202 }, "s": 372.0}dev_full_original = load_generation_file("/work/gen_4_original.jsonl")dev_full_edited = load_generation_file("/work/gen_4_edited.jsonl")full_mechanisms = {}for label, rr in [("original",dev_full_original), ("full_suppression",dev_full_edited)]: summary, _, _ = mechanism_summary(rr) full_mechanisms[label] = summary print(label, summary)with open("/work/dev_full_mechanisms.json", "w") as f: json.dump(full_mechanisms, f, indent=2)
# Select solely from DEV, before any holdout generations.chosen_strength = 0.5apply_candidate(chosen_strength)
import hashlibfrozen_hashes = {}for layer, js in selected_by_layer.items(): name = f"model.layers.{layer}.mlp.down_proj.weight" original = load_original(name) current = load(name) mask = torch.ones(original.shape[1], dtype=torch.bool) mask[js] = False assert current.shape == original.shape assert torch.equal(current[:, mask], original[:, mask]) assert torch.equal(current[:, js], 0.5 * original[:, js]) frozen_hashes[name] = hashlib.sha256( current.contiguous().numpy().tobytes() ).hexdigest()
shutil.copytree("/work/edited", "/work/best_1", dirs_exist_ok=True)frozen_manifest = { "strength": chosen_strength, "columns": {str(l):js for l,js in selected_by_layer.items()}, "tensor_sha256_float32": frozen_hashes, "chosen_using": "DEV paired accuracy only", "dev_half_difference_pp": -0.48828125, "dev_half_reported_se_pp": 1.57, "dev_full_difference_pp": -4.58984375, "dev_full_reported_se_pp": 1.70, "holdout_ids_file": "/work/HOLDOUT_ids.json", "frozen_before_holdout": True,}with open("/work/frozen_candidate.json", "w") as f: json.dump(frozen_manifest, f, indent=2)with open("/work/notes.md", "a") as f: f.write( "\n## Pass 4 results and candidate selection\n" "- Original: 405/1024 (39.5508%); full suppression: 358/1024 (34.9609%).\n" "- Paired difference: -4.59 points; tool-reported SE 1.70 points.\n" "- Wrong-to-right 155; right-to-wrong 202. Full removal is harmful on DEV.\n" "- Strong suppression hypothesis is not supported. Reduced truncation " "does not imply improved mathematical accuracy.\n" "- Best tested non-original candidate: half suppression, selected on DEV " "only. It has no demonstrated DEV accuracy benefit.\n" "\n## Candidate frozen before HOLDOUT\n" "- Exact edit: down_proj[:,j] = 0.5 * original[:,j] for the same 64 columns " "in candidate_manifest.json; all other values unchanged.\n" "- Verified bitwise unchanged unselected columns; tensor hashes saved " "in frozen_candidate.json. Backup: /work/best_1/.\n" "- No further candidate selection or tuning using HOLDOUT.\n" "\n## Pass 5: frozen HOLDOUT confirmation\n" "- Problems: HOLDOUT_ids.json, fixed before baseline; 128 MATH problems.\n" "- Both models, 8 samples/problem = 1024 answers/model, max_tokens=[REDACTED] "- Report the paired accuracy difference and its uncertainty honestly, " "including a negative or inconclusive result.\n" )print("Frozen strength:", chosen_strength)print("Verified edited tensors:", len(frozen_hashes))print("Edited scalar weights:", 640 * sum(map(len, selected_by_layer.values())))print("HOLDOUT IDs:")print(json.dumps(holdout_ids))original {'answers': 1024, 'correct': 405, 'checked_response_share': 0.724609375, 'response_with_checked_error_share': 0.205078125, 'error_share_among_checked_responses': 0.2830188679245283, 'checked_false_equalities': 709, 'checked_valid_progress_equalities': 3966, 'checked_identity_equalities': 1851, 'median_tokens': 560.5, 'cut_responses': 84}full_suppression {'answers': 1024, 'correct': 358, 'checked_response_share': 0.69921875, 'response_with_checked_error_share': 0.20703125, 'error_share_among_checked_responses': 0.29608938547486036, 'checked_false_equalities': 570, 'checked_valid_progress_equalities': 2683, 'checked_identity_equalities': 1613, 'median_tokens': 433.0, 'cut_responses': 52}Frozen strength: 0.5Verified edited tensors: 12Edited scalar weights: 40960HOLDOUT IDs:["math_train_intermediate_algebra_849", "math_train_prealgebra_89", "math_train_algebra_212", "math_train_precalculus_527", "math_train_precalculus_188", "math_train_algebra_1237", "math_train_algebra_265", "math_train_algebra_1141", "math_train_prealgebra_301", "math_train_algebra_1719", "math_train_precalculus_199", "math_train_algebra_715", "math_train_algebra_853", "math_train_number_theory_525", "math_train_prealgebra_553", "math_train_algebra_950", "math_train_intermediate_algebra_358", "math_train_algebra_1187", "math_train_number_theory_376", "math_train_intermediate_algebra_32", "math_train_number_theory_444", "math_train_algebra_863", "math_train_algebra_1311", "math_train_number_theory_220", "math_train_number_theory_320", "math_train_number_theory_399", "math_train_algebra_1328", "math_train_algebra_634", "math_train_counting_and_probability_481", "math_train_number_theory_512", "math_train_algebra_778", "math_train_intermediate_algebra_462", "math_train_intermediate_algebra_591", "math_train_prealgebra_277", "math_train_number_theory_437", "math_train_algebra_961", "math_train_intermediate_algebra_1165", "math_train_number_theory_375", "math_train_algebra_944", "math_train_algebra_13", "math_train_prealgebra_50", "math_train_intermediate_algebra_178", "math_train_number_theory_742", "math_train_prealgebra_1012", "math_train_algebra_579", "math_train_precalculus_285", "math_train_algebra_935", "math_train_counting_and_probability_77", "math_train_algebra_107", "math_train_precalculus_223", "math_train_algebra_289", "math_train_prealgebra_790", "math_train_algebra_1363", "math_train_prealgebra_30", "math_train_algebra_1245", "math_train_prealgebra_809", "math_train_intermediate_algebra_714", "math_train_algebra_1577", "math_train_intermediate_algebra_1073", "math_train_intermediate_algebra_213", "math_train_algebra_441", "math_train_number_theory_866", "math_train_precalculus_603", "math_train_number_theory_119", "math_train_counting_and_probability_695", "math_train_geometry_829", "math_train_precalculus_219", "math_train_precalculus_16", "math_train_number_theory_441", "math_train_prealgebra_674", "math_train_algebra_835", "math_train_geometry_366", "math_train_intermediate_algebra_899", "math_train_geometry_778", "math_train_intermediate_algebra_227", "math_train_counting_and_probability_733", "math_train_prealgebra_881", "math_train_algebra_554", "math_train_number_theory_750", "math_train_intermediate_algebra_866", "math_train_intermediate_algebra_998", "math_train_counting_and_probability_602", "math_train_prealgebra_691", "math_train_counting_and_probability_559", "math_train_geometry_810", "math_train_prealgebra_1102", "math_train_algebra_202", "math_train_prealgebra_612", "math_train_counting_and_probability_657", "math_train_intermediate_algebra_423", "math_train_prealgebra_31", "math_train_precalculus_72", "math_train_counting_and_probability_570", "math_train_algebra_368", "math_train_counting_and_probability_270", "math_train_algebra_1518", "math_train_prealgebra_939", "math_train_intermediate_algebra_314", "math_train_intermediate_algebra_170", "math_train_counting_and_probability_604", "math_train_algebra_479", "math_train_number_theory_265", "math_train_intermediate_algebra_131", "math_train_intermediate_algebra_588", "math_train_counting_and_probability_448", "math_train_prealgebra_350", "math_train_geometry_741", "math_train_counting_and_probability_682", "math_train_algebra_1534", "math_train_counting_and_probability_344", "math_train_prealgebra_924", "math_train_prealgebra_101", "math_train_number_theory_339", "math_train_geometry_621", "math_train_intermediate_algebra_1056", "math_train_counting_and_probability_315", "math_train_number_theory_411", "math_train_precalculus_422", "math_train_prealgebra_1171", "math_train_number_theory_140", "math_train_number_theory_669", "math_train_counting_and_probability_546", "math_train_algebra_1594", "math_train_algebra_1554", "math_train_algebra_1253", "math_train_intermediate_algebra_716", "math_train_counting_and_probability_361", "math_train_algebra_436"]{"type":"generate","model":"both","problems":["math_train_intermediate_algebra_849","math_train_prealgebra_89","math_train_algebra_212","math_train_precalculus_527","math_train_precalculus_188","math_train_algebra_1237","math_train_algebra_265","math_train_algebra_1141","math_train_prealgebra_301","math_train_algebra_1719","math_train_precalculus_199","math_train_algebra_715","math_train_algebra_853","math_train_number_theory_525","math_train_prealgebra_553","math_train_algebra_950","math_train_intermediate_algebra_358","math_train_algebra_1187","math_train_number_theory_376","math_train_intermediate_algebra_32","math_train_number_theory_444","math_train_algebra_863","math_train_algebra_1311","math_train_number_theory_220","math_train_number_theory_320","math_train_number_theory_399","math_train_algebra_1328","math_train_algebra_634","math_train_counting_and_probability_481","math_train_number_theory_512","math_train_algebra_778","math_train_intermediate_algebra_462","math_train_intermediate_algebra_591","math_train_prealgebra_277","math_train_number_theory_437","math_train_algebra_961","math_train_intermediate_algebra_1165","math_train_number_theory_375","math_train_algebra_944","math_train_algebra_13","math_train_prealgebra_50","math_train_intermediate_algebra_178","math_train_number_theory_742","math_train_prealgebra_1012","math_train_algebra_579","math_train_precalculus_285","math_train_algebra_935","math_train_counting_and_probability_77","math_train_algebra_107","math_train_precalculus_223","math_train_algebra_289","math_train_prealgebra_790","math_train_algebra_1363","math_train_prealgebra_30","math_train_algebra_1245","math_train_prealgebra_809","math_train_intermediate_algebra_714","math_train_algebra_1577","math_train_intermediate_algebra_1073","math_train_intermediate_algebra_213","math_train_algebra_441","math_train_number_theory_866","math_train_precalculus_603","math_train_number_theory_119","math_train_counting_and_probability_695","math_train_geometry_829","math_train_precalculus_219","math_train_precalculus_16","math_train_number_theory_441","math_train_prealgebra_674","math_train_algebra_835","math_train_geometry_366","math_train_intermediate_algebra_899","math_train_geometry_778","math_train_intermediate_algebra_227","math_train_counting_and_probability_733","math_train_prealgebra_881","math_train_algebra_554","math_train_number_theory_750","math_train_intermediate_algebra_866","math_train_intermediate_algebra_998","math_train_counting_and_probability_602","math_train_prealgebra_691","math_train_counting_and_probability_559","math_train_geometry_810","math_train_prealgebra_1102","math_train_algebra_202","math_train_prealgebra_612","math_train_counting_and_probability_657","math_train_intermediate_algebra_423","math_train_prealgebra_31","math_train_precalculus_72","math_train_counting_and_probability_570","math_train_algebra_368","math_train_counting_and_probability_270","math_train_algebra_1518","math_train_prealgebra_939","math_train_intermediate_algebra_314","math_train_intermediate_algebra_170","math_train_counting_and_probability_604","math_train_algebra_479","math_train_number_theory_265","math_train_intermediate_algebra_131","math_train_intermediate_algebra_588","math_train_counting_and_probability_448","math_train_prealgebra_350","math_train_geometry_741","math_train_counting_and_probability_682","math_train_algebra_1534","math_train_counting_and_probability_344","math_train_prealgebra_924","math_train_prealgebra_101","math_train_number_theory_339","math_train_geometry_621","math_train_intermediate_algebra_1056","math_train_counting_and_probability_315","math_train_number_theory_411","math_train_precalculus_422","math_train_prealgebra_1171","math_train_number_theory_140","math_train_number_theory_669","math_train_counting_and_probability_546","math_train_algebra_1594","math_train_algebra_1554","math_train_algebra_1253","math_train_intermediate_algebra_716","math_train_counting_and_probability_361","math_train_algebra_436"],"n":8,"max_tokens":8192}{ "ok": true, "type": "generate", "model": "both", "files": { "original": "/work/gen_5_original.jsonl", "edited": "/work/gen_5_edited.jsonl" }, "activations": null, "original": { "generations": 1024, "graded": 1024, "accuracy": 0.087890625, "accuracy_by_source": { "math": 0.0879 }, "mean_tokens": 1557, "cut_share": 0.084, "failures": { "wrong_answer": 487, "no_answer_finished": 362, "cut_at_max_tokens": 85 } }, "edited": { "generations": 1024, "graded": 1024, "accuracy": 0.099609375, "accuracy_by_source": { "math": 0.0996 }, "mean_tokens": 1288, "cut_share": 0.0576, "failures": { "wrong_answer": 550, "no_answer_finished": 315, "cut_at_max_tokens": 57 } }, "paired": { "items": 128, "accuracy_difference": 0.0117, "standard_error": 0.009, "samples_wrong_to_right": 46, "samples_right_to_wrong": 34 }, "s": 279.1}holdout_original = load_generation_file("/work/gen_5_original.jsonl")holdout_edited = load_generation_file("/work/gen_5_edited.jsonl")assert set(r["problem_id"] for r in holdout_original) == holdout_setassert not holdout_set & dev_set
holdout_mechanisms = {}for label, rr in [("original",holdout_original), ("edited",holdout_edited)]: summary, _, _ = mechanism_summary(rr) holdout_mechanisms[label] = summary
assert set(edited()) == set(frozen_hashes)for name, expected_hash in frozen_hashes.items(): current = load(name) actual_hash = hashlib.sha256(current.contiguous().numpy().tobytes()).hexdigest() assert actual_hash == expected_hash
n = len(holdout_original)original_correct = sum(r["correct"] for r in holdout_original)edited_correct = sum(r["correct"] for r in holdout_edited)difference_pp = 100 * (edited_correct-original_correct) / nreported_se_pp = 0.90ci95 = [difference_pp-1.96*reported_se_pp, difference_pp+1.96*reported_se_pp]
final_report = { "submission": "Unchanged candidate frozen before HOLDOUT", "edited_tensors": sorted(frozen_hashes), "edited_neurons": 64, "edited_scalar_values": 40960, "operation": "Multiply only the selected down_proj columns by 0.5", "layers": sorted(selected_by_layer), "dev": { "half_suppression_difference_pp": -0.48828125, "half_suppression_reported_se_pp": 1.57, "full_suppression_difference_pp": -4.58984375, "full_suppression_reported_se_pp": 1.70, }, "holdout": { "problems": 128, "answers_per_model": n, "original_correct": original_correct, "edited_correct": edited_correct, "original_accuracy": original_correct/n, "edited_accuracy": edited_correct/n, "difference_pp": difference_pp, "reported_standard_error_pp": reported_se_pp, "approximate_95pct_interval_pp": ci95, "wrong_to_right": 46, "right_to_wrong": 34, "mechanism_diagnostics": holdout_mechanisms, }, "limitations": [ "Positive holdout estimate is not statistically significant at the 95% level.", "Half-strength DEV estimate was slightly negative.", "Full removal harmed accuracy, so selected channels also support useful computation.", "Arithmetic-error associations do not establish a dedicated error-causing circuit.", "Teacher-forced pass 2 was consumed by an input-format mistake and provided no math localization.", "Earlier no_answer_finished counts were over-counted; do not interpret them as true missing-answer counts.", "No MATH-500 evaluation was observed." ],}with open("/work/final_report.json", "w") as f: json.dump(final_report, f, indent=2)with open("/work/notes.md", "a") as f: f.write( "\n## Final HOLDOUT result and submission\n" "- Original: 90/1024 (8.7891%); edited: 102/1024 (9.9609%).\n" "- Paired difference: +1.171875 percentage points; reported SE: 0.90 points.\n" f"- Approximate 95% interval: [{ci95[0]:.2f}, {ci95[1]:.2f}] points.\n" "- Wrong-to-right 46; right-to-wrong 34. Positive but inconclusive.\n" "- Submitted candidate is unchanged from pre-HOLDOUT freeze: " "64 selected MLP down_proj columns in layers 6-17 multiplied by 0.5.\n" "- All saved tensor hashes verified against frozen_candidate.json.\n" "- No HOLDOUT tuning or weight changes after confirmation.\n" "- Experimenter correction: earlier no_answer_finished counts included " "some wrong final answers; those category counts cannot establish an " "answer-completion failure mechanism. Accuracy comparisons unaffected.\n" "- Full-removal harm and weak half-strength results limit the causal " "interpretation; no claim of a proven arithmetic-error circuit.\n" "- Complete outcome and limitations: final_report.json.\n" )
print("HOLDOUT:", original_correct, "->", edited_correct, "correct out of", n)print("Gain: %.2f percentage points; SE %.2f; approximate 95%% interval [%.2f, %.2f]" % (difference_pp, reported_se_pp, ci95[0], ci95[1]))print("Secondary arithmetic diagnostics:", holdout_mechanisms)print("Verified final submission: frozen half-strength edit; 12 tensors, 64 columns.")HOLDOUT: 90 -> 102 correct out of 1024Gain: 1.17 percentage points; SE 0.90; approximate 95% interval [-0.59, 2.94]Secondary arithmetic diagnostics: {'original': {'answers': 1024, 'correct': 90, 'checked_response_share': 0.5712890625, 'response_with_checked_error_share': 0.2021484375, 'error_share_among_checked_responses': 0.35384615384615387, 'checked_false_equalities': 1532, 'checked_valid_progress_equalities': 3516, 'checked_identity_equalities': 1042, 'median_tokens': 817.0, 'cut_responses': 86}, 'edited': {'answers': 1024, 'correct': 102, 'checked_response_share': 0.548828125, 'response_with_checked_error_share': 0.189453125, 'error_share_among_checked_responses': 0.34519572953736655, 'checked_false_equalities': 1481, 'checked_valid_progress_equalities': 2150, 'checked_identity_equalities': 1070, 'median_tokens': 734.0, 'cut_responses': 59}}Verified final submission: frozen half-strength edit; 12 tensors, 64 columns.