Lightning-AI / Lightning-AI/pytorch-lightning
Support `xser` for saving checkpoints for XLA
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 31.4k
- Forks
- 3.8k
- Avg merge
- 6d 7h
- Merged PRs (30d)
- 6
Description
## 🚀 Feature
```python
import torch_xla.utils.serialization as xser
xser.save(model.state_dict(), path)
```
### Motivation
In case where memory is limited compared to the size of the model parameters, an API is provided that reduces the memory footprint on the host:
```python
import torch_xla.utils.serialization as xser
xser.save(model.state_dict(), path)
```
This API streams XLA tensors to CPU one at a time, reducing the amount of host memory used, but it requires a matching load API to restore:
```python
import torch_xla.utils.serialization as xser
state_dict = xser.load(path)
model.load_state_dict(state_dict)
```
### Pitch
### Alternatives
### Additional context
cc @borda @kaushikb11 @rohitgr7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the torch_xla.utils.serialization API shown in the issue and trace the existing checkpoint serialization path. The work is done when matching save and load APIs support model state dictionaries for XLA while streaming tensors to CPU one at a time to reduce host memory use.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100