Lightning-AI / Lightning-AI/pytorch-lightning

Support saving and loading remote paths with FSDP

Open
#18,786 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

checkpointing feature help wanted strategy: fsdp
Dominant language
Python
Stars
31.4k
Forks
3.8k
Avg merge
6d 7h
Merged PRs (30d)
6

Description

### Bug description

`FSDPStrategy.load_checkpoint` casts `checkpoint_path` to a `pathlib.Path` [here](https://github.com/Lightning-AI/lightning/blob/master/src/lightning/pytorch/strategies/fsdp.py#L539). This will bork URIs, such as cloud checkpoint paths, e.g. `s3://...`.

Example:

```python
from pathlib import Path

checkpoint_path = "s3://asd/asd"
assert Path(checkpoint_path).as_posix() == checkpoint_path
```

NOTE: I am reporting this merely by looking at the source code; I have yet to confirm this with a test.

### What version are you seeing the problem on?

master

### How to reproduce the bug

```python
from lightning.pytorch.strategies import FSDPStrategy

FSDPStrategy(...).load_checkpoint("s3://my/checkpoint")
```

### Error messages and logs

I believe [this](https://github.com/Lightning-AI/lightning/blob/master/src/lightning/pytorch/strategies/fsdp.py#L620) exception will be raised.

### Environment

Current environment

```
#- Lightning Component (e.g. Trainer, LightningModule, LightningApp, LightningWork, LightningFlow):
#- PyTorch Lightning Version (e.g., 1.5.0):
#- Lightning App Version (e.g., 0.5.2):
#- PyTorch Version (e.g., 2.0):
#- Python version (e.g., 3.9):
#- OS (e.g., Linux):
#- CUDA/cuDNN version:
#- GPU models and configuration:
#- How you installed Lightning(`conda`, `pip`, source):
#- Running environment of LightningApp (e.g. local, cloud):
```

### More info

_No response_

cc @borda @awaelchli @carmocca

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/lightning/pytorch/strategies/fsdp.py at FSDPStrategy.load_checkpoint and inspect the checkpoint_path handling around the referenced lines. Reproduce the s3:// example, then trace the corresponding save path behavior. Done means remote URI paths are preserved for saving and loading, with regression coverage for the reported case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
distributed-systems, machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.