• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @generated DO NOT EDIT MANUALLY
2
3# Template is at:    .github/templates/macos_binary_build_workflow.yml.j2
4# Generation script: .github/scripts/generate_ci_workflows.py
5name: macos-arm64-binary-conda
6
7on:
8# TODO: Migrate to new ciflow trigger, reference https://github.com/pytorch/pytorch/pull/70321
9  push:
10    # NOTE: Meta Employees can trigger new nightlies using: https://fburl.com/trigger_pytorch_nightly_build
11    branches:
12      - nightly
13    tags:
14      # NOTE: Binary build pipelines should only get triggered on release candidate builds
15      # Release candidate tags look like: v1.11.0-rc1
16      - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
17      - 'ciflow/binaries/*'
18      - 'ciflow/binaries_conda/*'
19  workflow_dispatch:
20
21env:
22  # Needed for conda builds
23  ALPINE_IMAGE: "308535385114.dkr.ecr.us-east-1.amazonaws.com/tool/alpine"
24  ANACONDA_USER: pytorch
25  AWS_DEFAULT_REGION: us-east-1
26  BUILD_ENVIRONMENT: macos-arm64-binary-conda
27  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28  PR_NUMBER: ${{ github.event.pull_request.number }}
29  SKIP_ALL_TESTS: 0
30concurrency:
31  group: macos-arm64-binary-conda-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
32  cancel-in-progress: true
33
34jobs:
35  conda-py3_8-cpu-build:
36    if: ${{ github.repository_owner == 'pytorch' }}
37    runs-on: macos-14-xlarge
38    timeout-minutes: 240
39    env:
40      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
41      BUILDER_ROOT: ${{ github.workspace }}/builder
42      PACKAGE_TYPE: conda
43      # TODO: This is a legacy variable that we eventually want to get rid of in
44      #       favor of GPU_ARCH_VERSION
45      DESIRED_CUDA: cpu
46      GPU_ARCH_TYPE: cpu
47      SKIP_ALL_TESTS: 1
48      DESIRED_PYTHON: "3.8"
49      # For sccache access (only on non-forked PRs)
50      AWS_ACCESS_KEY_ID: ${{ secrets.MACOS_SCCACHE_S3_ACCESS_KEY_ID }}
51      AWS_SECRET_ACCESS_KEY: ${{ secrets.MACOS_SCCACHE_S3_SECRET_ACCESS_KEY }}
52    steps:
53      # NOTE: These environment variables are put here so that they can be applied on every job equally
54      #       They are also here because setting them at a workflow level doesn't give us access to the
55      #       runner.temp variable, which we need.
56      - name: Populate binary env
57        shell: bash
58        run: |
59          # shellcheck disable=SC2129
60          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
61          # shellcheck disable=SC2129
62          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
63          # shellcheck disable=SC2129
64          echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}"
65      - name: Install conda and dependencies
66        run: |
67          # Install conda, setup-miniconda messes with the path that messes with the ruby stuff we do later on
68          curl --retry 3 --retry-all-errors -o "${RUNNER_TEMP}/conda.sh" "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-MacOSX-$(uname -m).sh"
69          chmod +x "${RUNNER_TEMP}/conda.sh"
70          /bin/bash "${RUNNER_TEMP}/conda.sh" -b -p "${RUNNER_TEMP}/anaconda"
71          echo "${RUNNER_TEMP}/anaconda/bin" >> "${GITHUB_PATH}"
72          if [ -d "/Applications/Xcode_14.3.1.app" ]; then
73            echo "DEVELOPER_DIR=/Applications/Xcode_14.3.1.app/Contents/Developer" >> "${GITHUB_ENV}"
74          elif [ -d "/Applications/Xcode_13.3.1.app" ]; then
75            echo "DEVELOPER_DIR=/Applications/Xcode_13.3.1.app/Contents/Developer" >> "${GITHUB_ENV}"
76          fi
77      - name: Checkout PyTorch
78        uses: malfet/checkout@silent-checkout
79        with:
80          submodules: recursive
81          path: pytorch
82          quiet-checkout: true
83      - name: Clean PyTorch checkout
84        run: |
85          # Remove any artifacts from the previous checkouts
86          git clean -fxd
87        working-directory: pytorch
88      - name: Checkout pytorch/builder
89        uses: malfet/checkout@silent-checkout
90        with:
91          ref: release/2.4
92          submodules: recursive
93          repository: pytorch/builder
94          path: builder
95          quiet-checkout: true
96      - name: Clean pytorch/builder checkout
97        run: |
98          # Remove any artifacts from the previous checkouts
99          git clean -fxd
100        working-directory: builder
101      - name: Install sccache (only for non-forked PRs, and pushes to trunk)
102        uses: nick-fields/retry@v2.8.2
103        if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
104        with:
105          timeout_minutes: 5
106          max_attempts: 3
107          retry_wait_seconds: 90
108          command: |
109            sudo curl --retry 3 --retry-all-errors https://s3.amazonaws.com/ossci-macos/sccache_v2.15 --output /usr/local/bin/sccache
110            sudo chmod +x /usr/local/bin/sccache
111            echo "SCCACHE_BUCKET=ossci-compiler-cache-circleci-v2" >> "${GITHUB_ENV}"
112      - name: Populate binary env
113        run: |
114          # shellcheck disable=SC1091
115          source "${RUNNER_TEMP}/anaconda/bin/activate"
116          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
117      - name: Build PyTorch binary
118        run: |
119          # shellcheck disable=SC1091
120          source "${RUNNER_TEMP}/anaconda/bin/activate"
121          "${PYTORCH_ROOT}/.circleci/scripts/binary_macos_build.sh"
122      - uses: actions/upload-artifact@v3
123        if: always()
124        with:
125          name: conda-py3_8-cpu
126          retention-days: 14
127          if-no-files-found: error
128          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
129  conda-py3_8-cpu-upload:  # Uploading
130    if: ${{ github.repository_owner == 'pytorch' }}
131    permissions:
132      id-token: write
133      contents: read
134    needs: conda-py3_8-cpu-build
135    with:
136      PYTORCH_ROOT: /pytorch
137      BUILDER_ROOT: /builder
138      PACKAGE_TYPE: conda
139      # TODO: This is a legacy variable that we eventually want to get rid of in
140      #       favor of GPU_ARCH_VERSION
141      DESIRED_CUDA: cpu
142      GPU_ARCH_TYPE: cpu
143      DOCKER_IMAGE: pytorch/conda-builder:cpu-2.4
144      DESIRED_PYTHON: "3.8"
145      build_name: conda-py3_8-cpu
146      use_s3: False
147    secrets:
148      github-token: ${{ secrets.GITHUB_TOKEN }}
149      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
150      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
151    uses: ./.github/workflows/_binary-upload.yml
152  conda-py3_9-cpu-build:
153    if: ${{ github.repository_owner == 'pytorch' }}
154    runs-on: macos-14-xlarge
155    timeout-minutes: 240
156    env:
157      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
158      BUILDER_ROOT: ${{ github.workspace }}/builder
159      PACKAGE_TYPE: conda
160      # TODO: This is a legacy variable that we eventually want to get rid of in
161      #       favor of GPU_ARCH_VERSION
162      DESIRED_CUDA: cpu
163      GPU_ARCH_TYPE: cpu
164      SKIP_ALL_TESTS: 1
165      DESIRED_PYTHON: "3.9"
166      # For sccache access (only on non-forked PRs)
167      AWS_ACCESS_KEY_ID: ${{ secrets.MACOS_SCCACHE_S3_ACCESS_KEY_ID }}
168      AWS_SECRET_ACCESS_KEY: ${{ secrets.MACOS_SCCACHE_S3_SECRET_ACCESS_KEY }}
169    steps:
170      # NOTE: These environment variables are put here so that they can be applied on every job equally
171      #       They are also here because setting them at a workflow level doesn't give us access to the
172      #       runner.temp variable, which we need.
173      - name: Populate binary env
174        shell: bash
175        run: |
176          # shellcheck disable=SC2129
177          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
178          # shellcheck disable=SC2129
179          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
180          # shellcheck disable=SC2129
181          echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}"
182      - name: Install conda and dependencies
183        run: |
184          # Install conda, setup-miniconda messes with the path that messes with the ruby stuff we do later on
185          curl --retry 3 --retry-all-errors -o "${RUNNER_TEMP}/conda.sh" "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-MacOSX-$(uname -m).sh"
186          chmod +x "${RUNNER_TEMP}/conda.sh"
187          /bin/bash "${RUNNER_TEMP}/conda.sh" -b -p "${RUNNER_TEMP}/anaconda"
188          echo "${RUNNER_TEMP}/anaconda/bin" >> "${GITHUB_PATH}"
189          if [ -d "/Applications/Xcode_14.3.1.app" ]; then
190            echo "DEVELOPER_DIR=/Applications/Xcode_14.3.1.app/Contents/Developer" >> "${GITHUB_ENV}"
191          elif [ -d "/Applications/Xcode_13.3.1.app" ]; then
192            echo "DEVELOPER_DIR=/Applications/Xcode_13.3.1.app/Contents/Developer" >> "${GITHUB_ENV}"
193          fi
194      - name: Checkout PyTorch
195        uses: malfet/checkout@silent-checkout
196        with:
197          submodules: recursive
198          path: pytorch
199          quiet-checkout: true
200      - name: Clean PyTorch checkout
201        run: |
202          # Remove any artifacts from the previous checkouts
203          git clean -fxd
204        working-directory: pytorch
205      - name: Checkout pytorch/builder
206        uses: malfet/checkout@silent-checkout
207        with:
208          ref: release/2.4
209          submodules: recursive
210          repository: pytorch/builder
211          path: builder
212          quiet-checkout: true
213      - name: Clean pytorch/builder checkout
214        run: |
215          # Remove any artifacts from the previous checkouts
216          git clean -fxd
217        working-directory: builder
218      - name: Install sccache (only for non-forked PRs, and pushes to trunk)
219        uses: nick-fields/retry@v2.8.2
220        if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
221        with:
222          timeout_minutes: 5
223          max_attempts: 3
224          retry_wait_seconds: 90
225          command: |
226            sudo curl --retry 3 --retry-all-errors https://s3.amazonaws.com/ossci-macos/sccache_v2.15 --output /usr/local/bin/sccache
227            sudo chmod +x /usr/local/bin/sccache
228            echo "SCCACHE_BUCKET=ossci-compiler-cache-circleci-v2" >> "${GITHUB_ENV}"
229      - name: Populate binary env
230        run: |
231          # shellcheck disable=SC1091
232          source "${RUNNER_TEMP}/anaconda/bin/activate"
233          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
234      - name: Build PyTorch binary
235        run: |
236          # shellcheck disable=SC1091
237          source "${RUNNER_TEMP}/anaconda/bin/activate"
238          "${PYTORCH_ROOT}/.circleci/scripts/binary_macos_build.sh"
239      - uses: actions/upload-artifact@v3
240        if: always()
241        with:
242          name: conda-py3_9-cpu
243          retention-days: 14
244          if-no-files-found: error
245          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
246  conda-py3_9-cpu-upload:  # Uploading
247    if: ${{ github.repository_owner == 'pytorch' }}
248    permissions:
249      id-token: write
250      contents: read
251    needs: conda-py3_9-cpu-build
252    with:
253      PYTORCH_ROOT: /pytorch
254      BUILDER_ROOT: /builder
255      PACKAGE_TYPE: conda
256      # TODO: This is a legacy variable that we eventually want to get rid of in
257      #       favor of GPU_ARCH_VERSION
258      DESIRED_CUDA: cpu
259      GPU_ARCH_TYPE: cpu
260      DOCKER_IMAGE: pytorch/conda-builder:cpu-2.4
261      DESIRED_PYTHON: "3.9"
262      build_name: conda-py3_9-cpu
263      use_s3: False
264    secrets:
265      github-token: ${{ secrets.GITHUB_TOKEN }}
266      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
267      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
268    uses: ./.github/workflows/_binary-upload.yml
269  conda-py3_10-cpu-build:
270    if: ${{ github.repository_owner == 'pytorch' }}
271    runs-on: macos-14-xlarge
272    timeout-minutes: 240
273    env:
274      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
275      BUILDER_ROOT: ${{ github.workspace }}/builder
276      PACKAGE_TYPE: conda
277      # TODO: This is a legacy variable that we eventually want to get rid of in
278      #       favor of GPU_ARCH_VERSION
279      DESIRED_CUDA: cpu
280      GPU_ARCH_TYPE: cpu
281      SKIP_ALL_TESTS: 1
282      DESIRED_PYTHON: "3.10"
283      # For sccache access (only on non-forked PRs)
284      AWS_ACCESS_KEY_ID: ${{ secrets.MACOS_SCCACHE_S3_ACCESS_KEY_ID }}
285      AWS_SECRET_ACCESS_KEY: ${{ secrets.MACOS_SCCACHE_S3_SECRET_ACCESS_KEY }}
286    steps:
287      # NOTE: These environment variables are put here so that they can be applied on every job equally
288      #       They are also here because setting them at a workflow level doesn't give us access to the
289      #       runner.temp variable, which we need.
290      - name: Populate binary env
291        shell: bash
292        run: |
293          # shellcheck disable=SC2129
294          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
295          # shellcheck disable=SC2129
296          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
297          # shellcheck disable=SC2129
298          echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}"
299      - name: Install conda and dependencies
300        run: |
301          # Install conda, setup-miniconda messes with the path that messes with the ruby stuff we do later on
302          curl --retry 3 --retry-all-errors -o "${RUNNER_TEMP}/conda.sh" "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-MacOSX-$(uname -m).sh"
303          chmod +x "${RUNNER_TEMP}/conda.sh"
304          /bin/bash "${RUNNER_TEMP}/conda.sh" -b -p "${RUNNER_TEMP}/anaconda"
305          echo "${RUNNER_TEMP}/anaconda/bin" >> "${GITHUB_PATH}"
306          if [ -d "/Applications/Xcode_14.3.1.app" ]; then
307            echo "DEVELOPER_DIR=/Applications/Xcode_14.3.1.app/Contents/Developer" >> "${GITHUB_ENV}"
308          elif [ -d "/Applications/Xcode_13.3.1.app" ]; then
309            echo "DEVELOPER_DIR=/Applications/Xcode_13.3.1.app/Contents/Developer" >> "${GITHUB_ENV}"
310          fi
311      - name: Checkout PyTorch
312        uses: malfet/checkout@silent-checkout
313        with:
314          submodules: recursive
315          path: pytorch
316          quiet-checkout: true
317      - name: Clean PyTorch checkout
318        run: |
319          # Remove any artifacts from the previous checkouts
320          git clean -fxd
321        working-directory: pytorch
322      - name: Checkout pytorch/builder
323        uses: malfet/checkout@silent-checkout
324        with:
325          ref: release/2.4
326          submodules: recursive
327          repository: pytorch/builder
328          path: builder
329          quiet-checkout: true
330      - name: Clean pytorch/builder checkout
331        run: |
332          # Remove any artifacts from the previous checkouts
333          git clean -fxd
334        working-directory: builder
335      - name: Install sccache (only for non-forked PRs, and pushes to trunk)
336        uses: nick-fields/retry@v2.8.2
337        if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
338        with:
339          timeout_minutes: 5
340          max_attempts: 3
341          retry_wait_seconds: 90
342          command: |
343            sudo curl --retry 3 --retry-all-errors https://s3.amazonaws.com/ossci-macos/sccache_v2.15 --output /usr/local/bin/sccache
344            sudo chmod +x /usr/local/bin/sccache
345            echo "SCCACHE_BUCKET=ossci-compiler-cache-circleci-v2" >> "${GITHUB_ENV}"
346      - name: Populate binary env
347        run: |
348          # shellcheck disable=SC1091
349          source "${RUNNER_TEMP}/anaconda/bin/activate"
350          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
351      - name: Build PyTorch binary
352        run: |
353          # shellcheck disable=SC1091
354          source "${RUNNER_TEMP}/anaconda/bin/activate"
355          "${PYTORCH_ROOT}/.circleci/scripts/binary_macos_build.sh"
356      - uses: actions/upload-artifact@v3
357        if: always()
358        with:
359          name: conda-py3_10-cpu
360          retention-days: 14
361          if-no-files-found: error
362          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
363  conda-py3_10-cpu-upload:  # Uploading
364    if: ${{ github.repository_owner == 'pytorch' }}
365    permissions:
366      id-token: write
367      contents: read
368    needs: conda-py3_10-cpu-build
369    with:
370      PYTORCH_ROOT: /pytorch
371      BUILDER_ROOT: /builder
372      PACKAGE_TYPE: conda
373      # TODO: This is a legacy variable that we eventually want to get rid of in
374      #       favor of GPU_ARCH_VERSION
375      DESIRED_CUDA: cpu
376      GPU_ARCH_TYPE: cpu
377      DOCKER_IMAGE: pytorch/conda-builder:cpu-2.4
378      DESIRED_PYTHON: "3.10"
379      build_name: conda-py3_10-cpu
380      use_s3: False
381    secrets:
382      github-token: ${{ secrets.GITHUB_TOKEN }}
383      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
384      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
385    uses: ./.github/workflows/_binary-upload.yml
386  conda-py3_11-cpu-build:
387    if: ${{ github.repository_owner == 'pytorch' }}
388    runs-on: macos-14-xlarge
389    timeout-minutes: 240
390    env:
391      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
392      BUILDER_ROOT: ${{ github.workspace }}/builder
393      PACKAGE_TYPE: conda
394      # TODO: This is a legacy variable that we eventually want to get rid of in
395      #       favor of GPU_ARCH_VERSION
396      DESIRED_CUDA: cpu
397      GPU_ARCH_TYPE: cpu
398      SKIP_ALL_TESTS: 1
399      DESIRED_PYTHON: "3.11"
400      # For sccache access (only on non-forked PRs)
401      AWS_ACCESS_KEY_ID: ${{ secrets.MACOS_SCCACHE_S3_ACCESS_KEY_ID }}
402      AWS_SECRET_ACCESS_KEY: ${{ secrets.MACOS_SCCACHE_S3_SECRET_ACCESS_KEY }}
403    steps:
404      # NOTE: These environment variables are put here so that they can be applied on every job equally
405      #       They are also here because setting them at a workflow level doesn't give us access to the
406      #       runner.temp variable, which we need.
407      - name: Populate binary env
408        shell: bash
409        run: |
410          # shellcheck disable=SC2129
411          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
412          # shellcheck disable=SC2129
413          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
414          # shellcheck disable=SC2129
415          echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}"
416      - name: Install conda and dependencies
417        run: |
418          # Install conda, setup-miniconda messes with the path that messes with the ruby stuff we do later on
419          curl --retry 3 --retry-all-errors -o "${RUNNER_TEMP}/conda.sh" "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-MacOSX-$(uname -m).sh"
420          chmod +x "${RUNNER_TEMP}/conda.sh"
421          /bin/bash "${RUNNER_TEMP}/conda.sh" -b -p "${RUNNER_TEMP}/anaconda"
422          echo "${RUNNER_TEMP}/anaconda/bin" >> "${GITHUB_PATH}"
423          if [ -d "/Applications/Xcode_14.3.1.app" ]; then
424            echo "DEVELOPER_DIR=/Applications/Xcode_14.3.1.app/Contents/Developer" >> "${GITHUB_ENV}"
425          elif [ -d "/Applications/Xcode_13.3.1.app" ]; then
426            echo "DEVELOPER_DIR=/Applications/Xcode_13.3.1.app/Contents/Developer" >> "${GITHUB_ENV}"
427          fi
428      - name: Checkout PyTorch
429        uses: malfet/checkout@silent-checkout
430        with:
431          submodules: recursive
432          path: pytorch
433          quiet-checkout: true
434      - name: Clean PyTorch checkout
435        run: |
436          # Remove any artifacts from the previous checkouts
437          git clean -fxd
438        working-directory: pytorch
439      - name: Checkout pytorch/builder
440        uses: malfet/checkout@silent-checkout
441        with:
442          ref: release/2.4
443          submodules: recursive
444          repository: pytorch/builder
445          path: builder
446          quiet-checkout: true
447      - name: Clean pytorch/builder checkout
448        run: |
449          # Remove any artifacts from the previous checkouts
450          git clean -fxd
451        working-directory: builder
452      - name: Install sccache (only for non-forked PRs, and pushes to trunk)
453        uses: nick-fields/retry@v2.8.2
454        if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
455        with:
456          timeout_minutes: 5
457          max_attempts: 3
458          retry_wait_seconds: 90
459          command: |
460            sudo curl --retry 3 --retry-all-errors https://s3.amazonaws.com/ossci-macos/sccache_v2.15 --output /usr/local/bin/sccache
461            sudo chmod +x /usr/local/bin/sccache
462            echo "SCCACHE_BUCKET=ossci-compiler-cache-circleci-v2" >> "${GITHUB_ENV}"
463      - name: Populate binary env
464        run: |
465          # shellcheck disable=SC1091
466          source "${RUNNER_TEMP}/anaconda/bin/activate"
467          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
468      - name: Build PyTorch binary
469        run: |
470          # shellcheck disable=SC1091
471          source "${RUNNER_TEMP}/anaconda/bin/activate"
472          "${PYTORCH_ROOT}/.circleci/scripts/binary_macos_build.sh"
473      - uses: actions/upload-artifact@v3
474        if: always()
475        with:
476          name: conda-py3_11-cpu
477          retention-days: 14
478          if-no-files-found: error
479          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
480  conda-py3_11-cpu-upload:  # Uploading
481    if: ${{ github.repository_owner == 'pytorch' }}
482    permissions:
483      id-token: write
484      contents: read
485    needs: conda-py3_11-cpu-build
486    with:
487      PYTORCH_ROOT: /pytorch
488      BUILDER_ROOT: /builder
489      PACKAGE_TYPE: conda
490      # TODO: This is a legacy variable that we eventually want to get rid of in
491      #       favor of GPU_ARCH_VERSION
492      DESIRED_CUDA: cpu
493      GPU_ARCH_TYPE: cpu
494      DOCKER_IMAGE: pytorch/conda-builder:cpu-2.4
495      DESIRED_PYTHON: "3.11"
496      build_name: conda-py3_11-cpu
497      use_s3: False
498    secrets:
499      github-token: ${{ secrets.GITHUB_TOKEN }}
500      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
501      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
502    uses: ./.github/workflows/_binary-upload.yml
503  conda-py3_12-cpu-build:
504    if: ${{ github.repository_owner == 'pytorch' }}
505    runs-on: macos-14-xlarge
506    timeout-minutes: 240
507    env:
508      PYTORCH_ROOT: ${{ github.workspace }}/pytorch
509      BUILDER_ROOT: ${{ github.workspace }}/builder
510      PACKAGE_TYPE: conda
511      # TODO: This is a legacy variable that we eventually want to get rid of in
512      #       favor of GPU_ARCH_VERSION
513      DESIRED_CUDA: cpu
514      GPU_ARCH_TYPE: cpu
515      SKIP_ALL_TESTS: 1
516      DESIRED_PYTHON: "3.12"
517      # For sccache access (only on non-forked PRs)
518      AWS_ACCESS_KEY_ID: ${{ secrets.MACOS_SCCACHE_S3_ACCESS_KEY_ID }}
519      AWS_SECRET_ACCESS_KEY: ${{ secrets.MACOS_SCCACHE_S3_SECRET_ACCESS_KEY }}
520    steps:
521      # NOTE: These environment variables are put here so that they can be applied on every job equally
522      #       They are also here because setting them at a workflow level doesn't give us access to the
523      #       runner.temp variable, which we need.
524      - name: Populate binary env
525        shell: bash
526        run: |
527          # shellcheck disable=SC2129
528          echo "BINARY_ENV_FILE=${RUNNER_TEMP}/env" >> "${GITHUB_ENV}"
529          # shellcheck disable=SC2129
530          echo "PYTORCH_FINAL_PACKAGE_DIR=${RUNNER_TEMP}/artifacts" >> "${GITHUB_ENV}"
531          # shellcheck disable=SC2129
532          echo "MAC_PACKAGE_WORK_DIR=${RUNNER_TEMP}" >> "${GITHUB_ENV}"
533      - name: Install conda and dependencies
534        run: |
535          # Install conda, setup-miniconda messes with the path that messes with the ruby stuff we do later on
536          curl --retry 3 --retry-all-errors -o "${RUNNER_TEMP}/conda.sh" "https://repo.anaconda.com/miniconda/Miniconda3-py310_23.5.2-0-MacOSX-$(uname -m).sh"
537          chmod +x "${RUNNER_TEMP}/conda.sh"
538          /bin/bash "${RUNNER_TEMP}/conda.sh" -b -p "${RUNNER_TEMP}/anaconda"
539          echo "${RUNNER_TEMP}/anaconda/bin" >> "${GITHUB_PATH}"
540          if [ -d "/Applications/Xcode_14.3.1.app" ]; then
541            echo "DEVELOPER_DIR=/Applications/Xcode_14.3.1.app/Contents/Developer" >> "${GITHUB_ENV}"
542          elif [ -d "/Applications/Xcode_13.3.1.app" ]; then
543            echo "DEVELOPER_DIR=/Applications/Xcode_13.3.1.app/Contents/Developer" >> "${GITHUB_ENV}"
544          fi
545      - name: Checkout PyTorch
546        uses: malfet/checkout@silent-checkout
547        with:
548          submodules: recursive
549          path: pytorch
550          quiet-checkout: true
551      - name: Clean PyTorch checkout
552        run: |
553          # Remove any artifacts from the previous checkouts
554          git clean -fxd
555        working-directory: pytorch
556      - name: Checkout pytorch/builder
557        uses: malfet/checkout@silent-checkout
558        with:
559          ref: release/2.4
560          submodules: recursive
561          repository: pytorch/builder
562          path: builder
563          quiet-checkout: true
564      - name: Clean pytorch/builder checkout
565        run: |
566          # Remove any artifacts from the previous checkouts
567          git clean -fxd
568        working-directory: builder
569      - name: Install sccache (only for non-forked PRs, and pushes to trunk)
570        uses: nick-fields/retry@v2.8.2
571        if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
572        with:
573          timeout_minutes: 5
574          max_attempts: 3
575          retry_wait_seconds: 90
576          command: |
577            sudo curl --retry 3 --retry-all-errors https://s3.amazonaws.com/ossci-macos/sccache_v2.15 --output /usr/local/bin/sccache
578            sudo chmod +x /usr/local/bin/sccache
579            echo "SCCACHE_BUCKET=ossci-compiler-cache-circleci-v2" >> "${GITHUB_ENV}"
580      - name: Populate binary env
581        run: |
582          # shellcheck disable=SC1091
583          source "${RUNNER_TEMP}/anaconda/bin/activate"
584          "${PYTORCH_ROOT}/.circleci/scripts/binary_populate_env.sh"
585      - name: Build PyTorch binary
586        run: |
587          # shellcheck disable=SC1091
588          source "${RUNNER_TEMP}/anaconda/bin/activate"
589          "${PYTORCH_ROOT}/.circleci/scripts/binary_macos_build.sh"
590      - uses: actions/upload-artifact@v3
591        if: always()
592        with:
593          name: conda-py3_12-cpu
594          retention-days: 14
595          if-no-files-found: error
596          path: "${{ env.PYTORCH_FINAL_PACKAGE_DIR }}"
597  conda-py3_12-cpu-upload:  # Uploading
598    if: ${{ github.repository_owner == 'pytorch' }}
599    permissions:
600      id-token: write
601      contents: read
602    needs: conda-py3_12-cpu-build
603    with:
604      PYTORCH_ROOT: /pytorch
605      BUILDER_ROOT: /builder
606      PACKAGE_TYPE: conda
607      # TODO: This is a legacy variable that we eventually want to get rid of in
608      #       favor of GPU_ARCH_VERSION
609      DESIRED_CUDA: cpu
610      GPU_ARCH_TYPE: cpu
611      DOCKER_IMAGE: pytorch/conda-builder:cpu-2.4
612      DESIRED_PYTHON: "3.12"
613      build_name: conda-py3_12-cpu
614      use_s3: False
615    secrets:
616      github-token: ${{ secrets.GITHUB_TOKEN }}
617      conda-pytorchbot-token: ${{ secrets.CONDA_PYTORCHBOT_TOKEN }}
618      conda-pytorchbot-token-test: ${{ secrets.CONDA_PYTORCHBOT_TOKEN_TEST }}
619    uses: ./.github/workflows/_binary-upload.yml
620