SuperAPI AI 工具集

physicalai-runtime-configuring-inference-pipeline

智能体与模型

查看项目

更新于 10-16 07:25

技能介绍

用途:在 PhysicalAI Runtime 中配置推理流水线,围绕 InferenceModel 组织预处理器(preprocessors)、后处理器(postprocessors)和 runner。流水线顺序为:观测 → 预处理器 → 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(依据 manifest 规格构建处理器链)。内置预处理器/后处理器位于 preprocessors/ 与 postprocessors/ 下,runner 位于 runners/ 下。

使用方式:读取 manifest 中 preprocessors、postprocessors 与 model.runner 部分,先确认规格使用 type(注册表短名)还是 class_path。内置组件优先用 type(如文档中的 normalize/denormalize 模式);显式类用 class_path 加 init_args,例如 class_path: physicalai.inference.preprocessors.StatsNormalizer 配合 init_args 中的 artifact: stats.safetensors,且 init_args 路径需经 resolve_artifact 相对导出目录解析。新增内置处理器时,在相应包中实现 Preprocessor/Postprocessor 子类,必要时在 component_factory 注册短类型名,并在 tests/unit/inference/preprocessors/ 或 postprocessors/ 下添加单元测试。

验证与限制:可运行 uv run pytest tests/unit/inference/preprocessors tests/unit/inference/postprocessors tests/unit/inference/test_manifest.py -q 做校验。要求处理器顺序与训练/导出语义一致(归一化在 runner 前,反归一化在其后);manifest 中的 artifact 文件名不得进行路径穿越(如 ..、绝对路径);新增公开处理器需出现在 docs/reference/inference-api.md 或 how-to 文档中;runner 选择(SinglePass、分块 runner)需与 predict_action_chunk 及 select_action 文档一致。init_args 中的嵌套组件需保持在 _MAX_COMPONENT_DEPTH 之内,避免循环规格。参考文档:docs/reference/manifest-schema.md、docs/how-to/inference/use-manifest.md。其他细节暂未提供。