目录

torchx.components

该模块包含一组内置的 TorchX 组件。目录 structure 按组件类别进行组织。组件只是 模板化的应用程序规格。将它们视为不同类型的工厂方法 的作业定义。在此 module 就是我们所说的组件。specs.AppDef

您可以浏览模块中的组件库 或在我们的 Docs 页面上torchx.components

组件可以通过 torchx cli 或 torchx sdk 开箱即用。

# using via sdk
from torchx.runner import get_runner
get_runner().run_from_path("distributed.ddp", app_args=[], scheduler="local", ...)

# using via torchx-cli

>> torchx run --scheduler local distributed.ddp --param1 --param2

组件开发

添加新组件非常简单,包括

以下步骤:

  • 确定组件位置

  • 将组件创建为函数

  • 单元测试

确定组件位置。每个组件都属于一个或另一个类别, ,并应相应地找到。例如,分布式组件的定义 应位于 file 中。distributed.py

Create component as function(创建组件作为函数)。每个组件都代表一个函数,该函数接受

arbitrary 参数并返回 .specs.AppDef

该函数应 具有以下属性:

  • 函数的所有参数都必须进行注释

  • 当前支持的类型:
    • 基元:int、float、str

    • 可选基元: Optional[int], Optional[float], Optional[str]

    • 字典: Dict[Primitive_key, Primitive_value]

    • 列表:列表[Primitive_value]

    • 可选 [列表], 可选 [字典]

  • 该函数应在

    https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html 格式

单元测试。编写用于验证的单元测试 组件的结构,类似于 .torchx.specs.file_lintertorchx.components.tests.distributed_test.py

_images/components_diagram.jpg

注意

上图仅用于说明目的。并非所有盒子 目前是开箱即用的。

文档

访问 PyTorch 的全面开发人员文档

查看文档

教程

获取面向初学者和高级开发人员的深入教程

查看教程

资源

查找开发资源并解答您的问题

查看资源