summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--RESIDUAL_MIRROR.md73
-rw-r--r--experiments/analyze_residual_mirror_capture.py153
-rw-r--r--experiments/residual_mirror_capture_screen.py54
4 files changed, 281 insertions, 0 deletions
diff --git a/README.md b/README.md
index b49774c..0a4d9e4 100644
--- a/README.md
+++ b/README.md
@@ -147,6 +147,7 @@ the observed child response and learns only from the local prediction error;
unlike WM, its update is zero for every probe at exact symmetry. The extra
feedback prediction convolution is charged explicitly, and this rule receives
no SDIL novelty credit.
+`RESIDUAL_MIRROR.md` freezes its capture and conditional task gates.
The subsequent V3 mechanism estimates the required A/G matrix statistics
directly by perturbing the vectorizer parameter subspace. It remains
diff --git a/RESIDUAL_MIRROR.md b/RESIDUAL_MIRROR.md
new file mode 100644
index 0000000..312bc35
--- /dev/null
+++ b/RESIDUAL_MIRROR.md
@@ -0,0 +1,73 @@
+# Residual response-mirror baseline protocol
+
+## Status and method boundary
+
+Estimate-then-average WM passed its frozen capture gate but missed the short
+accuracy gate by under one point. Its final feedback/forward cosine plateaued
+near 0.81 in the deepest convolutional group despite frequent local probes.
+The diagnosed issue is stationary estimator noise: a fresh finite-sample W
+estimate is noisy even when Q already equals W.
+
+Residual response mirroring (RRM) is a substantive update-rule change, not a
+new cadence/batch/rate branch of failed WM. For each local Gaussian probe it
+compares the observed forward child response with Q's predicted response and
+updates from their difference. At Q=W, every individual stochastic update is
+zero. The observation and update remain separated; the update never reads a
+forward parameter. RRM is still inherited local predictive weight estimation,
+not SDIL or Harnett-specific novelty.
+
+A mechanics-only synthetic-image pilot was used to bound the mirror-rate grid.
+No CIFAR development-prefix alignment or validation/test endpoint was observed
+before this protocol and its executable selector were committed.
+
+## RRM-0: mechanics gate
+
+The convolutional smoke suite must verify:
+
+- exact-symmetry response-residual fraction below `1e-14` for every probe;
+- exact-symmetry parameter-update RMS below `1e-14`;
+- changing all forward parameters after observations are fixed changes the
+ feedback update by exactly zero;
+- all prior hierarchical and local-gradient checks remain green.
+
+This passes at response-residual fraction `3.08e-17`, update RMS `2.75e-18`,
+and forward-parameter independence error exactly zero.
+
+## RRM-1: frozen-forward capture gate
+
+Copy WM-1 exactly: seed-0 ResNet-20, random feedback scale 1, frozen 10k
+development prefix, 64-example exact-gradient audit, convolutional mirror batch
+1, Gaussian noise standard deviation 1, mirror seed 3000, 20 observations, and
+no forward/readout/BatchNorm update. Record fixed HFA and cross
+`eta_M in {0.03,0.1,0.3}`. Select early alignment, then all-layer alignment,
+then lower rate.
+
+All four records must be finite, and selected RRM must reach early alignment
+0.65, all-layer alignment 0.70, mean feedback/forward cosine 0.93, norm ratios
+in `[0.5,1.5]`, and zero task-loss queries. No extra observation, rate, batch,
+noise, cadence, or layer-specific setting follows a failure.
+
+## RRM-2: short accuracy gate
+
+Only an RRM-1 pass opens two 10k-example, 20-epoch ResNet-20 validation jobs.
+Copy WM-2 exactly: hidden LR `{0.03,0.1}`, output LR 0.1, batch 128, cosine
+decay, no warmup, momentum 0.9, weight decay `1e-4`, 20 mirror warmup
+observations, then one batch-1 observation every 16 task updates. The extra Q
+response-prediction convolution is charged explicitly.
+
+Select accuracy, then total MACs/rate. Both records must be finite; selected
+RRM must reach 65%, lie within 10 points of matched BP 74.94%, retain early
+alignment 0.50, use zero task-loss queries for feedback learning, and cost no
+more than 1.15x matched BP MACs. Failure closes RRM.
+
+## RRM-3: conditional full baseline
+
+Only an RRM-2 pass opens one 200-epoch seed-0 validation run, copying selected
+settings and the A1 epoch-100/150 step drops on all 45,000 development-training
+examples. It must be finite, reach 88%, retain early alignment 0.50, and cost
+at most 1.15x BP. It does not authorize test access. A pass instead freezes the
+same scalable substrate for a raw-versus-innovation mixed-traffic experiment.
+
+RRM is a baseline throughout. RRM-1/RRM-2 cannot raise the reviewer score;
+only a later load-bearing innovation result on top of it can do so.
+
diff --git a/experiments/analyze_residual_mirror_capture.py b/experiments/analyze_residual_mirror_capture.py
new file mode 100644
index 0000000..361aba8
--- /dev/null
+++ b/experiments/analyze_residual_mirror_capture.py
@@ -0,0 +1,153 @@
+#!/usr/bin/env python3
+"""Audit and gate residual-response mirror causal capture."""
+import argparse
+import glob
+import json
+import math
+import os
+
+
+SPLIT_HASH = "8328b206a97c420e49e54e3eca4abe3274c4756b084355784ea3fb8059e4515b"
+RATES = (0.03, 0.1, 0.3)
+
+
+def load(path):
+ with open(path) as handle:
+ record = json.load(handle)
+ args = record["args"]
+ mode = args.get("mode")
+ if mode not in ("hfa", "rrm"):
+ raise ValueError(f"{path}: unexpected method")
+ expected = {
+ "depth": 20, "width": 16, "seed": 0, "loader_seed": 0,
+ "epochs": 0, "train_limit": 10000, "val_examples": 5000,
+ "split_seed": 2027, "eval_split": "validation", "eval_every": 0,
+ "normalization": "batchnorm", "a_scale": 1.0,
+ "alignment_probe": 64, "mirror_batch_size": 1,
+ "mirror_noise_std": 1.0, "mirror_seed": 3000,
+ }
+ for key, value in expected.items():
+ if args.get(key) != value:
+ raise ValueError(f"{path}: {key} drift")
+ expected_steps = 0 if mode == "hfa" else 20
+ if args.get("mirror_warmup_steps") != expected_steps:
+ raise ValueError(f"{path}: mirror warmup drift")
+ if mode == "rrm" and float(args["mirror_eta"]) not in RATES:
+ raise ValueError(f"{path}: unregistered mirror rate")
+ if record["provenance"]["git_tracked_dirty"]:
+ raise ValueError(f"tracked-dirty result: {path}")
+ if record["split"]["validation_index_sha256"] != SPLIT_HASH:
+ raise ValueError(f"split drift: {path}")
+ if record["evaluation_protocol"]["test_evaluations"]:
+ raise ValueError(f"test touched: {path}")
+ expected_space = (None if mode == "hfa"
+ else "local_parent_child_response_residual")
+ if record.get("calibration_metric_space") != expected_space:
+ raise ValueError(f"metric-space drift: {path}")
+ diagnostics = record["diagnostics"]
+ values = diagnostics["teaching_negative_gradient_cosine"]
+ early_count = max(1, len(values) // 3)
+ norm_ratios = diagnostics["feedback_forward_norm_ratio"]
+ feedback_cosines = diagnostics["feedback_forward_cosine"]
+ metrics = {
+ "early_third_alignment": sum(values[:early_count]) / early_count,
+ "all_layer_alignment": sum(values) / len(values),
+ "mean_feedback_forward_cosine": (
+ sum(feedback_cosines) / len(feedback_cosines)),
+ "min_feedback_forward_norm_ratio": min(norm_ratios),
+ "max_feedback_forward_norm_ratio": max(norm_ratios),
+ }
+ if mode == "rrm":
+ warmup = record.get("mirror_warmup", {}).get("mean")
+ if warmup is None:
+ raise ValueError(f"missing RRM aggregate: {path}")
+ metrics.update({
+ "mean_mirror_update_rms": warmup["mirror_update_rms"],
+ "mean_response_residual_rms": (
+ warmup["mirror_response_residual_rms"]),
+ "mean_response_residual_fraction": (
+ warmup["mirror_response_residual_fraction"]),
+ })
+ finite = (bool(record["final"]["finite"])
+ and all(math.isfinite(value) for value in metrics.values()))
+ return {
+ "path": path, "mode": mode,
+ "mirror_eta": (None if mode == "hfa" else float(args["mirror_eta"])),
+ "metrics": metrics, "finite": finite,
+ "logical_batch_loss_queries": int(
+ record["work"]["logical_batch_loss_queries"]),
+ "mirror_events": int(record["counters"]["mirror_events"]),
+ "total_macs": int(record["work"]["total_macs_estimate"]),
+ "source_commit": record["provenance"]["git_commit"],
+ }
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--input", default="results/residual_mirror_capture")
+ parser.add_argument(
+ "--out", default="results/residual_mirror_capture_gate.json")
+ args = parser.parse_args()
+ rows = [load(path) for path in sorted(
+ glob.glob(os.path.join(args.input, "*.json")))]
+ references = [row for row in rows if row["mode"] == "hfa"]
+ candidates = [row for row in rows if row["mode"] == "rrm"]
+ if len(references) != 1 or len(candidates) != len(RATES):
+ raise ValueError("incomplete RRM-1 method grid")
+ if {row["mirror_eta"] for row in candidates} != set(RATES):
+ raise ValueError("incomplete RRM-1 rate grid")
+ if len({row["source_commit"] for row in rows}) != 1:
+ raise ValueError("RRM-1 source commits differ")
+ eligible = [row for row in candidates if row["finite"]]
+ eligible.sort(key=lambda row: (
+ -row["metrics"]["early_third_alignment"],
+ -row["metrics"]["all_layer_alignment"], row["mirror_eta"]))
+ selected = eligible[0] if eligible else None
+ checks = {
+ "all_four_records_finite": all(row["finite"] for row in rows),
+ "candidate_selected": selected is not None,
+ }
+ if selected is None:
+ checks.update({
+ "early_third_at_least_0.65": False,
+ "all_layer_at_least_0.70": False,
+ "mean_feedback_forward_cosine_at_least_0.93": False,
+ "feedback_norm_ratios_in_0.5_to_1.5": False,
+ "zero_task_loss_queries": False,
+ })
+ else:
+ metrics = selected["metrics"]
+ checks.update({
+ "early_third_at_least_0.65": (
+ metrics["early_third_alignment"] >= 0.65),
+ "all_layer_at_least_0.70": (
+ metrics["all_layer_alignment"] >= 0.70),
+ "mean_feedback_forward_cosine_at_least_0.93": (
+ metrics["mean_feedback_forward_cosine"] >= 0.93),
+ "feedback_norm_ratios_in_0.5_to_1.5": (
+ metrics["min_feedback_forward_norm_ratio"] >= 0.5
+ and metrics["max_feedback_forward_norm_ratio"] <= 1.5),
+ "zero_task_loss_queries": all(
+ row["logical_batch_loss_queries"] == 0 for row in rows),
+ })
+ output = {
+ "protocol": "residual_response_mirror_capture_v1",
+ "status": "passed" if all(checks.values()) else "failed",
+ "checks": checks, "rows": rows, "matched_fixed_hfa": references[0],
+ "selected_rrm": selected, "confirmation_test_seeds_touched": False,
+ "review_score_before": 5, "review_score_after": 5,
+ "score_change_rule": "inherited baseline capture 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,
+ "reference": references[0], "selected_rrm": selected,
+ }, indent=2))
+
+
+if __name__ == "__main__":
+ main()
+
diff --git a/experiments/residual_mirror_capture_screen.py b/experiments/residual_mirror_capture_screen.py
new file mode 100644
index 0000000..223a1db
--- /dev/null
+++ b/experiments/residual_mirror_capture_screen.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python3
+"""Run a shard of the frozen residual-response mirror capture screen."""
+import argparse
+import os
+import subprocess
+import sys
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--device", default="cuda")
+ parser.add_argument("--shard_index", type=int, default=0)
+ parser.add_argument("--num_shards", type=int, default=1)
+ parser.add_argument("--dry_run", action="store_true")
+ args = parser.parse_args()
+ if not 0 <= args.shard_index < args.num_shards:
+ raise ValueError("invalid shard index")
+ common = [
+ sys.executable, "experiments/conv_run.py", "--device", args.device,
+ "--depth", "20", "--width", "16", "--seed", "0",
+ "--loader_seed", "0", "--batch_size", "128", "--epochs", "0",
+ "--train_limit", "10000", "--val_examples", "5000",
+ "--split_seed", "2027", "--eval_split", "validation",
+ "--eval_every", "0", "--augment_train", "1", "--lr", "0.1",
+ "--output_lr", "0.1", "--lr_schedule", "constant",
+ "--warmup_epochs", "0", "--momentum", "0.9",
+ "--weight_decay", "1e-4", "--normalization", "batchnorm",
+ "--a_scale", "1", "--alignment_probe", "64",
+ "--mirror_batch_size", "1", "--mirror_noise_std", "1",
+ "--mirror_seed", "3000",
+ ]
+ jobs = [("fixed_hfa", common + [
+ "--mode", "hfa", "--out",
+ "results/residual_mirror_capture/fixed_hfa.json",
+ ])]
+ for rate in (0.03, 0.1, 0.3):
+ tag = f"rrm_etaM{rate}"
+ jobs.append((tag, common + [
+ "--mode", "rrm", "--mirror_eta", str(rate),
+ "--mirror_warmup_steps", "20", "--out",
+ f"results/residual_mirror_capture/{tag}.json",
+ ]))
+ os.makedirs("results/residual_mirror_capture", exist_ok=True)
+ for index, (tag, command) in enumerate(jobs):
+ if index % args.num_shards != args.shard_index:
+ continue
+ print(tag, " ".join(command), flush=True)
+ if not args.dry_run:
+ subprocess.run(command, check=True)
+
+
+if __name__ == "__main__":
+ main()
+