Skip to content

Commit da572d7

Browse files
Refactor PL examples to examples/pytorch/ (#16925)
Co-authored-by: awaelchli <[email protected]>
1 parent b6c693d commit da572d7

26 files changed

+19
-19
lines changed

.azure/gpu-tests-pytorch.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ pr:
2323
- ".actions/**"
2424
- ".azure/gpu-tests-pytorch.yml"
2525
- "examples/run_pl_examples.sh"
26-
- "examples/pl_basics/backbone_image_classifier.py"
27-
- "examples/pl_basics/autoencoder.py"
26+
- "examples/pytorch/basics/backbone_image_classifier.py"
27+
- "examples/pytorch/basics/autoencoder.py"
2828
- "requirements/pytorch/**"
2929
- "src/lightning/__about__.py"
3030
- "src/lightning/__init__.py"
@@ -158,7 +158,7 @@ jobs:
158158
python .actions/assistant.py copy_replace_imports --source_dir="./tests/tests_pytorch" \
159159
--source_import="lightning.fabric,lightning.pytorch" \
160160
--target_import="lightning_fabric,pytorch_lightning"
161-
python .actions/assistant.py copy_replace_imports --source_dir="./examples/pl_basics" \
161+
python .actions/assistant.py copy_replace_imports --source_dir="./examples/pytorch/basics" \
162162
--source_import="lightning.fabric,lightning.pytorch" \
163163
--target_import="lightning_fabric,pytorch_lightning"
164164
condition: eq(variables['PACKAGE_NAME'], 'pytorch')

.azure/hpu-tests.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pr:
1919
include:
2020
- ".actions/**"
2121
- ".azure/hpu-tests.yml"
22-
- "examples/pl_hpu/mnist_sample.py"
22+
- "examples/pytorch/hpu/mnist_sample.py"
2323
- "requirements/fabric/**"
2424
- "src/lightning/__about__.py"
2525
- "src/lightning/__init__.py"
@@ -92,7 +92,7 @@ jobs:
9292
python .actions/assistant.py copy_replace_imports --source_dir="./tests/tests_pytorch" \
9393
--source_import="lightning.fabric,lightning.pytorch" \
9494
--target_import="lightning_fabric,pytorch_lightning"
95-
python .actions/assistant.py copy_replace_imports --source_dir="./examples/pl_hpu" \
95+
python .actions/assistant.py copy_replace_imports --source_dir="./examples/pytorch/hpu" \
9696
--source_import="lightning.fabric,lightning.pytorch" \
9797
--target_import="lightning_fabric,pytorch_lightning"
9898
displayName: 'Adjust tests & examples'
@@ -117,7 +117,7 @@ jobs:
117117
118118
- bash: |
119119
export PYTHONPATH="${PYTHONPATH}:$(pwd)"
120-
python "pl_hpu/mnist_sample.py"
120+
python "pytorch/hpu/mnist_sample.py"
121121
workingDirectory: examples
122122
displayName: 'Testing: HPU examples'
123123

.github/ISSUE_TEMPLATE/1_bug_report.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ body:
3535
label: How to reproduce the bug
3636
description: >
3737
Provide steps and example code here.
38-
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).
38+
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).
3939
placeholder: |
4040
```python
4141
# Sample code to reproduce the problem

.github/checkgroup.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ subprojects:
4646
# only the azure GPU workflow runs the examples
4747
# all examples don't need to be added because they aren't used in CI, but these are
4848
- "examples/run_pl_examples.sh"
49-
- "examples/pl_basics/backbone_image_classifier.py"
50-
- "examples/pl_basics/autoencoder.py"
49+
- "examples/pytorch/basics/backbone_image_classifier.py"
50+
- "examples/pytorch/basics/autoencoder.py"
5151
- "requirements/pytorch/**"
5252
- "src/lightning/__about__.py"
5353
- "src/lightning/__init__.py"
@@ -83,7 +83,7 @@ subprojects:
8383
paths:
8484
- ".actions/**"
8585
- ".azure/hpu-tests.yml"
86-
- "examples/pl_hpu/mnist_sample.py"
86+
- "examples/pytorch/hpu/mnist_sample.py"
8787
- "requirements/fabric/**"
8888
- "src/lightning/__about__.py"
8989
- "src/lightning/__init__.py"

docs/source-pytorch/accelerators/hpu_intermediate.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ This enables advanced users to provide their own BF16 and FP32 operator list ins
4545
accelerator="hpu",
4646
devices=1,
4747
# Optional Habana mixed precision params to be set
48-
# Checkout `examples/pl_hpu/ops_bf16_mnist.txt` for the format
48+
# Checkout `examples/pytorch/hpu/ops_bf16_mnist.txt` for the format
4949
plugins=[
5050
HPUPrecisionPlugin(
5151
precision=16,

docs/source-pytorch/accelerators/ipu_basic.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Known limitations
6363

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

66-
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.
66+
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.
6767

6868
* ``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.
6969
* Multiple optimizers are not supported. ``training_step`` only supports returning one loss from the ``training_step`` function as a result.

docs/source-pytorch/deploy/production_advanced.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,4 @@ In order to do so, your LightningModule needs to subclass the :class:`~lightning
7373

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

76-
.. literalinclude:: ../../../examples/pl_servable_module/production.py
76+
.. literalinclude:: ../../../examples/pytorch/servable_module/production.py

examples/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ ______________________________________________________________________
2525

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

28-
- [Image Classifier](pl_basics/backbone_image_classifier.py) (trains arbitrary datasets with arbitrary backbones).
29-
- [Autoencoder](pl_basics/autoencoder.py)
28+
- [Image Classifier](pytorch/basics/backbone_image_classifier.py) (trains arbitrary datasets with arbitrary backbones).
29+
- [Autoencoder](pytorch/basics/autoencoder.py)
3030

3131
______________________________________________________________________
3232

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

examples/run_pl_examples.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ args="
2626
--optimizer=Adam
2727
"
2828

29-
python "${dir_path}/pl_basics/backbone_image_classifier.py" ${args} "$@"
30-
python "${dir_path}/pl_basics/autoencoder.py" ${args} "$@"
29+
python "${dir_path}/pytorch/basics/backbone_image_classifier.py" ${args} "$@"
30+
python "${dir_path}/pytorch/basics/autoencoder.py" ${args} "$@"
3131

3232

3333
# test that a user can manually launch individual processes
3434
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"
35-
MASTER_ADDR="localhost" MASTER_PORT=1234 LOCAL_RANK=1 python "${dir_path}/pl_basics/autoencoder.py" ${args} &
36-
MASTER_ADDR="localhost" MASTER_PORT=1234 LOCAL_RANK=0 python "${dir_path}/pl_basics/autoencoder.py" ${args}
35+
MASTER_ADDR="localhost" MASTER_PORT=1234 LOCAL_RANK=1 python "${dir_path}/pytorch/basics/autoencoder.py" ${args} &
36+
MASTER_ADDR="localhost" MASTER_PORT=1234 LOCAL_RANK=0 python "${dir_path}/pytorch/basics/autoencoder.py" ${args}

0 commit comments

Comments
 (0)