Skip to content

Fix path in find_library_location for libs in pytorch/build/lib - #194884

Closed
dominikjastrzebskix wants to merge 2 commits into
pytorch:mainfrom
dominikjastrzebskix:djastrzx/4436/correctly-load-libtorchbind_test
Closed

dominikjastrzebskix wants to merge 2 commits into
pytorch:mainfrom
dominikjastrzebskix:djastrzx/4436/correctly-load-libtorchbind_test

Conversation

@dominikjastrzebskix

@dominikjastrzebskix dominikjastrzebskix commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes issues found in intel/torch-xpu-ops#4436

Currently, find_library_location() for libtorchbind_test.so resolves to:
pytorch/torch/build/lib/libtorchbind_test.so
but the actual built library is here:
pytorch/build/lib/libtorchbind_test.so

Issue initially caused by: #129409, but it only exposed old issue introduced to find_library_location() here: #61960

@pytorch-bot

pytorch-bot Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

✅ You can merge normally! (2 Unrelated Failures)

As of commit d3e2399 with merge base a402343 (image):

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.

@dominikjastrzebskix

Copy link
Copy Markdown
Contributor Author

@pytorchbot label "topic: not user facing"

@pbielak pbielak added ciflow/trunk Trigger trunk jobs on your pull request ciflow/xpu Run XPU CI tasks ci-no-td Do not run TD on this PR labels Sep 15, 2026
@pytorch-bot

pytorch-bot Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Workflows were awaiting approval. CI has now been triggered for the ciflow labels on this PR.

@pbielak

pbielak commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

@pytorchbot rebase

@pbielak
pbielak requested a review from guangyey September 22, 2026 14:11
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Successfully rebased djastrzx/4436/correctly-load-libtorchbind_test onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via git checkout djastrzx/4436/correctly-load-libtorchbind_test && git pull --rebase)

@pytorchmergebot
pytorchmergebot force-pushed the djastrzx/4436/correctly-load-libtorchbind_test branch from 0cf2242 to d3e2399 Compare September 22, 2026 14:13

@guangyey guangyey 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.

Good catch!

@guangyey
guangyey marked this pull request as ready for review September 23, 2026 02:09
@guangyey
guangyey requested a review from a team as a code owner September 23, 2026 02:09
@Skylion007

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

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

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@guangyey

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

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

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

The merge job was canceled or timed out. This most often happen if two merge requests were issued for the same PR, or if merge job was waiting for more than 6 hours for tests to finish. In later case, please do not hesitate to reissue the merge command
For more information see pytorch-bot wiki.

@Skylion007

Copy link
Copy Markdown
Collaborator

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

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

@BBBela

BBBela commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Hello @dominikjastrzebskix,
I checked torch-xpu-ops CI and it looks like before this PR was merged, there were 214 failures with the torchbind_test.so with the following error:

OSError: /__w/torch-xpu-ops/torch-xpu-ops/.venv/lib/python3.10/site-packages/torch/build/lib/libtorchbind_test.so: cannot open shared object file: No such file or directory ; OSError: Could not load this library: /__w/torch-xpu-ops/torch-xpu-ops/.venv/lib/python3.10/site-packages/torch/build/lib/libtorchbind_test.so

CI RUN: https://github.com/intel/torch-xpu-ops/actions/runs/36428748505

After this PR was merged, there are 503 failures with this new message:

FileNotFoundError: Could not find library 'libtorchbind_test.so' in installed or build paths

CI RUN: https://github.com/intel/torch-xpu-ops/actions/runs/36868895669

So it looks like the problem hasn't been fixed, only the error message changed and even more tests are now failing with this message. Could you please check that?

My short investigation showed that the whole torchbind_test.so unavailability problem is related to lack of INSTALL_TEST env variable during PyTorch build in torch-xpu-ops CI, but I haven't dived deeper into it. Tests that fail in CI are perfectly fine and passing on my local platform build from source (I checked the test_with_effects_xpu.py` test file).

CC: @guangyey

ZhaoqiongZ added a commit to ZhaoqiongZ/pytorch that referenced this pull request Nov 12, 2026
On a wheel install `libtorchbind_test.so` is absent, and
`WeakKeyDictionaryScriptObjectTestCase` errors instead of skipping. Two causes:

1. `load_torchbind_test_lib()` never raises `SkipTest` anymore. pytorch#193122 added an
   `.exists()` check for that, but pytorch#194884 later made `find_library_location`
   raise `FileNotFoundError` when the library is missing, so the check became
   unreachable. Fix: convert the `FileNotFoundError` to `SkipTest` in the loader.
   This also fixes the other callers of the loader.
2. The test class called the loader from `__init__`, and unittest ignores
   `SkipTest` raised there. Fix: load in `setUp`. Under
   `PYTORCH_TEST_WITH_DYNAMO`, `setUp` is compiled and tracing the
   `_TorchScriptTesting._Foo` construction fails on the unregistered fake class,
   so the fixtures are built in a `torch._dynamo.disable`'d helper.

Test Plan:
On `2.15.0.dev20260915+xpu` (no torchbind library), with main's
`find_library_location` injected and this PR's `torchbind_impls.py` and
`test_weak.py`:

```
python test/test_weak.py -k ScriptObject                             # OK (skipped=14)
PYTORCH_TEST_WITH_DYNAMO=1 python test/test_weak.py -k ScriptObject  # OK (skipped=14)
```

Without the fix: 14 errors (`FileNotFoundError`). The library-present path is
covered by CI.

Fixes intel/torch-xpu-ops#5127

Authored with an AI assistant.
pytorchmergebot pushed a commit to ZhaoqiongZ/pytorch that referenced this pull request Nov 24, 2026
On a wheel install `libtorchbind_test.so` is absent, and
`WeakKeyDictionaryScriptObjectTestCase` errors instead of skipping. Two causes:

1. `load_torchbind_test_lib()` never raises `SkipTest` anymore. pytorch#193122 added an
   `.exists()` check for that, but pytorch#194884 later made `find_library_location`
   raise `FileNotFoundError` when the library is missing, so the check became
   unreachable. Fix: convert the `FileNotFoundError` to `SkipTest` in the loader.
   This also fixes the other callers of the loader.
2. The test class called the loader from `__init__`, and unittest ignores
   `SkipTest` raised there. Fix: load in `setUp`. Under
   `PYTORCH_TEST_WITH_DYNAMO`, `setUp` is compiled and tracing the
   `_TorchScriptTesting._Foo` construction fails on the unregistered fake class,
   so the fixtures are built in a `torch._dynamo.disable`'d helper.

Test Plan:
On `2.15.0.dev20260915+xpu` (no torchbind library), with main's
`find_library_location` injected and this PR's `torchbind_impls.py` and
`test_weak.py`:

```
python test/test_weak.py -k ScriptObject                             # OK (skipped=14)
PYTORCH_TEST_WITH_DYNAMO=1 python test/test_weak.py -k ScriptObject  # OK (skipped=14)
```

Without the fix: 14 errors (`FileNotFoundError`). The library-present path is
covered by CI.

Fixes intel/torch-xpu-ops#5127

Authored with an AI assistant.
pytorchmergebot pushed a commit to ZhaoqiongZ/pytorch that referenced this pull request Nov 24, 2026
On a wheel install `libtorchbind_test.so` is absent, and
`WeakKeyDictionaryScriptObjectTestCase` errors instead of skipping. Two causes:

1. `load_torchbind_test_lib()` never raises `SkipTest` anymore. pytorch#193122 added an
   `.exists()` check for that, but pytorch#194884 later made `find_library_location`
   raise `FileNotFoundError` when the library is missing, so the check became
   unreachable. Fix: convert the `FileNotFoundError` to `SkipTest` in the loader.
   This also fixes the other callers of the loader.
2. The test class called the loader from `__init__`, and unittest ignores
   `SkipTest` raised there. Fix: load in `setUp`. Under
   `PYTORCH_TEST_WITH_DYNAMO`, `setUp` is compiled and tracing the
   `_TorchScriptTesting._Foo` construction fails on the unregistered fake class,
   so the fixtures are built in a `torch._dynamo.disable`'d helper.

Test Plan:
On `2.15.0.dev20260915+xpu` (no torchbind library), with main's
`find_library_location` injected and this PR's `torchbind_impls.py` and
`test_weak.py`:

```
python test/test_weak.py -k ScriptObject                             # OK (skipped=14)
PYTORCH_TEST_WITH_DYNAMO=1 python test/test_weak.py -k ScriptObject  # OK (skipped=14)
```

Without the fix: 14 errors (`FileNotFoundError`). The library-present path is
covered by CI.

Fixes intel/torch-xpu-ops#5127

Authored with an AI assistant.
ZhaoqiongZ added a commit to ZhaoqiongZ/pytorch that referenced this pull request Nov 27, 2026
On a wheel install `libtorchbind_test.so` is absent, and
`WeakKeyDictionaryScriptObjectTestCase` errors instead of skipping. Two causes:

1. `load_torchbind_test_lib()` never raises `SkipTest` anymore. pytorch#193122 added an
   `.exists()` check for that, but pytorch#194884 later made `find_library_location`
   raise `FileNotFoundError` when the library is missing, so the check became
   unreachable. Fix: convert the `FileNotFoundError` to `SkipTest` in the loader.
   This also fixes the other callers of the loader.
2. The test class called the loader from `__init__`, and unittest ignores
   `SkipTest` raised there. Fix: load in `setUpClass`, which skips the whole
   class and loads the library once. Under
   `PYTORCH_TEST_WITH_DYNAMO`, `setUp` is compiled and tracing the
   `_TorchScriptTesting._Foo` construction fails on the unregistered fake class,
   so the fixtures are built in a `torch._dynamo.disable`'d helper.

Test Plan:
On `2.15.0.dev20260915+xpu` (no torchbind library), with main's
`find_library_location` injected and this PR's `torchbind_impls.py` and
`test_weak.py`:

```
python test/test_weak.py -k ScriptObject                             # OK (skipped=1)
PYTORCH_TEST_WITH_DYNAMO=1 python test/test_weak.py -k ScriptObject  # OK (skipped=1)
```

Without the fix: 14 errors (`FileNotFoundError`). The library-present path is
covered by CI.

Fixes intel/torch-xpu-ops#5127

Authored with an AI assistant.
pytorchmergebot pushed a commit to ZhaoqiongZ/pytorch that referenced this pull request Nov 28, 2026
On a wheel install `libtorchbind_test.so` is absent, and
`WeakKeyDictionaryScriptObjectTestCase` errors instead of skipping. Two causes:

1. `load_torchbind_test_lib()` never raises `SkipTest` anymore. pytorch#193122 added an
   `.exists()` check for that, but pytorch#194884 later made `find_library_location`
   raise `FileNotFoundError` when the library is missing, so the check became
   unreachable. Fix: convert the `FileNotFoundError` to `SkipTest` in the loader.
   This also fixes the other callers of the loader.
2. The test class called the loader from `__init__`, and unittest ignores
   `SkipTest` raised there. Fix: load in `setUpClass`, which skips the whole
   class and loads the library once. Under
   `PYTORCH_TEST_WITH_DYNAMO`, `setUp` is compiled and tracing the
   `_TorchScriptTesting._Foo` construction fails on the unregistered fake class,
   so the fixtures are built in a `torch._dynamo.disable`'d helper.

Test Plan:
On `2.15.0.dev20260915+xpu` (no torchbind library), with main's
`find_library_location` injected and this PR's `torchbind_impls.py` and
`test_weak.py`:

```
python test/test_weak.py -k ScriptObject                             # OK (skipped=1)
PYTORCH_TEST_WITH_DYNAMO=1 python test/test_weak.py -k ScriptObject  # OK (skipped=1)
```

Without the fix: 14 errors (`FileNotFoundError`). The library-present path is
covered by CI.

Fixes intel/torch-xpu-ops#5127

Authored with an AI assistant.
pytorchmergebot pushed a commit to ZhaoqiongZ/pytorch that referenced this pull request Nov 30, 2026
On a wheel install `libtorchbind_test.so` is absent, and
`WeakKeyDictionaryScriptObjectTestCase` errors instead of skipping. Two causes:

1. `load_torchbind_test_lib()` never raises `SkipTest` anymore. pytorch#193122 added an
   `.exists()` check for that, but pytorch#194884 later made `find_library_location`
   raise `FileNotFoundError` when the library is missing, so the check became
   unreachable. Fix: convert the `FileNotFoundError` to `SkipTest` in the loader.
   This also fixes the other callers of the loader.
2. The test class called the loader from `__init__`, and unittest ignores
   `SkipTest` raised there. Fix: load in `setUpClass`, which skips the whole
   class and loads the library once. Under
   `PYTORCH_TEST_WITH_DYNAMO`, `setUp` is compiled and tracing the
   `_TorchScriptTesting._Foo` construction fails on the unregistered fake class,
   so the fixtures are built in a `torch._dynamo.disable`'d helper.

Test Plan:
On `2.15.0.dev20260915+xpu` (no torchbind library), with main's
`find_library_location` injected and this PR's `torchbind_impls.py` and
`test_weak.py`:

```
python test/test_weak.py -k ScriptObject                             # OK (skipped=1)
PYTORCH_TEST_WITH_DYNAMO=1 python test/test_weak.py -k ScriptObject  # OK (skipped=1)
```

Without the fix: 14 errors (`FileNotFoundError`). The library-present path is
covered by CI.

Fixes intel/torch-xpu-ops#5127

Authored with an AI assistant.
pytorchmergebot pushed a commit to ZhaoqiongZ/pytorch that referenced this pull request Dec 2, 2026
On a wheel install `libtorchbind_test.so` is absent, and
`WeakKeyDictionaryScriptObjectTestCase` errors instead of skipping. Two causes:

1. `load_torchbind_test_lib()` never raises `SkipTest` anymore. pytorch#193122 added an
   `.exists()` check for that, but pytorch#194884 later made `find_library_location`
   raise `FileNotFoundError` when the library is missing, so the check became
   unreachable. Fix: convert the `FileNotFoundError` to `SkipTest` in the loader.
   This also fixes the other callers of the loader.
2. The test class called the loader from `__init__`, and unittest ignores
   `SkipTest` raised there. Fix: load in `setUpClass`, which skips the whole
   class and loads the library once. Under
   `PYTORCH_TEST_WITH_DYNAMO`, `setUp` is compiled and tracing the
   `_TorchScriptTesting._Foo` construction fails on the unregistered fake class,
   so the fixtures are built in a `torch._dynamo.disable`'d helper.

Test Plan:
On `2.15.0.dev20260915+xpu` (no torchbind library), with main's
`find_library_location` injected and this PR's `torchbind_impls.py` and
`test_weak.py`:

```
python test/test_weak.py -k ScriptObject                             # OK (skipped=1)
PYTORCH_TEST_WITH_DYNAMO=1 python test/test_weak.py -k ScriptObject  # OK (skipped=1)
```

Without the fix: 14 errors (`FileNotFoundError`). The library-present path is
covered by CI.

Fixes intel/torch-xpu-ops#5127

Authored with an AI assistant.
pytorchmergebot pushed a commit to ZhaoqiongZ/pytorch that referenced this pull request Dec 4, 2026
On a wheel install `libtorchbind_test.so` is absent, and
`WeakKeyDictionaryScriptObjectTestCase` errors instead of skipping. Two causes:

1. `load_torchbind_test_lib()` never raises `SkipTest` anymore. pytorch#193122 added an
   `.exists()` check for that, but pytorch#194884 later made `find_library_location`
   raise `FileNotFoundError` when the library is missing, so the check became
   unreachable. Fix: convert the `FileNotFoundError` to `SkipTest` in the loader.
   This also fixes the other callers of the loader.
2. The test class called the loader from `__init__`, and unittest ignores
   `SkipTest` raised there. Fix: load in `setUpClass`, which skips the whole
   class and loads the library once. Under
   `PYTORCH_TEST_WITH_DYNAMO`, `setUp` is compiled and tracing the
   `_TorchScriptTesting._Foo` construction fails on the unregistered fake class,
   so the fixtures are built in a `torch._dynamo.disable`'d helper.

Test Plan:
On `2.15.0.dev20260915+xpu` (no torchbind library), with main's
`find_library_location` injected and this PR's `torchbind_impls.py` and
`test_weak.py`:

```
python test/test_weak.py -k ScriptObject                             # OK (skipped=1)
PYTORCH_TEST_WITH_DYNAMO=1 python test/test_weak.py -k ScriptObject  # OK (skipped=1)
```

Without the fix: 14 errors (`FileNotFoundError`). The library-present path is
covered by CI.

Fixes intel/torch-xpu-ops#5127

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

Labels

ci-no-td Do not run TD on this PR ciflow/trunk Trigger trunk jobs on your pull request ciflow/xpu Run XPU CI tasks Merged open source topic: not user facing topic category

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

9 participants