@@ -20,138 +20,104 @@ on:
2020 default: "pytorch/tutorials"
2121
2222jobs:
23- worker:
24- name: pytorch_tutorial_build_worker
25- strategy:
26- matrix:
27- include:
28- - { shard: 1, num_shards: 15, runner: "linux.g5.12xlarge.nvidia.gpu" }
29- - { shard: 2, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
30- - { shard: 3, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
31- - { shard: 4, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
32- - { shard: 5, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
33- - { shard: 6, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
34- - { shard: 7, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
35- - { shard: 8, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
36- - { shard: 9, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
37- - { shard: 10, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
38- - { shard: 11, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
39- - { shard: 12, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
40- - { shard: 13, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
41- - { shard: 14, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
42- - { shard: 15, num_shards: 15, runner: "linux.g5.4xlarge.nvidia.gpu" }
43- fail-fast: false
44- runs-on: ${{ matrix.runner }}
23+ docker-image:
24+ name: Resolve CI docker image
25+ runs-on: ubuntu-latest
26+ outputs:
27+ docker-image: ${{ steps.tag.outputs.docker-image }}
4528 steps:
46- - name: Setup SSH (Click me for login details)
47- uses: pytorch/test-infra/.github/actions/setup-ssh@main
48- with:
49- github-secret: ${{ secrets.GITHUB_TOKEN }}
50- instructions: |
51- All testing is done inside the container, to start an interactive session run:
52- docker exec -it $(docker container ps --format '{{.ID}}') bash
53-
5429 - name: Checkout Tutorials
5530 uses: actions/checkout@v6
56- with:
57- fetch-depth: 0
5831
59- - name: Setup Linux
60- uses: pytorch/pytorch/.github/actions/setup-linux@main
61-
62- - name: Install nvidia driver, nvidia-docker runtime, set GPU_FLAG
63- uses: pytorch/test-infra/.github/actions/setup-nvidia@main
64-
65- - name: Calculate/build docker image
66- id: calculate-docker-image
67- uses: pytorch/test-infra/.github/actions/calculate-docker-image@main
68- with:
69- docker-image-name: tutorials
70-
71- - name: Pull docker image
72- uses: pytorch/test-infra/.github/actions/pull-docker-image@main
73- with:
74- docker-image: ${{ steps.calculate-docker-image.outputs.docker-image }}
75-
76- - name: Build
77- shell: bash
78- env:
79- DOCKER_IMAGE: ${{ steps.calculate-docker-image.outputs.docker-image }}
80- NUM_WORKERS: ${{ matrix.num_shards }}
81- WORKER_ID: ${{ matrix.shard }}
82- COMMIT_ID: ${{ github.sha }}
83- JOB_TYPE: worker
84- COMMIT_SOURCE: ${{ github.ref }}
85- USE_NIGHTLY: ${{ inputs.USE_NIGHTLY }}
86- UPLOAD: ${{ inputs.UPLOAD }}
32+ # Built and pushed by docker-build.yml, which a PR changing .ci/docker gets
33+ # through the ciflow/docker label
34+ - name: Compute the image tag
35+ id: tag
8736 run: |
88- set -ex
89-
90- chmod +x ".jenkins/build.sh"
91-
92- container_name=$(docker run \
93- ${GPU_FLAG:-} \
94- -e WORKER_ID \
95- -e NUM_WORKERS \
96- -e COMMIT_ID \
97- -e JOB_TYPE \
98- -e COMMIT_SOURCE \
99- -e USE_NIGHTLY \
100- -e UPLOAD \
101- --env-file="/tmp/github_env_${GITHUB_RUN_ID}" \
102- --tty \
103- --detach \
104- --shm-size=2gb \
105- --name="${container_name}" \
106- -v "${GITHUB_WORKSPACE}:/var/lib/workspace" \
107- -w /var/lib/workspace \
108- "${DOCKER_IMAGE}"
109- )
110-
111- docker exec -u ci-user -t "${container_name}" sh -c ".jenkins/build.sh"
112-
113- - name: Teardown Linux
114- uses: pytorch/test-infra/.github/actions/teardown-linux@main
115- if: always()
37+ set -eu
38+ DOCKER_TAG="$(git rev-parse HEAD:.ci/docker)"
39+ echo "docker-image=308535385114.dkr.ecr.us-east-1.amazonaws.com/tutorials/tutorials:${DOCKER_TAG}" >> "${GITHUB_OUTPUT}"
11640
41+ worker:
42+ name: pytorch_tutorial_build_worker
43+ needs: docker-image
44+ uses: pytorch/test-infra/.github/workflows/linux_job_v3.yml@main
45+ permissions:
46+ id-token: write
47+ contents: read
48+ strategy:
49+ matrix:
50+ include:
51+ - { shard: 1, num_shards: 15, runner: "mt-l-x86aavx2-45-167-a10g-4" }
52+ - { shard: 2, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
53+ - { shard: 3, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
54+ - { shard: 4, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
55+ - { shard: 5, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
56+ - { shard: 6, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
57+ - { shard: 7, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
58+ - { shard: 8, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
59+ - { shard: 9, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
60+ - { shard: 10, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
61+ - { shard: 11, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
62+ - { shard: 12, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
63+ - { shard: 13, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
64+ - { shard: 14, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
65+ - { shard: 15, num_shards: 15, runner: "mt-l-x86aavx2-11-41-a10g" }
66+ fail-fast: false
67+ with:
68+ job-name: pytorch_tutorial_build_worker
69+ runner: ${{ matrix.runner }}
70+ docker-image: ${{ needs.docker-image.outputs.docker-image }}
71+ gpu-arch-type: cuda
72+ fetch-depth: 0
73+ timeout: 120
74+ script: |
75+ set -ex
76+
77+ export NUM_WORKERS=${{ matrix.num_shards }}
78+ export WORKER_ID=${{ matrix.shard }}
79+ export COMMIT_ID=${{ github.sha }}
80+ export JOB_TYPE=worker
81+ export COMMIT_SOURCE=${{ github.ref }}
82+ export USE_NIGHTLY=${{ inputs.USE_NIGHTLY }}
83+ export UPLOAD=${{ inputs.UPLOAD }}
84+
85+ .jenkins/build.sh
86+
87+ # Not on linux_job_v3: a job calling a reusable workflow cannot set the environment
88+ # that holds PYTORCHBOT_TOKEN, and the preview goes to a caller-chosen S3 prefix
11789 manager:
11890 name: pytorch_tutorial_build_manager
119- needs: worker
120- runs-on: [self-hosted, linux.2xlarge]
91+ needs: [docker-image, worker]
92+ runs-on: mt-l-x86iavx512-8-64
93+ container:
94+ image: ${{ needs.docker-image.outputs.docker-image }}
12195 if: ${{ inputs.UPLOAD == 1 }}
12296 environment: ${{ github.ref == 'refs/heads/main' && 'pytorchbot-env' || '' }}
97+ permissions:
98+ id-token: write
99+ contents: read
100+ timeout-minutes: 120
123101 steps:
124- - name: Setup SSH (Click me for login details)
125- uses: pytorch/test-infra/.github/actions/setup-ssh@main
126- with:
127- github-secret: ${{ secrets.GITHUB_TOKEN }}
128- instructions: |
129- All testing is done inside the container, to start an interactive session run:
130- docker exec -it $(docker container ps --format '{{.ID}}') bash
102+ # The workspace is created as uid 1001, which the image's ci-user cannot write to
103+ - name: Fix workspace permissions
104+ run: sudo chmod -R 777 "${GITHUB_WORKSPACE}" 2>/dev/null || true
131105
132106 - name: Checkout Tutorials
133107 uses: actions/checkout@v6
134108 with:
135109 fetch-depth: 0
136110
137- - name: Setup Linux
138- uses: pytorch/pytorch/.github/actions/setup-linux@main
139-
140- - name: Calculate/build docker image
141- id: calculate-docker-image
142- uses: pytorch/test-infra/.github/actions/calculate-docker-image@main
111+ - name: Configure AWS credentials
112+ uses: aws-actions/configure-aws-credentials@v4
143113 with:
144- docker-image-name: tutorials
145-
146- - name: Pull docker image
147- uses: pytorch/test-infra/.github/actions/pull-docker-image@main
148- with:
149- docker-image: ${{ steps.calculate-docker-image.outputs.docker-image }}
114+ role-to-assume: arn:aws:iam::308535385114:role/arc
115+ aws-region: us-east-1
116+ role-duration-seconds: 18000
150117
151118 - name: Build
152119 shell: bash
153120 env:
154- DOCKER_IMAGE: ${{ steps.calculate-docker-image.outputs.docker-image }}
155121 NUM_WORKERS: 15
156122 WORKER_ID: 0
157123 COMMIT_ID: ${{ github.sha }}
@@ -161,39 +127,21 @@ jobs:
161127 USE_NIGHTLY: ${{ inputs.USE_NIGHTLY }}
162128 run: |
163129 set -ex
130+ .jenkins/build.sh
164131
165- chmod +x ".jenkins/build.sh"
166-
167- container_name=$(docker run \
168- ${GPU_FLAG:-} \
169- -e WORKER_ID \
170- -e NUM_WORKERS \
171- -e COMMIT_ID \
172- -e JOB_TYPE \
173- -e COMMIT_SOURCE \
174- -e GITHUB_PYTORCHBOT_TOKEN \
175- -e USE_NIGHTLY \
176- --env-file="/tmp/github_env_${GITHUB_RUN_ID}" \
177- --tty \
178- --detach \
179- --name="${container_name}" \
180- -v "${GITHUB_WORKSPACE}:/var/lib/workspace" \
181- -w /var/lib/workspace \
182- "${DOCKER_IMAGE}"
183- )
184-
185- docker exec -u ci-user -t "${container_name}" sh -c ".jenkins/build.sh"
132+ # The ciflow/docs/<pr> tag still names the pull request, so the preview
133+ # keeps the per-PR prefix. An expression cannot split a ref, hence the step.
134+ - name: Resolve the preview prefix
135+ id: preview
136+ if: ${{ startsWith(github.ref, 'refs/tags/ciflow/docs/') }}
137+ run: echo "prefix=${GITHUB_REF##*/}" >> "${GITHUB_OUTPUT}"
186138
187139 - name: Upload docs preview
188140 uses: seemethere/upload-artifact-s3@v5
189- if: ${{ github.event_name == 'pull_request' }}
141+ if: ${{ startsWith( github.ref, 'refs/tags/ciflow/docs/') }}
190142 with:
191143 retention-days: 14
192144 s3-bucket: doc-previews
193145 if-no-files-found: error
194146 path: docs
195- s3-prefix: ${{ inputs.S3_PREFIX }}/${{ github.event.pull_request.number }}
196-
197- - name: Teardown Linux
198- uses: pytorch/test-infra/.github/actions/teardown-linux@main
199- if: always()
147+ s3-prefix: ${{ inputs.S3_PREFIX }}/${{ steps.preview.outputs.prefix }}
0 commit comments