• 文档 >
  • 火炬分布式弹性 >
  • Events
快捷键

事件 ¬

模块包含与标准 Python 日志集成的事件处理机制。

使用示例:

from torch.distributed.elastic import events

event = events.Event(
    name="test_event", source=events.EventSource.WORKER, metadata={...}
)
events.get_logging_handler(destination="console").info(event)

API 方法 ¬

torch.distributed.elastic.events.record(event, destination='null')[source][source]
torch.distributed.elastic.events.construct_and_record_rdzv_event(run_id, message, node_state, name='', hostname='', pid=None, master_endpoint='', local_id=None, rank=None)[source][source]

初始化 rendezvous 事件对象并记录其操作。

参数:
  • run_id (str) – 集合点的运行 ID。

  • 事件描述消息(字符串)- 描述事件的短信。

  • 节点状态(NodeState)- 节点状态(初始化,运行中,成功,失败)。

  • 名称(字符串)- 事件名称。(例如,正在执行的操作)。

  • 主机名(字符串)- 节点的主机名。

  • pid(可选[int])- 节点的进程 ID。

  • master_endpoint(str)- 如果已知, rendezvous 存储的 master 端点。

  • local_id(可选[int])- 如果在 dynamic_rendezvous.py 中定义,则节点的 local_id。

  • rank(可选[int])- 如果已知,节点的 rank。

返回值:

无。

返回类型:

无。

示例

>>> # See DynamicRendezvousHandler class
>>> def _record(
...     self,
...     message: str,
...     node_state: NodeState = NodeState.RUNNING,
...     rank: Optional[int] = None,
... ) -> None:
...     construct_and_record_rdzv_event(
...         name=f"{self.__class__.__name__}.{get_method_name()}",
...         run_id=self._settings.run_id,
...         message=message,
...         node_state=node_state,
...         hostname=self._this_node.addr,
...         pid=self._this_node.pid,
...         local_id=self._this_node.local_id,
...         rank=rank,
...     )
torch.distributed.elastic.events.get_logging_handler(目标='null')[来源][来源] ¶
返回类型:

处理器

事件对象

类 torch.distributed.elastic.events.api.Event(名称, 来源, 时间戳=0, 元数据=<工厂>)[来源][来源] ¶

该类表示在 torchelastic 作业执行过程中发生的通用事件。

事件可以是任何有意义的行为。

参数:
  • name (str) – 事件名称。

  • source (EventSource) – 事件生产者,例如代理或工作节点。

  • 时间戳(整数)- 事件发生时的毫秒级时间戳。

  • 元数据(字典[str, Union[str, int, float, bool, NoneType]])- 与事件相关联的附加数据。

class torch.distributed.elastic.events.api.EventSource(value, names=<未提供>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source][source] ¶

事件生产者的已知标识符。

torch.distributed.elastic.events.api.事件元数据值

Optional 的别名 Union [ str [ int , float , bool ]]


© 版权所有 PyTorch 贡献者。

使用 Sphinx 构建,主题由 Read the Docs 提供。

文档

查看 PyTorch 的全面开发者文档

查看文档

教程

深入了解初学者和高级开发者的教程

查看教程

资源

查找开发资源并获得您的疑问解答

查看资源