Lightning-AI / pytorch-lightning

Pretrain, finetune ANY AI model of ANY size on multiple GPUs, TPUs with zero code changes.
https://lightning.ai
Apache License 2.0
28.18k stars 3.37k forks source link

Flatten the Strategy inheritance #11863

Open four4fish opened 2 years ago

four4fish commented 2 years ago

Proposed refactor

Flatten the Strategy inheritance: Part of #10416

Motivation

Reduce coupling between strategies, reduce unintentional overrides/inheritance and avoid silent failures eg:

  1. DeepSpeed inherited configure_ddp() from DDP, which is unnecessary and error-prone.
  2. DDP and FSDP have totally different distributed behavior, but with current inheritance, adding a DDP strategy method will automatically enable this method for FSDP

Pitch

Tasks list:

Additional context

The downside of this task will be code duplications. Align DDP/DDPSpawn precess group creation #11643 and Collective refactor #9414 will reduce the duplication.


If you enjoy Lightning, check out our other projects! ⚡

cc @justusschock @awaelchli @akihironitta @rohitgr7

awaelchli commented 2 years ago

Let's first get process launchers #11643 done so the ddp launch logic does not get duplicated into every strategy? cc @rohitgr7