Download code/tt_rdt2/tests/conftest.py from changh95/rdt2-base-p150: direct link, hf CLI and curl.
- Browser
- Download file 3.35 kB
-
https://huggingface.co/changh95/rdt2-base-p150/resolve/main/code/tt_rdt2/tests/conftest.py
- Command line
-
hf download hf://changh95/rdt2-base-p150/code/tt_rdt2/tests/conftest.py
-
curl -L -o conftest.py https://huggingface.co/changh95/rdt2-base-p150/resolve/main/code/tt_rdt2/tests/conftest.py
3.35 kB
| # SPDX-License-Identifier: Apache-2.0 | |
| """Host-test fixtures of tt_rdt2 (no device). | |
| Markers: ``golden`` needs the golden dumps (``RDT2_GOLDEN_DIR``, default assets/rdt2/golden); ``weights`` needs the | |
| pinned checkpoints (``RDT2_VLM_DIR`` / ``RDT2_EXPERT_DIR`` / ...); ``slow`` runs the 7B VLM prefix on CPU (minutes). | |
| Missing data skips, never fails. Run: ``TT_VISIBLE_DEVICES=none python -m pytest -q code/tt_rdt2/tests/test_reference_host.py`` | |
| (add ``-m "not slow"`` for the fast subset). | |
| """ | |
| from __future__ import annotations | |
| import os | |
| import sys | |
| import pytest | |
| _CODE = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| if _CODE not in sys.path: # make ``tt_rdt2`` importable when pytest is started from anywhere | |
| sys.path.insert(0, _CODE) | |
| def pytest_configure(config): | |
| for m in ("golden: needs the RDT2 golden dumps", "weights: needs the pinned RDT2 checkpoints", | |
| "slow: runs the Qwen2.5-VL vision tower / LM prefix on CPU (minutes)"): | |
| config.addinivalue_line("markers", m) | |
| def dirs(): | |
| from tt_rdt2.reference.config import DEFAULT_DIRS | |
| return DEFAULT_DIRS | |
| def golden(dirs): | |
| from tt_rdt2.reference.golden import GoldenSet | |
| if not os.path.exists(os.path.join(dirs["golden"], "fp32", "manifest.json")): | |
| pytest.skip("golden dumps not found (RDT2_GOLDEN_DIR)") | |
| return GoldenSet("fp32") | |
| def golden_bf16(dirs): | |
| from tt_rdt2.reference.golden import GoldenSet | |
| if not os.path.exists(os.path.join(dirs["golden"], "bf16", "manifest.json")): | |
| pytest.skip("bf16 golden dumps not found") | |
| return GoldenSet("bf16") | |
| def golden_ext(dirs): | |
| """Ext golden (official fp32): large states (10 * N(0, 1)) and prompts in the 448 / 512 buckets.""" | |
| from tt_rdt2.reference.golden import GoldenSet | |
| root = os.path.join(dirs["golden"], "ext") | |
| if not os.path.exists(os.path.join(root, "fp32", "manifest.json")): | |
| pytest.skip("ext golden dumps not found (RDT2_GOLDEN_DIR/ext)") | |
| return GoldenSet("fp32", root=root) | |
| def golden_ext_bf16(dirs): | |
| """The same ext cases run by the official code in its own bf16 dtype: the per-case noise floor.""" | |
| from tt_rdt2.reference.golden import GoldenSet | |
| root = os.path.join(dirs["golden"], "ext") | |
| if not os.path.exists(os.path.join(root, "bf16", "manifest.json")): | |
| pytest.skip("ext bf16 golden dumps not found") | |
| return GoldenSet("bf16", root=root) | |
| def _need(path): | |
| if not os.path.exists(path): | |
| pytest.skip(f"missing {path}") | |
| def expert(dirs): | |
| from tt_rdt2.reference.expert import ActionExpert | |
| from tt_rdt2.reference.weights import load_action_normalizer, load_expert_state_dict | |
| _need(os.path.join(dirs["expert"], "pytorch_model.bin")) | |
| ex = ActionExpert(load_expert_state_dict()) | |
| ex.norm = load_action_normalizer() | |
| return ex | |
| def reference(dirs): | |
| import torch | |
| from tt_rdt2.reference.pipeline import RDT2FMReference | |
| _need(os.path.join(dirs["vlm"], "model.safetensors.index.json")) | |
| torch.set_num_threads(int(os.environ.get("RDT2_TEST_THREADS", "6"))) | |
| return RDT2FMReference() | |