Download examples/quickstart.py from changh95/rdt2-base-p150: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/changh95/rdt2-base-p150/resolve/main/examples/quickstart.py
- Command line
-
hf download hf://changh95/rdt2-base-p150/examples/quickstart.py
-
curl -L -o quickstart.py https://huggingface.co/changh95/rdt2-base-p150/resolve/main/examples/quickstart.py
1.22 kB
| # SPDX-License-Identifier: Apache-2.0 | |
| """Quickstart: one action chunk of RDT2-FM on a Tenstorrent Blackhole p150 from the shipped sample. | |
| pip install -e . # from the repo root, in a tt-metal environment with the patches in patches/ | |
| python examples/quickstart.py | |
| The first run downloads the pinned weights (about 11 GB) into the Hugging Face cache and JIT-compiles the kernels. | |
| """ | |
| import numpy as np | |
| from tt_rdt2 import RDT2FM, load_sample | |
| sample = load_sample() # two 384x384 wrist cameras (left_stereo, right_stereo), the instruction, a zero state | |
| with RDT2FM.from_pretrained() as model: # weights -> device (ETH dispatch) -> every prompt bucket traced and warm | |
| out = model(sample["images"], sample["instruction"], state=sample["state"], seed=0) | |
| print(f"instruction: {sample['instruction']!r} -> bucket {out.prompt_bucket} ({out.num_tokens} tokens)") | |
| print(f"actions {out.actions.shape} (24 steps at 30 Hz; right arm cols 0-9, left arm 10-19)") | |
| np.set_printoptions(precision=4, suppress=True) | |
| print("first step, right arm position (m):", out.actions[0, 0:3], " gripper width (m):", out.actions[0, 9]) | |
| print("timing_ms:", {k: round(v, 1) for k, v in out.timing_ms.items()}) | |