2022-09-29 04:38:30 +08:00
|
|
|
name: Roll PyTorch
|
|
|
|
|
2022-09-30 06:15:32 +08:00
|
|
|
on:
|
2022-10-13 08:18:54 +08:00
|
|
|
schedule:
|
2022-11-24 01:31:02 +08:00
|
|
|
- cron: '0 13 * * *'
|
2022-09-30 06:15:32 +08:00
|
|
|
workflow_dispatch:
|
2022-09-29 04:38:30 +08:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
build_linux:
|
|
|
|
name: Manylinux Build
|
2023-02-16 01:17:12 +08:00
|
|
|
runs-on: a100
|
2022-09-30 06:15:32 +08:00
|
|
|
|
2022-10-26 06:56:59 +08:00
|
|
|
# Don't run this in everyone's forks.
|
|
|
|
if: github.repository == 'llvm/torch-mlir'
|
|
|
|
|
|
|
|
steps:
|
2023-04-07 01:36:30 +08:00
|
|
|
|
|
|
|
- name: Prepare workspace
|
|
|
|
run: |
|
|
|
|
# Clear the workspace directory so that we don't run into errors about
|
|
|
|
# existing lock files.
|
|
|
|
sudo rm -rf $GITHUB_WORKSPACE/*
|
|
|
|
|
2022-09-29 04:38:30 +08:00
|
|
|
- name: Get torch-mlir
|
2022-09-30 06:15:32 +08:00
|
|
|
uses: actions/checkout@v3
|
2022-09-29 04:38:30 +08:00
|
|
|
with:
|
2023-09-23 22:00:16 +08:00
|
|
|
submodules: 'false'
|
2022-09-30 06:15:32 +08:00
|
|
|
token: ${{ secrets.WORKFLOW_INVOCATION_TOKEN }}
|
|
|
|
|
2023-09-23 22:00:16 +08:00
|
|
|
- name: Get LLVM and StableHlo submodules
|
|
|
|
run: |
|
|
|
|
set -eo pipefail
|
|
|
|
cd ${GITHUB_WORKSPACE}
|
|
|
|
|
|
|
|
# Fetching the submodules concurrently may cause problems, so we fetch
|
|
|
|
# them one after another.
|
|
|
|
rm -f .git/modules/externals/llvm-project/index.lock
|
|
|
|
rm -f .git/modules/externals/stablehlo/index.lock
|
|
|
|
git submodule update --init --recursive externals/llvm-project
|
|
|
|
git submodule update --init --recursive externals/stablehlo
|
|
|
|
|
2022-09-29 04:38:30 +08:00
|
|
|
- name: Setup ccache
|
|
|
|
uses: ./.github/actions/setup-build
|
|
|
|
with:
|
ci: enable ccache on Windows (#1548)
This patch makes a few small, but key, changes to enable ccache on
Windows. First, it replaces the hendrikmuhs/ccache-action action with
command line invocations to the ccache binary, since the action has two
bugs, one of which causes CI to refer to different ccache artifacts
before versus after the build on Windows whereas the other bug can
sometimes cause the action to incorrectly infer that the cache is empty.
Second, this patch slightly alters the cache key, so that our old cache
artifacts, which have grown too big, are eventually discarded in favor
of the new, smaller cache artifacts. Along the way, this patch also
keeps the RollPyTorch's cache artifact separate from the regular build's
cache artifact so as to keep these artifacts small, and also because the
RollPyTorch action is off the critical path for most contributors.
Finally, this patch makes small changes to the CMake file so that on
Windows, the ccache binary is added as a prefix, as recommended on the
[ccache Wiki](https://github.com/ccache/ccache/wiki/MS-Visual-Studio).
2022-11-04 01:17:22 +08:00
|
|
|
cache-suffix: 'rollPyTorch'
|
2022-09-30 06:15:32 +08:00
|
|
|
|
2022-09-29 04:38:30 +08:00
|
|
|
- name: Determine nightly PyTorch version
|
|
|
|
run: |
|
2022-11-15 05:56:02 +08:00
|
|
|
set -eo pipefail
|
|
|
|
|
2022-09-29 04:38:30 +08:00
|
|
|
cd ${GITHUB_WORKSPACE}
|
|
|
|
python -m pip install wheel
|
2023-02-20 07:49:08 +08:00
|
|
|
sudo apt-get install unzip
|
2022-11-15 05:56:02 +08:00
|
|
|
|
|
|
|
# Fetch the most recent nightly torchvision release
|
|
|
|
VISION_RELEASE=$(python -m pip index versions -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html --pre torchvision | grep "Available versions" | tr ' ' '\n' | grep "^[0-9]" | sort --version-sort --reverse | head -n1 | tr -d ',' | sed 's/\([^+]*\).*/\1/')
|
|
|
|
echo "Found torchvision release ${VISION_RELEASE}"
|
|
|
|
|
|
|
|
# Fetch the whl file associated with the nightly torchvision release
|
2022-11-24 03:54:54 +08:00
|
|
|
rm -f torch*.whl
|
2022-11-15 05:56:02 +08:00
|
|
|
python -m pip download -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html --pre "torchvision==${VISION_RELEASE}"
|
|
|
|
|
2022-11-24 03:54:54 +08:00
|
|
|
# Downloading the torchvision WHL also downloads the PyTorch WHL file
|
|
|
|
# Read the version from the downloaded whl file without extracting it
|
|
|
|
PT_RELEASE=$(unzip -p torch-*.whl 'torch-*/METADATA' | grep "^Version:" | awk '{ print $2 }' | sed 's/\([^+]*\).*/\1/')
|
2022-11-15 05:56:02 +08:00
|
|
|
echo "Found torch release ${PT_RELEASE}"
|
2023-02-14 11:22:09 +08:00
|
|
|
printf -- "-f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html\n--pre\ntorch==%s\n" "${PT_RELEASE}" > pytorch-requirements.txt
|
|
|
|
printf -- "-f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html\n--pre\ntorchvision==%s\n" "${VISION_RELEASE}" > torchvision-requirements.txt
|
2022-11-15 05:56:02 +08:00
|
|
|
|
2022-09-29 04:38:30 +08:00
|
|
|
# Read the commit hash from the downloaded whl file without extracting it
|
2024-01-24 18:25:12 +08:00
|
|
|
PT_HASH=$(unzip -p torch-"${PT_RELEASE}"*.whl torch/version.py | grep git_version | tail -1 | awk '{ print $3 }' | tr -d "'")
|
2022-11-15 05:56:02 +08:00
|
|
|
echo "Found torch commit hash ${PT_HASH}"
|
|
|
|
|
2022-10-03 05:04:26 +08:00
|
|
|
PT_HASH_CHANGED=0
|
2022-11-01 11:03:05 +08:00
|
|
|
echo "${PT_HASH}" | cmp - pytorch-hash.txt --quiet || PT_HASH_CHANGED=$?
|
|
|
|
echo "${PT_HASH}" > pytorch-hash.txt
|
2022-09-29 04:38:30 +08:00
|
|
|
rm torch-"${PT_RELEASE}"*.whl
|
2022-11-15 05:56:02 +08:00
|
|
|
|
2022-09-29 04:38:30 +08:00
|
|
|
# Write the release and hash to the environment file so that we can
|
|
|
|
# retrieve them when creating a PR
|
|
|
|
echo "PT_HASH=${PT_HASH}" >> ${GITHUB_ENV}
|
|
|
|
echo "PT_RELEASE=${PT_RELEASE}" >> ${GITHUB_ENV}
|
2022-12-19 03:45:30 +08:00
|
|
|
echo "PTVISION_RELEASE=${VISION_RELEASE}" >> ${GITHUB_ENV}
|
2022-10-01 01:47:43 +08:00
|
|
|
echo "PT_HASH_CHANGED=${PT_HASH_CHANGED}" >> ${GITHUB_ENV}
|
2022-09-30 06:15:32 +08:00
|
|
|
|
2023-09-23 22:00:16 +08:00
|
|
|
- name: Build and test (out-of-tree), also update ODS and abstract interpretation library
|
2022-10-01 01:47:43 +08:00
|
|
|
if: env.PT_HASH_CHANGED != '0'
|
2022-09-29 04:38:30 +08:00
|
|
|
run: |
|
|
|
|
cd ${GITHUB_WORKSPACE}
|
2023-09-23 22:00:16 +08:00
|
|
|
TM_PACKAGES="out-of-tree" TM_USE_PYTORCH_BINARY="OFF" \
|
2022-09-29 04:38:30 +08:00
|
|
|
TORCH_MLIR_SRC_PYTORCH_BRANCH="${{ env.PT_HASH }}" \
|
|
|
|
TORCH_MLIR_SRC_PYTORCH_RELEASE="${{ env.PT_RELEASE }}" \
|
2022-12-14 00:25:41 +08:00
|
|
|
TM_UPDATE_ODS_AND_ABSTRACT_INTERP_LIB="ON" \
|
2022-09-29 04:38:30 +08:00
|
|
|
./build_tools/python_deploy/build_linux_packages.sh
|
2022-09-29 20:09:16 +08:00
|
|
|
|
2022-12-19 03:45:30 +08:00
|
|
|
- name: Post issue comment on build failure
|
|
|
|
if: failure()
|
|
|
|
uses: peter-evans/create-or-update-comment@v2
|
|
|
|
with:
|
|
|
|
issue-number: 1690
|
|
|
|
body: |
|
|
|
|
The RollPyTorch action has failed. See [CI log](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.
|
|
|
|
|
|
|
|
The following information may come handy when fixing the code.
|
|
|
|
```
|
|
|
|
torch version: ${{ env.PT_RELEASE }}
|
|
|
|
torch commit hash: ${{ env.PT_HASH }}
|
|
|
|
torchvision version: ${{ env.PTVISION_RELEASE }}
|
|
|
|
```
|
|
|
|
|
2023-05-10 22:25:59 +08:00
|
|
|
- name: Update PyTorch Build Cache (if running on main branch)
|
|
|
|
if: github.ref_name == 'main'
|
|
|
|
id: cache-pytorch
|
2023-05-13 12:25:17 +08:00
|
|
|
uses: actions/cache@v3
|
2023-05-10 22:25:59 +08:00
|
|
|
with:
|
|
|
|
path: ${{ github.workspace }}/build_tools/python_deploy/wheelhouse
|
|
|
|
key: ${{ runner.os }}-pytorch-${{ env.PT_HASH }}
|
|
|
|
|
|
|
|
- name: Commit changes locally
|
2022-10-01 01:47:43 +08:00
|
|
|
if: env.PT_HASH_CHANGED != '0'
|
2022-09-30 06:15:32 +08:00
|
|
|
run: |
|
|
|
|
cd ${GITHUB_WORKSPACE}
|
|
|
|
git config user.email "torch-mlir@users.noreply.github.com"
|
|
|
|
git config user.name "Roll PyTorch Action"
|
2022-10-01 01:47:43 +08:00
|
|
|
git fetch --recurse-submodules=no
|
2022-09-30 06:15:32 +08:00
|
|
|
git checkout main
|
2022-12-14 03:41:41 +08:00
|
|
|
git pull origin main
|
2022-10-18 13:42:42 +08:00
|
|
|
|
2023-05-10 22:25:59 +08:00
|
|
|
- name: Create pull request
|
|
|
|
uses: peter-evans/create-pull-request@v5.0.1
|
2022-10-18 13:42:42 +08:00
|
|
|
with:
|
2023-05-10 22:25:59 +08:00
|
|
|
author: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
|
2023-06-05 21:48:20 +08:00
|
|
|
branch: rollpytorch
|
2023-05-10 22:25:59 +08:00
|
|
|
body: |
|
|
|
|
torch version: ${{ env.PT_RELEASE }}
|
|
|
|
torch commit hash: ${{ env.PT_HASH }}
|
|
|
|
torchvision version: ${{ env.PTVISION_RELEASE }}
|
|
|
|
commit-message: |
|
|
|
|
update PyTorch version to ${{ env.PT_RELEASE }}
|
|
|
|
|
|
|
|
- torch version: ${{ env.PT_RELEASE }}
|
|
|
|
- torch commit hash: ${{ env.PT_HASH }}
|
|
|
|
- torchvision version: ${{ env.PTVISION_RELEASE }}
|
|
|
|
committer: Roll PyTorch Action <torch-mlir@users.noreply.github.com>
|
|
|
|
title: update PyTorch version to ${{ env.PT_RELEASE }}
|
2023-05-20 12:18:03 +08:00
|
|
|
token: ${{ secrets.ROLLPYTORCH_TOKEN0 }}
|