Skip to content

CI: stop the torch-free bindings check from matching load addresses - #24470

Open
shoumikhin wants to merge 1 commit into
pytorch:mainfrom
shoumikhin:ci-noaten-ldd-load-addresses
Open

shoumikhin wants to merge 1 commit into
pytorch:mainfrom
shoumikhin:ci-noaten-ldd-load-addresses

Conversation

@shoumikhin

@shoumikhin shoumikhin commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

The test-pybindings-no-aten job builds the Python bindings without PyTorch, runs their tests, and then checks that the built library does not link against PyTorch. The check searches the output of ldd for torch, aten or c10.

ldd also prints the address where it loaded each library, as a hex number such as (0x00007f8ec1000000). The addresses change on every run, and sometimes one of them contains c10. The check then fails after every test has passed, although nothing links PyTorch. This has turned the job red on recent main commits.

This change uses the check that release/1.6 already has (from #24338). It matches only library names and prints the ldd output so a failure shows what matched. With it, the job is the same on both branches.

Test plan: checked the ldd output of a library with 5 dependencies 4000 times, on Linux x86_64. The old pattern matched 57 times and the new check never did. The new check still flags PyTorch's libtorch_python.so, and reports a missing dependency when that library is copied away from the libraries it needs.

The test-pybindings-no-aten job checks that the torch-free Python
bindings do not link against PyTorch. It searches the output of `ldd`
for "torch", "aten" or "c10". But `ldd` also prints where it loaded each
library, as a hex number such as `(0x00007f8ec1000000)`, and such a
number sometimes contains "c10". The job then fails after every test has
passed, even though nothing links PyTorch.

Use the check that release/1.6 already has (from pytorch#24338). It matches only
library names, prints the `ldd` output, and fails on a missing
dependency.

Test plan: checked the `ldd` output of a library with five dependencies
4000 times. The old pattern matched 69 times and the new check never
did. The new check still flags PyTorch's `libtorch_python.so`, and
reports a missing dependency when that library is copied away from the
libraries it needs.
Copilot AI balanced review requested due to automatic review settings November 2, 2026 21:54
@pytorch-bot

pytorch-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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 ea3ca98 with merge base 893d815 (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 2, 2026

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@shoumikhin

Copy link
Copy Markdown
Contributor Author

@claude /pr-review

@github-actions

github-actions Bot commented Nov 2, 2026

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.

@claude

claude Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Claude finished @shoumikhin's task in 17m 29s —— View job


Nothing blocks this PR; the three optional cleanups below would each need the same change on release/1.6 to keep the two branches identical.

Detailed review

PR Review: #24470

Summary

The PR replaces the ldd | grep -Eiq 'torch|aten|c10' check in test-pybindings-no-aten with the version from release/1.6. That version matches only library names, so a load address that contains c10 no longer fails the job. Nothing blocks it; there are three minor cleanups below. I couldn't fetch release/1.6 in this sandbox, so I haven't checked the claim that the block matches it.

Code Quality

  • .github/workflows/pull.yml:218-221: the not found branch adds no coverage in this job.
    • A missing _C*.so already fails the job at line 195. test_pybindings_no_aten.py:20-21 raises unittest.SkipTest at import time, and run as a script that exits 1.
    • A dependency that disappears with the pip uninstall on line 204 makes importlib.import_module("_C") (test line 23) fail at line 205.
    • So by line 216, _C has already loaded without torch. The branch can only fire when ldd resolves libraries differently from the interpreter.
    • It also means the description's "fails when the built library is missing, where the old check passed" holds for the check alone, not for the job. Fix this →
  • .github/workflows/pull.yml:217: the printf duplicates output that is already in the log.
    • The script runs under set -eux (line 161), so the xtrace line for the assignment on line 216 already prints the whole ldd output.
    • The printf adds two more copies: its own trace line and its output.
    • The same capture-and-print block in .ci/scripts/test-rocm-aoti.sh:103-104 needs the printf, because that script runs under set -euo pipefail without -x. Fix this →
  • .github/workflows/pull.yml:222: the second alternative is the first one with a path in front.
    • '^[[:space:]]*([^[:space:]]*/)?lib(torch|aten|c10)[^[:space:]/]*\.so' is equivalent.
    • I ran both patterns over 13 sample ldd lines (load addresses, libexecutorch.so, libtorch*, libATen.so.1, libc10.so => not found, a bare-path libc10.so line), and they matched the same 6. Fix this →

Recommendation

Approve

None of the findings blocks the fix. All three are cleanups of the block copied from release/1.6, so making them only on main would bring back the difference between the branches that this PR removes. Do them on both branches or skip them.

@shoumikhin

Copy link
Copy Markdown
Contributor Author

Thanks. I'll keep the block exactly as it is on release/1.6, so both branches stay the same, as you suggest. None of the cleanups changes what the job catches. Making them on both branches would need a cherry-pick to the release branch, which is not worth it for a CI script.

You are right about the description. In this job, if the built library is missing, the tests already fail before this check runs. I removed that sentence.

This branch has not been deployed

No deployments
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. topic: not user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants