From 640522076c770d0746dc58dde868586ace568752 Mon Sep 17 00:00:00 2001 From: YurenHao0426 Date: Thu, 6 Aug 2026 14:32:26 -0500 Subject: experiment: freeze no-KP causal capture runner --- experiments/analyze_oral_a_v5_calibration.py | 102 +++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 experiments/analyze_oral_a_v5_calibration.py (limited to 'experiments/analyze_oral_a_v5_calibration.py') diff --git a/experiments/analyze_oral_a_v5_calibration.py b/experiments/analyze_oral_a_v5_calibration.py new file mode 100644 index 0000000..2844743 --- /dev/null +++ b/experiments/analyze_oral_a_v5_calibration.py @@ -0,0 +1,102 @@ +#!/usr/bin/env python3 +"""Validate and gate the frozen no-KP layerwise causal-bootstrap screen.""" +import argparse +import json +import math +import os + + +SPLIT_HASH = "8328b206a97c420e49e54e3eca4abe3274c4756b084355784ea3fb8059e4515b" + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument( + "--input", default="results/oral_a_v5_calibration/result.json") + parser.add_argument( + "--out", default="results/oral_a_v5_calibration_gate.json") + args = parser.parse_args() + with open(args.input) as handle: + record = json.load(handle) + if record.get("protocol") != "oral_a_v5_layerwise_causal_bootstrap_capture_v1": + raise ValueError("unexpected V5 protocol") + expected = { + "depth": 20, "width": 16, "seed": 0, "loader_seed": 0, + "batch_size": 128, "train_limit": 10000, + "val_examples": 5000, "split_seed": 2027, + "normalization": "batchnorm", "residual_scale": 1.0, + "feedback_scale": 1.0, "sigma": 0.01, "eta_A": 0.1, + "perturb_seed": 5000, "sweeps": 20, "alignment_probe": 64, + "calibration_augmentation": False, + } + if record.get("settings") != expected: + raise ValueError("V5 settings drift") + if record["provenance"]["git_tracked_dirty"]: + raise ValueError("V5 result came from a tracked-dirty tree") + if record["split"]["validation_index_sha256"] != SPLIT_HASH: + raise ValueError("V5 split drift") + if record["test_examples_touched"] or record["validation_endpoints_observed"]: + raise ValueError("V5 touched a held-out endpoint") + work = record["work"] + audit = record["method_audit"] + fixed = record["fixed_hfa"] + learned = record["learned_lcb"] + finite_metrics = [ + fixed["early_third_alignment"], fixed["all_layer_alignment"], + learned["early_third_alignment"], learned["all_layer_alignment"], + learned["min_feedback_forward_norm_ratio"], + learned["max_feedback_forward_norm_ratio"], + ] + checks = { + "finite": bool(record["finite"]) + and all(math.isfinite(value) for value in finite_metrics), + "exactly_380_edge_events": work["edge_events"] == 380, + "exactly_760_batch_loss_queries": ( + work["logical_batch_loss_queries"] == 760), + "exactly_48640_per_example_observations": ( + work["per_example_causal_observations"] == 48640), + "forward_state_bitwise_fixed": ( + audit["forward_state_max_absolute_difference"] == 0.0), + "zero_forward_weight_reads_in_update": ( + audit["forward_weight_reads_in_feedback_update"] == 0), + "zero_reverse_mode_learning_operations": ( + audit["reverse_mode_learning_operations"] == 0), + "early_third_at_least_0.10": ( + learned["early_third_alignment"] >= 0.10), + "all_layer_at_least_0.20": ( + learned["all_layer_alignment"] >= 0.20), + "early_gain_over_fixed_hfa_at_least_0.08": ( + learned["early_third_alignment"] + - fixed["early_third_alignment"] >= 0.08), + "feedback_norm_ratios_in_0.1_to_3": ( + learned["min_feedback_forward_norm_ratio"] >= 0.1 + and learned["max_feedback_forward_norm_ratio"] <= 3.0), + } + output = { + "protocol": "oral_a_v5_layerwise_causal_bootstrap_gate_v1", + "status": "passed" if all(checks.values()) else "failed", + "checks": checks, + "fixed_hfa": fixed, + "learned_lcb": learned, + "work": work, + "source_commit": record["provenance"]["git_commit"], + "source_result": args.input, + "conditional_short_task_gate_open": all(checks.values()), + "confirmation_test_seeds_touched": False, + "review_score_before": 5, + "review_score_after": 5, + "score_change_rule": "causal capture alone cannot raise score", + } + os.makedirs(os.path.dirname(os.path.abspath(args.out)), exist_ok=True) + with open(args.out, "w") as handle: + json.dump(output, handle, indent=2, sort_keys=True) + handle.write("\n") + print(json.dumps({ + "status": output["status"], "checks": checks, + "fixed_hfa": fixed, "learned_lcb": learned, + }, indent=2)) + + +if __name__ == "__main__": + main() + -- cgit v1.2.3