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

Introduce new precision layout in PL #16783

Merged
merged 29 commits into from Feb 17, 2023
Merged

Introduce new precision layout in PL #16783

merged 29 commits into from Feb 17, 2023

Conversation

justusschock
Copy link
Member

@justusschock justusschock commented Feb 16, 2023

What does this PR do?

Adds the new precision inputs from #16767 to PL.
From now on, the plugins and strategies internally only care about the new values ('64-true', '32-true', '16-mixed', 'bf16-mixed') while the connector translates all other supported values (64, '64', 32, '32', 16, '16', 'bf16') to these values and raises a warning for the mixed precision ones accordingly.

Fixes #9956

There will be a follow-up PR to re-enable testing the external colossal-ai strategy once these changes are reflected and released within this strategy.

Before submitting
  • Was this discussed/agreed via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you list all the breaking changes introduced by this pull request?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or minor internal changes/refactors)

PR review

Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:

Reviewer checklist
  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

cc @Borda @carmocca @justusschock @awaelchli

@github-actions github-actions bot added app Generic label for Lightning App package fabric lightning.fabric.Fabric pl Generic label for PyTorch Lightning package labels Feb 16, 2023
@justusschock justusschock changed the title adapt precision in fabric Introduce new precision layout in PL Feb 16, 2023
@justusschock justusschock changed the base branch from master to 2.0/precision February 16, 2023 15:07
@github-actions github-actions bot removed the fabric lightning.fabric.Fabric label Feb 16, 2023
Base automatically changed from 2.0/precision to master February 17, 2023 10:41
@justusschock justusschock changed the title Introduce new precision layout in PL [WIP] Introduce new precision layout in PL Feb 17, 2023
@justusschock justusschock marked this pull request as ready for review February 17, 2023 10:46
@justusschock justusschock added precision: double Double precision precision: amp Automatic Mixed Precision labels Feb 17, 2023
@justusschock justusschock added this to the 2.0 milestone Feb 17, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Feb 17, 2023

⚡ Required checks status: All passing 🟢

Groups summary

🟢 pytorch_lightning: Tests workflow
Check ID Status
pl-cpu (macOS-11, lightning, 3.8, 1.11) success
pl-cpu (macOS-11, lightning, 3.9, 1.12) success
pl-cpu (macOS-11, lightning, 3.10, 1.13) success
pl-cpu (macOS-11, lightning, 3.8, 1.11, oldest) success
pl-cpu (ubuntu-20.04, lightning, 3.9, 1.11) success
pl-cpu (ubuntu-20.04, lightning, 3.10, 1.12) success
pl-cpu (ubuntu-20.04, lightning, 3.10, 1.13) success
pl-cpu (ubuntu-20.04, lightning, 3.8, 1.11, oldest) success
pl-cpu (windows-2022, lightning, 3.9, 1.11) success
pl-cpu (windows-2022, lightning, 3.10, 1.12) success
pl-cpu (windows-2022, lightning, 3.10, 1.13) success
pl-cpu (windows-2022, lightning, 3.8, 1.11, oldest) success
pl-cpu (macOS-11, pytorch, 3.8, 1.13) success
pl-cpu (ubuntu-20.04, pytorch, 3.8, 1.13) success
pl-cpu (windows-2022, pytorch, 3.8, 1.13) success

These checks are required after the changes to src/lightning/pytorch/plugins/precision/amp.py, src/lightning/pytorch/plugins/precision/deepspeed.py, src/lightning/pytorch/plugins/precision/double.py, src/lightning/pytorch/plugins/precision/fsdp.py, src/lightning/pytorch/plugins/precision/hpu.py, src/lightning/pytorch/plugins/precision/ipu.py, src/lightning/pytorch/plugins/precision/tpu_bf16.py, src/lightning/pytorch/strategies/deepspeed.py, src/lightning/pytorch/strategies/fsdp.py, src/lightning/pytorch/strategies/utils.py, src/lightning/pytorch/trainer/connectors/accelerator_connector.py, src/lightning/pytorch/trainer/trainer.py, tests/tests_pytorch/accelerators/test_hpu.py, tests/tests_pytorch/accelerators/test_ipu.py, tests/tests_pytorch/checkpointing/test_legacy_checkpoints.py, tests/tests_pytorch/helpers/deterministic_model.py, tests/tests_pytorch/models/test_amp.py, tests/tests_pytorch/models/test_ddp_fork_amp.py, tests/tests_pytorch/models/test_hooks.py, tests/tests_pytorch/models/test_tpu.py, tests/tests_pytorch/plugins/precision/hpu/test_hpu.py, tests/tests_pytorch/plugins/precision/test_amp.py, tests/tests_pytorch/plugins/precision/test_amp_integration.py, tests/tests_pytorch/plugins/precision/test_deepspeed_precision.py, tests/tests_pytorch/plugins/test_amp_plugins.py, tests/tests_pytorch/plugins/test_double_plugin.py, tests/tests_pytorch/strategies/test_ddp.py, tests/tests_pytorch/strategies/test_deepspeed_strategy.py, tests/tests_pytorch/strategies/test_fsdp.py, tests/tests_pytorch/strategies/test_registry.py, tests/tests_pytorch/trainer/connectors/test_accelerator_connector.py, tests/tests_pytorch/trainer/optimization/test_manual_optimization.py, tests/tests_pytorch/trainer/test_trainer.py, tests/tests_pytorch/tuner/test_scale_batch_size.py, tests/tests_pytorch/utilities/test_deepspeed_collate_checkpoint.py, tests/tests_pytorch/utilities/test_deepspeed_model_summary.py, tests/tests_pytorch/utilities/test_torchdistx.py.

🟢 pytorch_lightning: Azure GPU
Check ID Status
pytorch-lightning (GPUs) success

These checks are required after the changes to src/lightning/pytorch/plugins/precision/amp.py, src/lightning/pytorch/plugins/precision/deepspeed.py, src/lightning/pytorch/plugins/precision/double.py, src/lightning/pytorch/plugins/precision/fsdp.py, src/lightning/pytorch/plugins/precision/hpu.py, src/lightning/pytorch/plugins/precision/ipu.py, src/lightning/pytorch/plugins/precision/tpu_bf16.py, src/lightning/pytorch/strategies/deepspeed.py, src/lightning/pytorch/strategies/fsdp.py, src/lightning/pytorch/strategies/utils.py, src/lightning/pytorch/trainer/connectors/accelerator_connector.py, src/lightning/pytorch/trainer/trainer.py, tests/tests_pytorch/accelerators/test_hpu.py, tests/tests_pytorch/accelerators/test_ipu.py, tests/tests_pytorch/checkpointing/test_legacy_checkpoints.py, tests/tests_pytorch/helpers/deterministic_model.py, tests/tests_pytorch/models/test_amp.py, tests/tests_pytorch/models/test_ddp_fork_amp.py, tests/tests_pytorch/models/test_hooks.py, tests/tests_pytorch/models/test_tpu.py, tests/tests_pytorch/plugins/precision/hpu/test_hpu.py, tests/tests_pytorch/plugins/precision/test_amp.py, tests/tests_pytorch/plugins/precision/test_amp_integration.py, tests/tests_pytorch/plugins/precision/test_deepspeed_precision.py, tests/tests_pytorch/plugins/test_amp_plugins.py, tests/tests_pytorch/plugins/test_double_plugin.py, tests/tests_pytorch/strategies/test_ddp.py, tests/tests_pytorch/strategies/test_deepspeed_strategy.py, tests/tests_pytorch/strategies/test_fsdp.py, tests/tests_pytorch/strategies/test_registry.py, tests/tests_pytorch/trainer/connectors/test_accelerator_connector.py, tests/tests_pytorch/trainer/optimization/test_manual_optimization.py, tests/tests_pytorch/trainer/test_trainer.py, tests/tests_pytorch/tuner/test_scale_batch_size.py, tests/tests_pytorch/utilities/test_deepspeed_collate_checkpoint.py, tests/tests_pytorch/utilities/test_deepspeed_model_summary.py, tests/tests_pytorch/utilities/test_torchdistx.py.

🟢 pytorch_lightning: Azure HPU
Check ID Status
pytorch-lightning (HPUs) success

These checks are required after the changes to examples/pl_hpu/mnist_sample.py, src/lightning/pytorch/plugins/precision/amp.py, src/lightning/pytorch/plugins/precision/deepspeed.py, src/lightning/pytorch/plugins/precision/double.py, src/lightning/pytorch/plugins/precision/fsdp.py, src/lightning/pytorch/plugins/precision/hpu.py, src/lightning/pytorch/plugins/precision/ipu.py, src/lightning/pytorch/plugins/precision/tpu_bf16.py, src/lightning/pytorch/strategies/deepspeed.py, src/lightning/pytorch/strategies/fsdp.py, src/lightning/pytorch/strategies/utils.py, src/lightning/pytorch/trainer/connectors/accelerator_connector.py, src/lightning/pytorch/trainer/trainer.py, tests/tests_pytorch/accelerators/test_hpu.py, tests/tests_pytorch/accelerators/test_ipu.py, tests/tests_pytorch/checkpointing/test_legacy_checkpoints.py, tests/tests_pytorch/helpers/deterministic_model.py, tests/tests_pytorch/models/test_amp.py, tests/tests_pytorch/models/test_ddp_fork_amp.py, tests/tests_pytorch/models/test_hooks.py, tests/tests_pytorch/models/test_tpu.py, tests/tests_pytorch/plugins/precision/hpu/test_hpu.py, tests/tests_pytorch/plugins/precision/test_amp.py, tests/tests_pytorch/plugins/precision/test_amp_integration.py, tests/tests_pytorch/plugins/precision/test_deepspeed_precision.py, tests/tests_pytorch/plugins/test_amp_plugins.py, tests/tests_pytorch/plugins/test_double_plugin.py, tests/tests_pytorch/strategies/test_ddp.py, tests/tests_pytorch/strategies/test_deepspeed_strategy.py, tests/tests_pytorch/strategies/test_fsdp.py, tests/tests_pytorch/strategies/test_registry.py, tests/tests_pytorch/trainer/connectors/test_accelerator_connector.py, tests/tests_pytorch/trainer/optimization/test_manual_optimization.py, tests/tests_pytorch/trainer/test_trainer.py, tests/tests_pytorch/tuner/test_scale_batch_size.py, tests/tests_pytorch/utilities/test_deepspeed_collate_checkpoint.py, tests/tests_pytorch/utilities/test_deepspeed_model_summary.py, tests/tests_pytorch/utilities/test_torchdistx.py.

🟢 pytorch_lightning: Azure IPU
Check ID Status
pytorch-lightning (IPUs) success

These checks are required after the changes to src/lightning/pytorch/plugins/precision/amp.py, src/lightning/pytorch/plugins/precision/deepspeed.py, src/lightning/pytorch/plugins/precision/double.py, src/lightning/pytorch/plugins/precision/fsdp.py, src/lightning/pytorch/plugins/precision/hpu.py, src/lightning/pytorch/plugins/precision/ipu.py, src/lightning/pytorch/plugins/precision/tpu_bf16.py, src/lightning/pytorch/strategies/deepspeed.py, src/lightning/pytorch/strategies/fsdp.py, src/lightning/pytorch/strategies/utils.py, src/lightning/pytorch/trainer/connectors/accelerator_connector.py, src/lightning/pytorch/trainer/trainer.py, tests/tests_pytorch/accelerators/test_hpu.py, tests/tests_pytorch/accelerators/test_ipu.py, tests/tests_pytorch/checkpointing/test_legacy_checkpoints.py, tests/tests_pytorch/helpers/deterministic_model.py, tests/tests_pytorch/models/test_amp.py, tests/tests_pytorch/models/test_ddp_fork_amp.py, tests/tests_pytorch/models/test_hooks.py, tests/tests_pytorch/models/test_tpu.py, tests/tests_pytorch/plugins/precision/hpu/test_hpu.py, tests/tests_pytorch/plugins/precision/test_amp.py, tests/tests_pytorch/plugins/precision/test_amp_integration.py, tests/tests_pytorch/plugins/precision/test_deepspeed_precision.py, tests/tests_pytorch/plugins/test_amp_plugins.py, tests/tests_pytorch/plugins/test_double_plugin.py, tests/tests_pytorch/strategies/test_ddp.py, tests/tests_pytorch/strategies/test_deepspeed_strategy.py, tests/tests_pytorch/strategies/test_fsdp.py, tests/tests_pytorch/strategies/test_registry.py, tests/tests_pytorch/trainer/connectors/test_accelerator_connector.py, tests/tests_pytorch/trainer/optimization/test_manual_optimization.py, tests/tests_pytorch/trainer/test_trainer.py, tests/tests_pytorch/tuner/test_scale_batch_size.py, tests/tests_pytorch/utilities/test_deepspeed_collate_checkpoint.py, tests/tests_pytorch/utilities/test_deepspeed_model_summary.py, tests/tests_pytorch/utilities/test_torchdistx.py.

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

These checks are required after the changes to src/lightning/pytorch/plugins/precision/amp.py, src/lightning/pytorch/plugins/precision/deepspeed.py, src/lightning/pytorch/plugins/precision/double.py, src/lightning/pytorch/plugins/precision/fsdp.py, src/lightning/pytorch/plugins/precision/hpu.py, src/lightning/pytorch/plugins/precision/ipu.py, src/lightning/pytorch/plugins/precision/tpu_bf16.py, src/lightning/pytorch/strategies/deepspeed.py, src/lightning/pytorch/strategies/fsdp.py, src/lightning/pytorch/strategies/utils.py, src/lightning/pytorch/trainer/connectors/accelerator_connector.py, src/lightning/pytorch/trainer/trainer.py, docs/source-pytorch/common/precision_basic.rst, docs/source-pytorch/common/precision_expert.rst, docs/source-pytorch/common/precision_intermediate.rst, docs/source-pytorch/common/trainer.rst, docs/source-pytorch/fabric/fundamentals/launch.rst.

🟢 lightning_app: Examples
Check ID Status
app-examples (macOS-11, lightning, 3.9, latest) success
app-examples (macOS-11, lightning, 3.9, oldest) success
app-examples (macOS-11, app, 3.9, latest) success
app-examples (ubuntu-20.04, lightning, 3.9, latest) success
app-examples (ubuntu-20.04, lightning, 3.9, oldest) success
app-examples (ubuntu-20.04, app, 3.9, latest) success
app-examples (windows-2022, lightning, 3.9, latest) success
app-examples (windows-2022, lightning, 3.9, oldest) success
app-examples (windows-2022, app, 3.9, latest) success

These checks are required after the changes to examples/app_multi_node/train_fabric.py.

🟢 mypy
Check ID Status
mypy success

These checks are required after the changes to src/lightning/pytorch/plugins/precision/amp.py, src/lightning/pytorch/plugins/precision/deepspeed.py, src/lightning/pytorch/plugins/precision/double.py, src/lightning/pytorch/plugins/precision/fsdp.py, src/lightning/pytorch/plugins/precision/hpu.py, src/lightning/pytorch/plugins/precision/ipu.py, src/lightning/pytorch/plugins/precision/tpu_bf16.py, src/lightning/pytorch/strategies/deepspeed.py, src/lightning/pytorch/strategies/fsdp.py, src/lightning/pytorch/strategies/utils.py, src/lightning/pytorch/trainer/connectors/accelerator_connector.py, src/lightning/pytorch/trainer/trainer.py.

🟢 install
Check ID Status
install-pkg (ubuntu-22.04, app, 3.8) success
install-pkg (ubuntu-22.04, app, 3.10) success
install-pkg (ubuntu-22.04, fabric, 3.8) success
install-pkg (ubuntu-22.04, fabric, 3.10) success
install-pkg (ubuntu-22.04, pytorch, 3.8) success
install-pkg (ubuntu-22.04, pytorch, 3.10) success
install-pkg (ubuntu-22.04, lightning, 3.8) success
install-pkg (ubuntu-22.04, lightning, 3.10) success
install-pkg (ubuntu-22.04, notset, 3.8) success
install-pkg (ubuntu-22.04, notset, 3.10) success
install-pkg (macOS-12, app, 3.8) success
install-pkg (macOS-12, app, 3.10) success
install-pkg (macOS-12, fabric, 3.8) success
install-pkg (macOS-12, fabric, 3.10) success
install-pkg (macOS-12, pytorch, 3.8) success
install-pkg (macOS-12, pytorch, 3.10) success
install-pkg (macOS-12, lightning, 3.8) success
install-pkg (macOS-12, lightning, 3.10) success
install-pkg (macOS-12, notset, 3.8) success
install-pkg (macOS-12, notset, 3.10) success
install-pkg (windows-2022, app, 3.8) success
install-pkg (windows-2022, app, 3.10) success
install-pkg (windows-2022, fabric, 3.8) success
install-pkg (windows-2022, fabric, 3.10) success
install-pkg (windows-2022, pytorch, 3.8) success
install-pkg (windows-2022, pytorch, 3.10) success
install-pkg (windows-2022, lightning, 3.8) success
install-pkg (windows-2022, lightning, 3.10) success
install-pkg (windows-2022, notset, 3.8) success
install-pkg (windows-2022, notset, 3.10) success

These checks are required after the changes to src/lightning/pytorch/plugins/precision/amp.py, src/lightning/pytorch/plugins/precision/deepspeed.py, src/lightning/pytorch/plugins/precision/double.py, src/lightning/pytorch/plugins/precision/fsdp.py, src/lightning/pytorch/plugins/precision/hpu.py, src/lightning/pytorch/plugins/precision/ipu.py, src/lightning/pytorch/plugins/precision/tpu_bf16.py, src/lightning/pytorch/strategies/deepspeed.py, src/lightning/pytorch/strategies/fsdp.py, src/lightning/pytorch/strategies/utils.py, src/lightning/pytorch/trainer/connectors/accelerator_connector.py, src/lightning/pytorch/trainer/trainer.py.

🟢 link-check
Check ID Status
markdown-link-check success

These checks are required after the changes to src/lightning/pytorch/CHANGELOG.md.


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.

@codecov
Copy link

codecov bot commented Feb 17, 2023

Codecov Report

Merging #16783 (9cfbc24) into master (7f92d5c) will decrease coverage by 16%.
The diff coverage is 77%.

Additional details and impacted files
@@            Coverage Diff            @@
##           master   #16783     +/-   ##
=========================================
- Coverage      82%      65%    -16%     
=========================================
  Files         441      421     -20     
  Lines       31692    31472    -220     
=========================================
- Hits        25879    20563   -5316     
- Misses       5813    10909   +5096     

@github-actions github-actions bot removed the fabric lightning.fabric.Fabric label Feb 17, 2023
@@ -839,6 +841,7 @@ def get_defaults(cls):

@RunIf(min_cuda_gpus=1) # trigger this test on our GPU pipeline, because we don't install the package on the CPU suite
@pytest.mark.skipif(not package_available("lightning_colossalai"), reason="Requires Colossal AI Strategy")
@pytest.mark.skip
Copy link
Member Author

Choose a reason for hiding this comment

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

This is skipped here, since the validation for the precision argument is hardcoded in https://github.com/Lightning-AI/lightning-colossalai . I tried to first change it there, but these changes won't become effective until the strategy was released to pypi again.

After this was merged, I will post a follow-up PR in https://github.com/Lightning-AI/lightning-colossalai which will then be released and then have a follow-up PR to again add this test.

Discussed offline with @awaelchli

@justusschock justusschock changed the title [WIP] Introduce new precision layout in PL Introduce new precision layout in PL Feb 17, 2023
Copy link
Member

@carmocca carmocca left a comment

Choose a reason for hiding this comment

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

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app Generic label for Lightning App package pl Generic label for PyTorch Lightning package precision: amp Automatic Mixed Precision precision: double Double precision ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is precision="mixed" redundant?
3 participants