{"record":{"id":"b8c143c378634d5c","repo":"Lightning-AI/pytorch-lightning","slug":"type-self-name-does-not-own-a-group-hint","errorCode":null,"errorMessage":"`{type(self).__name__}` does not own a group. HINT: try `collective.create_group().group`","messagePattern":"`(.+?)` does not own a group\\. HINT: try `collective\\.create_group\\(\\)\\.group`","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/lightning/fabric/plugins/collectives/collective.py","lineNumber":35,"sourceCode":"    \"\"\"\n\n    def __init__(self) -> None:\n        self._group: Optional[CollectibleGroup] = None\n\n    @property\n    @abstractmethod\n    def rank(self) -> int:\n        \"\"\"Rank.\"\"\"\n\n    @property\n    @abstractmethod\n    def world_size(self) -> int:\n        \"\"\"World size.\"\"\"\n\n    @property\n    def group(self) -> CollectibleGroup:\n        if self._group is None:\n            raise RuntimeError(\n                f\"`{type(self).__name__}` does not own a group. HINT: try `collective.create_group().group`\"\n            )\n        return self._group\n\n    @abstractmethod\n    def broadcast(self, tensor: Tensor, src: int) -> Tensor: ...\n\n    @abstractmethod\n    def all_reduce(self, tensor: Tensor, op: str) -> Tensor: ...\n\n    @abstractmethod\n    def reduce(self, tensor: Tensor, dst: int, op: str) -> Tensor: ...\n\n    @abstractmethod\n    def all_gather(self, tensor_list: list[Tensor], tensor: Tensor) -> list[Tensor]: ...\n\n    @abstractmethod\n    def gather(self, tensor: Tensor, gather_list: list[Tensor], dst: int = 0) -> list[Tensor]: ...","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/plugins/collectives/collective.py#L17-L53","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Call `collective.create_group(ranks=..., backend=...)` before accessing `.group` (the error's HINT states this exactly)","If a default process group already exists and fits, use `torch.distributed.group.WORLD` instead of collective.group"],"exampleFix":"# before\ncollective = TorchCollective()\ngroup = collective.group  # RuntimeError\n\n# after\ncollective = TorchCollective()\ncollective.create_group(ranks=list(range(world_size)), backend='nccl')\ngroup = collective.group","handlingStrategy":"validation","validationCode":"if collective._group is None:\n    collective.create_group(ranks=ranks, backend=backend)\ngroup = collective.group","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always call create_group before touching collective.group","Wrap group access in an initialization helper"],"tags":["pytorch-lightning","distributed","process-group","collectives"],"backgroundTag":"process-group-not-initialized","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}