Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FP8 + FSDP2 + torch.compile examples for PyTorch Lightning and Fabric #20440

Merged
merged 13 commits into from
Nov 26, 2024

Conversation

lantiga
Copy link
Collaborator

@lantiga lantiga commented Nov 22, 2024

What does this PR do?

This PR adds:

  • examples for FP8 (via torchao), FSDP2 (via DTensors) and torch.compile for both PyTorch Lightning and Fabric, together with the respective READMEs
  • tests for calling torch.compile from configure_module and parallelize_fn when using ModelParallelStrategy
  • docs for torch.compile called from configure_module and parallelize_fn in PyTorch Lightning and Fabric

This PR unearthed several issues with integration tests, which are addressed here to get CI green.

cc @Borda @awaelchli @justusschock

@github-actions github-actions bot added fabric lightning.fabric.Fabric pl Generic label for PyTorch Lightning package labels Nov 22, 2024
@lantiga lantiga marked this pull request as ready for review November 25, 2024 23:29
Copy link
Contributor

github-actions bot commented Nov 25, 2024

⚡ Required checks status: All passing 🟢

Groups summary

🟢 pytorch_lightning: Tests workflow
Check ID Status
pl-cpu (macOS-14, lightning, 3.9, 2.1, oldest) success
pl-cpu (macOS-14, lightning, 3.10, 2.1) success
pl-cpu (macOS-14, lightning, 3.11, 2.2.2) success
pl-cpu (macOS-14, lightning, 3.11, 2.3) success
pl-cpu (macOS-14, lightning, 3.12, 2.4.1) success
pl-cpu (macOS-14, lightning, 3.12, 2.5.1) success
pl-cpu (ubuntu-20.04, lightning, 3.9, 2.1, oldest) success
pl-cpu (ubuntu-20.04, lightning, 3.10, 2.1) success
pl-cpu (ubuntu-20.04, lightning, 3.11, 2.2.2) success
pl-cpu (ubuntu-20.04, lightning, 3.11, 2.3) success
pl-cpu (ubuntu-22.04, lightning, 3.12, 2.4.1) success
pl-cpu (ubuntu-22.04, lightning, 3.12, 2.5.1) success
pl-cpu (windows-2022, lightning, 3.9, 2.1, oldest) success
pl-cpu (windows-2022, lightning, 3.10, 2.1) success
pl-cpu (windows-2022, lightning, 3.11, 2.2.2) success
pl-cpu (windows-2022, lightning, 3.11, 2.3) success
pl-cpu (windows-2022, lightning, 3.12, 2.4.1) success
pl-cpu (windows-2022, lightning, 3.12, 2.5.1) success
pl-cpu (macOS-14, pytorch, 3.9, 2.1) success
pl-cpu (ubuntu-20.04, pytorch, 3.9, 2.1) success
pl-cpu (windows-2022, pytorch, 3.9, 2.1) success
pl-cpu (macOS-14, pytorch, 3.12, 2.5.1) success
pl-cpu (ubuntu-22.04, pytorch, 3.12, 2.5.1) success
pl-cpu (windows-2022, pytorch, 3.12, 2.5.1) success

These checks are required after the changes to tests/tests_pytorch/strategies/test_model_parallel_integration.py.

🟢 pytorch_lightning: Azure GPU
Check ID Status
pytorch-lightning (GPUs) (testing Lightning | latest) success
pytorch-lightning (GPUs) (testing PyTorch | latest) success

These checks are required after the changes to tests/tests_pytorch/strategies/test_model_parallel_integration.py, tests/run_standalone_tests.sh.

🟢 fabric: Docs
Check ID Status
docs-make (fabric, doctest) success
docs-make (fabric, html) success

These checks are required after the changes to docs/source-fabric/advanced/compile.rst.

🟢 pytorch_lightning: Docs
Check ID Status
docs-make (pytorch, doctest) success
docs-make (pytorch, html) success

These checks are required after the changes to docs/source-pytorch/advanced/compile.rst.

🟢 lightning_fabric: CPU workflow
Check ID Status
fabric-cpu (macOS-14, lightning, 3.9, 2.1, oldest) success
fabric-cpu (macOS-14, lightning, 3.10, 2.1) success
fabric-cpu (macOS-14, lightning, 3.11, 2.2.2) success
fabric-cpu (macOS-14, lightning, 3.11, 2.3) success
fabric-cpu (macOS-14, lightning, 3.12, 2.4.1) success
fabric-cpu (macOS-14, lightning, 3.12, 2.5.1) success
fabric-cpu (ubuntu-20.04, lightning, 3.9, 2.1, oldest) success
fabric-cpu (ubuntu-20.04, lightning, 3.10, 2.1) success
fabric-cpu (ubuntu-20.04, lightning, 3.11, 2.2.2) success
fabric-cpu (ubuntu-20.04, lightning, 3.11, 2.3) success
fabric-cpu (ubuntu-22.04, lightning, 3.12, 2.4.1) success
fabric-cpu (ubuntu-22.04, lightning, 3.12, 2.5.1) success
fabric-cpu (windows-2022, lightning, 3.9, 2.1, oldest) success
fabric-cpu (windows-2022, lightning, 3.10, 2.1) success
fabric-cpu (windows-2022, lightning, 3.11, 2.2.2) success
fabric-cpu (windows-2022, lightning, 3.11, 2.3) success
fabric-cpu (windows-2022, lightning, 3.12, 2.4.1) success
fabric-cpu (windows-2022, lightning, 3.12, 2.5.1) success
fabric-cpu (macOS-14, fabric, 3.9, 2.1) success
fabric-cpu (ubuntu-20.04, fabric, 3.9, 2.1) success
fabric-cpu (windows-2022, fabric, 3.9, 2.1) success
fabric-cpu (macOS-14, fabric, 3.12, 2.5.1) success
fabric-cpu (ubuntu-22.04, fabric, 3.12, 2.5.1) success
fabric-cpu (windows-2022, fabric, 3.12, 2.5.1) success

These checks are required after the changes to tests/tests_fabric/conftest.py, tests/tests_fabric/strategies/test_model_parallel_integration.py.

🟢 lightning_fabric: Azure GPU
Check ID Status
lightning-fabric (GPUs) (testing Fabric | latest) success
lightning-fabric (GPUs) (testing Lightning | latest) success

These checks are required after the changes to examples/fabric/fp8_distributed_transformer/requirements.txt, examples/fabric/fp8_distributed_transformer/train.py, tests/tests_fabric/conftest.py, tests/tests_fabric/strategies/test_model_parallel_integration.py, tests/run_standalone_tests.sh.


Thank you for your contribution! 💜

Note
This comment is automatically generated and updates for 60 minutes every 180 seconds. If you have any other questions, contact carmocca for help.

@lantiga lantiga force-pushed the luca/fp8-fsdp2-compile-examples branch from 1cf53e6 to 55a6fde Compare November 25, 2024 23:36
@github-actions github-actions bot added the docs Documentation related label Nov 25, 2024
@lantiga lantiga changed the title Minimal FP8 + FSDP2 + compile examples for PyTorch Lightning and Fabric FP8 + FSDP2 + torch.compile examples for PyTorch Lightning and Fabric Nov 25, 2024
Copy link

codecov bot commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88%. Comparing base (8ce5287) to head (71a4b97).
Report is 8 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #20440   +/-   ##
=======================================
  Coverage      88%      88%           
=======================================
  Files         267      267           
  Lines       23203    23274   +71     
=======================================
+ Hits        20313    20381   +68     
- Misses       2890     2893    +3     

@lantiga
Copy link
Collaborator Author

lantiga commented Nov 26, 2024

Investigating CI failures in isolation, the same code succeeds when running standalone but something's up.

@lantiga
Copy link
Collaborator Author

lantiga commented Nov 26, 2024

Also, updates to docs at https://lightning.ai/docs/pytorch/stable/advanced/model_parallel/ will be coming as a follow up

Copy link
Member

@Borda Borda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think would be easier and more robust to refer the examples directly in docs and not copy the code which maybe yield in accidently updating only one of them...

@mergify mergify bot added the ready PRs ready to be merged label Nov 26, 2024
@lantiga
Copy link
Collaborator Author

lantiga commented Nov 26, 2024

I think would be easier and more robust to refer the examples directly in docs and not copy the code which maybe yield in accidently updating only one of them...

That's fair, will code examples expand on the page?

Also, docs skip the torch ao part, since it's an optional / cutting-edge dependency (it depends on triton nightly) so it only appears in the examples

@lantiga
Copy link
Collaborator Author

lantiga commented Nov 26, 2024

Ok CI has been fixed. Merging, the only failing tests are doc links to master (which don't exist yet until this is merged).

@lantiga lantiga merged commit 87565cb into master Nov 26, 2024
70 of 72 checks passed
@lantiga lantiga deleted the luca/fp8-fsdp2-compile-examples branch November 26, 2024 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distributed Generic distributed-related topic docs Documentation related fabric lightning.fabric.Fabric pl Generic label for PyTorch Lightning package ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants