Skip to content

Commit

Permalink
Merge branch 'master' into ci/tpu
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda authored Dec 2, 2022
2 parents a771df4 + fee52f9 commit 8644a16
Show file tree
Hide file tree
Showing 33 changed files with 283 additions and 199 deletions.
9 changes: 1 addition & 8 deletions .azure/gpu-benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,7 @@ jobs:
pip list
displayName: 'Image info & NVIDIA'
- bash: |
python .actions/assistant.py requirements_prune_pkgs --packages [horovod,bagua,colossalai] --req_files [requirements/pytorch/strategies.txt]
PYTORCH_VERSION=$(python -c "import torch; print(torch.__version__.split('+')[0])")
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/base.txt ${PYTORCH_VERSION}
displayName: 'Adjust dependencies'
- bash: pip install -e .[dev,strategies,examples] --find-links ${TORCH_URL}
- bash: pip install -e .[dev] --find-links ${TORCH_URL}
env:
PACKAGE_NAME: "pytorch"
FREEZE_REQUIREMENTS: "1"
Expand Down
24 changes: 16 additions & 8 deletions .github/actions/pkg-publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ inputs:
pkg-pattern:
description: what file pattern is searched in folder, so for example `*_app*`
required: true
pypi-test-token:
description: login token for PyPI
default: ''
required: false
pypi-token:
description: login token for PyPI
required: true
default: ''
required: false

runs:
using: "composite"
Expand All @@ -20,16 +25,19 @@ runs:
shell: bash

# We do this, since failures on test.pypi aren't that bad
#- name: Publish to Test PyPI
# uses: pypa/gh-action-pypi-publish@v1.5.1
# with:
# user: __token__
# password: ${{ secrets.test_pypi_token_lai }}
# repository_url: https://test.pypi.org/legacy/
# verbose: true
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@v1.5.1
if: inputs.pypi-test-token != ''
with:
user: __token__
password: ${{ secrets.test_pypi_token_lai }}
repository_url: https://test.pypi.org/legacy/
packages_dir: pypi/
verbose: true

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@v1.5.1
if: inputs.pypi-token != ''
with:
user: __token__
password: ${{ inputs.pypi-token }}
Expand Down
18 changes: 15 additions & 3 deletions .github/workflows/legacy-checkpoints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ on:
AWS_SECRET_KEY_ID:
required: true

defaults:
run:
shell: bash

jobs:
create-legacy-ckpts:
runs-on: ubuntu-20.04
outputs:
pl-version: ${{ steps.decide-pl-version.outputs.pl-version }}
pl-version: ${{ steps.decide-version.outputs.pl-version }}
defaults:
run:
working-directory: tests/legacy
Expand All @@ -69,16 +73,24 @@ jobs:
env:
PACKAGE_NAME: pytorch
run: |
pip install -e . -f https://download.pytorch.org/whl/cpu/torch_stable.html
pip install . -f https://download.pytorch.org/whl/cpu/torch_stable.html
pip list
if: inputs.pl_version == ''

- name: Install PL version
run: |
pip install "pytorch-lightning==${{ inputs.pl_version }}" \
-f https://download.pytorch.org/whl/cpu/torch_stable.html \
--extra-index-url https://test.pypi.org/simple/
pip list
if: inputs.pl_version != ''

- name: Pull legacy checkpoints
working-directory: ./
run: bash .actions/pull_legacy_checkpoints.sh

- name: Decide PL version to create a PR with
id: decide-pl-version
id: decide-version
run: |
python -c "import pytorch_lightning as pl; print(f'pl-version={pl.__version__}')" >> $GITHUB_OUTPUT || echo pl-version='' >> $GITHUB_OUTPUT
Expand Down
108 changes: 97 additions & 11 deletions .github/workflows/release-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
release:
types: [published]

defaults:
run:
shell: bash

jobs:
init:
runs-on: ubuntu-20.04
Expand All @@ -24,8 +28,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
fail-fast: true
# run sequential
max-parallel: 1
max-parallel: 1 # run sequential to prevent download/upload collisions
matrix:
pkg-name: ["lightning", "app", "lite", "pytorch"]
steps:
Expand Down Expand Up @@ -70,7 +73,69 @@ jobs:
files: 'dist/*'
repo-token: ${{ secrets.GITHUB_TOKEN }}

publish-packages:
release-version:
runs-on: ubuntu-20.04
outputs:
tag: ${{ steps.lai-package.outputs.version }}
steps:
- uses: actions/checkout@v3
- name: install Package
env:
PACKAGE_NAME: "lightning"
run: pip install . -f https://download.pytorch.org/whl/cpu/torch_stable.html
- name: package Version
id: lai-package
run: python -c "import lightning as L; print(f'version={L.__version__}')" >> $GITHUB_OUTPUT

signaling:
runs-on: ubuntu-20.04
needs: [release-version, pre-publish-packages]
env:
TAG: ${{ needs.release-version.outputs.tag }}
steps:
- uses: actions/setup-python@v4
with:
python-version: 3.8
- uses: actions/checkout@v3
with:
repository: gridai/base-images
token: ${{ secrets.PAT_GHOST }}
ref: main
- uses: fregante/setup-git-token@v1
with:
token: ${{ secrets.PAT_GHOST }}
name: PL Ghost
email: pl-github@grid.ai
- name: Update lightning version
run: |
import json, os
with open("versions.json") as fo:
vers = json.load(fo)
vers["lightning_version"] = os.getenv('TAG')
with open("versions.json", "w") as fw:
json.dump(vers, fw)
shell: python
- name: GIT Commit
run: |
git add versions.json
git commit -m "bumping lightning version -> ${TAG}"
cat versions.json
- name: GIT Push
run: |
git status
git push
waiting:
# TODO: replace with back signal from build images/ loop checking for a specific branch?
runs-on: ubuntu-20.04
needs: signaling
steps:
- name: Delay releasing
uses: juliangruber/sleep-action@v1
with:
time: 30m

pre-publish-packages:
runs-on: ubuntu-20.04
needs: build-packages
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
Expand All @@ -82,38 +147,59 @@ jobs:
path: dist
- run: ls -lh dist/
- run: mkdir pypi/

- name: Delay releasing
uses: juliangruber/sleep-action@v1
- uses: ./.github/actions/pkg-publish
with:
time: 10m
pkg-pattern: "*app*"
pypi-test-token: ${{ secrets.PYPI_TEST_TOKEN_APP }}
- uses: ./.github/actions/pkg-publish
with:
pkg-pattern: "*lite*"
pypi-test-token: ${{ secrets.PYPI_TEST_TOKEN_LITE }}
- uses: ./.github/actions/pkg-publish
with:
pkg-pattern: "*pytorch*"
pypi-test-token: ${{ secrets.PYPI_TEST_TOKEN_PYTORCH }}
- uses: ./.github/actions/pkg-publish
with:
pkg-pattern: "*"
pypi-test-token: ${{ secrets.PYPI_TEST_TOKEN_LAI }}

publish-packages:
runs-on: ubuntu-20.04
needs: waiting
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: dist-packages-${{ github.sha }}
path: dist
- run: ls -lh dist/
- run: mkdir pypi/
- uses: ./.github/actions/pkg-publish
with:
pkg-pattern: "*app*"
pypi-token: ${{ secrets.PYPI_TOKEN_APP }}

- uses: ./.github/actions/pkg-publish
with:
pkg-pattern: "*lite*"
pypi-token: ${{ secrets.PYPI_TOKEN_LITE }}

- uses: ./.github/actions/pkg-publish
with:
pkg-pattern: "*pytorch*"
pypi-token: ${{ secrets.PYPI_TOKEN_PYTORCH }}

- uses: ./.github/actions/pkg-publish
with:
pkg-pattern: "*"
pypi-token: ${{ secrets.PYPI_TOKEN_LAI }}

legacy-checkpoints:
needs: publish-packages
needs: [release-version, pre-publish-packages]
uses: ./.github/workflows/legacy-checkpoints.yml
with:
push_to_s3: true
create_pr: true
pl_version: ${{ needs.release-version.outputs.tag }}
secrets:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_KEY_ID: ${{ secrets.AWS_SECRET_KEY_ID }}
3 changes: 0 additions & 3 deletions docs/source-pytorch/advanced/model_parallel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1108,9 +1108,6 @@ Combine hooks for accumulated benefit:
When using Post-localSGD, you must also pass ``model_averaging_period`` to allow for model parameter averaging:

.. note::
Post-localSGD support requires PyTorch>=1.10.0

.. code-block:: python
from pytorch_lightning import Trainer
Expand Down
5 changes: 1 addition & 4 deletions docs/source-pytorch/common/precision_intermediate.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ BFloat16 Mixed Precision

.. warning::

BFloat16 requires PyTorch 1.10 or later and is only supported with PyTorch Native AMP.

BFloat16 is also experimental and may not provide significant speedups or memory improvements, offering better numerical stability.

Do note for GPUs, the most significant benefits require `Ampere <https://en.wikipedia.org/wiki/Ampere_(microarchitecture)>`__ based GPUs, such as A100s or 3090s.
Expand All @@ -126,14 +124,13 @@ BFloat16 Mixed precision is similar to FP16 mixed precision, however, it maintai
Under the hood, we use `torch.autocast <https://pytorch.org/docs/stable/amp.html>`__ with the dtype set to ``bfloat16``, with no gradient scaling.

.. testcode::
:skipif: not _TORCH_GREATER_EQUAL_1_10 or not torch.cuda.is_available()
:skipif: not torch.cuda.is_available()

Trainer(accelerator="gpu", devices=1, precision="bf16")

It is also possible to use BFloat16 mixed precision on the CPU, relying on MKLDNN under the hood.

.. testcode::
:skipif: not _TORCH_GREATER_EQUAL_1_10

Trainer(precision="bf16")

Expand Down
1 change: 0 additions & 1 deletion docs/source-pytorch/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ def package_list_from_file(file):
from pytorch_lightning.utilities import (
_APEX_AVAILABLE,
_TORCHVISION_AVAILABLE,
_TORCH_GREATER_EQUAL_1_10,
)
from pytorch_lightning.loggers.neptune import _NEPTUNE_AVAILABLE
from pytorch_lightning.loggers.comet import _COMET_AVAILABLE
Expand Down
1 change: 0 additions & 1 deletion requirements/app/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ beautifulsoup4>=4.8.0, <4.11.2
inquirer>=2.10.0
psutil<5.9.4
click<=8.1.3
lightning_api_access>=0.0.3
2 changes: 2 additions & 0 deletions requirements/app/components.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# deps required by components in the lightning app repository (src/lightning_app/components)
lightning_api_access>=0.0.3
3 changes: 3 additions & 0 deletions requirements/app/devel.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
# extended list of dependencies for UI
-r ./ui.txt

# extended list of dependencies for UI
-r ./components.txt

-r ./examples.txt
4 changes: 4 additions & 0 deletions src/lightning_app/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

- Fixed the `enable_spawn` method of the `WorkRunExecutor` ([#15812](https://github.com/Lightning-AI/lightning/pull/15812)

- Fixed Sigterm Handler causing thread lock which caused KeyboardInterrupt to hang ([#15881](https://github.com/Lightning-AI/lightning/pull/15881))


## [1.8.3] - 2022-11-22

Expand Down Expand Up @@ -94,6 +96,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [1.8.1] - 2022-11-10

- Fixed bug when launching apps on multiple clusters ([#15484](https://github.com/Lightning-AI/lightning/pull/15484))


### Added

Expand Down
10 changes: 8 additions & 2 deletions src/lightning_app/components/serve/python_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import uvicorn
from fastapi import FastAPI
from lightning_utilities.core.imports import module_available
from pydantic import BaseModel
from starlette.staticfiles import StaticFiles

Expand All @@ -17,9 +18,14 @@

logger = Logger(__name__)

__doctest_skip__ = []
# Skip doctests if requirements aren't available
if not module_available("lightning_api_access"):
__doctest_skip__ += ["PythonServer", "PythonServer.*"]

# Skip doctests if requirements aren't available
if not _is_torch_available():
__doctest_skip__ = ["PythonServer", "PythonServer.*"]
__doctest_skip__ += ["PythonServer", "PythonServer.*"]


class _PyTorchSpawnRunExecutor(WorkRunExecutor):
Expand Down Expand Up @@ -90,7 +96,7 @@ def _get_sample_data() -> Dict[Any, Any]:


class PythonServer(LightningWork, abc.ABC):
@requires("torch")
@requires(["torch", "lightning_api_access"])
def __init__( # type: ignore
self,
host: str = "127.0.0.1",
Expand Down
Loading

0 comments on commit 8644a16

Please sign in to comment.