---
title: lightning.fabric.plugins.environments.xla.XLAEnvironment
description: Cluster environment for training on a TPU Pod with the PyTorch/XLA library.
canonical: >-
  https://lightning.ai/docs/fabric/stable/full-api-reference/api/generated/lightning.fabric.plugins.environments.xla.XLAEnvironment
---
# lightning.fabric.plugins.environments.xla.XLAEnvironment {#lightning-fabric-plugins-environments-xla-xlaenvironment}

### `class lightning.fabric.plugins.environments.xla.XLAEnvironment(*args, **kwargs)` {#lightning.fabric.plugins.environments.xla.XLAEnvironment}

Bases: [`ClusterEnvironment`](/docs/fabric/2.6.6/full-api-reference/api/generated/lightning.fabric.plugins.environments.cluster_environment.ClusterEnvironment.md#lightning.fabric.plugins.environments.cluster_environment.ClusterEnvironment "lightning.fabric.plugins.environments.cluster_environment.ClusterEnvironment")

Cluster environment for training on a TPU Pod with the [PyTorch/XLA](https://pytorch.org/xla) library.

A list of environment variables set by XLA can be found [here](https://github.com/pytorch/xla/blob/master/torch_xla/core/xla_env_vars.py).

#### `static detect()` {#lightning.fabric.plugins.environments.xla.XLAEnvironment.detect}

Detects the environment settings corresponding to this cluster and returns `True` if they match.

Return type:

[`bool`](https://docs.python.org/3/builtins/functions.html#bool "(in Python v3.15)")

#### `global_rank()` {#lightning.fabric.plugins.environments.xla.XLAEnvironment.global_rank}

The rank (index) of the currently running process across all host and devices.

The output is cached for performance.

Return type:

[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")

#### `local_rank()` {#lightning.fabric.plugins.environments.xla.XLAEnvironment.local_rank}

The rank (index) of the currently running process inside of the current host.

The output is cached for performance.

Return type:

[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")

#### `node_rank()` {#lightning.fabric.plugins.environments.xla.XLAEnvironment.node_rank}

The rank (index) of the host on which the current process runs.

The output is cached for performance.

Return type:

[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")

#### `world_size()` {#lightning.fabric.plugins.environments.xla.XLAEnvironment.world_size}

The number of processes across all devices and hosts.

The output is cached for performance.

Return type:

[`int`](https://docs.python.org/3/builtins/functions.html#int "(in Python v3.15)")

#### `property creates_processes_externally: bool` {#lightning.fabric.plugins.environments.xla.XLAEnvironment.creates_processes_externally}

Whether the environment creates the subprocesses or not.

#### `property main_address: str` {#lightning.fabric.plugins.environments.xla.XLAEnvironment.main_address}

The main address through which all processes connect and communicate.

#### `property main_port: int` {#lightning.fabric.plugins.environments.xla.XLAEnvironment.main_port}

An open and configured port in the main node through which all processes communicate.

---

**Navigation**

- Parent: [Generated](/docs/fabric/2.6.6/full-api-reference/api/generated.md)
