{"record":{"id":"9169804cf380e52f","repo":"Lightning-AI/pytorch-lightning","slug":"type-self-name-does-not-own-a-group-to-de","errorCode":null,"errorMessage":"`{type(self).__name__}` does not own a group to destroy.","messagePattern":"`(.+?)` does not own a group to destroy\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/lightning/fabric/plugins/collectives/collective.py","lineNumber":116,"sourceCode":"        if not self.is_initialized():\n            self.init_group(**kwargs)\n        return self\n\n    def create_group(self, **kwargs: Any) -> Self:\n        \"\"\"Create a group.\n\n        This assumes that :meth:`~lightning.fabric.plugins.collectives.Collective.init_group` has been\n        called already by the user.\n\n        \"\"\"\n        if self._group is not None:\n            raise RuntimeError(f\"`{type(self).__name__}` already owns a group.\")\n        self._group = self.new_group(**kwargs)\n        return self\n\n    def teardown(self) -> Self:\n        if self._group is None:\n            raise RuntimeError(f\"`{type(self).__name__}` does not own a group to destroy.\")\n        self.destroy_group(self._group)\n        self._group = None\n        return self\n","sourceCodeStart":98,"sourceCodeEnd":120,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/plugins/collectives/collective.py#L98-L120","documentation":"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`.","triggerScenarios":"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.","commonSituations":"Generic cleanup code in `finally` blocks; re-running teardown in tests; error paths where create_group raised before assigning the group.","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"],"exampleFix":"# before\nfinally:\n    collective.teardown()  # may not own a group\n\n# after\nfinally:\n    if collective._group is not None:\n        collective.teardown()","handlingStrategy":"validation","validationCode":"if collective._group is not None:\n    collective.teardown()","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Call teardown only after successful group creation","Track group lifecycle state explicitly in orchestration code"],"tags":["pytorch-lightning","distributed","process-group","collectives","teardown"],"backgroundTag":"cleanup-without-initialization","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}