physicalai-runtime-loading-exported-policies

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Loading Exported Policies

加载导出的策略

Runtime loads Studio export directories (or Hub snapshots that mirror them) through
InferenceModel
in
src/physicalai/inference/model.py
. Manifest parsing lives in
src/physicalai/inference/manifest.py
; backends register in
src/physicalai/inference/adapters/registry.py
(
onnx
.onnx
,
openvino
.xml
). Hub downloads use
src/physicalai/inference/utils/_hub.py
.
Runtime通过
src/physicalai/inference/model.py
中的
InferenceModel
加载Studio导出目录(或镜像这些目录的Hub快照)。清单解析逻辑位于
src/physicalai/inference/manifest.py
;后端在
src/physicalai/inference/adapters/registry.py
中注册(
onnx
对应
.onnx
openvino
对应
.xml
)。Hub下载功能使用
src/physicalai/inference/utils/_hub.py

Workflow

工作流程

  1. Identify the artifact: local export directory or Hub
    repo_id
    , expected backend, and whether the user needs
    select_action
    vs
    predict_action_chunk
    .
    • Done when: load path and API entry point are chosen before editing code.
  2. Load with auto-detection first (local):
    python
    from physicalai.inference import InferenceModel
    model = InferenceModel("./exports/act_policy")
    • Done when:
      model
      constructs without explicit
      backend=
      when artifacts match a registered extension.
  3. Hub load when the package is published:
    python
    model = InferenceModel.from_pretrained("OpenVINO/act-fp16-ov", revision="<commit-sha>")
    • Done when: revision is pinned for reproducibility when security or CI matters.
  4. Explicit backend only when auto-detection is ambiguous:
    python
    model = InferenceModel("./exports/act_policy", backend="openvino", device="CPU")
  5. Validate structure against
    references/export-load-contract.md
    and backend notes (
    references/onnx.md
    ,
    references/openvino.md
    ).
    • Done when: manifest, model file, and processor artifacts resolve under the export directory.
  6. Smoke inference without owning robot timing:
    python
    model.reset()
    action = model.select_action(observation)
    • Done when: one forward pass succeeds on representative observation keys/shapes. For hardware loops, hand off to
      physicalai-runtime-running-policy-on-robot
      .
  1. 识别工件:本地导出目录或Hub
    repo_id
    、预期后端,以及用户是否需要
    select_action
    predict_action_chunk
    • 完成标志:在编辑代码前确定加载路径和API入口点。
  2. 先使用自动检测加载(本地):
    python
    from physicalai.inference import InferenceModel
    model = InferenceModel("./exports/act_policy")
    • 完成标志:当工件匹配已注册的扩展名时,无需显式指定
      backend=
      即可成功构建
      model
  3. 当包已发布时从Hub加载
    python
    model = InferenceModel.from_pretrained("OpenVINO/act-fp16-ov", revision="<commit-sha>")
    • 完成标志:在安全性或CI相关场景中,固定版本号以确保可复现性。
  4. 仅在自动检测存在歧义时指定显式后端
    python
    model = InferenceModel("./exports/act_policy", backend="openvino", device="CPU")
  5. 对照
    references/export-load-contract.md
    和后端说明(
    references/onnx.md
    references/openvino.md
    )验证结构
    • 完成标志:清单、模型文件和处理器工件可在导出目录下正常解析。
  6. 脱离机器人时序限制进行快速推理测试
    python
    model.reset()
    action = model.select_action(observation)
    • 完成标志:针对代表性观测键/形状的一次前向传递成功。对于硬件循环场景,移交至
      physicalai-runtime-running-policy-on-robot
      处理。

Validation loop

验证循环

bash
uv run pytest tests/unit/inference/test_model.py tests/unit/inference/test_manifest.py -q
For adapter changes, add or run targeted tests under
tests/unit/inference/
.
bash
uv run pytest tests/unit/inference/test_model.py tests/unit/inference/test_manifest.py -q
对于适配器变更,请在
tests/unit/inference/
下添加或运行针对性测试。

Required checks

必要检查

  • Export directory contains backend model file(s) and
    manifest.json
    consistent with
    docs/reference/manifest-schema.md
    .
  • Metadata input/output/feature names align with preprocessors in the manifest.
  • Optional backends fail with clear install guidance (
    onnxruntime
    , OpenVINO).
  • Do not document a backend unless an adapter is registered in
    src/physicalai/inference/adapters/
    .
  • Hub loads must not log tokens; prefer pinned
    revision=
    for production docs.
  • 导出目录包含后端模型文件和符合
    docs/reference/manifest-schema.md
    规范的
    manifest.json
  • 元数据中的输入/输出/特征名称与清单中的预处理器对齐。
  • 可选后端加载失败时需提供清晰的安装指引(
    onnxruntime
    、OpenVINO)。
  • 除非适配器已在
    src/physicalai/inference/adapters/
    中注册,否则不得记录该后端。
  • Hub加载不得记录令牌;生产文档中优先使用固定的
    revision=
    参数。

References

参考资料

  • references/export-load-contract.md
    — consumer-side contract (coordinate with Studio export skill).
  • references/onnx.md
    ,
    references/openvino.md
    — adapter constraints.
  • references/export-load-contract.md
    —— 消费端契约(与Studio导出功能协同)。
  • references/onnx.md
    references/openvino.md
    —— 适配器约束条件。