Factorial channel ablation: --physics-mode (gamma_only/headspace_only) in train.py + evaluator matching + factorial job script
Browse files
scripts/evaluate_drydown_physics.py
CHANGED
|
@@ -74,6 +74,8 @@ def main() -> int:
|
|
| 74 |
ap.add_argument("--split", choices=["molecule", "formula"], default="formula")
|
| 75 |
ap.add_argument("--arm-label", default=None)
|
| 76 |
ap.add_argument("--use-gamma", action="store_true")
|
|
|
|
|
|
|
| 77 |
ap.add_argument("--max-eval", type=int, default=400)
|
| 78 |
ap.add_argument("--output", required=True)
|
| 79 |
args = ap.parse_args()
|
|
@@ -127,7 +129,14 @@ def main() -> int:
|
|
| 127 |
# target_obj is already the (3,138) pyramid for this dataset
|
| 128 |
target = item["target_obj"].clamp(0.0, 1.0).to(device) # (3,138)
|
| 129 |
|
| 130 |
-
# physics ON
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
lat_on = model(tokens, physics)
|
| 132 |
pyr_on = heads(lat_on, physics, mask)["objective"][0] # (3,138)
|
| 133 |
# physics OFF (zeroed)
|
|
@@ -145,7 +154,7 @@ def main() -> int:
|
|
| 145 |
cos_on /= max(used, 1); cos_off /= max(used, 1)
|
| 146 |
result = {
|
| 147 |
"arm": args.arm_label or Path(args.checkpoint).stem,
|
| 148 |
-
"use_gamma": bool(args.use_gamma), "seed": args.seed, "model_dims": dims,
|
| 149 |
"task": "3-tier descriptor pyramid (top/mid/base); physics-on vs physics-off inference ablation",
|
| 150 |
"n_eval": used,
|
| 151 |
"bce_physics_on": float(np.mean(bce_on)),
|
|
|
|
| 74 |
ap.add_argument("--split", choices=["molecule", "formula"], default="formula")
|
| 75 |
ap.add_argument("--arm-label", default=None)
|
| 76 |
ap.add_argument("--use-gamma", action="store_true")
|
| 77 |
+
ap.add_argument("--physics-mode", choices=["full", "off", "gamma_only", "headspace_only"], default="full",
|
| 78 |
+
help="Match the arm's training conditioning: gamma_only zeroes channels 0-1 of the 'on' tensor, headspace_only zeroes channel 2, off zeroes all. Ensures each factorial arm is evaluated with the same masked physics it was trained on.")
|
| 79 |
ap.add_argument("--max-eval", type=int, default=400)
|
| 80 |
ap.add_argument("--output", required=True)
|
| 81 |
args = ap.parse_args()
|
|
|
|
| 129 |
# target_obj is already the (3,138) pyramid for this dataset
|
| 130 |
target = item["target_obj"].clamp(0.0, 1.0).to(device) # (3,138)
|
| 131 |
|
| 132 |
+
# physics ON -- with the arm's training conditioning (factorial modes
|
| 133 |
+
# mask channels so eval matches what the model saw during training)
|
| 134 |
+
if args.physics_mode == "off":
|
| 135 |
+
physics = torch.zeros_like(physics)
|
| 136 |
+
elif args.physics_mode == "gamma_only":
|
| 137 |
+
physics = physics.clone(); physics[..., 0] = 0.0; physics[..., 1] = 0.0
|
| 138 |
+
elif args.physics_mode == "headspace_only":
|
| 139 |
+
physics = physics.clone(); physics[..., 2] = 0.0
|
| 140 |
lat_on = model(tokens, physics)
|
| 141 |
pyr_on = heads(lat_on, physics, mask)["objective"][0] # (3,138)
|
| 142 |
# physics OFF (zeroed)
|
|
|
|
| 154 |
cos_on /= max(used, 1); cos_off /= max(used, 1)
|
| 155 |
result = {
|
| 156 |
"arm": args.arm_label or Path(args.checkpoint).stem,
|
| 157 |
+
"use_gamma": bool(args.use_gamma), "physics_mode": args.physics_mode, "seed": args.seed, "model_dims": dims,
|
| 158 |
"task": "3-tier descriptor pyramid (top/mid/base); physics-on vs physics-off inference ablation",
|
| 159 |
"n_eval": used,
|
| 160 |
"bce_physics_on": float(np.mean(bce_on)),
|