deepspeedai / deepspeedai/DeepSpeed

PipelineModule inflated checkpoints when using FP16 param flattening

Open
#549 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
43.1k
Forks
5k
Avg merge
4d 15h
Merged PRs (30d)
112

Description

Hi,

When using the pipeline module/engine, checkpoints are saved per layer within each module/stage. But when using one of the FP16 optimizers, each layers checkpoint size is the full size of the whole pipeline stage (all layers in the stage), which causes checkpoint sizes to be quadratic in the number of layers per stage.

The issue seems to be related to the FP16 optimizers using one large flattened param buffer for the whole param group, but pytorch saves the whole tensor even when only saving a view of it.

Currently, I can overcome this by passing per-layer param-groups to the optimizer:

params = [{"params": [p for p in layer.parameters() if p.requires_grad]} for layer in net.forward_funcs]

But this doesn't seem super clean. Is there a cleaner way I missed to handle this? And if not maybe worth adding a method to PipelineModule to retrieve the parameters in groups per layer?

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 reproducing the pipeline module checkpoint behavior with an FP16 optimizer and inspect how per-layer parameters and flattened parameter buffers are serialized. Done means checkpoints no longer duplicate the full pipeline-stage buffer for each layer, while preserving correct checkpoint loading.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.