@@ -20,138 +20,100 @@ 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
58-
59- - name : Setup Linux
60- uses : pytorch/pytorch/.github/actions/setup-linux@main
6131
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
131-
132102 - name : Checkout Tutorials
133103 uses : actions/checkout@v6
134104 with :
135105 fetch-depth : 0
136106
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
107+ - name : Configure AWS credentials
108+ uses : aws-actions/configure-aws-credentials@v4
143109 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 }}
110+ role-to-assume : arn:aws:iam::308535385114:role/arc
111+ aws-region : us-east-1
112+ role-duration-seconds : 18000
150113
151114 - name : Build
152115 shell : bash
153116 env :
154- DOCKER_IMAGE : ${{ steps.calculate-docker-image.outputs.docker-image }}
155117 NUM_WORKERS : 15
156118 WORKER_ID : 0
157119 COMMIT_ID : ${{ github.sha }}
@@ -161,39 +123,21 @@ jobs:
161123 USE_NIGHTLY : ${{ inputs.USE_NIGHTLY }}
162124 run : |
163125 set -ex
126+ .jenkins/build.sh
164127
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"
128+ # The ciflow/docs/<pr> tag still names the pull request, so the preview
129+ # keeps the per-PR prefix. An expression cannot split a ref, hence the step.
130+ - name : Resolve the preview prefix
131+ id : preview
132+ if : ${{ startsWith(github.ref, 'refs/tags/ciflow/docs/') }}
133+ run : echo "prefix=${GITHUB_REF##*/}" >> "${GITHUB_OUTPUT}"
186134
187135 - name : Upload docs preview
188136 uses : seemethere/upload-artifact-s3@v5
189- if : ${{ github.event_name == 'pull_request' }}
137+ if : ${{ startsWith( github.ref, 'refs/tags/ciflow/docs/') }}
190138 with :
191139 retention-days : 14
192140 s3-bucket : doc-previews
193141 if-no-files-found : error
194142 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()
143+ s3-prefix : ${{ inputs.S3_PREFIX }}/${{ steps.preview.outputs.prefix }}
0 commit comments