Skip to content

Ship the NCCL pin files in the sdist and the release tarball - #197544

Closed
zklaus wants to merge 2 commits into
pytorch:mainfrom
zklaus:fix-sdist-nccl-pin
Closed

zklaus wants to merge 2 commits into
pytorch:mainfrom
zklaus:fix-sdist-nccl-pin

Conversation

@zklaus

@zklaus zklaus commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Fixes #152532.

Since #146073 NCCL is not a submodule but cloned at configure time from a tag in .ci/docker/ci_commit_pins/nccl*.txt. Neither release source artifact has ever shipped those files: the plain tarball strips .ci (since #63022, no recorded reason) and the PEP 517 sdist excludes it (#190192). A survey of all 16 archives from v2.7.0 to v2.14.0 confirms this; what varies is only whether third_party/nccl is present. The 2.14.0 sdist is the first artifact since 2.7.x with neither, because #190192 also stopped shipping the pre-cloned NCCL tree (deliberately: a snapshot freezes the default pin even where the cu126 pin applies). Configure then fails in cmake/External/nccl.cmake with ExternalProject's "No download info given for 'nccl_external'", which names neither cause nor remedy.

Two commits:

  1. The two pin files join the sdist include list, so an sdist build clones NCCL exactly like a git checkout does, with the CUDA-version-specific pin honoured. The pre-build step now warns when neither the NCCL sources nor a pin exist, and nccl.cmake fails with a message naming the ways out (provide the sources, USE_SYSTEM_NCCL=1, or USE_NCCL=0). The fatal check lives in nccl.cmake rather than the pre-build step because the latter runs before CUDA is decided; a CPU-only build from a pin-less tree keeps working.
  2. The release workflow copies the same two files back into the plain tarball after the .ci strip, so both artifacts carry the pins and nothing else from .ci. The pre-cloned third_party/nccl stays: the tarball exists for offline, complete-source builds.

Official wheels use system NCCL, so pip users are unaffected; this is for people building from the source archives. Small enough to cherry-pick into a 2.14 patch release.

Offered for this PR if wanted: a check in the pre-build step that compares an existing third_party/nccl (its makefiles/version.mk) against the selected pin and warns on mismatch. That is what would make a cu126 build from the plain tarball notice it got the default NCCL, and it also catches a developer checkout whose clone predates a pin bump. Left out for now to keep the change minimal.

Follow-up, separate PR: move the pins out of .ci next to third_party/eigen_pin.txt, which makes both include exceptions above unnecessary. It touches install_nccl.sh and five Dockerfiles under .ci/docker, so it forces a Docker image rebuild and should ride the next planned one.

Test plan: see the commit messages. sdist built from this tree contains exactly nccl.txt and nccl-cu126.txt under .ci, byte-identical to the tree, and no third_party/nccl; the CMake behaviour was driven through a minimal project in a fake source tree for all five cases; the tarball staging lines were run against a mock tree. Not exercised: the release workflow itself (release tags and nightly only) and an end-to-end CUDA build from the sdist.

…t be obtained

The 2.14.0 PEP 517 sdist cannot build with CUDA unless USE_SYSTEM_NCCL is
set. Since pytorch#146073 NCCL is not a submodule but cloned at configure time
from a tag read out of .ci/docker/ci_commit_pins/nccl*.txt. The sdist
configuration from pytorch#190192 deliberately leaves third_party/nccl out
(shipping a fetched tree would freeze the default pin even where the
cu126 pin applies) and, in the same change, excludes all of .ci, which
takes the pin files with it. cmake/PreBuildSteps.cmake then silently
skips the clone, and the build dies later in cmake/External/nccl.cmake
with ExternalProject's "No download info given for 'nccl_external'",
which names neither the cause nor a way out. 2.13.0 was the last sdist
that built, only because it still used setuptools and shipped the
pre-cloned NCCL tree.

The fix keeps the pytorch#190192 decision and makes the fetch work instead:
the two pin files join the sdist include list, where an include match
beats the .ci/** exclude. An sdist build now clones NCCL exactly like a
git checkout does, with the CUDA-version-specific pin honoured.

The second half is diagnostics. The pre-build step now warns when
neither third_party/nccl nor a pin file exists, and nccl.cmake fails
with a message naming the three ways out (provide the sources, set
USE_SYSTEM_NCCL=1, or set USE_NCCL=0) before declaring the
ExternalProject. The hard failure lives in nccl.cmake rather than in
the pre-build step because the pre-build step runs before CUDA is
decided: a CPU-only build from a tree without the pin must keep
working, and making the pre-build step fatal would have broken it.

Not addressed here: the plain pytorch-vX.tar.gz strips .ci as well and
builds only because the release workflow pre-clones NCCL at the default
pin, so a CUDA 12.6 build from it silently gets the default NCCL. Moving
the pins out of .ci (as third_party/eigen_pin.txt already is) fixes both
artifacts uniformly, but touches .ci/docker and therefore forces a
Docker image rebuild; that is a follow-up, and this small change is the
one to cherry-pick into a 2.14 patch release.

Fixes pytorch#152532.

Test Plan:

sdist contents, built from this tree:
```
uv run --no-project --python 3.12 --with build python -m build --sdist --outdir /tmp/sdist-out .
tar tzf /tmp/sdist-out/torch-*.tar.gz | grep -E '/\.ci/'        # exactly the two nccl pin files
tar tzf /tmp/sdist-out/torch-*.tar.gz | grep -c 'third_party/nccl/'   # 0
```

CMake behaviour, driven through a minimal project that includes the two
files from a fake source tree (no third_party/nccl, no .ci):
```
cmake -S fake -B build -DUSE_SYSTEM_LIBS=ON                       # PreBuildSteps: warning, configure continues
cmake -S fake -B build -DUSE_SYSTEM_LIBS=ON -DUSE_SYSTEM_NCCL=ON   # silent
cmake -S fake -B build -DUSE_SYSTEM_LIBS=ON -DUSE_NCCL=OFF         # silent
mkdir -p fake/third_party/nccl && cmake -S fake -B build -DUSE_SYSTEM_LIBS=ON   # silent
cmake -S fake-including-nccl.cmake -B build                       # fatal with the new message; passes once third_party/nccl/Makefile exists
lintrunner pyproject.toml cmake/PreBuildSteps.cmake cmake/External/nccl.cmake
```

Authored with an AI assistant.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
The plain pytorch-vX.tar.gz has stripped .ci since the workflow was
added in pytorch#63022, with no recorded reason; since pytorch#146073 that directory
holds the NCCL pins the configure step reads. The tarball builds today
only because the workflow pre-clones third_party/nccl at the default
pin (pytorch#156615), so a build that selects the cu126 pin gets the default
NCCL without any notice, and a tree whose NCCL directory is removed
cannot re-clone at all.

Copy the two pin files back after the strip, so the tarball carries
the same pins as the sdist (previous commit) and no other .ci content.
The pre-cloned tree stays: the tarball exists for offline, complete
source builds, and the pins make it self-describing for a later check
of the clone against the selected pin.

Test Plan:

The staging lines run against a mock tree (.ci with pins plus an
unrelated script, third_party/nccl, .gitmodules): the result holds
exactly .ci/docker/ci_commit_pins/{nccl.txt,nccl-cu126.txt},
byte-identical to the source, no other .ci file, no .git* entries, and
third_party/nccl intact.
```
lintrunner .github/workflows/create_release.yml
```
Not exercised here: the workflow itself, which only runs on release
tags and nightly.

Authored with an AI assistant.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@zklaus
zklaus requested a review from a team as a code owner September 18, 2026 12:19
@pytorch-bot

pytorch-bot Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ You can merge normally! (2 Unrelated Failures)

As of commit c4229d6 with merge base 1a70a6e (image):

CRCR (non-blocking) - The following CRCR downstream CI jobs failed but are non-blocking:

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

@pytorch-bot pytorch-bot Bot added the release notes: releng release notes category label Sep 18, 2026
@zklaus
zklaus requested a review from atalman September 18, 2026 12:19
@Skylion007

Copy link
Copy Markdown
Collaborator

Agree with the idea but installing to .ci seems dangerous and error prone should we just move the pin somewhere for OSS easy enough.

@Skylion007
Skylion007 requested a review from malfet September 18, 2026 15:47
@zklaus

zklaus commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator Author

@Skylion007, I agree with that in principle and would like it as a follow-up PR (c.f. the description:

Follow-up, separate PR: move the pins out of .ci next to third_party/eigen_pin.txt, which makes both include exceptions above unnecessary. It touches install_nccl.sh and five Dockerfiles under .ci/docker, so it forces a Docker image rebuild and should ride the next planned one.

), but I think I was not clear enough why I did not do this here, so let me explain better.

This PR is meant to fix purely the packaging issue to allow us to fix past releases by re-uploading without changes in the build code in a documented and coherent manner.

The long-term fix is absolutely as you suggested.

@ezyang
ezyang requested a review from Skylion007 September 21, 2026 19:04
@ezyang ezyang added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Sep 21, 2026

@atalman atalman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@atalman

atalman commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

@pytorchmergebot merge -f "all looks good, lets merge"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged open source release notes: releng release notes category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The 2.7.0 release tarball is missing .ci/docker/ci_commit_pins/nccl-cu12.txt required for building

6 participants