diff --git a/.github/workflows/_get_torch_commit.yml b/.github/workflows/_get_torch_commit.yml index debaecd8194..062a95a248e 100644 --- a/.github/workflows/_get_torch_commit.yml +++ b/.github/workflows/_get_torch_commit.yml @@ -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" diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml index 8a454cc075b..ed0376558eb 100644 --- a/.github/workflows/_test.yml +++ b/.github/workflows/_test.yml @@ -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: @@ -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: diff --git a/.github/workflows/_test_requiring_torch_cuda.yml b/.github/workflows/_test_requiring_torch_cuda.yml index a3e265e557f..a56b85616a5 100644 --- a/.github/workflows/_test_requiring_torch_cuda.yml +++ b/.github/workflows/_test_requiring_torch_cuda.yml @@ -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: @@ -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: diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 1a924f65036..7cb8dd9adff 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -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"