Repository navigation
Conversation
**Problem** Building a C++ or CUDA extension against a PyTorch installed in editable mode (pip install -e .) fails to find any installed torch header. The compile aborts on the first include, e.g.: fatal error: torch/csrc/autograd/profiler_kineto.h: No such file or directory The recent migration to scikit-build-core changed editable installs so that compiled artifacts -- the installed headers, libraries, and binaries -- live in the installed package directory instead of the source tree. The C++ extension helper still looked for them under the source tree, which an editable install never populates, so extension builds lose their header and library search paths. Regular wheel installs are unaffected because their package directory and their import location are the same. **Fix** The scikit-build-core migration (pytorch#180247) already added _compute_torch_parent so get_file_path resolves to the installed package directory for editable installs, but torch.utils.cpp_extension still computed its own root from dirname(dirname(__file__)). Resolve _TORCH_PATH with get_file_path("torch") instead, so cpp_extension reuses that same editable-aware logic. _TORCH_PATH feeds every include, library, precompiled-header, and hipify path in the module, so this single change fixes all of them; non-editable installs resolve exactly as before. **Test Plan** Verified torch/utils/cpp_extension.py compiles (python -m py_compile). The runtime path was not exercised here (no torch build in this environment); validate against a fresh editable install with: ``` pip install --no-build-isolation -e . python -c "import os, torch.utils.cpp_extension as e; print(os.path.exists(os.path.join(e._TORCH_PATH, 'include', 'torch', 'csrc', 'autograd', 'profiler_kineto.h')))" # expect: True python -m pytest test/profiler/test_cpp_thread.py ``` Authored with assistance from an AI agent (Claude Code).
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/190829
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ✅ No FailuresAs of commit b96a5b9 with merge base 0dff903 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
atalman
approved these changes
Jul 22, 2026
Collaborator
|
@pytorchmergebot merge -i |
Collaborator
Merge startedYour change will be merged while ignoring the following 0 checks: Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
youlituao
pushed a commit
to youlituao/pytorch
that referenced
this pull request
Jul 28, 2026
…#190829) **Problem** Building a C++ or CUDA extension against a PyTorch installed in editable mode (`pip install -e .`) fails to find any installed torch header. The compile aborts on the first include, e.g.: ``` fatal error: torch/csrc/autograd/profiler_kineto.h: No such file or directory ``` The recent migration to scikit-build-core changed editable installs so that compiled artifacts (the installed headers, libraries, and binaries) live in the installed package directory instead of the source tree. The C++ extension helper still looked for them under the source tree, which an editable install never populates, so extension builds lose their header and library search paths. Regular wheel installs are unaffected because their package directory and their import location are the same. **Fix** The scikit-build-core migration (pytorch#180247) already added `_compute_torch_parent` so `get_file_path` resolves to the installed package directory for editable installs, but `torch.utils.cpp_extension` still computed its own root from `dirname(dirname(__file__))`. Resolve `_TORCH_PATH` with `get_file_path("torch")` instead, so `cpp_extension` reuses that same editable-aware logic. `_TORCH_PATH` feeds every include, library, precompiled-header, and hipify path in the module, so this single change fixes all of them; non-editable installs resolve exactly as before. Authored with assistance from an AI agent (Claude Code). Pull Request resolved: pytorch#190829 Approved by: https://github.com/atalman, https://github.com/albanD
youlituao
pushed a commit
to youlituao/pytorch
that referenced
this pull request
Jul 28, 2026
…#190829) **Problem** Building a C++ or CUDA extension against a PyTorch installed in editable mode (`pip install -e .`) fails to find any installed torch header. The compile aborts on the first include, e.g.: ``` fatal error: torch/csrc/autograd/profiler_kineto.h: No such file or directory ``` The recent migration to scikit-build-core changed editable installs so that compiled artifacts (the installed headers, libraries, and binaries) live in the installed package directory instead of the source tree. The C++ extension helper still looked for them under the source tree, which an editable install never populates, so extension builds lose their header and library search paths. Regular wheel installs are unaffected because their package directory and their import location are the same. **Fix** The scikit-build-core migration (pytorch#180247) already added `_compute_torch_parent` so `get_file_path` resolves to the installed package directory for editable installs, but `torch.utils.cpp_extension` still computed its own root from `dirname(dirname(__file__))`. Resolve `_TORCH_PATH` with `get_file_path("torch")` instead, so `cpp_extension` reuses that same editable-aware logic. `_TORCH_PATH` feeds every include, library, precompiled-header, and hipify path in the module, so this single change fixes all of them; non-editable installs resolve exactly as before. Authored with assistance from an AI agent (Claude Code). Pull Request resolved: pytorch#190829 Approved by: https://github.com/atalman, https://github.com/albanD
aws-kingrj
pushed a commit
to amazon-contributing/upstream-to-pytorch
that referenced
this pull request
Jul 29, 2026
…#190829) **Problem** Building a C++ or CUDA extension against a PyTorch installed in editable mode (`pip install -e .`) fails to find any installed torch header. The compile aborts on the first include, e.g.: ``` fatal error: torch/csrc/autograd/profiler_kineto.h: No such file or directory ``` The recent migration to scikit-build-core changed editable installs so that compiled artifacts (the installed headers, libraries, and binaries) live in the installed package directory instead of the source tree. The C++ extension helper still looked for them under the source tree, which an editable install never populates, so extension builds lose their header and library search paths. Regular wheel installs are unaffected because their package directory and their import location are the same. **Fix** The scikit-build-core migration (pytorch#180247) already added `_compute_torch_parent` so `get_file_path` resolves to the installed package directory for editable installs, but `torch.utils.cpp_extension` still computed its own root from `dirname(dirname(__file__))`. Resolve `_TORCH_PATH` with `get_file_path("torch")` instead, so `cpp_extension` reuses that same editable-aware logic. `_TORCH_PATH` feeds every include, library, precompiled-header, and hipify path in the module, so this single change fixes all of them; non-editable installs resolve exactly as before. Authored with assistance from an AI agent (Claude Code). Pull Request resolved: pytorch#190829 Approved by: https://github.com/atalman, https://github.com/albanD
MelindaTan
pushed a commit
to MelindaTan/pytorch
that referenced
this pull request
Jul 31, 2026
…#190829) **Problem** Building a C++ or CUDA extension against a PyTorch installed in editable mode (`pip install -e .`) fails to find any installed torch header. The compile aborts on the first include, e.g.: ``` fatal error: torch/csrc/autograd/profiler_kineto.h: No such file or directory ``` The recent migration to scikit-build-core changed editable installs so that compiled artifacts (the installed headers, libraries, and binaries) live in the installed package directory instead of the source tree. The C++ extension helper still looked for them under the source tree, which an editable install never populates, so extension builds lose their header and library search paths. Regular wheel installs are unaffected because their package directory and their import location are the same. **Fix** The scikit-build-core migration (pytorch#180247) already added `_compute_torch_parent` so `get_file_path` resolves to the installed package directory for editable installs, but `torch.utils.cpp_extension` still computed its own root from `dirname(dirname(__file__))`. Resolve `_TORCH_PATH` with `get_file_path("torch")` instead, so `cpp_extension` reuses that same editable-aware logic. `_TORCH_PATH` feeds every include, library, precompiled-header, and hipify path in the module, so this single change fixes all of them; non-editable installs resolve exactly as before. Authored with assistance from an AI agent (Claude Code). Pull Request resolved: pytorch#190829 Approved by: https://github.com/atalman, 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.
Problem
Building a C++ or CUDA extension against a PyTorch installed in editable mode (
pip install -e .) fails to find any installed torch header. The compile aborts on the first include, e.g.:The recent migration to scikit-build-core changed editable installs so that compiled artifacts (the installed headers, libraries, and binaries) live in the installed package directory instead of the source tree. The C++ extension helper still looked for them under the source tree, which an editable install never populates, so extension builds lose their header and library search paths. Regular wheel installs are unaffected because their package directory and their import location are the same.
Fix
The scikit-build-core migration (#180247) already added
_compute_torch_parentsoget_file_pathresolves to the installed package directory for editable installs, buttorch.utils.cpp_extensionstill computed its own root fromdirname(dirname(__file__)). Resolve_TORCH_PATHwithget_file_path("torch")instead, socpp_extensionreuses that same editable-aware logic._TORCH_PATHfeeds every include, library, precompiled-header, and hipify path in the module, so this single change fixes all of them; non-editable installs resolve exactly as before.Authored with assistance from an AI agent (Claude Code).