From 993a286a05d92c9ce89f05b5a260438d53a6db02 Mon Sep 17 00:00:00 2001 From: Andrey Talman Date: Wed, 28 Oct 2026 15:32:53 -0400 Subject: [PATCH] Revert "Move the tutorials build to OSDC runners (#3976)" This reverts commit ce8d551d11baebcf8064be3caba7b28a4d84a15d. --- .ci/docker/common/install_user.sh | 6 +- .github/labeler.yml | 14 -- .github/pytorch-probot.yml | 1 - .github/workflows/_build-tutorials-base.yml | 220 +++++++++++------- .github/workflows/build-tutorials-nightly.yml | 3 - .github/workflows/build-tutorials.yml | 8 +- 6 files changed, 142 insertions(+), 110 deletions(-) diff --git a/.ci/docker/common/install_user.sh b/.ci/docker/common/install_user.sh index dc9d1b8a863..6deb62086bc 100644 --- a/.ci/docker/common/install_user.sh +++ b/.ci/docker/common/install_user.sh @@ -9,9 +9,9 @@ set -ex -# Same uid as the OSDC runner, which owns the job workspace -echo "ci-user:x:1001:1001::/var/lib/ci-user:" >> /etc/passwd -echo "ci-user:x:1001:" >> /etc/group +# Same as ec2-user +echo "ci-user:x:1000:1000::/var/lib/ci-user:" >> /etc/passwd +echo "ci-user:x:1000:" >> /etc/group # Needed on Focal or newer echo "ci-user:*:19110:0:99999:7:::" >> /etc/shadow diff --git a/.github/labeler.yml b/.github/labeler.yml index 33e8f2a3181..d1a7c744ed1 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -3,17 +3,3 @@ - .ci/docker/** - .github/workflows/docker-build.yml draft: false - -"ciflow/docs": - globs: - - "*.rst" - - "*.py" - - Makefile - - requirements.txt - - _static/** - - _templates/** - - "*_source/**" - - .jenkins/** - - .github/workflows/_build-tutorials-base.yml - - .github/workflows/build-tutorials.yml - draft: false diff --git a/.github/pytorch-probot.yml b/.github/pytorch-probot.yml index ca3fc45398a..606596e520e 100644 --- a/.github/pytorch-probot.yml +++ b/.github/pytorch-probot.yml @@ -1,5 +1,4 @@ tracking_issue: 1896 ciflow_push_tags: - ciflow/docker -- ciflow/docs labeler_config: labeler.yml diff --git a/.github/workflows/_build-tutorials-base.yml b/.github/workflows/_build-tutorials-base.yml index 9c6d749302e..f42ef7e1d23 100644 --- a/.github/workflows/_build-tutorials-base.yml +++ b/.github/workflows/_build-tutorials-base.yml @@ -20,100 +20,138 @@ on: default: "pytorch/tutorials" jobs: - docker-image: - name: Resolve CI docker image - runs-on: ubuntu-latest - outputs: - docker-image: ${{ steps.tag.outputs.docker-image }} - steps: - - name: Checkout Tutorials - uses: actions/checkout@v6 - - # Built and pushed by docker-build.yml, which a PR changing .ci/docker gets - # through the ciflow/docker label - - name: Compute the image tag - id: tag - run: | - set -eu - DOCKER_TAG="$(git rev-parse HEAD:.ci/docker)" - echo "docker-image=308535385114.dkr.ecr.us-east-1.amazonaws.com/tutorials/tutorials:${DOCKER_TAG}" >> "${GITHUB_OUTPUT}" - worker: name: pytorch_tutorial_build_worker - needs: docker-image - uses: pytorch/test-infra/.github/workflows/linux_job_v3.yml@main - permissions: - id-token: write - contents: read strategy: matrix: include: - - { shard: 1, num_shards: 15, runner: "mt-l-x86aavx2-45-167-a10g-4" } - - { shard: 2, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" } - - { shard: 3, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" } - - { shard: 4, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" } - - { shard: 5, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" } - - { shard: 6, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" } - - { shard: 7, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" } - - { shard: 8, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" } - - { shard: 9, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" } - - { shard: 10, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" } - - { shard: 11, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" } - - { shard: 12, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" } - - { shard: 13, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" } - - { shard: 14, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" } - - { shard: 15, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" } + - { shard: 1, num_shards: 15, runner: "linux.g5.12xlarge.nvidia.gpu" } + - { shard: 2, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" } + - { shard: 3, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" } + - { shard: 4, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" } + - { shard: 5, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" } + - { shard: 6, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" } + - { shard: 7, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" } + - { shard: 8, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" } + - { shard: 9, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" } + - { shard: 10, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" } + - { shard: 11, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" } + - { shard: 12, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" } + - { shard: 13, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" } + - { shard: 14, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" } + - { shard: 15, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" } fail-fast: false - with: - job-name: pytorch_tutorial_build_worker - runner: ${{ matrix.runner }} - docker-image: ${{ needs.docker-image.outputs.docker-image }} - gpu-arch-type: cuda - fetch-depth: 0 - timeout: 120 - script: | - set -ex - - export NUM_WORKERS=${{ matrix.num_shards }} - export WORKER_ID=${{ matrix.shard }} - export COMMIT_ID=${{ github.sha }} - export JOB_TYPE=worker - export COMMIT_SOURCE=${{ github.ref }} - export USE_NIGHTLY=${{ inputs.USE_NIGHTLY }} - export UPLOAD=${{ inputs.UPLOAD }} - - .jenkins/build.sh - - # Not on linux_job_v3: a job calling a reusable workflow cannot set the environment - # that holds PYTORCHBOT_TOKEN, and the preview goes to a caller-chosen S3 prefix + runs-on: ${{ matrix.runner }} + steps: + - name: Setup SSH (Click me for login details) + uses: pytorch/test-infra/.github/actions/setup-ssh@main + with: + github-secret: ${{ secrets.GITHUB_TOKEN }} + instructions: | + All testing is done inside the container, to start an interactive session run: + docker exec -it $(docker container ps --format '{{.ID}}') bash + + - name: Checkout Tutorials + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Setup Linux + uses: pytorch/pytorch/.github/actions/setup-linux@main + + - name: Install nvidia driver, nvidia-docker runtime, set GPU_FLAG + uses: pytorch/test-infra/.github/actions/setup-nvidia@main + + - name: Calculate/build docker image + id: calculate-docker-image + uses: pytorch/test-infra/.github/actions/calculate-docker-image@main + with: + docker-image-name: tutorials + + - name: Pull docker image + uses: pytorch/test-infra/.github/actions/pull-docker-image@main + with: + docker-image: ${{ steps.calculate-docker-image.outputs.docker-image }} + + - name: Build + shell: bash + env: + DOCKER_IMAGE: ${{ steps.calculate-docker-image.outputs.docker-image }} + NUM_WORKERS: ${{ matrix.num_shards }} + WORKER_ID: ${{ matrix.shard }} + COMMIT_ID: ${{ github.sha }} + JOB_TYPE: worker + COMMIT_SOURCE: ${{ github.ref }} + USE_NIGHTLY: ${{ inputs.USE_NIGHTLY }} + UPLOAD: ${{ inputs.UPLOAD }} + run: | + set -ex + + chmod +x ".jenkins/build.sh" + + container_name=$(docker run \ + ${GPU_FLAG:-} \ + -e WORKER_ID \ + -e NUM_WORKERS \ + -e COMMIT_ID \ + -e JOB_TYPE \ + -e COMMIT_SOURCE \ + -e USE_NIGHTLY \ + -e UPLOAD \ + --env-file="/tmp/github_env_${GITHUB_RUN_ID}" \ + --tty \ + --detach \ + --shm-size=2gb \ + --name="${container_name}" \ + -v "${GITHUB_WORKSPACE}:/var/lib/workspace" \ + -w /var/lib/workspace \ + "${DOCKER_IMAGE}" + ) + + docker exec -u ci-user -t "${container_name}" sh -c ".jenkins/build.sh" + + - name: Teardown Linux + uses: pytorch/test-infra/.github/actions/teardown-linux@main + if: always() + manager: name: pytorch_tutorial_build_manager - needs: [docker-image, worker] - runs-on: mt-l-x86iavx512-8-64 - container: - image: ${{ needs.docker-image.outputs.docker-image }} + needs: worker + runs-on: [self-hosted, linux.2xlarge] if: ${{ inputs.UPLOAD == 1 }} environment: ${{ github.ref == 'refs/heads/main' && 'pytorchbot-env' || '' }} - permissions: - id-token: write - contents: read - timeout-minutes: 120 steps: + - name: Setup SSH (Click me for login details) + uses: pytorch/test-infra/.github/actions/setup-ssh@main + with: + github-secret: ${{ secrets.GITHUB_TOKEN }} + instructions: | + All testing is done inside the container, to start an interactive session run: + docker exec -it $(docker container ps --format '{{.ID}}') bash + - name: Checkout Tutorials uses: actions/checkout@v6 with: fetch-depth: 0 - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 + - name: Setup Linux + uses: pytorch/pytorch/.github/actions/setup-linux@main + + - name: Calculate/build docker image + id: calculate-docker-image + uses: pytorch/test-infra/.github/actions/calculate-docker-image@main with: - role-to-assume: arn:aws:iam::308535385114:role/arc - aws-region: us-east-1 - role-duration-seconds: 18000 + docker-image-name: tutorials + + - name: Pull docker image + uses: pytorch/test-infra/.github/actions/pull-docker-image@main + with: + docker-image: ${{ steps.calculate-docker-image.outputs.docker-image }} - name: Build shell: bash env: + DOCKER_IMAGE: ${{ steps.calculate-docker-image.outputs.docker-image }} NUM_WORKERS: 15 WORKER_ID: 0 COMMIT_ID: ${{ github.sha }} @@ -123,21 +161,39 @@ jobs: USE_NIGHTLY: ${{ inputs.USE_NIGHTLY }} run: | set -ex - .jenkins/build.sh - # The ciflow/docs/ tag still names the pull request, so the preview - # keeps the per-PR prefix. An expression cannot split a ref, hence the step. - - name: Resolve the preview prefix - id: preview - if: ${{ startsWith(github.ref, 'refs/tags/ciflow/docs/') }} - run: echo "prefix=${GITHUB_REF##*/}" >> "${GITHUB_OUTPUT}" + chmod +x ".jenkins/build.sh" + + container_name=$(docker run \ + ${GPU_FLAG:-} \ + -e WORKER_ID \ + -e NUM_WORKERS \ + -e COMMIT_ID \ + -e JOB_TYPE \ + -e COMMIT_SOURCE \ + -e GITHUB_PYTORCHBOT_TOKEN \ + -e USE_NIGHTLY \ + --env-file="/tmp/github_env_${GITHUB_RUN_ID}" \ + --tty \ + --detach \ + --name="${container_name}" \ + -v "${GITHUB_WORKSPACE}:/var/lib/workspace" \ + -w /var/lib/workspace \ + "${DOCKER_IMAGE}" + ) + + docker exec -u ci-user -t "${container_name}" sh -c ".jenkins/build.sh" - name: Upload docs preview uses: seemethere/upload-artifact-s3@v5 - if: ${{ startsWith(github.ref, 'refs/tags/ciflow/docs/') }} + if: ${{ github.event_name == 'pull_request' }} with: retention-days: 14 s3-bucket: doc-previews if-no-files-found: error path: docs - s3-prefix: ${{ inputs.S3_PREFIX }}/${{ steps.preview.outputs.prefix }} + s3-prefix: ${{ inputs.S3_PREFIX }}/${{ github.event.pull_request.number }} + + - name: Teardown Linux + uses: pytorch/test-infra/.github/actions/teardown-linux@main + if: always() diff --git a/.github/workflows/build-tutorials-nightly.yml b/.github/workflows/build-tutorials-nightly.yml index 98935baa332..57aff644a88 100644 --- a/.github/workflows/build-tutorials-nightly.yml +++ b/.github/workflows/build-tutorials-nightly.yml @@ -29,9 +29,6 @@ concurrency: jobs: build: - permissions: - id-token: write - contents: read uses: ./.github/workflows/_build-tutorials-base.yml secrets: inherit with: diff --git a/.github/workflows/build-tutorials.yml b/.github/workflows/build-tutorials.yml index bbbeedeaab4..58372d557e6 100644 --- a/.github/workflows/build-tutorials.yml +++ b/.github/workflows/build-tutorials.yml @@ -1,13 +1,10 @@ name: Build tutorials on: + pull_request: push: branches: - main - # A fork PR gets no OIDC token to upload the preview, so a PR builds through - # the ciflow/docs label, which pushes this tag from the base repo - tags: - - ciflow/docs/* concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }} @@ -15,9 +12,6 @@ concurrency: jobs: build: - permissions: - id-token: write - contents: read uses: ./.github/workflows/_build-tutorials-base.yml secrets: inherit with: