Lightning-AI/pytorch-lightning · error · RuntimeError

`{type(self).__name__}` does not own a group. HINT: try `col

Error message

`{type(self).__name__}` does not own a group. HINT: try `collective.create_group().group`

What it means

Accessing `collective.group` on a Fabric `Collective` before a process group has been created raises this RuntimeError. The `group` property only exposes `self._group`, which is None until `create_group()` (or `init_group` flows) sets it.

Source

Thrown at src/lightning/fabric/plugins/collectives/collective.py:35

    """

    def __init__(self) -> None:
        self._group: Optional[CollectibleGroup] = None

    @property
    @abstractmethod
    def rank(self) -> int:
        """Rank."""

    @property
    @abstractmethod
    def world_size(self) -> int:
        """World size."""

    @property
    def group(self) -> CollectibleGroup:
        if self._group is None:
            raise RuntimeError(
                f"`{type(self).__name__}` does not own a group. HINT: try `collective.create_group().group`"
            )
        return self._group

    @abstractmethod
    def broadcast(self, tensor: Tensor, src: int) -> Tensor: ...

    @abstractmethod
    def all_reduce(self, tensor: Tensor, op: str) -> Tensor: ...

    @abstractmethod
    def reduce(self, tensor: Tensor, dst: int, op: str) -> Tensor: ...

    @abstractmethod
    def all_gather(self, tensor_list: list[Tensor], tensor: Tensor) -> list[Tensor]: ...

    @abstractmethod
    def gather(self, tensor: Tensor, gather_list: list[Tensor], dst: int = 0) -> list[Tensor]: ...

View on GitHub (pinned to 9fed5c27d2)

Solutions

  1. Call `collective.create_group(ranks=..., backend=...)` before accessing `.group` (the error's HINT states this exactly)
  2. If a default process group already exists and fits, use `torch.distributed.group.WORLD` instead of collective.group

Example fix

# before
collective = TorchCollective()
group = collective.group  # RuntimeError

# after
collective = TorchCollective()
collective.create_group(ranks=list(range(world_size)), backend='nccl')
group = collective.group
Defensive patterns

Strategy: validation

Validate before calling

if collective._group is None:
    collective.create_group(ranks=ranks, backend=backend)
group = collective.group

Prevention

When it happens

Trigger: Reading `collective.group` right after constructing a `TorchCollective` without calling `collective.create_group(...)` first; using the collective's group in a custom op before group creation.

Common situations: Custom distributed code that grabs the raw `dist` group for third-party collectives (e.g. HF accelerate-style communications) but skips group creation; reordering initialization during refactors.

Related errors


AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28). Data as JSON: /api/errors/b8c143c378634d5c. Report an issue: GitHub.