Lightning-AI / Lightning-AI/pytorch-lightning

Lightning Fabric: generic method to get the full state dict

Open
#19,923 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

fabric feature
Dominant language
Python
Stars
31.4k
Forks
3.8k
Avg merge
6d 7h
Merged PRs (30d)
6

Description

### Description & Motivation

Hi,
I would like a generic method of getting the full state dict on rank 0 for a lightning fabric wrapped module. Base lightning seems to have lightning_module_state_dict, but fabric only has save_checkpoint (which for my usecase doesn't work, as I do not want to save the entire state to a single file).

### Pitch

See above.

### Alternatives

None.

### Additional context

_No response_

cc @lantiga @borda @justusschock

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 by comparing Lightning Fabric's existing save_checkpoint behavior with Base Lightning's lightning_module_state_dict method. Trace how a Fabric-wrapped module exposes state across ranks and determine the expected rank-0 result without writing the full state to one file. Done means a generic, documented method is available for retrieving the full state dict and its behavior is covered by appropriate tests.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.