|
| 1 | +name: torchprime E2E tests |
| 2 | +description: | |
| 3 | + This workflow builds a docker image with the PyTorch/XLA wheels and then |
| 4 | + triggers a torchprime (https://github.com/AI-Hypercomputer/torchprime) |
| 5 | + E2E test using that docker image. It is intended to catch performance |
| 6 | + regressions and API breaking changes in PyTorch/XLA pull requests. |
| 7 | +on: |
| 8 | + workflow_call: |
| 9 | + inputs: |
| 10 | + timeout-minutes: |
| 11 | + required: false |
| 12 | + type: number |
| 13 | + description: Timeout in minutes for the job run |
| 14 | + default: 80 |
| 15 | + has_code_changes: |
| 16 | + required: false |
| 17 | + type: string |
| 18 | + description: Whether to run full workflow or not |
| 19 | + default: 'true' |
| 20 | + secrets: |
| 21 | + # This is a token for the `torchxlabot2` user, which has access to the torchprime repo. |
| 22 | + # It is used to trigger the torchprime E2E test workflow. |
| 23 | + # The token should be managed in the "Settings > Secrets and variables > Actions" |
| 24 | + # section of the repo. |
| 25 | + TORCH_XLA_BOT_TOKEN: |
| 26 | + required: true |
| 27 | + GCLOUD_SERVICE_KEY: |
| 28 | + required: true |
| 29 | +jobs: |
| 30 | + torchprime-e2e-test: |
| 31 | + name: Run torchprime E2E tests |
| 32 | + timeout-minutes: ${{ inputs.timeout-minutes }} |
| 33 | + runs-on: ubuntu-22.04 |
| 34 | + steps: |
| 35 | + - name: Use Docker in rootless mode |
| 36 | + if: inputs.has_code_changes == 'true' |
| 37 | + |
| 38 | + - name: Add user to docker group |
| 39 | + if: inputs.has_code_changes == 'true' |
| 40 | + run: | |
| 41 | + sudo usermod -aG docker $USER |
| 42 | + newgrp docker |
| 43 | + shell: bash |
| 44 | + # Googlers: if this fails, follow go/ptxla-sa-key to debug. |
| 45 | + - uses: google-github-actions/auth@v2 |
| 46 | + if: inputs.has_code_changes == 'true' |
| 47 | + with: |
| 48 | + credentials_json: '${{ secrets.GCLOUD_SERVICE_KEY }}' |
| 49 | + - uses: google-github-actions/setup-gcloud@v2 |
| 50 | + if: inputs.has_code_changes == 'true' |
| 51 | + with: |
| 52 | + version: '>= 363.0.0' |
| 53 | + install_components: 'beta,gke-gcloud-auth-plugin' |
| 54 | + - name: Verify GCP setup |
| 55 | + if: inputs.has_code_changes == 'true' |
| 56 | + run: gcloud info |
| 57 | + shell: bash |
| 58 | + - name: Authenticate Docker |
| 59 | + if: inputs.has_code_changes == 'true' |
| 60 | + run: gcloud auth configure-docker --quiet |
| 61 | + shell: bash |
| 62 | + - name: Activate SA credentials |
| 63 | + if: inputs.has_code_changes == 'true' |
| 64 | + run: gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS |
| 65 | + shell: bash |
| 66 | + - name: Checkout infra |
| 67 | + if: inputs.has_code_changes == 'true' |
| 68 | + uses: actions/checkout@v4 |
| 69 | + with: |
| 70 | + sparse-checkout: | |
| 71 | + infra |
| 72 | + fetch-depth: 1 |
| 73 | + path: pytorch-xla |
| 74 | + # Build a docker image for torchprime E2E test |
| 75 | + # First download the torch-xla-wheels |
| 76 | + - name: Fetch wheels |
| 77 | + if: inputs.has_code_changes == 'true' |
| 78 | + uses: actions/download-artifact@v4 |
| 79 | + with: |
| 80 | + name: torch-xla-wheels |
| 81 | + path: /tmp/wheels/ |
| 82 | + # Generate a 16-character random ID for the docker tag |
| 83 | + - name: Generate random docker tag |
| 84 | + if: inputs.has_code_changes == 'true' |
| 85 | + id: random_tag |
| 86 | + shell: bash |
| 87 | + run: | |
| 88 | + echo "random_id=$(openssl rand -hex 8)" >> $GITHUB_OUTPUT |
| 89 | + # Then run docker to install them and push a docker |
| 90 | + - name: Build and push docker image |
| 91 | + if: inputs.has_code_changes == 'true' |
| 92 | + id: build_docker |
| 93 | + shell: bash |
| 94 | + working-directory: pytorch-xla |
| 95 | + run: | |
| 96 | + . ./infra/ansible/publish_torchprime_e2e_test_docker.sh |
| 97 | + echo "docker_url=gcr.io/${DOCKER_PROJECT}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" >> $GITHUB_OUTPUT |
| 98 | + env: |
| 99 | + DEFAULT_CONTEXT_PATH: /tmp/wheels |
| 100 | + DOCKER_IMAGE_NAME: for-torchprime-ci |
| 101 | + DOCKER_IMAGE_TAG: ${{ steps.random_tag.outputs.random_id }} |
| 102 | + DOCKER_PROJECT: tpu-pytorch |
| 103 | + # Trigger torchprime E2E test workflow. |
| 104 | + # (Googlers only) in case of infra failure, refer to go/ptxla-torchprime-trigger |
| 105 | + # Refer to the same doc on the retention policy of the docker images. |
| 106 | + - uses: convictional/[email protected] |
| 107 | + if: inputs.has_code_changes == 'true' |
| 108 | + with: |
| 109 | + owner: AI-Hypercomputer |
| 110 | + repo: torchprime |
| 111 | + github_token: ${{ secrets.TORCH_XLA_BOT_TOKEN }} |
| 112 | + workflow_file_name: e2e_test.yml |
| 113 | + wait_interval: 60 |
| 114 | + ref: main |
| 115 | + client_payload: '{"docker_url": "${{ steps.build_docker.outputs.docker_url }}"}' |
0 commit comments