Skip to content

Commit

Permalink
Minor LightningLite clean up (#15780)
Browse files Browse the repository at this point in the history
  • Loading branch information
awaelchli authored Nov 24, 2022
1 parent 8ca6dfe commit a1bea00
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 23 deletions.
3 changes: 1 addition & 2 deletions src/lightning_lite/lite.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.
import inspect
import os
from abc import ABC
from contextlib import contextmanager, nullcontext
from functools import partial
from pathlib import Path
Expand Down Expand Up @@ -55,7 +54,7 @@
from lightning_lite.wrappers import _LiteDataLoader, _LiteModule, _LiteOptimizer


class LightningLite(ABC):
class LightningLite:
"""Lite accelerates your PyTorch training or inference code with minimal changes required.
- Automatic placement of models and data onto the device.
Expand Down
6 changes: 6 additions & 0 deletions src/lightning_lite/strategies/fsdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,9 @@ def no_backward_sync(self, module: Module) -> Generator:
)
with module.no_sync():
yield


def _optimizer_has_flat_params(optimizer: Optimizer) -> bool:
from torch.distributed.fsdp import FlatParameter

return any(isinstance(param, FlatParameter) for param in optimizer.param_groups[0]["params"])
20 changes: 0 additions & 20 deletions src/lightning_lite/strategies/fsdp_native.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/pytorch_lightning/strategies/fully_sharded_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import pytorch_lightning as pl
from lightning_lite.plugins import CheckpointIO, ClusterEnvironment
from lightning_lite.strategies.fsdp_native import _optimizer_has_flat_params
from lightning_lite.strategies.fsdp import _optimizer_has_flat_params
from lightning_lite.utilities.distributed import (
_get_default_process_group_backend_for_device,
_init_dist_connection,
Expand Down

0 comments on commit a1bea00

Please sign in to comment.