Upload src/pino/train.py with huggingface_hub
Browse files- src/pino/train.py +15 -0
src/pino/train.py
CHANGED
|
@@ -40,6 +40,10 @@ SMOKE_TEST_CONFIG = {
|
|
| 40 |
"checkpoint_name": "pimt_smoke_test.pt",
|
| 41 |
}
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
def pad_trajectory_collate(batch: list[dict[str, Any]]) -> dict[str, Any]:
|
| 44 |
"""
|
| 45 |
Collate variable-length formulations into a single padded batch.
|
|
@@ -88,6 +92,13 @@ def pad_trajectory_collate(batch: list[dict[str, Any]]) -> dict[str, Any]:
|
|
| 88 |
# Objective Head treats them as zero-contribution even without the mask.
|
| 89 |
physics[..., 1] = physics[..., 1].masked_fill(src_key_padding_mask.unsqueeze(1), -6.0)
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
return {
|
| 92 |
"tokens": tokens,
|
| 93 |
"physics": physics,
|
|
@@ -277,8 +288,12 @@ def main():
|
|
| 277 |
parser.add_argument("--smoke-test", action="store_true", help="Run lightweight CPU smoke test")
|
| 278 |
parser.add_argument("--use-gamma", action="store_true", help="Add the UNIFAC blend-interaction (gamma) 3rd physics channel; requires a gamma-augmented dataset (physics_gamma field)")
|
| 279 |
parser.add_argument("--split-strategy", choices=["molecule", "formula"], default="molecule", help="molecule = strict molecule-disjoint holdout (default, used for frozen-task headline results); formula = random formula-level holdout (E1 physics-gamma substantivity experiment; discloses molecule leakage for measured-Poucher eval power)")
|
|
|
|
| 280 |
args = parser.parse_args()
|
| 281 |
|
|
|
|
|
|
|
|
|
|
| 282 |
logging.basicConfig(
|
| 283 |
level=logging.INFO,
|
| 284 |
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
|
|
|
|
| 40 |
"checkpoint_name": "pimt_smoke_test.pt",
|
| 41 |
}
|
| 42 |
|
| 43 |
+
# Idea3 physics-off ablation: when True, pad_trajectory_collate zeroes the
|
| 44 |
+
# physics tensor for every batch (train + val). Set from --physics-off-train.
|
| 45 |
+
_PHYSICS_OFF_TRAIN = False
|
| 46 |
+
|
| 47 |
def pad_trajectory_collate(batch: list[dict[str, Any]]) -> dict[str, Any]:
|
| 48 |
"""
|
| 49 |
Collate variable-length formulations into a single padded batch.
|
|
|
|
| 92 |
# Objective Head treats them as zero-contribution even without the mask.
|
| 93 |
physics[..., 1] = physics[..., 1].masked_fill(src_key_padding_mask.unsqueeze(1), -6.0)
|
| 94 |
|
| 95 |
+
# Idea3 physics-off ablation arm: zero the entire physics state so the FiLM
|
| 96 |
+
# block and physics-informed heads receive no physics signal during BOTH
|
| 97 |
+
# training and validation. This is a fair trained baseline (not an
|
| 98 |
+
# inference-time shock), isolating the physics channel's contribution.
|
| 99 |
+
if _PHYSICS_OFF_TRAIN:
|
| 100 |
+
physics = torch.zeros_like(physics)
|
| 101 |
+
|
| 102 |
return {
|
| 103 |
"tokens": tokens,
|
| 104 |
"physics": physics,
|
|
|
|
| 288 |
parser.add_argument("--smoke-test", action="store_true", help="Run lightweight CPU smoke test")
|
| 289 |
parser.add_argument("--use-gamma", action="store_true", help="Add the UNIFAC blend-interaction (gamma) 3rd physics channel; requires a gamma-augmented dataset (physics_gamma field)")
|
| 290 |
parser.add_argument("--split-strategy", choices=["molecule", "formula"], default="molecule", help="molecule = strict molecule-disjoint holdout (default, used for frozen-task headline results); formula = random formula-level holdout (E1 physics-gamma substantivity experiment; discloses molecule leakage for measured-Poucher eval power)")
|
| 291 |
+
parser.add_argument("--physics-off-train", action="store_true", help="Idea3 ablation: zero the physics tensor for every batch (train+val) so the model is a fair no-physics baseline")
|
| 292 |
args = parser.parse_args()
|
| 293 |
|
| 294 |
+
global _PHYSICS_OFF_TRAIN
|
| 295 |
+
_PHYSICS_OFF_TRAIN = bool(getattr(args, "physics_off_train", False))
|
| 296 |
+
|
| 297 |
logging.basicConfig(
|
| 298 |
level=logging.INFO,
|
| 299 |
format="%(asctime)s %(levelname)s %(name)s: %(message)s",
|