Lightning-AI/pytorch-lightning · error · RuntimeError
`{type(self).__name__}` does not own a group to destroy.
Error message
`{type(self).__name__}` does not own a group to destroy. What it means
Raised by `Collective.teardown()` when `self._group` is None — i.e. there is no process group to destroy. Teardown must be paired with a successful `create_group`.
Source
Thrown at src/lightning/fabric/plugins/collectives/collective.py:116
if not self.is_initialized():
self.init_group(**kwargs)
return self
def create_group(self, **kwargs: Any) -> Self:
"""Create a group.
This assumes that :meth:`~lightning.fabric.plugins.collectives.Collective.init_group` has been
called already by the user.
"""
if self._group is not None:
raise RuntimeError(f"`{type(self).__name__}` already owns a group.")
self._group = self.new_group(**kwargs)
return self
def teardown(self) -> Self:
if self._group is None:
raise RuntimeError(f"`{type(self).__name__}` does not own a group to destroy.")
self.destroy_group(self._group)
self._group = None
return self
View on GitHub (pinned to 9fed5c27d2)
Solutions
- Only call teardown after a successful create_group; guard with `if collective._group is not None`
- Set `collective._group = None`-equivalent state tracking, or recreate the collective per phase
- Restructure cleanup so teardown only runs on the success path of group creation
Example fix
# before
finally:
collective.teardown() # may not own a group
# after
finally:
if collective._group is not None:
collective.teardown() Defensive patterns
Strategy: validation
Validate before calling
if collective._group is not None:
collective.teardown() Prevention
- Call teardown only after successful group creation
- Track group lifecycle state explicitly in orchestration code
When it happens
Trigger: Calling `collective.teardown()` on a freshly constructed collective, or calling teardown twice without recreating the group; cleanup paths in try/finally blocks that run even when group creation failed or was skipped.
Common situations: Generic cleanup code in `finally` blocks; re-running teardown in tests; error paths where create_group raised before assigning the group.
Related errors
- `{type(self).__name__}` does not own a group. HINT: try `col
- `{type(self).__name__}` already owns a group.
- Torch distributed is not available.
- Unsupported op {op!r} of type {type(op).__name__}
- op {op!r} is not a member of `ReduceOp`
AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28).
Data as JSON: /api/errors/9169804cf380e52f.
Report an issue: GitHub.