File size: 1,970 Bytes
1c78d11 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | """gen_q#274 TD-MPC2 reproduction check -- upstream's own evaluate.py, run VERBATIM via runpy,
with only `install_safe_to()` applied first.
Why the shim exists (measured, status/nb/td_repro_eval.txt, LSF 1877000 slot1):
TDMPC2.__init__ does `WorldModel(cfg).to(self.device)`; `WorldModel.init()` leaves vmap
PLACEHOLDER parameters on the meta device inside `_detach_Qs` / `_target_Qs`, and this torch
refuses to move:
NotImplementedError: Cannot copy out of meta tensor; no data!
That is a torch-version incompatibility in the vendored checkout, not a property of the method.
`td_corpus.install_safe_to` is the same patch our own trainer already runs under, so the
reproduction is checked through exactly the code path our columns use.
Nothing in code/tdmpc2 is edited; the checkout stays clean (the runner re-asserts that).
"""
from __future__ import annotations
import runpy, sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent))
from td_corpus import TD_SRC, install_safe_to # noqa: E402
from td_repro_compat import install_api_conversion_compat # noqa: E402
if __name__ == "__main__":
sys.path.insert(0, str(TD_SRC))
install_safe_to()
# second version-drift shim: tensordict 0.14.2 no longer emits the `__batch_size` / `__device`
# metadata entries that upstream's api_model_conversion copies out of the LIVE model when it
# upgrades a pre-torch.compile checkpoint. See code/tdmpc2_rise/td_repro_compat.py -- weights
# are untouched, and what was skipped is printed into the reproduction log.
install_api_conversion_compat()
from common.world_model import WorldModel
assert getattr(WorldModel, "_rr_safe_to", False), "safe .to() did not install"
print(f"[td_repro_eval] safe WorldModel.to installed; running {TD_SRC/'evaluate.py'} verbatim",
flush=True)
sys.argv = ["evaluate.py"] + sys.argv[1:]
runpy.run_path(str(TD_SRC / "evaluate.py"), run_name="__main__")
|