summaryrefslogtreecommitdiff
path: root/experiments/contrastive_bias_smoke.py
diff options
context:
space:
mode:
Diffstat (limited to 'experiments/contrastive_bias_smoke.py')
-rw-r--r--experiments/contrastive_bias_smoke.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/experiments/contrastive_bias_smoke.py b/experiments/contrastive_bias_smoke.py
new file mode 100644
index 0000000..026eb01
--- /dev/null
+++ b/experiments/contrastive_bias_smoke.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python3
+"""Static smoke checks for the frozen B1 registry and author patch."""
+import json
+from pathlib import Path
+import sys
+
+
+ROOT = Path(__file__).resolve().parents[1]
+sys.path.insert(0, str(ROOT / "experiments"))
+from contrastive_bias_b1 import BIAS_PATCH, bias_cells, jobs, registry_sha256
+
+
+def main():
+ rows = jobs("/frozen/author/python")
+ cells = bias_cells()
+ assert len(rows) == len(cells) == 17
+ assert sum(row["kind"] == "common" for row in rows) == 1
+ assert sum(row["kind"] == "fixed" for row in rows) == 6
+ assert sum(row["kind"] == "activity" for row in rows) == 9
+ assert sum(row["rule"] == "innovation" for row in rows) == 5
+ for row in rows:
+ command = row["command"]
+ assert command[0] == "/frozen/author/python"
+ assert command[command.index("--seeds") + 1] == "1988"
+ assert command[command.index("--test-policy") + 1] == "none"
+ assert command[command.index("--num-epochs") + 1] == "20"
+ assert command[command.index("--model") + 1] == "miniCNN"
+ if row["rule"] == "none":
+ assert "--dp-bias-rule" not in command
+ else:
+ assert command[command.index("--dp-bias-rule") + 1] == row["rule"]
+ patch = BIAS_PATCH.read_text(encoding="utf-8")
+ for token in (
+ "create_dp_bias_auxiliary", "dp_bias_differences",
+ "train_dp_bias_epoch", "instruction_observations_for_predictor",
+ ):
+ assert token in patch
+ print(json.dumps({
+ "status": "passed", "num_cells": len(rows),
+ "registry_sha256": registry_sha256(rows),
+ }, indent=2, sort_keys=True))
+
+
+if __name__ == "__main__":
+ main()