physicalai-runtime-configuring-inference-pipeline
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseConfiguring the Inference Pipeline
配置推理管道
Pipeline order: observation → preprocessors → runner → postprocessors → action output. See .
docs/how-to/inference/configure-pre-post-processing.mdCore code:
- —
src/physicalai/inference/component_factory.py,ComponentRegistry,instantiate_component._MAX_COMPONENT_DEPTH - — builds processor chains from manifest specs.
src/physicalai/inference/model.py - Built-ins under and
preprocessors/; runners underpostprocessors/.runners/
管道顺序:observation → 预处理器 → runner → 后处理器 → 动作输出。详见。
docs/how-to/inference/configure-pre-post-processing.md核心代码:
- —
src/physicalai/inference/component_factory.py,ComponentRegistry,instantiate_component._MAX_COMPONENT_DEPTH - — 从清单规范构建处理器链。
src/physicalai/inference/model.py - 内置处理器位于和
preprocessors/目录下;运行器位于postprocessors/目录下。runners/
Workflow
工作流程
-
Read the manifest slice for,
preprocessors, andpostprocessors.model.runner- Done when: you know whether specs use (registry short name) or
type.class_path
- Done when: you know whether specs use
-
Preferfor built-ins registered in
type(e.g. normalize/denormalize patterns in docs).component_factory -
Use+
class_pathfor explicit classes:init_argsyamlpreprocessors: - class_path: physicalai.inference.preprocessors.StatsNormalizer init_args: artifact: stats.safetensors- Done when: paths resolve relative to the export directory via
init_args.resolve_artifact
- Done when:
-
Add a new built-in processor:
- Implement subclass of /
Preprocessorin the appropriate package.Postprocessor - Register a short name in
typeif manifest-friendly aliases are needed.component_factory - Add unit tests under or
tests/unit/inference/preprocessors/.postprocessors/ - Done when: manifest using or
typeinstantiates in a minimalclass_pathtest.InferenceModel
- Implement subclass of
-
Nested components inmust stay within
init_args; avoid cyclic specs._MAX_COMPONENT_DEPTH
-
读取清单中、
preprocessors和postprocessors的片段model.runner- 完成标志:明确规范是使用(注册表简称)还是
type。class_path
- 完成标志:明确规范是使用
-
对于在中注册的内置处理器,优先使用
component_factory(例如文档中的归一化/反归一化模式)。type -
对于显式类,使用+
class_path:init_argsyamlpreprocessors: - class_path: physicalai.inference.preprocessors.StatsNormalizer init_args: artifact: stats.safetensors- 完成标志:中的路径可通过
init_args相对于导出目录解析。resolve_artifact
- 完成标志:
-
添加新的内置处理器:
- 在对应包中实现/
Preprocessor的子类。Postprocessor - 如果需要便于在清单中使用的别名,在中注册一个简短的
component_factory名称。type - 在或
tests/unit/inference/preprocessors/目录下添加单元测试。postprocessors/ - 完成标志:使用或
type的清单可在最小化class_path测试中实例化。InferenceModel
- 在对应包中实现
-
中的嵌套组件必须保持在
init_args范围内;避免循环规范。_MAX_COMPONENT_DEPTH
Validation loop
验证循环
bash
uv run pytest tests/unit/inference/preprocessors tests/unit/inference/postprocessors tests/unit/inference/test_manifest.py -qbash
uv run pytest tests/unit/inference/preprocessors tests/unit/inference/postprocessors tests/unit/inference/test_manifest.py -qRequired checks
必要检查
- Processor order matches training/export semantics (normalization before runner, denormalization after).
- Artifact file names in manifests do not traverse paths (, absolute paths).
.. - New public processors appear in or how-to docs when user-visible.
docs/reference/inference-api.md - Runner choice (, chunking runners) stays consistent with
SinglePassvspredict_action_chunkdocs.select_action
- 处理器顺序需与训练/导出语义一致(归一化在runner之前,反归一化在runner之后)。
- 清单中的 artifact 文件名不得包含路径遍历(、绝对路径)。
.. - 新的公共处理器若对用户可见,需添加到或操作指南文档中。
docs/reference/inference-api.md - 运行器的选择(、分块运行器)需与
SinglePass和predict_action_chunk文档保持一致。select_action
References
参考资料
docs/reference/manifest-schema.mddocs/how-to/inference/use-manifest.md
docs/reference/manifest-schema.mddocs/how-to/inference/use-manifest.md