def offload_(self):
        r"""Offloads the group of modules to the offload_device."""

        torch_accelerator_module = (
            getattr(torch, torch.accelerator.current_accelerator().type)
            if hasattr(torch, "accelerator")
            else torch.cuda
        )
        if self.stream is not None:
            if not self.record_stream:
                torch_accelerator_module.current_stream().synchronize()
            for group_module in self.modules:
                for param in group_module.parameters():
                    param.data = self.cpu_param_dict[param]
            for param in self.parameters:
                param.data = self.cpu_param_dict[param]
            for buffer in self.buffers:
                buffer.data = self.cpu_param_dict[buffer]

        else:
            for group_module in self.modules:
                group_module.to(self.offload_device, non_blocking=self.non_blocking)
            for param in self.parameters:
                param.data = param.data.to(self.offload_device, non_blocking=self.non_blocking)
            for buffer in self.buffers:
                buffer.data = buffer.data.to(self.offload_device, non_blocking=self.non_blocking)
Offloads the group of modules to the offload_device.
src/diffusers/hooks/group_offloading.py