TRACE-VLA code snapshot 2026-11-22 11:47 +07: 456 canonical files + SHA256 manifest + sync report
b4396f0 verified Download code/sera_v4/tools/apply_unfreeze_fix1.py from phammminhhieu/trace-vla-code: direct link, hf CLI and curl.
- Browser
- Download file 2.34 kB
-
https://huggingface.co/phammminhhieu/trace-vla-code/resolve/main/code/sera_v4/tools/apply_unfreeze_fix1.py
- Command line
-
hf download hf://phammminhhieu/trace-vla-code/code/sera_v4/tools/apply_unfreeze_fix1.py
-
curl -L -o apply_unfreeze_fix1.py https://huggingface.co/phammminhhieu/trace-vla-code/resolve/main/code/sera_v4/tools/apply_unfreeze_fix1.py
2.34 kB
| #!/usr/bin/env python3 | |
| """UF FIX 1 (2026-11-20): apply_unfreeze_patch.py edited the | |
| encode_observation grad gate in modeling_base.py, but the model | |
| that actually trains is SERAVLAV3Model, which OVERRIDES | |
| encode_observation in modeling_sera_vla_v3.py with its own copy of | |
| the gate (still keyed only on _finetunes_vision). check_uf.py | |
| check [4] caught it: after the step-3000 flip, no gradient reached | |
| the unfrozen vision blocks because the override kept taking the | |
| no-grad tips.encode_image path. | |
| This fix applies the identical gate change to the override: | |
| _vision_grad = _finetunes_vision or _uf_unfrozen, in both the | |
| set_grad_enabled wrapper and the branch choice. With the UF flags | |
| at their defaults (_uf_unfrozen stays False) behaviour is | |
| unchanged for every old run. | |
| Backup: modeling_sera_vla_v3.py.bak-uf fix suffix | |
| .bak-uffix1-20261120. Exact-match, count==1 assert. | |
| """ | |
| import py_compile | |
| import shutil | |
| import sys | |
| from pathlib import Path | |
| SRC = Path.home() / "lerobot/src/lerobot/policies/sera_vla_v3" | |
| BAK_SUFFIX = ".bak-uffix1-20261120" | |
| FNAME = "modeling_sera_vla_v3.py" | |
| OLD = """ with torch.set_grad_enabled(torch.is_grad_enabled() and self.training and self._finetunes_vision): | |
| if self._finetunes_vision: | |
| cls, registers, patches = self.tips.vision_encoder(images.flatten(0, 1)) | |
| """ | |
| NEW = """ _vision_grad = self._finetunes_vision or getattr(self, "_uf_unfrozen", False) | |
| with torch.set_grad_enabled(torch.is_grad_enabled() and self.training and _vision_grad): | |
| if _vision_grad: | |
| cls, registers, patches = self.tips.vision_encoder(images.flatten(0, 1)) | |
| """ | |
| def main() -> int: | |
| path = SRC / FNAME | |
| text = path.read_text() | |
| if NEW in text and OLD not in text: | |
| print(f"{FNAME}: already applied, skipping") | |
| return 0 | |
| count = text.count(OLD) | |
| assert count == 1, f"{FNAME}: anchor found {count} times" | |
| text = text.replace(OLD, NEW) | |
| bak = path.with_name(path.name + BAK_SUFFIX) | |
| if not bak.exists(): | |
| shutil.copy2(path, bak) | |
| print(f"backup: {bak.name}") | |
| path.write_text(text) | |
| py_compile.compile(str(path), doraise=True) | |
| print(f"{FNAME}: UF gate applied to the SERAVLAV3Model override, compiles OK") | |
| print("UF FIX 1 DONE") | |
| return 0 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |