Name the Python extension after what it contains - #21816
Open
shoumikhin wants to merge 74 commits into
Open
Conversation
Contributor
Author
shoumikhin
requested review from
JacobSzwejbka and
kirklandsign
as code owners
August 13, 2026 15:36
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21816
Note: Links to docs will display an error until the docs builds have been completed. ❌ 12 New Failures, 23 Pending, 1 Unrelated Failure, 7 Unclassified FailuresAs of commit 72fbbc3 with merge base 8bfb3a9 ( NEW FAILURES - The following jobs have failed:
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:
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. |
This was referenced Aug 13, 2026
shoumikhin
added a commit
that referenced
this pull request
Aug 13, 2026
The compiled Python extension in the wheel was called `_portable_lib`. That name is misleading in two ways. "Portable" is the name of a kernel set in this project, the portable kernels, and this file does not contain them: it holds the Python bindings for the runtime. "Lib" says nothing, since every shared object is a library. Someone looking for the portable kernels finds the Python bindings instead, and someone looking for the bindings has no reason to open a file named after kernels. Rename it to `_C`, which is the usual name for a package's compiled C extension and what PyTorch calls the same thing (`torch/_C.cpython-*.so`). The package path already says `pybindings`, as in `executorch.extension.pybindings`, so a name like `_pybindings` would repeat itself while `_C` reads as "this package's C extension". Nothing user facing changes. Applications import the public wrapper: ```python from executorch.extension.pybindings import portable_lib ``` That wrapper re-exports everything from the compiled module and keeps its name, so existing code continues to work. Only the private module behind it is renamed, and it was already documented as experimental and subject to change. Test plan: Built a wheel and confirmed the shipped file is named for the new module: ``` extension/pybindings/_C.cpython-312-x86_64-linux-gnu.so ``` Installed that wheel into a fresh environment and checked both the public wrapper and the private module load, then exported and ran a model through the Python bindings: ``` public wrapper works: True module name : executorch.extension.pybindings._C exported symbols : 22 ``` Also grepped the tree to confirm no build file, test, or comment still names the old module. ghstack-source-id: 20f23fe ghstack-comment-id: 5282557165 Pull-Request: #21816
shoumikhin
added a commit
that referenced
this pull request
Aug 13, 2026
The compiled Python extension in the wheel was called `_portable_lib`. That name is misleading in two ways. "Portable" is the name of a kernel set in this project, the portable kernels, and this file does not contain them: it holds the Python bindings for the runtime. "Lib" says nothing, since every shared object is a library. Someone looking for the portable kernels finds the Python bindings instead, and someone looking for the bindings has no reason to open a file named after kernels. Rename it to `_C`, which is the usual name for a package's compiled C extension and what PyTorch calls the same thing (`torch/_C.cpython-*.so`). The package path already says `pybindings`, as in `executorch.extension.pybindings`, so a name like `_pybindings` would repeat itself while `_C` reads as "this package's C extension". Nothing user facing changes. Applications import the public wrapper: ```python from executorch.extension.pybindings import portable_lib ``` That wrapper re-exports everything from the compiled module and keeps its name, so existing code continues to work. Only the private module behind it is renamed, and it was already documented as experimental and subject to change. Test plan: Built a wheel and confirmed the shipped file is named for the new module: ``` extension/pybindings/_C.cpython-312-x86_64-linux-gnu.so ``` Installed that wheel into a fresh environment and checked both the public wrapper and the private module load, then exported and ran a model through the Python bindings: ``` public wrapper works: True module name : executorch.extension.pybindings._C exported symbols : 22 ``` Also grepped the tree to confirm no build file, test, or comment still names the old module. ghstack-source-id: 5386d2f ghstack-comment-id: 5282557165 Pull-Request: #21816
shoumikhin
added a commit
that referenced
this pull request
Aug 13, 2026
The compiled Python extension in the wheel was called `_portable_lib`. That name is misleading in two ways. "Portable" is the name of a kernel set in this project, the portable kernels, and this file does not contain them: it holds the Python bindings for the runtime. "Lib" says nothing, since every shared object is a library. Someone looking for the portable kernels finds the Python bindings instead, and someone looking for the bindings has no reason to open a file named after kernels. Rename it to `_C`, which is the usual name for a package's compiled C extension and what PyTorch calls the same thing (`torch/_C.cpython-*.so`). The package path already says `pybindings`, as in `executorch.extension.pybindings`, so a name like `_pybindings` would repeat itself while `_C` reads as "this package's C extension". Nothing user facing changes. Applications import the public wrapper: ```python from executorch.extension.pybindings import portable_lib ``` That wrapper re-exports everything from the compiled module and keeps its name, so existing code continues to work. Only the private module behind it is renamed, and it was already documented as experimental and subject to change. Test plan: Built a wheel and confirmed the shipped file is named for the new module: ``` extension/pybindings/_C.cpython-312-x86_64-linux-gnu.so ``` Installed that wheel into a fresh environment and checked both the public wrapper and the private module load, then exported and ran a model through the Python bindings: ``` public wrapper works: True module name : executorch.extension.pybindings._C exported symbols : 22 ``` Also grepped the tree to confirm no build file, test, or comment still names the old module. ghstack-source-id: e6925ec ghstack-comment-id: 5282557165 Pull-Request: #21816
digantdesai
approved these changes
Aug 18, 2026
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.
The compiled Python extension in the wheel was called
_portable_lib. That nameis misleading in two ways. "Portable" is the name of a kernel set in this project,
the portable kernels, and this file does not contain them: it holds the Python
bindings for the runtime. "Lib" says nothing, since every shared object is a
library. Someone looking for the portable kernels finds the Python bindings
instead, and someone looking for the bindings has no reason to open a file named
after kernels.
Rename it to
_C, which is the usual name for a package's compiled C extensionand what PyTorch calls the same thing (
torch/_C.cpython-*.so). The package pathalready says
pybindings, as inexecutorch.extension.pybindings, so a name like_pybindingswould repeat itself while_Creads as "this package's Cextension".
The documented import path is unaffected. Applications import the public wrapper:
That wrapper re-exports everything from the compiled module and keeps its name, so
code using it continues to work.
Code that imports the private module directly does break, and that pattern is in
real use despite the module being documented as experimental and subject to change.
No Python alias is added for the old name, since keeping the name reachable would
leave in place the thing this change exists to remove; such a caller moves to the
public wrapper. The C++ side is treated differently, because a CMake target name is
part of a published package interface rather than a private module: the package
config still answers to
executorch::_portable_liband to the bare_portable_libalongside
executorch::_C.Test plan:
Built a wheel and confirmed the shipped file is named for the new module:
Installed that wheel into a fresh environment and checked both the public wrapper
and the private module load, then exported and ran a model through the Python
bindings:
Also grepped the tree to confirm no build file, test, or comment still names the
old module.