Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/184336
Note: Links to docs will display an error until the docs builds have been completed. ❌ You can merge normally! (2 Unrelated Failures), 16 Unclassified FailuresAs of commit 10a9b57 with merge base 4e22359 ( UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
01f4272 to
343e998
Compare
343e998 to
3c8871a
Compare
nWEIdia
left a comment
There was a problem hiding this comment.
Asked a question.
Has libtorch CI been triggered?
I'm wondering the same that why the original error was not caught in the CI. Then it appears we don't have a CI that will test the extracted linux libtorch binary. A follow-up to add a libtorch smoke test on Linux would be valuable. |
malfet
left a comment
There was a problem hiding this comment.
Overall LGTM, but let's not add the test script which is not invoked by anyone.
Instead it would be nice to actually test that one can link hellowolrd application against libtorch
|
@tinglvv I believe test is good followup PR, we can add it to smoke test to validate libtorch builds this way during release/nightly validation |
bf7494a to
9ece764
Compare
2e78a38 to
8f7fb87
Compare
|
There are some recent change to the binary build workflow to run on OSDC k8s runners. Please help rebase your PR to get the latest change there. I did make a tweak with runner_temp as the folder is a bit different on the new runners |
The wheel packages set RPATH relative to pip's site-packages layout (e.g. $ORIGIN/../../nvidia/nvshmem/lib). After extraction, libtorch libraries live in a flat lib/ directory, so those RPATHs are wrong. fix_rpath() rewrites all .so RPATHs to $ORIGIN using patchelf, which is available in the manylinux2_28-builder container. Raises on any patchelf failure rather than silently continuing with broken libraries. Authored by Claude.
The patchelf-based RPATH fix requires running inside a manylinux2_28-builder container where patchelf is available. Propagate container_image and container_image_tag_prefix from source wheel configs into the libtorch extraction matrix, and add a container: directive to the extraction job. Regenerated generated-linux-binary-manywheel-nightly.yml from the template. Authored by Claude.
smoke_test_extract_libtorch.py covers the end-to-end extraction pipeline (find_wheel, extract, copy, zip) using a fake wheel, and fix_rpath unit tests (platform guard, patchelf invocation on .so and versioned .so files, non-.so filtering, missing patchelf, patchelf failure, and an integration test with a real compiler when available). Run in CI before the extraction step. Authored by Claude.
Consolidate the test file down to a single end-to-end extraction test that exercises the full pipeline (find wheel -> unzip -> copy libs/headers/cmake -> write metadata -> zip). Remove the separate TestFixRpath class and unit tests for individual helpers (compute_zip_prefix, find_wheel error handling) -- those were testing internals rather than the extraction flow. Also fix the compute_zip_prefix calls to pass the new required `arch` argument added in a prior commit. Test Plan: ``` cd .ci/libtorch && python3 -m unittest smoke_test_extract_libtorch -v ``` Authored with AI assistance. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
pytest is not available in the manylinux2_28-builder container used by the libtorch extraction CI job. The smoke test already uses the stdlib unittest module, so switch the invocation to python3 -m unittest discover which requires no extra dependencies. Test Plan: ``` python3 -m unittest discover -s .ci/libtorch -p smoke_test_extract_libtorch.py -v # Ran 1 test in 0.060s OK ``` Co-authored-by: Claude Sonnet 4.6 <[email protected]>
… test This branch adds a container (manylinux2_28-builder) to libtorch-extract so patchelf is available for fix_rpath. On main the job runs directly on the runner where $RUNNER_TEMP is accessible, but inside a Docker container $RUNNER_TEMP is not bind-mounted — only $GITHUB_WORKSPACE is guaranteed to be mounted. Switch all four path references (download- artifact, wheel-dir, output-dir, upload-artifact) to $GITHUB_WORKSPACE. Also replaces the pre-extraction unittest step with a post-extraction smoke test that runs against the real libtorch zip and verifies: - All .so files have $ORIGIN rpath (checked via patchelf) - libtorch.so can be loaded (checked via ctypes.CDLL) Co-authored-by: Claude Sonnet 4.6 <[email protected]>
The libtorch-extract job now runs inside the manylinux container, but its
run steps referenced the workspace via the ${{ github.workspace }} context
(and previously ${{ runner.temp }}). In a container job those contexts
evaluate to the host runner path, while the workspace is mounted inside the
container at $GITHUB_WORKSPACE (/__w/<repo>/<repo>).
GitHub translates the host-form path for uses: action inputs, so
download-artifact wrote the wheel to the in-container mount, but the run:
steps got the untranslated host path, which is an empty directory inside the
container. Extraction then failed with "No .whl files found in
.../wheel_artifact". This is why swapping runner.temp for github.workspace
did not help: both are host-path contexts with the same translation gap, and
it only surfaces once the job is containerized (the pre-container job on main
passed because host paths resolved consistently with no container).
The fix references the workspace via the $GITHUB_WORKSPACE env var in the
run steps so they resolve to the same in-container mount the translated
download/upload action paths point at. The uses: action path: inputs keep
the github.workspace context since the runner translates those correctly.
Test Plan:
Regenerated the workflow and confirmed the run steps use $GITHUB_WORKSPACE
while the download/upload actions keep ${{ github.workspace }}:
```
python3 .github/scripts/generate_ci_workflows.py
git diff .github/workflows/generated-linux-binary-manywheel-nightly.yml
```
Full validation requires re-running the containerized libtorch-extract job
in CI, since the path translation is environment-specific.
This change was authored with the assistance of an AI coding agent.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The smoke test previously did ctypes.CDLL(libtorch.so), which fails on CUDA
variants because the thin libtorch does not bundle CUDA runtime libs (cupti,
cudnn, nccl, ...); those come from the environment. That is not the failure
the test is meant to catch.
The test's purpose is to catch extraction bugs where a copied lib cannot
resolve another copied lib because its RPATH was not rewritten to $ORIGIN
(e.g. "libnvshmem_host.so.3 => not found"). Replace the dlopen with an ldd
sweep over each bundled .so that flags a "not found" dependency only when the
soname is itself present in lib/. Dependencies not bundled here are provided
by the environment and are ignored. Crucially, lib/ is no longer placed on
LD_LIBRARY_PATH, so resolution goes through the $ORIGIN RPATH and a broken
rpath actually fails the test rather than being masked.
Test Plan:
```
python3 -c "import ast; ast.parse(open('.ci/libtorch/smoke_test_extract_libtorch.py').read())"
```
Full validation is the containerized libtorch-extract job in CI, which runs
this smoke test against both the cpu and cuda extracted libtorch zips.
This change was authored with the assistance of an AI coding agent.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
ba766a1 to
254d159
Compare
Fixes the "libnvshmem_host.so.3 => not found" regression (#183971) in the CUDA libtorch shared-with-deps tarball. Root cause: libtorch is now assembled by extracting torch/lib/ from the pip wheel (#174753). The wheel is a "small wheel" (#180612): its NVIDIA runtime deps -- libnvshmem_host.so.3, libcudart.so.13, libcublas, libcudnn, ... -- are not in torch/lib/ but supplied at runtime by the pip nvidia-* packages via an RPATH into site-packages/nvidia/*/lib. The libtorch tarball has no such packages, so the extracted libtorch/lib/ shipped torch's own libtorch_nvshmem.so (which hard-NEEDs libnvshmem_host.so.3) with nothing to satisfy it. Fix: for linux CUDA shared-with-deps, bundle_cuda_deps() copies the required NVIDIA runtime libraries into libtorch/lib/ before the RPATH rewrite. It resolves NEEDED entries transitively starting from the torch libs, copying any soname that exists under the CUDA toolkit dirs in the builder container (/usr/local/cuda/lib64 and the CUPTI dir). Only libraries found there are copied, so base system libs and the driver stub (libcuda.so.1) are correctly left to the runtime environment. fix_rpath() then stamps $ORIGIN on the copied libs so the flat lib/ is self-resolving. This restores the pre-#180612 self-contained tarball while leaving the pip wheel untouched/small. Chose a transitive NEEDED resolver over reinstating the old hardcoded DEPS_LIST so it auto-adapts to CUDA version and the static->dynamic linking changes, and self-filters system libs by construction. smoke_test_extract_libtorch.py is a single ctypes.CDLL("libtorch.so") load: it resolves the whole NEEDED chain through the $ORIGIN RPATH, so a missing or mis-rpath'd bundled dep (torch or NVIDIA runtime) fails the test. Full dlopen was previously dropped because it failed when deps were not bundled; with bundling it works, and since libcuda.so.1 is dlopen'd lazily by cudart (not a load-time NEEDED) it succeeds on a driverless builder. Test Plan: Local static checks (no CUDA builder / wheel available on this host): ``` python3 -m py_compile .ci/libtorch/extract_libtorch_from_wheel.py python3 -m py_compile .ci/libtorch/smoke_test_extract_libtorch.py ``` Full validation is the libtorch-extract CI job on a CUDA config: the log should show "Bundled CUDA dep: libnvshmem_host.so.3 ..." (plus cudart/cublas/cudnn), and the smoke test must load libtorch.so with no "not found". Authored with assistance from an AI coding assistant (Claude). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
254d159 to
10a9b57
Compare
|
@pytorchbot merge -i |
|
This PR has pending changes requested. Please address the comments and update the PR before merging. |
|
@claude review this |
|
Claude finished @malfet's task in 47m 46s —— View job Reviewed — the RPATH fix and dep-bundling approach look sound, but I found one release-reproducibility hole (the extract job pins no docker suffix), a silent-failure path in the new transitive walk, and a Full review: PR #184336PR Review: #184336SummaryAdds Infrastructure1. The extract job drops the pinned docker image, breaking release-candidate reproducibility. This is the most significant finding.
image: pytorch/${{ matrix.container_image }}:${{ matrix.container_image_tag_prefix }}Compare the build job at line 274, which uses both computed values: image: !{{ docker_registry_host }}pytorch/!{{ first['container_image'] }}:!{{ first['container_image_tag_prefix'] }}!{{ docker_image_suffix }}The extract job omits
Please plumb 2. The new smoke test cannot block publication. This is pre-existing structure, but it means the regression test this PR adds is decorative. Either gate the upload on extraction success, or drop 3. Please demonstrate the smoke test is sensitive (negative control). Code Quality4.
def _needed(patchelf: str, so: Path) -> list[str]:
r = subprocess.run(
[patchelf, "--print-needed", str(so)], capture_output=True, text=True
)
return r.stdout.split() if r.returncode == 0 else []A non-zero exit returns The 5. 6. Trivial single-use helper. if args.desired_cuda.startswith("cu") and "with-deps" in args.libtorch_variant:
bundle_cuda_deps(libtorch_dir / "lib")7. Duplicated Backward Compatibility8. Line 120 uses
$PATCHELF_BIN --set-rpath '$ORIGIN:$ORIGIN/lib' $sofile
$PATCHELF_BIN --set-rpath '$ORIGIN' $sofileNo The PR description still says "NVIDIA deps (cudnn, nccl, nvshmem, etc.) are resolved from the user's system CUDA installation via LD_LIBRARY_PATH/ldconfig, matching the old libtorch behavior." After the 9. Tarball size is unmeasured. Testing10. The NEEDED-only walk has a dlopen blind spot — please verify the bundle empirically. Rather than guess: please run Code Quality (unrelated change)11. The ciflow glob narrowing is an unrelated fix with no mention in the description. Three conditions change from I believe this is correct: the generated workflow triggers on all three of But it's a distinct CI behavior change buried in a PR titled "fix RPATH in libtorch extraction from wheel," reviewers have already approved without it being called out, and it silently changes which builder image RecommendationRequest Changes Blocking: #1 (release-candidate tarballs built in an unpinned container, now that container contents are baked into the artifact), #4 (silent subtree pruning reintroduces the green-CI-broken-tarball failure mode this PR exists to fix), and #8 ( Also needed before merge: #2/#3, since the new smoke test currently neither blocks publication nor has a demonstrated negative control — without those it doesn't function as a regression test for #183971. Worth noting: the 16 unclassified ROCm |
|
@pytorchbot merge -f "Lint + binary builds are green" |
|
Though PR description is stale |
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
PR #174753 switched libtorch packaging from a dedicated CMake build to extracting from the pre-built wheels. This PR restores the old libtorch behavior that was changed in the extraction script.
RPATH. Wheel .so files carry RPATHs relative to pip's site-packages layout ($ORIGIN/../../nvidia/*/lib), which doesn't exist in the libtorch tree, giving errors like
libnvshmem_host.so.3 => not found. fix_rpath() rewrites every .so in libtorch/lib to $ORIGIN via patchelf. --force-rpath emits DT_RPATH (not DT_RUNPATH), so resolution is transitive and not overridable by LD_LIBRARY_PATH.Bundled CUDA deps. The small CUDA wheel omits NVIDIA runtime libs that shared-with-deps should ship. bundle_cuda_deps() walks NEEDED transitively from the torch libs and copies any soname found under /usr/local/cuda/lib64 or /usr/local/cuda/extras/CUPTI/lib64 into lib/. Only those dirs are searched, so system libs and the driver stub stay external. Linux CUDA shared-with-deps only.
Both need patchelf and /usr/local/cuda, so the extract job moves from python:3.11 to pytorch/manylinux2_28-builder:; the matrix threads container_image / container_image_tag_prefix through, and artifact paths mov
to github.workspace.
Test plan:
smoke_test_extract_libtorch.py extracts the produced zip and fully dlopens libtorch.so, so a missing or mis-rpath'd dep fails the job.
Fixes #183971
Created with Assistance from Claude