physicalai-train-benchmarking-a-policy
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBenchmarking a Studio Policy
Studio策略的基准测试
Benchmarking evaluates a trained policy by rolling it out in a gym and scoring success. Benchmark classes live in (, , ); results types in (, ); rollout logic in (). The library supports both direct Python API use and the CLI wrapper ().
library/src/physicalai/benchmark/gyms/benchmark.pyBenchmarkPushTBenchmarkLiberoBenchmarkbenchmark/gyms/results.pyBenchmarkResultsTaskResultlibrary/src/physicalai/eval/rollout.pyevaluate_policyphysicalai benchmarklibrary/src/physicalai/cli/benchmark.py基准测试通过在gym环境中运行训练好的策略并对成功情况打分来评估策略。Benchmark类位于(包含、、);结果类型定义在(包含、);rollout逻辑在(函数)。该库既支持直接调用Python API,也支持 CLI封装器(位于)。
library/src/physicalai/benchmark/gyms/benchmark.pyBenchmarkPushTBenchmarkLiberoBenchmarkbenchmark/gyms/results.pyBenchmarkResultsTaskResultlibrary/src/physicalai/eval/rollout.pyevaluate_policyphysicalai benchmarklibrary/src/physicalai/cli/benchmark.pyPython API invocation
Python API调用
Use this path for notebooks, tests, custom scripts, or direct library integrations.
python
from physicalai.benchmark.gyms import PushTBenchmark
from physicalai.policies import ACT
policy = ACT.load_from_checkpoint("experiments/act/version_0/checkpoints/last.ckpt")
benchmark = PushTBenchmark(num_episodes=1)
results = benchmark.evaluate(policy)
print(results.summary())
results.to_json("results/benchmark/results.json")
results.to_csv("results/benchmark/results.csv")For exported artifacts, load the Runtime-facing model first:
python
from physicalai.benchmark.gyms import PushTBenchmark
from physicalai.inference import InferenceModel
model = InferenceModel("./exports/act_policy")
results = PushTBenchmark(num_episodes=1).evaluate(model)适用于Notebook、测试、自定义脚本或直接的库集成场景。
python
from physicalai.benchmark.gyms import PushTBenchmark
from physicalai.policies import ACT
policy = ACT.load_from_checkpoint("experiments/act/version_0/checkpoints/last.ckpt")
benchmark = PushTBenchmark(num_episodes=1)
results = benchmark.evaluate(policy)
print(results.summary())
results.to_json("results/benchmark/results.json")
results.to_csv("results/benchmark/results.csv")对于导出的模型文件,需先加载面向Runtime的模型:
python
from physicalai.benchmark.gyms import PushTBenchmark
from physicalai.inference import InferenceModel
model = InferenceModel("./exports/act_policy")
results = PushTBenchmark(num_episodes=1).evaluate(model)CLI invocation
CLI调用
bash
physicalai benchmark \
--config configs/benchmark/pusht.yaml \
--policy physicalai.policies.ACT \
--ckpt_path experiments/act/version_0/checkpoints/last.ckpt \
--output_dir ./results/benchmark- — policy class path.
--policy - — a
--ckpt_pathor an export directory..ckpt - — a benchmark config (
--config,configs/benchmark/pusht.yaml) selecting theconfigs/benchmark/libero.yamlclass and its settings.Benchmark - — defaults to
--output_dir../results/benchmark
Override benchmark settings on the CLI, e.g. .
--benchmark.num_episodes 10 --benchmark.num_envs 8bash
physicalai benchmark \
--config configs/benchmark/pusht.yaml \
--policy physicalai.policies.ACT \
--ckpt_path experiments/act/version_0/checkpoints/last.ckpt \
--output_dir ./results/benchmark- — 策略类路径。
--policy - —
--ckpt_path文件路径或导出目录路径。.ckpt - — 基准测试配置文件(如
--config、configs/benchmark/pusht.yaml),用于选择configs/benchmark/libero.yaml类及其设置。Benchmark - — 默认路径为
--output_dir。./results/benchmark
可通过CLI覆盖基准测试设置,例如。
--benchmark.num_episodes 10 --benchmark.num_envs 8Output
输出内容
- Prints to stdout.
results.summary() - Writes and
results.jsonintoresults.csv.--output_dir - Optional video via config +
video_dir(record_mode|all|failures|successes).none
- 将输出到标准输出。
results.summary() - 在目录下生成
--output_dir和results.json文件。results.csv - 可通过配置和
video_dir(可选值:record_mode|all|failures|successes)录制视频。none
Workflow
工作流程
- Choose API or CLI deliberately. Use the Python API for code-level tasks; use CLI for config/docs/entry-point tasks.
- Done when: the selected path matches the user's requested surface area.
- Confirm the policy loads from the checkpoint/export before a full sweep:
bash
physicalai benchmark --config configs/benchmark/<suite>.yaml --policy <ClassPath> --ckpt_path <path> --benchmark.num_episodes 1- Done when: one episode runs end-to-end and a summary prints.
- Run the full benchmark with the intended episode/env counts.
- Done when: and
results.jsonare written and the success metric is populated.results.csv
- Done when:
- Interpret results via /
BenchmarkResultsfields; compare against a baseline checkpoint on the same config.TaskResult - Record videos for qualitative review when a task regresses ().
record_mode: failures
- 谨慎选择API或CLI方式。代码级任务使用Python API;配置/文档/入口点任务使用CLI。
- 完成标志:所选方式匹配用户需求场景。
- 在全面测试前确认策略可加载:
bash
physicalai benchmark --config configs/benchmark/<suite>.yaml --policy <ClassPath> --ckpt_path <path> --benchmark.num_episodes 1- 完成标志:单轮episode完整运行并输出摘要。
- 使用目标episode/env数量运行完整基准测试。
- 完成标志:生成和
results.json文件,且成功指标已填充。results.csv
- 完成标志:生成
- 通过/
BenchmarkResults字段解读结果;与相同配置下的基线checkpoint进行对比。TaskResult - 当任务性能退化时录制视频用于定性分析(设置)。
record_mode: failures
Adding or changing a Benchmark
添加或修改Benchmark
- Subclass in
Benchmark(studybenchmark/gyms//PushTBenchmark); the gym itself comes fromLiberoBenchmark(physicalai.gyms,pusht.py, …).libero.py - Add a matching config in .
library/configs/benchmark/ - Add tests under .
library/tests/unit/benchmark/- Done when: passes and a 1-episode run succeeds.
uv run pytest tests/unit/benchmark
- Done when:
- 在目录下继承
benchmark/gyms/类(可参考Benchmark/PushTBenchmark实现);gym环境来自LiberoBenchmark(如physicalai.gyms、pusht.py等)。libero.py - 在目录下添加对应的配置文件。
library/configs/benchmark/ - 在目录下添加测试用例。
library/tests/unit/benchmark/- 完成标志:执行通过,且单轮episode运行成功。
uv run pytest tests/unit/benchmark
- 完成标志:
Required checks
必要检查项
- The policy runs from both a and an export dir if both are supported paths.
.ckpt - The Python API path () and CLI wrapper agree on supported inputs for user-facing benchmark changes.
Benchmark(...).evaluate(...) - Success/episode metrics are populated (not zero/NaN by accident) and reproducible across runs.
- Env/episode counts match hardware; large fits memory.
num_envs - Heavy gym deps (e.g. ,
libero) are gated behind their optional extras and imported lazily.robocasa
- 若策略支持两种路径,则需确保从文件和导出目录均可加载运行。
.ckpt - Python API路径()与CLI封装器在用户可见的基准测试变更上支持的输入需保持一致。
Benchmark(...).evaluate(...) - 成功/episode指标已正确填充(避免意外为零或NaN),且多次运行结果可复现。
- Env/episode数量与硬件匹配;较大的需符合内存限制。
num_envs - 重型gym依赖(如、
libero)需通过可选扩展包引入,并延迟导入。robocasa
Related skills
相关技能
- — to produce the checkpoint being benchmarked.
physicalai-train-training-a-policy - — when benchmarking an exported artifact for deployment parity.
physicalai-train-exporting-and-validating
- — 生成待基准测试的checkpoint文件。
physicalai-train-training-a-policy - — 对导出的部署用模型进行基准测试以确保一致性。
physicalai-train-exporting-and-validating