Centralize torch-family version pins in torch_pin.py#19155
Centralize torch-family version pins in torch_pin.py#19155mergennachin wants to merge 1 commit intomainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/19155
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ❌ 4 New Failures, 5 Cancelled Jobs, 3 Pending, 4 Unrelated FailuresAs of commit ab8742b with merge base 3a62fac ( NEW FAILURES - The following jobs have failed:
CANCELLED JOBS - The following jobs were cancelled. Please retry:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
BROKEN TRUNK - The following jobs failed but was 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. |
This PR needs a
|
There was a problem hiding this comment.
Pull request overview
This PR makes torch_pin.py the single source of truth for torch + domain-library version pins and wheel index selection across the repo, so scripts/CI don’t re-encode version strings and channel-specific URLs.
Changes:
- Introduces
torch_pin.pyhelpers for channel-aware pip specs (*_spec()) and index URLs (torch_index_url_base()), plus release-branch derivation helpers. - Updates multiple install/test scripts and the pin-bump automation to consume
torch_pin.pyinstead of hardcoding versions/URLs. - Adds
pytestcoverage validating behavior fornightly,test, andreleasechannels.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
torch_pin.py |
Adds centralized channel + version constants and helpers to generate pip specs, index URLs, and release branches. |
test/test_torch_pin.py |
Adds tests covering spec/url/branch generation across channels. |
install_requirements.py |
Switches torch/vision/audio spec + index URL selection to torch_pin helpers. |
examples/models/moshi/mimi/install_requirements.sh |
Uses torch_pin to install torchcodec from the correct channel/index independent of CWD. |
.github/workflows/weekly-pytorch-pin-bump.yml |
Guards weekly bump on CHANNEL == nightly and updates NIGHTLY_VERSION in-place. |
.github/scripts/update_pytorch_pin.py |
Imports pin/channel info from torch_pin and writes either a nightly SHA or release branch ref. |
.ci/scripts/utils.sh |
Chooses audio/vision refs based on channel (PyTorch pins for nightly; release branches otherwise). |
.ci/scripts/test_wheel_package_qnn.sh |
Installs torch using torch_pin spec + index URL rather than reconstructing version strings. |
.ci/scripts/test_model_e2e.sh |
Installs torchcodec via torch_pin helpers instead of a hardcoded nightly spec. |
.ci/docker/common/install_pytorch.sh |
Mirrors channel-aware audio/vision ref selection for source builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| python -c " | ||
| import re, pathlib | ||
| p = pathlib.Path('torch_pin.py') | ||
| p.write_text(re.sub( | ||
| r'^NIGHTLY_VERSION\s*=\s*\".*\"$', | ||
| 'NIGHTLY_VERSION = \"${{ steps.nightly.outputs.version }}\"', | ||
| p.read_text(), | ||
| count=1, | ||
| flags=re.MULTILINE, | ||
| )) | ||
| " |
There was a problem hiding this comment.
The inline python -c block is indented inside the quoted string, which will be passed to Python with leading spaces and typically raises IndentationError: unexpected indent. Use an unindented heredoc (python - <<'PY' ... PY) or a single-line python -c command so the workflow reliably updates NIGHTLY_VERSION.
0206298 to
e9d0e26
Compare
e9d0e26 to
6c23dd0
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
eedfeae to
0d60c16
Compare
|
@claude Review this PR |
|
Claude finished @mergennachin's task in 3m 2s —— View job Review of PR #19155 — Centralize torch-family version pins in torch_pin.py
Overall: This is a well-structured consolidation. Having one file own channel selection, version constants, pip specs, index URLs, and branch derivation eliminates a real class of drift bugs. The three-channel design (nightly/test/release) with the Issues1.
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (2)
install_requirements.py:80
- In the pip install call, torch is installed with
--extra-index-urlpointing at the PyTorch wheel index. For CHANNEL="test"/"release", the pinned version (e.g.torch==2.12.0) also exists on PyPI, so pip can satisfy the requirement from PyPI first (typically CPU-only), ignoring the CUDA-specific index computed bydetermine_torch_url(...). To ensure the intended CPU/CUDA wheels are used when not on nightly, install the torch-family packages via--index-url <torch_url>(or split into a separate pip invocation for torch/vision/audio using--index-url) rather than relying on--extra-index-urlwith an exact version that is also present on PyPI.
# Determine the appropriate PyTorch URL based on CUDA delegate status
torch_url = determine_torch_url(torch_index_url_base())
# pip packages needed by exir.
TORCH_PACKAGE = [
# Default: install the specific pinned version from the channel selected
# in torch_pin.py. With --use-pt-pinned-commit, pass plain "torch" and
# let pip resolve its default (CI's source-build is already installed).
(torch_spec() if install_pinned_version else "torch"),
]
# Install the requirements for core ExecuTorch package.
# `--extra-index-url` tells pip to look for package versions on the
# provided URL if they aren't available on the default URL.
subprocess.run(
[
sys.executable,
"-m",
"pip",
"install",
*_NO_CACHE_DIR_FLAG,
"-r",
"requirements-dev.txt",
*TORCH_PACKAGE,
"--extra-index-url",
torch_url,
],
install_requirements.py:140
- Same issue for torchvision/torchaudio installs: with CHANNEL="test"/"release" the pinned versions are available on PyPI, so using only
--extra-index-urlcan cause pip to pull CPU wheels from PyPI instead of the CUDA-specific index returned bydetermine_torch_url(...). Consider installing these domain libraries in a separate pip call using--index-url <torch_url>(and only using PyPI as an extra index for non-torch deps) so the selected PyTorch index is actually authoritative.
def install_optional_example_requirements(install_pinned_version):
# Determine the appropriate PyTorch URL based on CUDA delegate status
torch_url = determine_torch_url(torch_index_url_base())
print("Installing torch domain libraries")
DOMAIN_LIBRARIES = [
(torchvision_spec() if install_pinned_version else "torchvision"),
(torchaudio_spec() if install_pinned_version else "torchaudio"),
]
# Then install domain libraries
subprocess.run(
[
sys.executable,
"-m",
"pip",
"install",
*_NO_CACHE_DIR_FLAG,
*DOMAIN_LIBRARIES,
"--extra-index-url",
torch_url,
],
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def torch_spec() -> str: | ||
| return _spec("torch", TORCH_VERSION) | ||
|
|
||
|
|
||
| def torchaudio_spec() -> str: | ||
| return _spec("torchaudio", TORCHAUDIO_VERSION) | ||
|
|
||
|
|
||
| def torchcodec_spec() -> str: | ||
| return _spec("torchcodec", TORCHCODEC_VERSION) | ||
|
|
||
|
|
||
| def torchvision_spec() -> str: | ||
| return _spec("torchvision", TORCHVISION_VERSION) | ||
|
|
||
|
|
||
| def torch_index_url_base() -> str: | ||
| if CHANNEL == "release": | ||
| return "https://download.pytorch.org/whl" | ||
| return f"https://download.pytorch.org/whl/{CHANNEL}" | ||
|
|
||
|
|
||
| def torch_branch() -> str: | ||
| # PyTorch uses "release/M.N" branches; derive from the pinned version. | ||
| # Used by update_pytorch_pin.py to write into pytorch.txt for test/release. | ||
| return f"release/{TORCH_VERSION.rsplit('.', 1)[0]}" |
There was a problem hiding this comment.
The PR description says torch_pin.py exposes torchaudio_branch() / torchvision_branch() (and mentions branch derivation for the domain libs), but this module currently only defines torch_branch(). Either add the missing branch helpers or update the PR description/header comments so the documented API matches what’s actually available.
0d60c16 to
ee7449d
Compare
ee7449d to
321bc6d
Compare
321bc6d to
466fc10
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 14 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
466fc10 to
addc31f
Compare
addc31f to
0ac917d
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 14 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
torch_pin.py is now the single source of truth for torch + the three domain libraries (vision/audio/codec). It exposes a CHANNEL field (nightly/test/release), the four version constants, NIGHTLY_VERSION, and helpers — torch_spec() / torchaudio_spec() / torchcodec_spec() / torchvision_spec() emit the right pip spec, torch_index_url_base() returns the right wheel index, and torch_branch() derives the upstream release/M.N branch from TORCH_VERSION. Every consumer — install_requirements.py, the two install_pytorch.sh / utils.sh shell helpers, test_model_e2e.sh, test_wheel_package_qnn.sh, the moshi/mimi install_requirements.sh, the update_pytorch_pin.py script, and the weekly bump workflow — reads through these helpers instead of re-encoding the version strings. For test/release the docker image build (install_pytorch.sh) and the CI bring-up path (utils.sh) install the published wheels directly via pip --index-url, replacing the source-build-from-git-branch dance inherited from the original 2.11 RC pin (#18287). Nightly keeps the source-build path so CI catches upstream regressions. This commit is a no-op for the active pin: CHANNEL = "test" with TORCH_VERSION = "2.11.0", TORCHAUDIO_VERSION = "2.11.0", TORCHCODEC_VERSION = "0.11.0", TORCHVISION_VERSION = "0.26.0" produces the same wheels (from /whl/test/cpu) that origin/main currently hardcodes. Switching channels later (e.g. to nightly post-release) becomes a one-line change in torch_pin.py plus bumping the version constants. update_pytorch_pin.py imports CHANNEL / NIGHTLY_VERSION / torch_branch directly (no more regex parsing of the file). For nightly it pins to an immutable SHA looked up by date; for test/release it writes torch_branch() (e.g. "release/2.11") into .ci/docker/ci_commit_pins/pytorch.txt so git checkout follows cherry-picks as they land. The weekly-pytorch-pin-bump workflow is guarded on CHANNEL == "nightly" and uses an in-place re.sub on NIGHTLY_VERSION (the previous \`printf '...' > torch_pin.py\` would have clobbered the new constants and helpers). test/test_torch_pin.py covers all three channels, all four specs, and the release/M.N branch derivation. Co-authored-by: Claude <noreply@anthropic.com>
0ac917d to
ab8742b
Compare
Centralize torch-family version pins in torch_pin.py
torch_pin.py is now the single source of truth for torch + the three
domain libraries (vision/audio/codec). It exposes a CHANNEL field
(nightly/test/release), the four version constants, NIGHTLY_VERSION,
and helpers — torch_spec() / torchaudio_spec() / torchcodec_spec() /
torchvision_spec() emit the right pip spec, torch_index_url_base()
returns the right wheel index, and torch_branch() / torchaudio_branch()
/ torchvision_branch() derive the upstream release/M.N branch from each
package's version. Every consumer — install_requirements.py, the two
install_pytorch.sh / utils.sh shell helpers, test_model_e2e.sh,
test_wheel_package_qnn.sh, the moshi/mimi install_requirements.sh, the
update_pytorch_pin.py script, and the weekly bump workflow — reads
through these helpers instead of re-encoding the version strings.
Switching to a release candidate is now a one-line change (CHANNEL =
"test") plus bumping the four version constants. The header in
torch_pin.py walks through the procedure.
update_pytorch_pin.py imports CHANNEL / NIGHTLY_VERSION / torch_branch
directly (no more regex parsing of the file). For nightly it pins to
an immutable SHA looked up by date; for test/release it writes
torch_branch() (e.g. "release/2.12") into
.ci/docker/ci_commit_pins/pytorch.txt so git checkout follows
cherry-picks as they land.
The weekly-pytorch-pin-bump workflow is guarded on CHANNEL == "nightly"
and uses an in-place re.sub on NIGHTLY_VERSION (the previous
printf '...' > torch_pin.pywould have clobbered the new constantsand helpers).
test/test_torch_pin.py covers all three channels, all four specs, and
the release/M.N branch derivation.
Co-authored-by: Claude noreply@anthropic.com