linkedin / linkedin/Liger-Kernel
TiledMLP
- Dominant language
- Python
- Stars
- 6.6k
- Forks
- 603
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 47
Description
### 🚀 The feature, motivation and pitch
TiledMLP can save memory for large bs/long seq as well
Reference code: https://github.com/deepspeedai/DeepSpeed/blob/16c1bf429f10db3e681b49fac37d641909aad69d/deepspeed/runtime/sequence_parallel/ulysses_sp.py#L781
Thanks to @upskyy, the base implementation has been done in https://github.com/linkedin/Liger-Kernel/pull/935
However, the current is not compatible with ddp and fsdp, see https://github.com/linkedin/Liger-Kernel/pull/935#issuecomment-3517964534.
For ddp support, one can try registering hooks to temporily accumulate gradients and only return the accumulated gradients in the last iteration, based on https://github.com/axolotl-ai-cloud/axolotl/blob/dd78f2e0cc5cc6458daaad02cc29b649ff1046f5/src/axolotl/monkeypatch/tiled_mlp/base.py#L99
For fsdp, parameters are always resharded after the first backward pass, one need to find a way to unshard parameters in the latter iterations.
- [x] base implementation based on deepspeed: https://github.com/linkedin/Liger-Kernel/pull/935 @upskyy
- [ ] ddp support (contribute welcome)
- [ ] fsdp support (contribute welcome)
### Alternatives
_No response_
### Additional context
_No response_
Contributor guide
Research direction
Start with the base implementation in PR #935 and compare it with the hook approach in axolotl/monkeypatch/tiled_mlp/base.py. Investigate DDP gradient accumulation and FSDP parameter resharding; done means TiledMLP works with both DDP and FSDP.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- distributed-systems, machine-learning
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100