meta-pytorch/torchtune
8 workflows · maturity 50% · 4 patterns · GitHub ↗
Practices
✓ Matrix✓ Permissions○ Security scan○ AI review○ Cache✓ Concurrency✓ Reusable workflows
Detected patterns
Security dimensions
Workflows (8)
build_docs matrix .github/workflows/build_docs.yaml
View raw YAML
name: Build Docs
on:
push:
branches:
- main
- release/*
tags:
- v[0-9]+.[0-9]+.[0-9]
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
pull_request:
workflow_dispatch:
concurrency:
group: build-docs-${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_number || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -l -eo pipefail {0}
jobs:
build_docs:
if: github.repository_owner == 'pytorch'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11']
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Setup conda env
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
miniconda-version: "latest"
activate-environment: test
python-version: ${{ matrix.python-version }}
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install dependencies
run: |
python -m pip install torch torchvision torchao
python -m pip install -e .
cd docs
python -m pip install -r requirements.txt
- name: Build docs
env:
TORCHTUNE_VERSION_DOCS: ${{ github.ref }}
run: |
cd docs
make html
- uses: actions/upload-artifact@v4
with:
name: Built-Docs
path: docs/build/html/
doc-preview:
runs-on: [self-hosted, linux.2xlarge]
needs: build_docs
if: ${{ github.repository_owner == 'pytorch' && github.event_name == 'pull_request' }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: Built-Docs
path: docs
- name: Add no-index tag
run: |
find docs -name "*.html" -print0 | xargs -0 sed -i '/<head>/a \ \ <meta name="robots" content="noindex">';
- name: Upload docs preview
uses: seemethere/upload-artifact-s3@v5
if: ${{ github.event_name == 'pull_request' }}
with:
retention-days: 14
s3-bucket: doc-previews
if-no-files-found: error
path: docs
s3-prefix: pytorch/torchtune/${{ github.event.pull_request.number }}
upload:
runs-on: ubuntu-latest
needs: build_docs
if: github.repository_owner == 'pytorch' && github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
environment: ${{ (github.ref == 'refs/heads/main' || startsWith(github.event.ref, 'refs/tags/v')) && 'docs-push' || '' }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: gh-pages
persist-credentials: false
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: Built-Docs
path: docs
- name: Add no-index tag
run: |
REF_NAME=$(echo "${{ github.ref }}")
echo "Ref name: ${REF_NAME}"
if [[ "${{ github.ref }}" == 'refs/heads/main' ]]; then
find docs -name "*.html" -print0 | xargs -0 sed -i '/<head>/a \ \ <meta name="robots" content="noindex">';
fi
- name: Move and commit changes
env:
GITHUB_PYTORCHBOT_TOKEN: ${{ secrets.GH_PYTORCHBOT_TOKEN }}
run: |
git remote set-url origin https://pytorchbot:${GITHUB_PYTORCHBOT_TOKEN}@github.com/pytorch/torchtune.git
set -euo pipefail
# Convert refs/tags/v1.12.0rc3 into 1.12.
# Adopted from https://github.com/pytorch/pytorch/blob/main/.github/workflows/_docs.yml#L150C11-L155C13
GITHUB_REF=${{ github.ref }}
if [[ "${GITHUB_REF}" =~ ^refs/tags/v([0-9]+\.[0-9]+)\.* ]]; then
TARGET_FOLDER="${BASH_REMATCH[1]}"
else
TARGET_FOLDER="main"
fi
echo "Target Folder: ${TARGET_FOLDER}"
mkdir -p "${TARGET_FOLDER}"
rm -rf "${TARGET_FOLDER}"/*
mv docs/* "${TARGET_FOLDER}"
git config user.name 'pytorchbot'
git config user.email 'soumith+bot@pytorch.org'
git add "${TARGET_FOLDER}" || true
git commit -m "auto-generating sphinx docs" || true
git push -f
build_linux_wheels perms .github/workflows/build_linux_wheels.yaml
View raw YAML
name: Build Linux Wheels
on:
push:
branches:
- nightly
- release/*
tags:
# NOTE: Binary build pipelines should only get triggered on release candidate builds
# Release candidate tags look like: v1.11.0-rc1
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
generate-matrix:
if: github.repository_owner == 'pytorch'
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main
with:
package-type: wheel
os: linux
test-infra-repository: pytorch/test-infra
test-infra-ref: main
with-cuda: enable
with-rocm: enable
with-xpu: enable
build-python-only: enable
build:
needs: generate-matrix
name: ${{ matrix.repository }}
uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@main
strategy:
fail-fast: false
with:
repository: pytorch/torchtune
ref: ""
test-infra-repository: pytorch/test-infra
test-infra-ref: main
package-name: torchtune
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
pre-script: .github/scripts/pre_build_script.sh
trigger-event: ${{ github.event_name }}
build-platform: 'python-build-package'
pip-install-torch-extra-args:
torchvision
torchao
export matrix .github/workflows/export.yaml
View raw YAML
name: Export
on:
push:
paths:
- 'torchtune/modules/_export/**'
- 'tests/torchtune/modules/_export/**'
pull_request:
paths:
- 'torchtune/modules/_export/**'
- 'tests/torchtune/modules/_export/**'
schedule:
# Runs at midnight evvery day
- cron: '0 0 * * *'
concurrency:
group: unit-test${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_number || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -l -eo pipefail {0}
jobs:
export_unit_tests:
if: github.repository_owner == 'pytorch'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Setup conda env
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
miniconda-version: "latest"
activate-environment: test
python-version: ${{ matrix.python-version }}
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install dependencies
run: |
bash torchtune/modules/_export/install_requirements.sh
python -m pip install torchao
python -m pip install -e ".[dev]"
- name: Run unit tests with coverage
run: pytest tests/torchtune/modules/_export --cov=. --cov-report=xml --durations=20 -vv
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
gpu_test matrix perms .github/workflows/gpu_test.yaml
View raw YAML
name: GPU tests
on:
schedule:
# Runs at midnight every day
- cron: '0 0 * * *'
push:
branches: [ main ]
pull_request:
workflow_dispatch:
concurrency:
group: gpu-test-${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_number || github.ref }}
cancel-in-progress: true
permissions:
id-token: write
contents: read
defaults:
run:
shell: bash -l -eo pipefail {0}
jobs:
gpu_test:
if: github.repository_owner == 'pytorch'
runs-on: linux.g5.12xlarge.nvidia.gpu
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
torch-version: ["stable", "nightly"]
# Do not run against nightlies on PR
exclude:
- torch-version: ${{ github.event_name == 'pull_request' && 'nightly' }}
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Setup conda env
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
miniconda-version: "latest"
activate-environment: test
python-version: ${{ matrix.python-version }}
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install nightly versions of PyTorch packages (if applicable)
if: ${{ matrix.torch-version == 'nightly' }}
run: python -m pip install --pre torch torchvision torchao --index-url https://download.pytorch.org/whl/nightly/cu126
- name: Install torch stable (if applicable)
if: ${{ matrix.torch-version == 'stable' }}
run: python -m pip install torch torchvision torchao
- name: Install recipe-specific dependencies
run: python -m pip install lm-eval==0.4.8
- name: Install the torchtune library with dev options
run: python -m pip install -e ".[dev]"
- name: Run recipe and unit tests with coverage
run: pytest tests --ignore tests/torchtune/modules/_export --with-integration --cov=. --cov-report=xml --durations=20 -vv
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
lint matrix .github/workflows/lint.yaml
View raw YAML
name: Lint
on:
pull_request:
workflow_dispatch:
concurrency:
group: lint-${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_number || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -l -eo pipefail {0}
jobs:
lint:
if: github.repository_owner == 'pytorch'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install lint utilities
run: |
python -m pip install pre-commit
pre-commit install-hooks
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@d6e91a2266cdb9d62096cebf1e8546899c6aa18f # v45.0.6
- name: Lint modified files
run: pre-commit run --files ${{ steps.changed-files.outputs.all_changed_files }}
regression_test matrix perms .github/workflows/regression_test.yaml
View raw YAML
name: Regression Tests
on:
schedule:
# Runs at midnight every day
- cron: '0 0 * * *'
concurrency:
group: regression-test-${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_number || github.ref }}
cancel-in-progress: true
permissions:
id-token: write
contents: read
defaults:
run:
shell: bash -l -eo pipefail {0}
jobs:
regression_test:
if: github.repository_owner == 'pytorch'
runs-on: linux.g5.12xlarge.nvidia.gpu
strategy:
matrix:
python-version: ['3.11']
torch-version: ["stable", "nightly"]
fail-fast: false
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Setup conda env
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
miniconda-version: "latest"
activate-environment: test
python-version: ${{ matrix.python-version }}
- name: Update pip
run: python -m pip install --upgrade pip
- name: configure aws credentials
id: aws_creds
uses: aws-actions/configure-aws-credentials@v1.7.0
with:
role-to-assume: arn:aws:iam::308535385114:role/gha_workflow_torchtune_pytorch-multimodal
aws-region: us-east-1
- name: Install S3 CLI
run: |
python3 -m pip install awscli==1.32.6
- name: Install torch nightly
if: ${{ matrix.torch-version == 'nightly' }}
run: python -m pip install --pre torch torchvision torchao --index-url https://download.pytorch.org/whl/nightly/cu118
- name: Install torch stable
if: ${{ matrix.torch-version == 'stable' }}
run: python -m pip install torch torchvision torchao
- name: Install remaining dependencies
run: |
python -m pip install lm-eval==0.4.8
python -m pip install -e ".[dev]"
- name: Run regression tests with coverage
run: pytest tests -m slow_integration_test --silence-s3-logs --cov=. --cov-report=xml --durations=20 -vv
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
rl_test matrix perms .github/workflows/rl_test.yaml
View raw YAML
name: RL tests
on:
push:
paths:
- 'torchtune/recipes/dev/**grpo**'
- 'torchtune/recipes/configs/dev/**grpo**'
- 'torchtune/dev/rl/**'
- 'torchtune/dev/grpo/**'
pull_request:
paths:
- 'torchtune/recipes/dev/**grpo**'
- 'torchtune/recipes/configs/dev/**grpo**'
- 'torchtune/dev/rl/**'
- 'torchtune/dev/grpo/**'
schedule:
# Runs at midnight evvery day
- cron: '0 0 * * *'
concurrency:
group: gpu-test-${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_number || github.ref }}
cancel-in-progress: true
permissions:
id-token: write
contents: read
defaults:
run:
shell: bash -l -eo pipefail {0}
jobs:
gpu_test:
if: github.repository_owner == 'pytorch'
runs-on: linux.g5.12xlarge.nvidia.gpu
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
torch-version: ["stable", "nightly"]
# Do not run against nightlies on PR
exclude:
- torch-version: ${{ github.event_name == 'pull_request' && 'nightly' }}
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Setup conda env
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
miniconda-version: "latest"
activate-environment: test
python-version: ${{ matrix.python-version }}
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install nightly versions of PyTorch packages (if applicable)
if: ${{ matrix.torch-version == 'nightly' }}
run: python -m pip install --pre torch torchvision torchao --index-url https://download.pytorch.org/whl/nightly/cu126
- name: Install torch stable (if applicable)
if: ${{ matrix.torch-version == 'stable' }}
run: python -m pip install torch torchvision torchao
- name: Install recipe-specific dependencies
run: python -m pip install lm-eval==0.4.8
- name: Install the torchtune library with dev options
run: python -m pip install -e ".[dev]"
- name: Install the torchtune libary with async_rl options
if: ${{ matrix.python-version != '3.9' }}
run: python -m pip install -e ".[async_rl]"
- name: Run recipe and unit tests with coverage
run: pytest tests/torchtune/dev/rl tests/recipes/dev --run-rl-tests --with-integration --cov=. --cov-report=xml --durations=20 -vv
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
unit_test matrix .github/workflows/unit_test.yaml
View raw YAML
name: Unit Test
on:
push:
branches: [ main ]
pull_request:
concurrency:
group: unit-test${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_number || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -l -eo pipefail {0}
jobs:
unit_tests:
if: github.repository_owner == 'pytorch'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11']
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Setup conda env
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
miniconda-version: "latest"
activate-environment: test
python-version: ${{ matrix.python-version }}
- name: Update pip
run: python -m pip install --upgrade pip
- name: Install dependencies
run: |
python -m pip install torch torchvision torchao
python -m pip install -e ".[dev]"
- name: Run unit tests with coverage
run: pytest tests --ignore tests/torchtune/modules/_export --cov=. --cov-report=xml --durations=20 -vv
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3