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
|
|
|
|
runs-on: ubuntu-latest
|
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:
|
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:
|
|
|
|
submodules: 'true'
|
2022-09-30 06:15:32 +08:00
|
|
|
token: ${{ secrets.WORKFLOW_INVOCATION_TOKEN }}
|
|
|
|
|
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
|
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}"
|
|
|
|
printf -- "-f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html\n--pre\ntorch==%s\ntorchvision==%s\n" "${PT_RELEASE}" "${VISION_RELEASE}" > pytorch-requirements.txt
|
|
|
|
|
2022-09-29 04:38:30 +08:00
|
|
|
# Read the commit hash from the downloaded whl file without extracting it
|
|
|
|
PT_HASH=$(unzip -p torch-"${PT_RELEASE}"*.whl torch/version.py | grep git_version | 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-10-01 01:47:43 +08:00
|
|
|
echo "PT_HASH_CHANGED=${PT_HASH_CHANGED}" >> ${GITHUB_ENV}
|
2022-09-30 06:15:32 +08:00
|
|
|
|
2022-10-03 07:02:34 +08:00
|
|
|
- name: Build and test (in-tree), also update ODS and shape 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}
|
2022-10-03 07:02:34 +08:00
|
|
|
TM_PACKAGES="in-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-10-03 07:02:34 +08:00
|
|
|
TM_UPDATE_ODS_AND_SHAPE_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-09-30 06:15:32 +08:00
|
|
|
- name: Push changes to main branch
|
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-11-01 11:03:05 +08:00
|
|
|
git add pytorch-hash.txt pytorch-requirements.txt lib/Dialect/Torch/Transforms/ShapeLibrary.cpp include/torch-mlir/Dialect/Torch/IR/GeneratedTorchOps.td
|
2022-10-01 01:47:43 +08:00
|
|
|
git diff --cached --exit-code || (git commit -m "update PyTorch version to ${{ env.PT_RELEASE }}" && git push --set-upstream origin main)
|
2022-10-18 13:42:42 +08:00
|
|
|
|
2022-11-01 04:14:53 +08:00
|
|
|
- name: Update PyTorch Build Cache (if running on main branch)
|
|
|
|
if: github.ref_name == 'main'
|
2022-10-18 13:42:42 +08:00
|
|
|
id: cache-pytorch
|
2022-11-02 14:26:17 +08:00
|
|
|
uses: ashay/cache@v1
|
2022-10-18 13:42:42 +08:00
|
|
|
with:
|
|
|
|
path: ${{ github.workspace }}/build_tools/python_deploy/wheelhouse
|
2022-11-02 14:26:17 +08:00
|
|
|
key: ${{ runner.os }}-pytorch-${{ env.PT_HASH }}
|