get_torchtpu_env_vars#
- SubslicePlacementGroup.get_torchtpu_env_vars(worker_id: int | None = None, worker_hostnames: str | List[str] | None = None, slicebuilder_addresses: str | List[str] | None = None, slicebuilder_port: int = 8471, master_addr: str | None = None) Dict[str, str][source]#
Returns the PyTorch/TPU (torch_tpu) environment variables for this subslice.
See
get_torchtpu_env_vars()for details on address ordering and requiredtorch.distributedrank variables.- Parameters:
worker_id (int | None) – Optional integer ID of the worker within the subslice (0-indexed), between 0 and num_hosts - 1. Defaults to 0 on a single-host subslice; when omitted on a multi-host subslice,
TPU_WORKER_IDis not set (passworker_idper bundle on multi-host subslices soTPU_WORKER_IDoverrides the parent slice’s worker rank).worker_hostnames (str | List[str] | None) – Optional comma-separated string or list of host IP addresses or DNS hostnames. If omitted, resolved from placement group bundles in this subslice.
slicebuilder_addresses (str | List[str] | None) – Optional explicit comma-separated string or list of address:port strings for this subslice.
slicebuilder_port (int) – Base port number for slicebuilder addresses (defaults to 8471).
master_addr (str | None) – Optional IP address or hostname of the rank-0 master node.
- Returns:
A dictionary mapping PyTorch/TPU environment variables to their values.
- Raises:
TypeError – If worker_id or slicebuilder_port is not an integer.
ValueError – If worker_id or any address or port argument is invalid.
RuntimeError – If worker hostnames cannot be resolved.
- Return type: