Lightning-AI / Lightning-AI/pytorch-lightning

Deepspeed ZERO MiCS support

Open
#20,378 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature strategy: deepspeed waiting on author
Dominant language
Python
Stars
31.4k
Forks
3.8k
Avg merge
6d 7h
Merged PRs (30d)
6

Description

### Description & Motivation

After deepspeed 0.9.2, they provided [Misc support](https://deepspeed.readthedocs.io/en/latest/zero3.html#example-mics-configurations), which can specify how to split parameters across devices [reference](https://github.com/microsoft/DeepSpeed/discussions/3438). It's a pleasure if lightning deepspeed strategy has such features.

### Pitch

By detecting if the keywords 'mics_shard_size' or 'mics_hierarchical_params_gather' in deepspeed args, deepspeed can decide whether to use mics.
This requires using 'deepspeed.zero.MiCS_Init()' instead 'deepspeed.zero.Init()' when initializing the model.

### Alternatives

_No response_

### Additional context

I simply override DeepSpeedStrategy.model_sharded_context (line 519 in lightning.pytorch.strategies.deepspeed.py) with
![image](https://github.com/user-attachments/assets/23dd2ff9-4055-4149-abde-1b2b2e71c7f5), it works. So, can we add some conditions here to use an alternative context manager?

cc @borda @awaelchli

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 in lightning.pytorch.strategies.deepspeed.py at DeepSpeedStrategy.model_sharded_context around line 519, and review the referenced DeepSpeed MiCS configuration and initialization APIs. Verify how the existing strategy detects its arguments, then confirm that MiCS settings select the alternative context manager while other configurations retain current behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.