Repository navigation
Update tensor factory method docs - #6640
Merged
Merged
Conversation
Also add new docs for `torch.empty`.
zou3519
requested review from
apaszke,
colesbury,
ezyang,
gchanan,
soumith and
zdevito
as code owners
April 16, 2018 22:48
Collaborator
|
Cool! Can you also add |
Contributor
|
I'm wondering if there's a reasonable way we can avoid copy-pasting the same block of three arguments to every site. Maybe not... |
Contributor
Author
Contributor
Author
|
Oh! Docstrings are strings so I could just add them together... Will look into it |
Contributor
Author
|
@gchanan how does this look to you? |
ezyang
approved these changes
Apr 17, 2018
Jorghi12
pushed a commit
to wsttiger/pytorch
that referenced
this pull request
May 10, 2018
* Update tensor factory method docs Also add new docs for `torch.empty`. * Add full; some refactoring to make docs nicer
atalman
added a commit
to atalman/pytorch
that referenced
this pull request
Jul 7, 2026
…ch` deadlock (pytorch#189110) `import torch` from ROCm 2.13 wheels intermittently hangs forever on hosts without a usable GPU / kfd (CPU-only nodes, or GPU nodes without amdgpu/amdkfd loaded). Root cause chain (native backtrace): import torch -> dlopen(_C) -> static init of libtorch_rocshmem.so -> rocshmem::NUMAWrapper::NUMAWrapper() (upstream rocSHMEM global ctor) -> dlopen("libnuma.so") == NULL -> exit(1) -> atexit -> rocprofiler::registration::finalize() -> ThreadPool::destroy_threadpool() -> std::thread::join() # HANGS Why it regressed at pytorch#182696: the old build_rocm.sh renamed bundled OS deps to bare sonames, so torch/lib shipped `libnuma.so`. The new repair_wheel.py keeps them versioned (`libnuma.so.1`) only. rocSHMEM's NUMAWrapper ctor does `dlopen("libnuma.so")` (bare) via libtorch_rocshmem.so's $ORIGIN RPATH; with only `libnuma.so.1` present that dlopen fails and NUMAWrapper calls exit() at library-load time, which trips a racy rocprofiler-sdk atexit finalize deadlock (hence the intermittency). The good (0513) wheel shipped bare `libnuma.so` and never hangs; the bad (0514+) wheel ships only `libnuma.so.1` and does. Fix: when bundling a versioned OS dep, also create a bare-name symlink (libnuma.so -> libnuma.so.1, etc.), restoring build_rocm.sh behavior. The bare symlink satisfies rocSHMEM's dlopen while the versioned file still satisfies NEEDED references. Verified: adding this symlink to an installed wheel makes `import torch` succeed deterministically on a no-kfd host. The underlying rocSHMEM bug (NUMAWrapper must not exit() from a global ctor; should dlopen "libnuma.so.1") is fixed upstream after our pinned commit (ROCm/rocm-systems pytorch#5918, pytorch#6640) and should be picked up via a pin bump too.
pytorchmergebot
pushed a commit
that referenced
this pull request
Jul 8, 2026
…ock (#189114) ## Summary `import torch` from ROCm 2.13 wheels **intermittently hangs forever** on hosts without a usable GPU / kfd (CPU-only nodes, or GPU nodes where `amdgpu`/`amdkfd` isn't loaded). Fixes #189110. This is related to this fix PR in upstream: ROCm/rocm-systems#6640 (this is not included in pytorch, hence a failure) ### Root cause (native backtrace) ``` import torch → dlopen(_C) → static init of libtorch_rocshmem.so → rocshmem::NUMAWrapper::NUMAWrapper() (upstream rocSHMEM global ctor) → dlopen("libnuma.so") == NULL → exit(1) (at library-load time!) → atexit → rocprofiler::registration::finalize() → ThreadPool::destroy_threadpool() → std::thread::join() # HANGS ``` ### Why it regressed here (and why 0513 was fine but 0514 hangs) This is a **packaging** regression from the ROCm manywheel pipeline port (#182696), not the rocSHMEM binary: | | bundled `libnuma` | `dlopen("libnuma.so")` from `$ORIGIN` | result | |---|---|---|---| | old `build_rocm.sh` (0513) | **`libnuma.so`** (bare) | resolves | ✅ no `exit()` → never hangs | | new `repair_wheel.py` (0514+) | **`libnuma.so.1`** only | fails (no bare name in-wheel) | ❌ `exit(1)` → rocprofiler atexit deadlock → intermittent hang | The old `build_rocm.sh` renamed bundled OS deps to **bare** sonames, so `torch/lib` shipped `libnuma.so`. `repair_wheel.py` keeps them **versioned** (`libnuma.so.1`). rocSHMEM's `NUMAWrapper` global ctor does `dlopen("libnuma.so")` (bare) via `libtorch_rocshmem.so`'s `$ORIGIN` RPATH — with only `libnuma.so.1` present it fails and `exit(1)`s at load, tripping a **racy** rocprofiler-sdk atexit `finalize()` deadlock (hence the intermittency; the `agent.cpp:608` kfd warning is a red herring). Same rocSHMEM binary in both wheels — only the bundled `libnuma` filename differs. ## Fix When bundling a versioned OS dep, also create a **bare-name symlink** (`libnuma.so` → `libnuma.so.1`, etc.), restoring `build_rocm.sh` behavior. The bare symlink satisfies rocSHMEM's `dlopen`; the versioned file still satisfies `NEEDED` references. **Verified:** adding this symlink to an installed wheel makes `import torch` succeed deterministically on a no-`kfd` host (loop-tested; the hang no longer reproduces). ## Follow-ups (upstream) The underlying rocSHMEM bug — `NUMAWrapper` must not `exit()` from a global constructor, and should `dlopen("libnuma.so.1")` — is already fixed upstream *after* PyTorch's pinned commit (`cb8a2d6`): ROCm/rocm-systems **#5918** (runtime numalib check) and **#6640** (link numa directly, no `dlopen` — removes `numa_wrapper.cpp`). Bumping `ROCSHMEM_VERSION` in `.ci/docker/common/install_rocSHMEM.sh` would also fix it and is worth doing separately. The rocprofiler-sdk atexit `finalize()` deadlock ("does not exit cleanly") is a separate AMD-side bug. Pull Request resolved: #189114 Approved by: https://github.com/huydhn, https://github.com/albanD
vishalgoyal316
pushed a commit
to vishalgoyal316/pytorch
that referenced
this pull request
Jul 16, 2026
…ock (pytorch#189114) ## Summary `import torch` from ROCm 2.13 wheels **intermittently hangs forever** on hosts without a usable GPU / kfd (CPU-only nodes, or GPU nodes where `amdgpu`/`amdkfd` isn't loaded). Fixes pytorch#189110. This is related to this fix PR in upstream: ROCm/rocm-systems#6640 (this is not included in pytorch, hence a failure) ### Root cause (native backtrace) ``` import torch → dlopen(_C) → static init of libtorch_rocshmem.so → rocshmem::NUMAWrapper::NUMAWrapper() (upstream rocSHMEM global ctor) → dlopen("libnuma.so") == NULL → exit(1) (at library-load time!) → atexit → rocprofiler::registration::finalize() → ThreadPool::destroy_threadpool() → std::thread::join() # HANGS ``` ### Why it regressed here (and why 0513 was fine but 0514 hangs) This is a **packaging** regression from the ROCm manywheel pipeline port (pytorch#182696), not the rocSHMEM binary: | | bundled `libnuma` | `dlopen("libnuma.so")` from `$ORIGIN` | result | |---|---|---|---| | old `build_rocm.sh` (0513) | **`libnuma.so`** (bare) | resolves | ✅ no `exit()` → never hangs | | new `repair_wheel.py` (0514+) | **`libnuma.so.1`** only | fails (no bare name in-wheel) | ❌ `exit(1)` → rocprofiler atexit deadlock → intermittent hang | The old `build_rocm.sh` renamed bundled OS deps to **bare** sonames, so `torch/lib` shipped `libnuma.so`. `repair_wheel.py` keeps them **versioned** (`libnuma.so.1`). rocSHMEM's `NUMAWrapper` global ctor does `dlopen("libnuma.so")` (bare) via `libtorch_rocshmem.so`'s `$ORIGIN` RPATH — with only `libnuma.so.1` present it fails and `exit(1)`s at load, tripping a **racy** rocprofiler-sdk atexit `finalize()` deadlock (hence the intermittency; the `agent.cpp:608` kfd warning is a red herring). Same rocSHMEM binary in both wheels — only the bundled `libnuma` filename differs. ## Fix When bundling a versioned OS dep, also create a **bare-name symlink** (`libnuma.so` → `libnuma.so.1`, etc.), restoring `build_rocm.sh` behavior. The bare symlink satisfies rocSHMEM's `dlopen`; the versioned file still satisfies `NEEDED` references. **Verified:** adding this symlink to an installed wheel makes `import torch` succeed deterministically on a no-`kfd` host (loop-tested; the hang no longer reproduces). ## Follow-ups (upstream) The underlying rocSHMEM bug — `NUMAWrapper` must not `exit()` from a global constructor, and should `dlopen("libnuma.so.1")` — is already fixed upstream *after* PyTorch's pinned commit (`cb8a2d6`): ROCm/rocm-systems **pytorch#5918** (runtime numalib check) and **pytorch#6640** (link numa directly, no `dlopen` — removes `numa_wrapper.cpp`). Bumping `ROCSHMEM_VERSION` in `.ci/docker/common/install_rocSHMEM.sh` would also fix it and is worth doing separately. The rocprofiler-sdk atexit `finalize()` deadlock ("does not exit cleanly") is a separate AMD-side bug. Pull Request resolved: pytorch#189114 Approved by: https://github.com/huydhn, https://github.com/albanD
DamJanusz
pushed a commit
to DamJanusz/pytorch
that referenced
this pull request
Jul 21, 2026
…ock (pytorch#189114) ## Summary `import torch` from ROCm 2.13 wheels **intermittently hangs forever** on hosts without a usable GPU / kfd (CPU-only nodes, or GPU nodes where `amdgpu`/`amdkfd` isn't loaded). Fixes pytorch#189110. This is related to this fix PR in upstream: ROCm/rocm-systems#6640 (this is not included in pytorch, hence a failure) ### Root cause (native backtrace) ``` import torch → dlopen(_C) → static init of libtorch_rocshmem.so → rocshmem::NUMAWrapper::NUMAWrapper() (upstream rocSHMEM global ctor) → dlopen("libnuma.so") == NULL → exit(1) (at library-load time!) → atexit → rocprofiler::registration::finalize() → ThreadPool::destroy_threadpool() → std::thread::join() # HANGS ``` ### Why it regressed here (and why 0513 was fine but 0514 hangs) This is a **packaging** regression from the ROCm manywheel pipeline port (pytorch#182696), not the rocSHMEM binary: | | bundled `libnuma` | `dlopen("libnuma.so")` from `$ORIGIN` | result | |---|---|---|---| | old `build_rocm.sh` (0513) | **`libnuma.so`** (bare) | resolves | ✅ no `exit()` → never hangs | | new `repair_wheel.py` (0514+) | **`libnuma.so.1`** only | fails (no bare name in-wheel) | ❌ `exit(1)` → rocprofiler atexit deadlock → intermittent hang | The old `build_rocm.sh` renamed bundled OS deps to **bare** sonames, so `torch/lib` shipped `libnuma.so`. `repair_wheel.py` keeps them **versioned** (`libnuma.so.1`). rocSHMEM's `NUMAWrapper` global ctor does `dlopen("libnuma.so")` (bare) via `libtorch_rocshmem.so`'s `$ORIGIN` RPATH — with only `libnuma.so.1` present it fails and `exit(1)`s at load, tripping a **racy** rocprofiler-sdk atexit `finalize()` deadlock (hence the intermittency; the `agent.cpp:608` kfd warning is a red herring). Same rocSHMEM binary in both wheels — only the bundled `libnuma` filename differs. ## Fix When bundling a versioned OS dep, also create a **bare-name symlink** (`libnuma.so` → `libnuma.so.1`, etc.), restoring `build_rocm.sh` behavior. The bare symlink satisfies rocSHMEM's `dlopen`; the versioned file still satisfies `NEEDED` references. **Verified:** adding this symlink to an installed wheel makes `import torch` succeed deterministically on a no-`kfd` host (loop-tested; the hang no longer reproduces). ## Follow-ups (upstream) The underlying rocSHMEM bug — `NUMAWrapper` must not `exit()` from a global constructor, and should `dlopen("libnuma.so.1")` — is already fixed upstream *after* PyTorch's pinned commit (`cb8a2d6`): ROCm/rocm-systems **pytorch#5918** (runtime numalib check) and **pytorch#6640** (link numa directly, no `dlopen` — removes `numa_wrapper.cpp`). Bumping `ROCSHMEM_VERSION` in `.ci/docker/common/install_rocSHMEM.sh` would also fix it and is worth doing separately. The rocprofiler-sdk atexit `finalize()` deadlock ("does not exit cleanly") is a separate AMD-side bug. Pull Request resolved: pytorch#189114 Approved by: https://github.com/huydhn, https://github.com/albanD
youlituao
pushed a commit
to youlituao/pytorch
that referenced
this pull request
Jul 28, 2026
…ock (pytorch#189114) ## Summary `import torch` from ROCm 2.13 wheels **intermittently hangs forever** on hosts without a usable GPU / kfd (CPU-only nodes, or GPU nodes where `amdgpu`/`amdkfd` isn't loaded). Fixes pytorch#189110. This is related to this fix PR in upstream: ROCm/rocm-systems#6640 (this is not included in pytorch, hence a failure) ### Root cause (native backtrace) ``` import torch → dlopen(_C) → static init of libtorch_rocshmem.so → rocshmem::NUMAWrapper::NUMAWrapper() (upstream rocSHMEM global ctor) → dlopen("libnuma.so") == NULL → exit(1) (at library-load time!) → atexit → rocprofiler::registration::finalize() → ThreadPool::destroy_threadpool() → std::thread::join() # HANGS ``` ### Why it regressed here (and why 0513 was fine but 0514 hangs) This is a **packaging** regression from the ROCm manywheel pipeline port (pytorch#182696), not the rocSHMEM binary: | | bundled `libnuma` | `dlopen("libnuma.so")` from `$ORIGIN` | result | |---|---|---|---| | old `build_rocm.sh` (0513) | **`libnuma.so`** (bare) | resolves | ✅ no `exit()` → never hangs | | new `repair_wheel.py` (0514+) | **`libnuma.so.1`** only | fails (no bare name in-wheel) | ❌ `exit(1)` → rocprofiler atexit deadlock → intermittent hang | The old `build_rocm.sh` renamed bundled OS deps to **bare** sonames, so `torch/lib` shipped `libnuma.so`. `repair_wheel.py` keeps them **versioned** (`libnuma.so.1`). rocSHMEM's `NUMAWrapper` global ctor does `dlopen("libnuma.so")` (bare) via `libtorch_rocshmem.so`'s `$ORIGIN` RPATH — with only `libnuma.so.1` present it fails and `exit(1)`s at load, tripping a **racy** rocprofiler-sdk atexit `finalize()` deadlock (hence the intermittency; the `agent.cpp:608` kfd warning is a red herring). Same rocSHMEM binary in both wheels — only the bundled `libnuma` filename differs. ## Fix When bundling a versioned OS dep, also create a **bare-name symlink** (`libnuma.so` → `libnuma.so.1`, etc.), restoring `build_rocm.sh` behavior. The bare symlink satisfies rocSHMEM's `dlopen`; the versioned file still satisfies `NEEDED` references. **Verified:** adding this symlink to an installed wheel makes `import torch` succeed deterministically on a no-`kfd` host (loop-tested; the hang no longer reproduces). ## Follow-ups (upstream) The underlying rocSHMEM bug — `NUMAWrapper` must not `exit()` from a global constructor, and should `dlopen("libnuma.so.1")` — is already fixed upstream *after* PyTorch's pinned commit (`cb8a2d6`): ROCm/rocm-systems **pytorch#5918** (runtime numalib check) and **pytorch#6640** (link numa directly, no `dlopen` — removes `numa_wrapper.cpp`). Bumping `ROCSHMEM_VERSION` in `.ci/docker/common/install_rocSHMEM.sh` would also fix it and is worth doing separately. The rocprofiler-sdk atexit `finalize()` deadlock ("does not exit cleanly") is a separate AMD-side bug. Pull Request resolved: pytorch#189114 Approved by: https://github.com/huydhn, https://github.com/albanD
aws-kingrj
pushed a commit
to amazon-contributing/upstream-to-pytorch
that referenced
this pull request
Jul 29, 2026
…ock (pytorch#189114) ## Summary `import torch` from ROCm 2.13 wheels **intermittently hangs forever** on hosts without a usable GPU / kfd (CPU-only nodes, or GPU nodes where `amdgpu`/`amdkfd` isn't loaded). Fixes pytorch#189110. This is related to this fix PR in upstream: ROCm/rocm-systems#6640 (this is not included in pytorch, hence a failure) ### Root cause (native backtrace) ``` import torch → dlopen(_C) → static init of libtorch_rocshmem.so → rocshmem::NUMAWrapper::NUMAWrapper() (upstream rocSHMEM global ctor) → dlopen("libnuma.so") == NULL → exit(1) (at library-load time!) → atexit → rocprofiler::registration::finalize() → ThreadPool::destroy_threadpool() → std::thread::join() # HANGS ``` ### Why it regressed here (and why 0513 was fine but 0514 hangs) This is a **packaging** regression from the ROCm manywheel pipeline port (pytorch#182696), not the rocSHMEM binary: | | bundled `libnuma` | `dlopen("libnuma.so")` from `$ORIGIN` | result | |---|---|---|---| | old `build_rocm.sh` (0513) | **`libnuma.so`** (bare) | resolves | ✅ no `exit()` → never hangs | | new `repair_wheel.py` (0514+) | **`libnuma.so.1`** only | fails (no bare name in-wheel) | ❌ `exit(1)` → rocprofiler atexit deadlock → intermittent hang | The old `build_rocm.sh` renamed bundled OS deps to **bare** sonames, so `torch/lib` shipped `libnuma.so`. `repair_wheel.py` keeps them **versioned** (`libnuma.so.1`). rocSHMEM's `NUMAWrapper` global ctor does `dlopen("libnuma.so")` (bare) via `libtorch_rocshmem.so`'s `$ORIGIN` RPATH — with only `libnuma.so.1` present it fails and `exit(1)`s at load, tripping a **racy** rocprofiler-sdk atexit `finalize()` deadlock (hence the intermittency; the `agent.cpp:608` kfd warning is a red herring). Same rocSHMEM binary in both wheels — only the bundled `libnuma` filename differs. ## Fix When bundling a versioned OS dep, also create a **bare-name symlink** (`libnuma.so` → `libnuma.so.1`, etc.), restoring `build_rocm.sh` behavior. The bare symlink satisfies rocSHMEM's `dlopen`; the versioned file still satisfies `NEEDED` references. **Verified:** adding this symlink to an installed wheel makes `import torch` succeed deterministically on a no-`kfd` host (loop-tested; the hang no longer reproduces). ## Follow-ups (upstream) The underlying rocSHMEM bug — `NUMAWrapper` must not `exit()` from a global constructor, and should `dlopen("libnuma.so.1")` — is already fixed upstream *after* PyTorch's pinned commit (`cb8a2d6`): ROCm/rocm-systems **pytorch#5918** (runtime numalib check) and **pytorch#6640** (link numa directly, no `dlopen` — removes `numa_wrapper.cpp`). Bumping `ROCSHMEM_VERSION` in `.ci/docker/common/install_rocSHMEM.sh` would also fix it and is worth doing separately. The rocprofiler-sdk atexit `finalize()` deadlock ("does not exit cleanly") is a separate AMD-side bug. Pull Request resolved: pytorch#189114 Approved by: https://github.com/huydhn, https://github.com/albanD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Also add new docs for
torch.empty.cc @gchanan @ssnl