Skip to content

fixed issue #20065#21683

Open
rohan-devbuilds wants to merge 1 commit into
Lightning-AI:masterfrom
rohan-devbuilds:master
Open

fixed issue #20065#21683
rohan-devbuilds wants to merge 1 commit into
Lightning-AI:masterfrom
rohan-devbuilds:master

Conversation

@rohan-devbuilds
Copy link
Copy Markdown

@rohan-devbuilds rohan-devbuilds commented Apr 22, 2026

What does this PR do?

Fixes #20065

Adds support for DeepSpeed's Universal Checkpointing feature in DeepSpeedStrategy.

Previously, if you trained a model on N GPUs and tried to resume training on a
different number of GPUs (e.g. 8 → 16), the checkpoint would be incompatible and
optimizer/model states would be lost. DeepSpeed provides a built-in solution called
Universal Checkpointing, but Lightning had no way to enable it.

This PR adds a load_full_weights: bool = False parameter to DeepSpeedStrategy.
When set to True, it injects {"checkpoint": {"load_universal": True}} into the
DeepSpeed config, enabling seamless checkpoint loading across different GPU counts.

Example usage:

strategy = DeepSpeedStrategy(load_full_weights=True)
trainer = Trainer(strategy=strategy)
trainer.fit(model, ckpt_path="path/to/universal_checkpoint")
` `` 

**Changes made:**
- Added `load_full_weights: bool = False` parameter to `DeepSpeedStrategy.__init__`
- Injected `checkpoint.load_universal` into the DeepSpeed config when the flag is `True`
- Updated docstring to document the new parameter
- Added unit tests for both the enabled and default (disabled) cases


  Before submitting

- Was this **discussed/agreed** via a GitHub issue? (not for typos and docs)
  - Yessee #20065
- [x] Did you read the [contributor guideline](https://github.com/Lightning-AI/pytorch-lightning/blob/master/.github/CONTRIBUTING.md), **Pull Request** section?
- [x] Did you make sure your **PR does only one thing**, instead of bundling different changes together?
- Did you make sure to **update the documentation** with your changes? (if necessary)
  - Yesupdated the `__init__` docstring in `DeepSpeedStrategy`
- Did you write any **new necessary tests**? (not for typos and docs)
  - Yesadded tests verifying config is correctly set when `load_full_weights=True` and clean when `False`
- [x] Did you verify new and **existing tests pass** locally with your changes?
- Did you list all the **breaking changes** introduced by this pull request?
  - No breaking changes. New parameter defaults to `False`, preserving existing behavior.
- Did you **update the CHANGELOG**?
  - Yesadded entry under unreleased section



## PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the
[review guidelines](https://github.com/Lightning-AI/lightning/wiki/Review-guidelines).


  Reviewer checklist

- [x] Is this pull request ready for review?
- [x] Check that all items from **Before submitting** are resolved
- [x] Title is self-explanatory and description concisely explains the PR
- [ ] Add labels and milestones (and optionally projects) to the PR so it can be classified

📚 Documentation preview 📚: https://pytorch-lightning--21683.org.readthedocs.build/en/21683/

@github-actions github-actions Bot added the pl Generic label for PyTorch Lightning package label Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pl Generic label for PyTorch Lightning package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enable loading universal checkpointing checkpoint in DeepSpeedStrategy

1 participant