NVIDIA / NVIDIA/apex

support for loading on cpu first when using DDP

Open
#476 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
9k
Forks
1.5k
Avg merge
2d 4h
Merged PRs (30d)
3

Description

in this example:

# Restore
model = ...
optimizer = ...
checkpoint = torch.load('amp_checkpoint.pt')

model, optimizer = amp.initialize(model, optimizer, opt_level=opt_level)
model.load_state_dict(checkpoint['model'])
optimizer.load_state_dict(checkpoint['optimizer'])
amp.load_state_dict(checkpoint['amp'])

# Continue training
...

one cannot load the model to CPU first before restoring weight. this is necessary as a way to not have OOM with RAM when using huge models.

The flow that needs support is:

model.load_state(... using_cpu)
model.cuda(x)
model = amp.initialize(...)

model = DDP(model)

Contributor guide

No contributing guide indexed for this repository

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 with the checkpoint restore flow using torch.load, load_state_dict, amp.initialize, and DDP as shown in the issue, then trace how model state is loaded and moved to CUDA. Done means the model can load weights on CPU first, move to CUDA, initialize AMP, and wrap with DDP without requiring excessive RAM.

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.