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

Update Lightning Lite examples #15599

Merged
merged 12 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion .azure/gpu-tests-lite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pr:
- "release/*"
paths:
include:
- "examples/lite/**"
- "examples/run_lite_examples.sh"
- ".azure/gpu-tests-lite.yml"
- "requirements/lite/**"
- "src/lightning_lite/**"
Expand Down Expand Up @@ -64,7 +66,7 @@ jobs:
- bash: |
set -e
CUDA_VERSION_MM=$(python -c "import torch ; print(''.join(map(str, torch.version.cuda.split('.')[:2])))")
pip install -e .[dev,strategies] --find-links https://download.pytorch.org/whl/cu${CUDA_VERSION_MM}/torch_stable.html
pip install -e .[dev,strategies,examples] --find-links https://download.pytorch.org/whl/cu${CUDA_VERSION_MM}/torch_stable.html
pip list
env:
PACKAGE_NAME: "lite"
Expand Down Expand Up @@ -108,3 +110,12 @@ jobs:
testResultsFiles: '$(Build.StagingDirectory)/test-results.xml'
testRunTitle: '$(Agent.OS) - $(Build.DefinitionName) - Python $(python.version)'
condition: succeededOrFailed()

- script: |
# In order to run the examples, we need to substitute the meta package imports with the standalone package
python ../.actions/assistant.py copy_replace_imports --source_dir="./lite" --source_import="lightning.lite" --target_import="lightning_lite.lite"
set -e
bash run_lite_examples.sh --accelerator=cuda --devices=1
bash run_lite_examples.sh --accelerator=cuda --devices=2 --strategy ddp
workingDirectory: examples
displayName: 'Testing: Lite examples'
4 changes: 0 additions & 4 deletions .azure/gpu-tests-pytorch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@ pr:
paths:
include:
- ".azure/gpu-tests-pytorch.yml"
- "examples/run_ddp_examples.sh"
- "examples/convert_from_pt_to_pl/**"
- "examples/run_pl_examples.sh"
- "examples/pl_basics/backbone_image_classifier.py"
- "examples/pl_basics/autoencoder.py"
- "examples/pl_loops/mnist_lite.py"
- "examples/pl_fault_tolerant/automatic.py"
- "examples/test_pl_examples.py"
- "examples/pl_integrations/dali_image_classifier.py"
Expand Down Expand Up @@ -169,7 +166,6 @@ jobs:

- script: |
set -e
bash run_ddp_examples.sh
bash run_pl_examples.sh --trainer.accelerator=gpu --trainer.devices=1
bash run_pl_examples.sh --trainer.accelerator=gpu --trainer.devices=2 --trainer.strategy=ddp
bash run_pl_examples.sh --trainer.accelerator=gpu --trainer.devices=2 --trainer.strategy=ddp --trainer.precision=16
Expand Down
5 changes: 2 additions & 3 deletions .github/checkgroup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ subprojects:
- id: "pytorch_lightning"
paths:
# all examples don't need to be added because they aren't used in CI, but these are
- "examples/run_ddp_examples.sh"
- "examples/convert_from_pt_to_pl/**"
- "examples/run_pl_examples.sh"
- "examples/pl_basics/backbone_image_classifier.py"
- "examples/pl_basics/autoencoder.py"
- "examples/pl_loops/mnist_lite.py"
- "examples/pl_fault_tolerant/automatic.py"
- "examples/test_pl_examples.py"
- "examples/pl_integrations/dali_image_classifier.py"
Expand Down Expand Up @@ -212,6 +209,8 @@ subprojects:

- id: "lightning_lite: Tests"
paths:
- "examples/lite/**"
- "examples/run_lite_examples.sh"
awaelchli marked this conversation as resolved.
Show resolved Hide resolved
- "tests/tests_lite/**"
checks:
- "lite-cpu (macOS-11, lite, 3.9, 1.11)"
Expand Down
18 changes: 7 additions & 11 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,19 @@ ______________________________________________________________________

______________________________________________________________________

## MNIST Examples
## Lightning Lite Examples

5 MNIST examples showing how to gradually convert from pure PyTorch to PyTorch Lightning.
We show how to accelerate your PyTorch code with [Lightning Lite](https://pytorch-lightning.readthedocs.io/en/latest/starter/lightning_lite.html) with minimal code changes.
You stay in full control of the training loop.

The transition through [LightningLite](https://pytorch-lightning.readthedocs.io/en/latest/starter/lightning_lite.html) from pure PyTorch is optional, but it might be helpful to learn about it.

- [MNIST with vanilla PyTorch](convert_from_pt_to_pl/image_classifier_1_pytorch.py)
- [MNIST with LightningLite](convert_from_pt_to_pl/image_classifier_2_lite.py)
- [MNIST LightningLite to LightningModule](convert_from_pt_to_pl/image_classifier_3_lite_to_lightning_module.py)
- [MNIST with LightningModule](convert_from_pt_to_pl/image_classifier_4_lightning_module.py)
- [MNIST with LightningModule + LightningDataModule](convert_from_pt_to_pl/image_classifier_5_lightning_datamodule.py)
- [MNIST with vanilla PyTorch](lite/image_classifier_1_pytorch.py)
- [MNIST with Lightning Lite](lite/image_classifier_2_lite.py)

______________________________________________________________________

## Basic Examples
## Lightning Trainer Examples

In this folder, we have 2 simple examples:
In this folder, we have 2 simple examples that showcase the power of the Lightning Trainer.

- [Image Classifier](pl_basics/backbone_image_classifier.py) (trains arbitrary datasets with arbitrary backbones).
- [Image Classifier + DALI](convert_from_pt_to_pl/image_classifier_4_dali.py) (defines the model inside the `LightningModule`).
Expand Down
67 changes: 0 additions & 67 deletions examples/convert_from_pt_to_pl/README.md

This file was deleted.

164 changes: 0 additions & 164 deletions examples/convert_from_pt_to_pl/image_classifier_2_lite.py

This file was deleted.