Skip to content

Commit

Permalink
Unify how we use torch commit in the CI. (#7164)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanbasten23 authored Jun 1, 2024
1 parent 09cfdbf commit 89832c3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 29 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/_get_torch_commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,9 @@ jobs:
run: |
ls -la
rm -rvf ${GITHUB_WORKSPACE}/*
- name: Checkout PyTorch Repo
uses: actions/checkout@v4
with:
repository: pytorch/pytorch
path: pytorch
submodules: recursive
- id: get_torch_commit
name: Get torch commit
run: |
cd pytorch
torch_commit=$(git rev-parse HEAD)
torch_commit=$(git ls-remote https://github.com/pytorch/pytorch.git HEAD | awk '{print $1}')
echo "torch_commit=$torch_commit" >> "$GITHUB_OUTPUT"
14 changes: 5 additions & 9 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ on:
type: boolean
default: false
description: Whether to install CUDA plugin package
torch-commit:
required: true
type: string
description: torch-commit

secrets:
gcloud-service-key:
Expand Down Expand Up @@ -128,20 +132,12 @@ jobs:
echo "Import check..."
python -c "import torch_xla"
- name: Record PyTorch commit
run: |
# Don't just pipe output in shell because imports may do extra logging
python -c "
import torch_xla.version
with open('$GITHUB_ENV', 'a') as f:
f.write(f'PYTORCH_COMMIT={torch_xla.version.__torch_gitrev__}\n')
"
- name: Checkout PyTorch Repo
uses: actions/checkout@v4
with:
repository: pytorch/pytorch
path: pytorch
ref: ${{ env.PYTORCH_COMMIT }}
ref: ${{ inputs.torch-commit }}
- name: Checkout PyTorch/XLA Repo
uses: actions/checkout@v4
with:
Expand Down
14 changes: 5 additions & 9 deletions .github/workflows/_test_requiring_torch_cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ on:
description: |
Set the maximum (in minutes) how long the workflow should take to finish
timeout-minutes:
torch-commit:
required: true
type: string
description: torch-commit

jobs:
test:
Expand Down Expand Up @@ -84,20 +88,12 @@ jobs:
echo "Check if CUDA is available for PyTorch..."
python -c "import torch; assert torch.cuda.is_available()"
echo "CUDA is available for PyTorch."
- name: Record PyTorch commit
run: |
# Don't just pipe output in shell because imports may do extra logging
python -c "
import torch_xla.version
with open('$GITHUB_ENV', 'a') as f:
f.write(f'PYTORCH_COMMIT={torch_xla.version.__torch_gitrev__}\n')
"
- name: Checkout PyTorch Repo
uses: actions/checkout@v4
with:
repository: pytorch/pytorch
path: pytorch
ref: ${{ env.PYTORCH_COMMIT }}
ref: ${{ inputs.torch-commit }}
- name: Checkout PyTorch/XLA Repo
uses: actions/checkout@v4
with:
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,36 +55,39 @@ jobs:
test-python-cpu:
name: "CPU tests"
uses: ./.github/workflows/_test.yml
needs: build-torch-xla
needs: [build-torch-xla, get-torch-commit]
with:
dev-image: us-central1-docker.pkg.dev/tpu-pytorch-releases/docker/development:3.10_tpuvm
timeout-minutes: 120
collect-coverage: false
torch-commit: ${{needs.get-torch-commit.outputs.torch_commit}}
secrets:
gcloud-service-key: ${{ secrets.GCLOUD_SERVICE_KEY }}

test-cuda:
name: "GPU tests"
uses: ./.github/workflows/_test.yml
needs: [build-torch-xla, build-cuda-plugin]
needs: [build-torch-xla, build-cuda-plugin, get-torch-commit]
with:
dev-image: us-central1-docker.pkg.dev/tpu-pytorch-releases/docker/development:3.10_cuda_12.1
runner: linux.8xlarge.nvidia.gpu
timeout-minutes: 300
collect-coverage: false
install-cuda-plugin: true
torch-commit: ${{needs.get-torch-commit.outputs.torch_commit}}
secrets:
gcloud-service-key: ${{ secrets.GCLOUD_SERVICE_KEY }}

test-cuda-with-pytorch-cuda-enabled:
name: "GPU tests requiring torch CUDA"
uses: ./.github/workflows/_test_requiring_torch_cuda.yml
needs: [build-torch-with-cuda, build-torch-xla, build-cuda-plugin]
needs: [build-torch-with-cuda, build-torch-xla, build-cuda-plugin, get-torch-commit]
with:
dev-image: us-central1-docker.pkg.dev/tpu-pytorch-releases/docker/development:3.10_cuda_12.1
runner: linux.8xlarge.nvidia.gpu
timeout-minutes: 300
collect-coverage: false
torch-commit: ${{needs.get-torch-commit.outputs.torch_commit}}

test-tpu:
name: "TPU tests"
Expand Down

0 comments on commit 89832c3

Please sign in to comment.