Lightning-AI / Lightning-AI/pytorch-lightning
Deepspeed ZERO MiCS support
Nobody has claimed this yet.
- 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
, it works. So, can we add some conditions here to use an alternative context manager?
cc @borda @awaelchli
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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