Skip to content

Commit

Permalink
Refactor PL examples to examples/pytorch/ (#16925)
Browse files Browse the repository at this point in the history
Co-authored-by: awaelchli <aedu.waelchli@gmail.com>
  • Loading branch information
aniketmaurya and awaelchli authored Mar 7, 2023
1 parent b6c693d commit da572d7
Show file tree
Hide file tree
Showing 26 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .azure/gpu-tests-pytorch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ pr:
- ".actions/**"
- ".azure/gpu-tests-pytorch.yml"
- "examples/run_pl_examples.sh"
- "examples/pl_basics/backbone_image_classifier.py"
- "examples/pl_basics/autoencoder.py"
- "examples/pytorch/basics/backbone_image_classifier.py"
- "examples/pytorch/basics/autoencoder.py"
- "requirements/pytorch/**"
- "src/lightning/__about__.py"
- "src/lightning/__init__.py"
Expand Down Expand Up @@ -158,7 +158,7 @@ jobs:
python .actions/assistant.py copy_replace_imports --source_dir="./tests/tests_pytorch" \
--source_import="lightning.fabric,lightning.pytorch" \
--target_import="lightning_fabric,pytorch_lightning"
python .actions/assistant.py copy_replace_imports --source_dir="./examples/pl_basics" \
python .actions/assistant.py copy_replace_imports --source_dir="./examples/pytorch/basics" \
--source_import="lightning.fabric,lightning.pytorch" \
--target_import="lightning_fabric,pytorch_lightning"
condition: eq(variables['PACKAGE_NAME'], 'pytorch')
Expand Down
6 changes: 3 additions & 3 deletions .azure/hpu-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pr:
include:
- ".actions/**"
- ".azure/hpu-tests.yml"
- "examples/pl_hpu/mnist_sample.py"
- "examples/pytorch/hpu/mnist_sample.py"
- "requirements/fabric/**"
- "src/lightning/__about__.py"
- "src/lightning/__init__.py"
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
python .actions/assistant.py copy_replace_imports --source_dir="./tests/tests_pytorch" \
--source_import="lightning.fabric,lightning.pytorch" \
--target_import="lightning_fabric,pytorch_lightning"
python .actions/assistant.py copy_replace_imports --source_dir="./examples/pl_hpu" \
python .actions/assistant.py copy_replace_imports --source_dir="./examples/pytorch/hpu" \
--source_import="lightning.fabric,lightning.pytorch" \
--target_import="lightning_fabric,pytorch_lightning"
displayName: 'Adjust tests & examples'
Expand All @@ -117,7 +117,7 @@ jobs:
- bash: |
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
python "pl_hpu/mnist_sample.py"
python "pytorch/hpu/mnist_sample.py"
workingDirectory: examples
displayName: 'Testing: HPU examples'
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/1_bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ body:
label: How to reproduce the bug
description: >
Provide steps and example code here.
You can also paste a link to Google Colab (see our [Colab bug report template](https://colab.research.google.com/github/Lightning-AI/lightning/blob/master/examples/pl_bug_report/bug_report_model.ipynb)) or adapt this minimal [snippet](https://github.com/Lightning-AI/lightning/blob/master/examples/pl_bug_report/bug_report_model.py).
You can also paste a link to Google Colab (see our [Colab bug report template](https://colab.research.google.com/github/Lightning-AI/lightning/blob/master/examples/pytorch/bug_report/bug_report_model.ipynb)) or adapt this minimal [snippet](https://github.com/Lightning-AI/lightning/blob/master/examples/pytorch/bug_report/bug_report_model.py).
placeholder: |
```python
# Sample code to reproduce the problem
Expand Down
6 changes: 3 additions & 3 deletions .github/checkgroup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ subprojects:
# only the azure GPU workflow runs the examples
# all examples don't need to be added because they aren't used in CI, but these are
- "examples/run_pl_examples.sh"
- "examples/pl_basics/backbone_image_classifier.py"
- "examples/pl_basics/autoencoder.py"
- "examples/pytorch/basics/backbone_image_classifier.py"
- "examples/pytorch/basics/autoencoder.py"
- "requirements/pytorch/**"
- "src/lightning/__about__.py"
- "src/lightning/__init__.py"
Expand Down Expand Up @@ -83,7 +83,7 @@ subprojects:
paths:
- ".actions/**"
- ".azure/hpu-tests.yml"
- "examples/pl_hpu/mnist_sample.py"
- "examples/pytorch/hpu/mnist_sample.py"
- "requirements/fabric/**"
- "src/lightning/__about__.py"
- "src/lightning/__init__.py"
Expand Down
2 changes: 1 addition & 1 deletion docs/source-pytorch/accelerators/hpu_intermediate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ This enables advanced users to provide their own BF16 and FP32 operator list ins
accelerator="hpu",
devices=1,
# Optional Habana mixed precision params to be set
# Checkout `examples/pl_hpu/ops_bf16_mnist.txt` for the format
# Checkout `examples/pytorch/hpu/ops_bf16_mnist.txt` for the format
plugins=[
HPUPrecisionPlugin(
precision=16,
Expand Down
2 changes: 1 addition & 1 deletion docs/source-pytorch/accelerators/ipu_basic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Known limitations

Currently there are some known limitations that are being addressed in the near future to make the experience seamless when moving from different devices.

Please see the `MNIST example <https://github.com/Lightning-AI/lightning/blob/master/examples/pl_ipu/mnist_sample.py>`__ which displays most of the limitations and how to overcome them till they are resolved.
Please see the `MNIST example <https://github.com/Lightning-AI/lightning/blob/master/examples/pytorch/ipu/mnist_sample.py>`__ which displays most of the limitations and how to overcome them till they are resolved.

* ``self.log`` is not supported in the ``training_step``, ``validation_step``, ``test_step`` or ``predict_step``. This is due to the step function being traced and sent to the IPU devices. We're actively working on fixing this.
* Multiple optimizers are not supported. ``training_step`` only supports returning one loss from the ``training_step`` function as a result.
Expand Down
2 changes: 1 addition & 1 deletion docs/source-pytorch/deploy/production_advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ In order to do so, your LightningModule needs to subclass the :class:`~lightning

Below you can find an example of how the serving of a resnet18 can be validated.

.. literalinclude:: ../../../examples/pl_servable_module/production.py
.. literalinclude:: ../../../examples/pytorch/servable_module/production.py
4 changes: 2 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ ______________________________________________________________________

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).
- [Autoencoder](pl_basics/autoencoder.py)
- [Image Classifier](pytorch/basics/backbone_image_classifier.py) (trains arbitrary datasets with arbitrary backbones).
- [Autoencoder](pytorch/basics/autoencoder.py)

______________________________________________________________________

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions examples/run_pl_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ args="
--optimizer=Adam
"

python "${dir_path}/pl_basics/backbone_image_classifier.py" ${args} "$@"
python "${dir_path}/pl_basics/autoencoder.py" ${args} "$@"
python "${dir_path}/pytorch/basics/backbone_image_classifier.py" ${args} "$@"
python "${dir_path}/pytorch/basics/autoencoder.py" ${args} "$@"


# test that a user can manually launch individual processes
args="--trainer.devices 2 --trainer.strategy ddp --trainer.max_epochs=1 --trainer.limit_train_batches=1 --trainer.limit_val_batches=1 --trainer.limit_test_batches=1"
MASTER_ADDR="localhost" MASTER_PORT=1234 LOCAL_RANK=1 python "${dir_path}/pl_basics/autoencoder.py" ${args} &
MASTER_ADDR="localhost" MASTER_PORT=1234 LOCAL_RANK=0 python "${dir_path}/pl_basics/autoencoder.py" ${args}
MASTER_ADDR="localhost" MASTER_PORT=1234 LOCAL_RANK=1 python "${dir_path}/pytorch/basics/autoencoder.py" ${args} &
MASTER_ADDR="localhost" MASTER_PORT=1234 LOCAL_RANK=0 python "${dir_path}/pytorch/basics/autoencoder.py" ${args}

0 comments on commit da572d7

Please sign in to comment.