Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .azure/gpu-tests-pytorch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ jobs:
- bash: |
set -e
python requirements/collect_env_details.py
python -c "import torch ; mgpu = torch.cuda.device_count() ; assert mgpu == 2, f'GPU: {mgpu}'"
python -c "import torch ; nb_gpus = torch.cuda.device_count() ; assert nb_gpus == 2, f'GPU: {nb_gpus}'"
python requirements/pytorch/check-avail-extras.py
python -c "import bitsandbytes"
displayName: "Env details"
Expand All @@ -138,10 +138,12 @@ jobs:
displayName: "Testing: PyTorch doctests"

- bash: |
python .actions/assistant.py copy_replace_imports --source_dir="./tests/tests_pytorch" \
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/pytorch/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"
# without succeeded this could run even if the job has already failed
Expand Down Expand Up @@ -183,8 +185,10 @@ jobs:
# https://docs.codecov.com/docs/codecov-uploader
curl -Os https://uploader.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov --token=$(CODECOV_TOKEN) --commit=$(Build.SourceVersion) \
--flags=gpu,pytest,${COVERAGE_SOURCE} --name="GPU-coverage" --env=linux,azure
./codecov --token=$(CODECOV_TOKEN) \
--commit=$(Build.SourceVersion) \
--flags=gpu,pytest,${COVERAGE_SOURCE} \
--name="GPU-coverage" --env=linux,azure
ls -l
workingDirectory: tests/tests_pytorch
displayName: "Statistics"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/_build-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
name: ${{ inputs.artifact-name }}
path: dist
retention-days: ${{ steps.keep-artifact.outputs.DAYS }}
include-hidden-files: true

build-packages:
needs: init
Expand Down Expand Up @@ -66,3 +67,4 @@ jobs:
with:
name: ${{ inputs.artifact-name }}
path: pypi
include-hidden-files: true
3 changes: 2 additions & 1 deletion .github/workflows/_legacy-checkpoints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ jobs:
name: checkpoints-${{ github.sha }}
path: ${{ env.LEGACY_FOLDER }}/checkpoints/
retention-days: ${{ env.KEEP_DAYS }}
include-hidden-files: true

- run: pip install -r requirements/ci.txt
- name: Upload checkpoints to S3
Expand Down Expand Up @@ -138,7 +139,7 @@ jobs:
run: echo ${PL_VERSION} >> back-compatible-versions.txt

- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
uses: peter-evans/create-pull-request@v7
with:
title: Adding test for legacy checkpoint created with ${{ env.PL_VERSION }}
committer: GitHub <[email protected]>
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/call-clear-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ on:
jobs:
cron-clear:
if: github.event_name == 'schedule' || github.event_name == 'pull_request'
uses: Lightning-AI/utilities/.github/workflows/[email protected].6
uses: Lightning-AI/utilities/.github/workflows/[email protected].7
with:
scripts-ref: v0.11.6
scripts-ref: v0.11.7
dry-run: ${{ github.event_name == 'pull_request' }}
pattern: "latest|docs"
age-days: 7

direct-clear:
if: github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request'
uses: Lightning-AI/utilities/.github/workflows/[email protected].6
uses: Lightning-AI/utilities/.github/workflows/[email protected].7
with:
scripts-ref: v0.11.6
scripts-ref: v0.11.7
dry-run: ${{ github.event_name == 'pull_request' }}
pattern: ${{ inputs.pattern || 'pypi_wheels' }} # setting str in case of PR / debugging
age-days: ${{ fromJSON(inputs.age-days) || 0 }} # setting 0 in case of PR / debugging
2 changes: 1 addition & 1 deletion .github/workflows/ci-check-md-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:

jobs:
check-md-links:
uses: Lightning-AI/utilities/.github/workflows/[email protected].6
uses: Lightning-AI/utilities/.github/workflows/[email protected].7
with:
config-file: ".github/markdown-links-config.json"
base-branch: "master"
2 changes: 1 addition & 1 deletion .github/workflows/ci-schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
check:
uses: Lightning-AI/utilities/.github/workflows/[email protected].6
uses: Lightning-AI/utilities/.github/workflows/[email protected].7
with:
# skip azure due to the wrong schema file by MSFT
# https://github.com/Lightning-AI/lightning-flash/pull/1455#issuecomment-1244793607
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/docs-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ jobs:
name: docs-${{ matrix.pkg-name }}-${{ github.sha }}
path: docs/build/html/
retention-days: ${{ env.ARTIFACT_DAYS }}
include-hidden-files: true

#- name: Dump handy wheels
# if: github.event_name == 'push' && github.ref == 'refs/heads/master'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs-tutorials.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:

- name: Create Pull Request
if: ${{ github.event_name != 'pull_request' && env.SHA_ACTUAL != env.SHA_LATEST }}
uses: peter-evans/create-pull-request@v6
uses: peter-evans/create-pull-request@v7
with:
title: "docs: update ref to latest tutorials"
committer: GitHub <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
with:
name: nightly-packages-${{ github.sha }}
path: dist
include-hidden-files: true

publish-packages:
runs-on: ubuntu-22.04
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:

- name: Create Pull Request
if: github.event_name != 'pull_request'
uses: peter-evans/create-pull-request@v6
uses: peter-evans/create-pull-request@v7
with:
title: "Bump lightning ver `${{ env.TAG }}`"
committer: GitHub <[email protected]>
Expand Down
105 changes: 55 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@

**The deep learning framework to pretrain, finetune and deploy AI models.**

**NEW- Lightning 2.0 features a clean and stable API!!**
**NEW- Deploying models? Check out [LitServe](https://github.com/Lightning-AI/litserve), the PyTorch Lightning for model serving**

______________________________________________________________________

<p align="center">
<a href="https://lightning.ai/">Lightning AI</a> •
<a href="#quick-start" style="margin: 0 10px;">Quick start</a> •
<a href="#examples">Examples</a> •
<a href="#pytorch-lightning-train-and-deploy-pytorch-at-scale">PyTorch Lightning</a> •
<a href="#why-pytorch-lightning">PyTorch Lightning</a> •
<a href="#lightning-fabric-expert-control">Fabric</a> •
<a href="https://pytorch-lightning.readthedocs.io/en/stable/">Docs</a> •
<a href="https://lightning.ai/">Lightning AI</a> •
<a href="#community">Community</a> •
<a href="https://lightning.ai/docs/pytorch/stable/generated/CONTRIBUTING.html">Contribute</a>
<a href="https://pytorch-lightning.readthedocs.io/en/stable/">Docs</a>
</p>

<!-- DO NOT ADD CONDA DOWNLOADS... README CHANGES MUST BE APPROVED BY EDEN OR WILL -->
Expand Down Expand Up @@ -53,9 +53,24 @@ ______________________________________________________________________

</div>

## Install Lightning
&nbsp;

# Lightning has 2 core packages

[PyTorch Lightning: Train and deploy PyTorch at scale](#why-pytorch-lightning).
<br/>
[Lightning Fabric: Expert control](#lightning-fabric-expert-control).

Lightning gives you granular control over how much abstraction you want to add over PyTorch.

<div align="center">
<img src="https://pl-public-data.s3.amazonaws.com/assets_lightning/continuum.png" width="80%">
</div>

&nbsp;

Simple installation from PyPI
# Quick start
Install Lightning:

```bash
pip install lightning
Expand All @@ -64,7 +79,7 @@ pip install lightning
<!-- following section will be skipped from PyPI description -->

<details>
<summary>Other installation options</summary>
<summary>Advanced install options</summary>
<!-- following section will be skipped from PyPI description -->

#### Install with optional dependencies
Expand Down Expand Up @@ -104,48 +119,8 @@ pip install -iU https://test.pypi.org/simple/ pytorch-lightning
</details>
<!-- end skipping PyPI description -->

______________________________________________________________________

## Lightning has 2 core packages

[PyTorch Lightning: Train and deploy PyTorch at scale](#pytorch-lightning-train-and-deploy-pytorch-at-scale).
<br/>
[Lightning Fabric: Expert control](#lightning-fabric-expert-control).

Lightning gives you granular control over how much abstraction you want to add over PyTorch.

<div align="center">
<img src="https://pl-public-data.s3.amazonaws.com/assets_lightning/continuum.png" width="80%">
</div>

&nbsp;
&nbsp;


# PyTorch Lightning: Train and Deploy PyTorch at Scale

PyTorch Lightning is just organized PyTorch - Lightning disentangles PyTorch code to decouple the science from the engineering.

![PT to PL](docs/source-pytorch/_static/images/general/pl_quick_start_full_compressed.gif)

______________________________________________________________________

### Examples
Explore various types of training possible with PyTorch Lightning. Pretrain and finetune ANY kind of model to perform ANY task like classification, segmentation, summarization and more:

| Task | Description | Run |
|-------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|---|
| [Hello world](#hello-simple-model) | Pretrain - Hello world example | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/pytorch-lightning-hello-world"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |
| [Image classification](https://lightning.ai/lightning-ai/studios/image-classification-with-pytorch-lightning) | Finetune - ResNet-34 model to classify images of cars | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/image-classification-with-pytorch-lightning"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |
| [Image segmentation](https://lightning.ai/lightning-ai/studios/image-segmentation-with-pytorch-lightning) | Finetune - ResNet-50 model to segment images | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/image-segmentation-with-pytorch-lightning"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |
| [Object detection](https://lightning.ai/lightning-ai/studios/object-detection-with-pytorch-lightning) | Finetune - Faster R-CNN model to detect objects | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/object-detection-with-pytorch-lightning"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |
| [Text classification](https://lightning.ai/lightning-ai/studios/text-classification-with-pytorch-lightning) | Finetune - text classifier (BERT model) | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/text-classification-with-pytorch-lightning"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |
| [Text summarization](https://lightning.ai/lightning-ai/studios/text-summarization-with-pytorch-lightning) | Finetune - text summarization (Hugging Face transformer model) | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/text-summarization-with-pytorch-lightning"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |
| [Audio generation](https://lightning.ai/lightning-ai/studios/finetune-a-personal-ai-music-generator) | Finetune - audio generator (transformer model) | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/finetune-a-personal-ai-music-generator"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |
| [LLM finetuning](https://lightning.ai/lightning-ai/studios/finetune-an-llm-with-pytorch-lightning) | Finetune - LLM (Meta Llama 3.1 8B) | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/finetune-an-llm-with-pytorch-lightning"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |
| [Image generation](https://lightning.ai/lightning-ai/studios/train-a-diffusion-model-with-pytorch-lightning) | Pretrain - Image generator (diffusion model) | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/train-a-diffusion-model-with-pytorch-lightning"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |

### Hello simple model
### PyTorch Lightning example
Define the training workflow. Here's a toy example ([explore real examples](https://lightning.ai/lightning-ai/studios?view=public&section=featured&query=pytorch+lightning)):

```python
# main.py
Expand Down Expand Up @@ -207,6 +182,36 @@ pip install torchvision
python main.py
```

&nbsp;


# Why PyTorch Lightning?

PyTorch Lightning is just organized PyTorch - Lightning disentangles PyTorch code to decouple the science from the engineering.

![PT to PL](docs/source-pytorch/_static/images/general/pl_quick_start_full_compressed.gif)

&nbsp;

----

### Examples
Explore various types of training possible with PyTorch Lightning. Pretrain and finetune ANY kind of model to perform ANY task like classification, segmentation, summarization and more:

| Task | Description | Run |
|-------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|---|
| [Hello world](#hello-simple-model) | Pretrain - Hello world example | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/pytorch-lightning-hello-world"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |
| [Image classification](https://lightning.ai/lightning-ai/studios/image-classification-with-pytorch-lightning) | Finetune - ResNet-34 model to classify images of cars | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/image-classification-with-pytorch-lightning"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |
| [Image segmentation](https://lightning.ai/lightning-ai/studios/image-segmentation-with-pytorch-lightning) | Finetune - ResNet-50 model to segment images | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/image-segmentation-with-pytorch-lightning"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |
| [Object detection](https://lightning.ai/lightning-ai/studios/object-detection-with-pytorch-lightning) | Finetune - Faster R-CNN model to detect objects | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/object-detection-with-pytorch-lightning"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |
| [Text classification](https://lightning.ai/lightning-ai/studios/text-classification-with-pytorch-lightning) | Finetune - text classifier (BERT model) | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/text-classification-with-pytorch-lightning"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |
| [Text summarization](https://lightning.ai/lightning-ai/studios/text-summarization-with-pytorch-lightning) | Finetune - text summarization (Hugging Face transformer model) | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/text-summarization-with-pytorch-lightning"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |
| [Audio generation](https://lightning.ai/lightning-ai/studios/finetune-a-personal-ai-music-generator) | Finetune - audio generator (transformer model) | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/finetune-a-personal-ai-music-generator"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |
| [LLM finetuning](https://lightning.ai/lightning-ai/studios/finetune-an-llm-with-pytorch-lightning) | Finetune - LLM (Meta Llama 3.1 8B) | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/finetune-an-llm-with-pytorch-lightning"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |
| [Image generation](https://lightning.ai/lightning-ai/studios/train-a-diffusion-model-with-pytorch-lightning) | Pretrain - Image generator (diffusion model) | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/train-a-diffusion-model-with-pytorch-lightning"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |
| [Recommendation system](https://lightning.ai/lightning-ai/studios/recommendation-system-with-pytorch-lightning) | Train - recommendation system (factorization and embedding) | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/recommendation-system-with-pytorch-lightning"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |
| [Time-series forecasting](https://lightning.ai/lightning-ai/studios/time-series-forecasting-with-pytorch-lightning) | Train - Time-series forecasting with LSTM | <a target="_blank" href="https://lightning.ai/lightning-ai/studios/time-series-forecasting-with-pytorch-lightning"><img src="https://pl-bolts-doc-images.s3.us-east-2.amazonaws.com/app-2/studio-badge.svg" alt="Open In Studio"/></a> |

______________________________________________________________________

## Advanced features
Expand Down
2 changes: 1 addition & 1 deletion _notebooks
Loading
Loading