快捷方式

事件

該模組包含與標準 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) – rendezvous 的執行 ID。

  • message (str) – 描述事件的訊息。

  • node_state (NodeState) – 節點的狀態(INIT, RUNNING, SUCCEEDED, FAILED)。

  • name (str) – 事件名稱。(例如,當前正在執行的操作)。

  • hostname (str) – 節點的 hostname。

  • pid (Optional[int]) – 節點的程序 ID。

  • master_endpoint (str) – rendezvous 儲存的主節點端點,如果已知的話。

  • local_id (Optional[int]) – 節點的 local_id,如果已在 dynamic_rendezvous.py 中定義。

  • rank (Optional[int]) – 節點的 rank,如果已知的話。

返回

None

返回型別

None

示例

>>> # 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(destination='null')[source][source]
返回型別

處理器

事件物件

class torch.distributed.elastic.events.api.Event(name, source, timestamp=0, metadata=<factory>)[source][source]

該類表示在 torchelastic 作業執行期間發生的通用事件。

該事件可以是任何有意義的操作。

引數
  • name (str) – 事件名稱。

  • source (EventSource) – 事件生產者,例如 agent 或 worker

  • timestamp (int) – 事件發生時的毫秒級時間戳。

  • metadata (dict[str, Union[str, int, float, bool, NoneType]]) – 與事件關聯的附加資料。

class torch.distributed.elastic.events.api.EventSource(value)[source][source]

已知的事件生產者識別符號。

torch.distributed.elastic.events.api.EventMetadataValue

Optional[Union[str, int, float, bool, NoneType]] 的別名

文件

訪問 PyTorch 全面的開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深入教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源