fix: apply finetuning_mods (APE + per-axis RoPE) before load for PNS ft ckpt
Browse files- rollout_eval.py +16 -1
rollout_eval.py
CHANGED
|
@@ -116,7 +116,22 @@ def build(config_path, ckpt_path, dataset_name, well_base_path, jitter, device,
|
|
| 116 |
fmap = dm.train_dataset.field_to_index_map
|
| 117 |
n_states = max(fmap.values()) + 1
|
| 118 |
model = instantiate(config.model, n_states=n_states)
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
model.to(device).eval()
|
| 121 |
formatter = ChannelsFirstWithTimeFormatter()
|
| 122 |
revin = instantiate(config.trainer.revin)()
|
|
|
|
| 116 |
fmap = dm.train_dataset.field_to_index_map
|
| 117 |
n_states = max(fmap.values()) + 1
|
| 118 |
model = instantiate(config.model, n_states=n_states)
|
| 119 |
+
# Faithful fine-tune arch (train.py:136-138): finetuning_mods are applied to
|
| 120 |
+
# the model AFTER instantiation, BEFORE loading weights. Base ckpt has
|
| 121 |
+
# finetuning_mods={} (no-op, loads clean). The PNS ft ckpt adds `ape` +
|
| 122 |
+
# per-axis learnable RoPE (`...rotary_emb.freqs.0/.1/.2`), so without this the
|
| 123 |
+
# released ft state_dict mismatches the config-instantiated model.
|
| 124 |
+
fmods = config.get("finetuning_mods", None) or {}
|
| 125 |
+
if len(fmods) and hasattr(model, "add_ft_options"):
|
| 126 |
+
print(f">>> applying finetuning_mods: {OmegaConf.to_container(fmods)}", flush=True)
|
| 127 |
+
model.add_ft_options(fmods)
|
| 128 |
+
try:
|
| 129 |
+
model.load_state_dict(checkpoint, strict=True)
|
| 130 |
+
except RuntimeError:
|
| 131 |
+
incompat = model.load_state_dict(checkpoint, strict=False)
|
| 132 |
+
print(f">>> load_state_dict strict FAILED; missing={list(incompat.missing_keys)[:12]} "
|
| 133 |
+
f"unexpected={list(incompat.unexpected_keys)[:12]}", flush=True)
|
| 134 |
+
raise
|
| 135 |
model.to(device).eval()
|
| 136 |
formatter = ChannelsFirstWithTimeFormatter()
|
| 137 |
revin = instantiate(config.trainer.revin)()
|