Skip to content

Upload the wheels to R2 from a workflow_run workflow - #25356

Merged
atalman merged 1 commit into
pytorch:mainfrom
atalman:executorch_r2_upload
Nov 21, 2026
Merged

atalman merged 1 commit into
pytorch:mainfrom
atalman:executorch_r2_upload

Conversation

@atalman

@atalman atalman commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Executorch wheels are not uploaded to R2 today. test-infra's reusable build workflows (_binary_upload.yml) upload to R2 only when the caller passes the R2 secrets, and none of executorch's build workflows does. pytorch/executorch is already on the R2 allowlist there, so only the secrets are missing.

Passing the repo-level secrets.R2_* from the build workflows would let a workflow in a pull request that gets a ciflow tag read them (pytorch/FBGEMM#6852 showed this in FBGEMM). A reusable workflow does not see the caller's environment secrets, and a calling job cannot set environment:, so the R2 upload gets its own workflow, as in pytorch/vision#9765, pytorch/audio#4244 and pytorch/FBGEMM#6855.

upload_wheels_r2.yml runs on workflow_run for the seven wheel builds: Linux, Aarch64 Linux, Linux CUDA, Aarch64 Linux CUDA, Windows, Windows CUDA and macOS. A workflow_run workflow always comes from main. It only acts when the build was a push to nightly in this repo. get-matrix reads the build matrix, which each build workflow now saves as the build-matrix artifact (the filtered matrix for the CUDA ones), and upload-r2 (environment: pytorchbot-env) downloads each wheel from the build run and copies it to R2 with the same steps as test-infra's _binary_upload.yml. The run is named after the build run it handled, and its summary links to it.

The architecture in the artifact name follows what each build passes to the upload: x86_64 for Linux, aarch64 for Aarch64 Linux, x64 for Windows, none for macOS. I checked these, and the CUDA names, against the artifacts of the 2026-11-20 nightly runs (for example pytorch_executorch__3.11_cpu_x86_64, ..._cu132_aarch64, ..._cpu_x64, pytorch_executorch__3.11_cpu_).

Not included: the two Native wheel workflows. They pass trigger-event: development, so they never upload, and the comment there says executorch-native is not published yet.

The build workflows' own S3 upload (an AWS role through OIDC) is unchanged. The only change to them is the save-build-matrix job.

DO NOT MERGE before the R2_ACCOUNT_ID, R2_ACCESS_KEY_ID and R2_SECRET_ACCESS_KEY secrets exist in the pytorchbot-env environment of pytorch/executorch. Rollout:

  1. A repo admin adds the three secrets to pytorchbot-env.
  2. Merge this.
  3. Check that the next nightly run triggers "Upload wheels to R2" and that the wheels reach R2.

Not verified: a workflow_run workflow only runs once it is on main, so none of this has run in executorch. pytorch/audio#4244 ran this design end to end, with the environment secrets, on 2026-11-19. I checked that the workflows parse as YAML and that shellcheck is clean on the new scripts, and that the matrix fields the upload reads (build_name, python_version, desired_cuda, upload_to_base_bucket) are kept by filter_cuda_matrix.py.

Created with Claude

The reusable build workflows in test-infra only upload to R2 when the caller passes
the R2 secrets, and executorch passes none, so executorch wheels never reach R2.
Passing repo-level secrets from the build workflows would expose them to a pull
request that gets a ciflow tag (pytorch/FBGEMM#6852), so the upload goes in its own
workflow, as in pytorch/vision#9765, pytorch/audio#4244 and pytorch/FBGEMM#6855.
@pytorch-bot

pytorch-bot Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/25356

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (1 Unrelated Failure)

As of commit 4d66e58 with merge base ba0d826 (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 20, 2026
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@huydhn huydhn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait a sec, I don't think ET uploads to R2 at all now that I check the secrets. It doesn't have any R2 secrets

@huydhn huydhn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, chatting with @atalman. This is a feature we want to do for a couple of additional repos like ET and Helion

@shoumikhin shoumikhin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. The workflow matches the audio and vision version, and I checked that the artifact names, channel and bucket path line up with the current S3 upload for all 7 builds. One thing blocks it, see the inline comment. It is a settings change, not a code change.

upload-r2:
needs: get-matrix
runs-on: ubuntu-22.04
environment: pytorchbot-env

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this job will be blocked by the environment rules in this repo.

A workflow_run run always has the default branch (main) as its ref, and GitHub checks the environment's allowed branches against that ref. In this repo, pytorchbot-env only allows nightly, release/* and 2 v tag patterns. main is not on the list, so every upload-r2 job would be refused and no wheel would reach R2. In audio and vision, pytorchbot-env allows main, which is why the same workflow works there.

Could a repo admin add main to the allowed branches of pytorchbot-env before this merges? Please also add that step to the rollout list in the description. The 3 R2 secrets are already in the environment, so this looks like the last missing piece.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shoumikhin this is correct we only want to upload from nightly to r2, not on main

@atalman
atalman merged commit f63b372 into pytorch:main Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants