Skip to content

Add Python inference bindings to the Native wheel (#24070) - #24070

Open
JakeStevens wants to merge 2 commits into
pytorch:mainfrom
JakeStevens:export-D126686193
Open

JakeStevens wants to merge 2 commits into
pytorch:mainfrom
JakeStevens:export-D126686193

Conversation

@JakeStevens

@JakeStevens JakeStevens commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Expose Native Model and Session through NumPy bindings in the separately installable executorch-native wheel, using its shared runtime. Keep the binding implementation, Python wrappers, type stubs, and binding tests in backends/native/pybindings, alongside the Native runtime.

Place the Python vision runner beside the C++ runner in backends/native/examples/vision and install it as executorch_native.vision. Bundle pretrained MobileNetV2, a preprocessed cat tensor, ImageNet labels, and reference logits in the existing SDK example location so python -m executorch_native.vision runs offline with just Native and NumPy. The default uses GGML and checks every logit against the reference; --engine vulkan selects Vulkan. Custom model and input paths remain paired, with optional labels and reference outputs.

Use the existing examples/native/vision/export.py to regenerate artifacts; keep the source image with that exporter and use its mv2 filenames for the bundled assets. Asset provenance, export versions, and checksums are documented with the data. The wheel uses the CPython ABI and includes the pybind11 license.

Authored with assistance from Codex.

Differential Revision: D126686193

@pytorch-bot

pytorch-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 1 Cancelled Job

As of commit 6cecdfa with merge base bf9bef3 (image):

CANCELLED JOB - The following job was cancelled. Please retry:

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 Oct 21, 2026
@meta-codesync

meta-codesync Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

@JakeStevens has exported this pull request. If you are a Meta employee, you can view the originating Diff in D126686193.

@github-actions

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.

@meta-codesync meta-codesync Bot changed the title Add Python inference bindings to the Native wheel Add Python inference bindings to the Native wheel (#24070) Oct 21, 2026
JakeStevens added a commit to JakeStevens/executorch that referenced this pull request Oct 21, 2026
Summary:
Pull Request resolved: pytorch#24070

Expose Native `Model` and `Session` through NumPy bindings in the separately installable `executorch-native` wheel, using its shared runtime. Keep the binding implementation, Python wrappers, type stubs, and binding tests in `backends/native/pybindings`, alongside the Native runtime.

Place the Python vision runner beside the C++ runner in `backends/native/examples/vision` and install it as `executorch_native.vision`. Bundle pretrained MobileNetV2, a preprocessed cat tensor, ImageNet labels, and reference logits in the existing SDK example location so `python -m executorch_native.vision` runs offline with just Native and NumPy. The default uses GGML and checks every logit against the reference; `--engine vulkan` selects Vulkan. Custom model and input paths remain paired, with optional labels and reference outputs.

Use the existing `examples/native/vision/export.py` to regenerate artifacts; keep the source image with that exporter and use its `mv2` filenames for the bundled assets. Asset provenance, export versions, and checksums are documented with the data. The wheel uses the CPython ABI and includes the `pybind11` license.

allow-large-files: The 14,097,630-byte pretrained MobileNetV2 `.ptn` and its demo tensors are intentionally checked in so the installed Native vision demo runs offline without exporter dependencies. Artifact provenance and SHA-256 checksums are documented alongside the files.

Authored with assistance from Codex.

Differential Revision: D126686193
JakeStevens added a commit to JakeStevens/executorch that referenced this pull request Oct 21, 2026
Summary:
Pull Request resolved: pytorch#24070

Expose Native `Model` and `Session` through NumPy bindings in the separately installable `executorch-native` wheel, using its shared runtime. Keep the binding implementation, Python wrappers, type stubs, and binding tests in `backends/native/pybindings`, alongside the Native runtime.

Place the Python vision runner beside the C++ runner in `backends/native/examples/vision` and install it as `executorch_native.vision`. Bundle pretrained MobileNetV2, a preprocessed cat tensor, ImageNet labels, and reference logits in the existing SDK example location so `python -m executorch_native.vision` runs offline with just Native and NumPy. The default uses GGML and checks every logit against the reference; `--engine vulkan` selects Vulkan. Custom model and input paths remain paired, with optional labels and reference outputs.

Use the existing `examples/native/vision/export.py` to regenerate artifacts; keep the source image with that exporter and use its `mv2` filenames for the bundled assets. Asset provenance, export versions, and checksums are documented with the data. The wheel uses the CPython ABI and includes the `pybind11` license.

allow-large-files: The 14,097,630-byte pretrained MobileNetV2 `.ptn` and its demo tensors are intentionally checked in so the installed Native vision demo runs offline without exporter dependencies. Artifact provenance and SHA-256 checksums are documented alongside the files.

Authored with assistance from Codex.

Differential Revision: D126686193

@SS-JIA SS-JIA 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.

Review automatically exported from Phabricator review in Meta.

…orch#24069)

Summary:

Add a separately installable Linux SDK wheel containing the Native runtime, Vulkan engine and shaders, and GGML CPU engine. Its CMake package lets consumers build the shipped vision runner without rebuilding the runtime, and the package coexists with `executorch`.

Keep the standalone wheel recipe in `backends/native/python` and its Python wrappers alongside the runtime in `backends/native/pybindings`. CMake installs those sources into `executorch_native`; the source tree does not need a nested copy of the import package. Python execution bindings are added in the following diff.

Authored with assistance from Codex.

Reviewed By: SS-JIA

Differential Revision: D126459370
Summary:

Expose Native `Model` and `Session` through NumPy bindings in the separately installable `executorch-native` wheel, using its shared runtime. Keep the binding implementation, Python wrappers, type stubs, and binding tests in `backends/native/pybindings`, alongside the Native runtime.

Place the Python vision runner beside the C++ runner in `backends/native/examples/vision` and install it as `executorch_native.vision`. Bundle pretrained MobileNetV2, a preprocessed cat tensor, ImageNet labels, and reference logits in the existing SDK example location so `python -m executorch_native.vision` runs offline with just Native and NumPy. The default uses GGML and checks every logit against the reference; `--engine vulkan` selects Vulkan. Custom model and input paths remain paired, with optional labels and reference outputs.

Use the existing `examples/native/vision/export.py` to regenerate artifacts; keep the source image with that exporter and use its `mv2` filenames for the bundled assets. Asset provenance, export versions, and checksums are documented with the data. The wheel uses the CPython ABI and includes the `pybind11` license.


Authored with assistance from Codex.

Differential Revision: D126686193

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. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants