Download code_src/tdmpc2_rise/td_repro_eval.py from rli14/rsm_rise_code: direct link, hf CLI and curl.
- Browser
- Download file 1.97 kB
-
https://huggingface.co/rli14/rsm_rise_code/resolve/main/code_src/tdmpc2_rise/td_repro_eval.py
- Command line
-
hf download hf://rli14/rsm_rise_code/code_src/tdmpc2_rise/td_repro_eval.py
-
curl -L -o td_repro_eval.py https://huggingface.co/rli14/rsm_rise_code/resolve/main/code_src/tdmpc2_rise/td_repro_eval.py
1.97 kB
| """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__") | |