[RFC] Ship the ExecuTorch C++ SDK as a standalone archive with each release, starting with 1.6.0
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Feature
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- cmake, docker, github-actions, python
- Bereich
- build-system, developer-experience, release
Rechercherichtung
Start with the existing C++ SDK test at .ci/scripts/wheel/test_cpp_sdk.py and the release workflow pattern in build-cmsis-pack.yml; the RFC also identifies the published 1.6.0 wheels as the archive source. First determine how those workflows build and verify wheel contents, then map the plan's archive, platform and release requirements onto them. Done means release archives are attached and a test consumes each unpacked archive without Python on PATH, including the stated oldest supported systems.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Summary
ExecuTorch already builds a C++ SDK (headers, shared libraries and a CMake package) for Linux, macOS and Windows, but ships it only inside the Python wheels. This RFC proposes attaching that SDK to each GitHub release as a plain archive per platform, with a stated platform contract and a test that consumes it the way a native user does. A C++ developer then downloads one file and points CMake at it, with no Python involved.
No new build is needed. Each archive is the include/, lib/ and share/cmake/ tree from a published wheel, plus license notices, a manifest and a checksum. So the first step is small: create the v1.6.0 GitHub release and attach archives repacked from the published 1.6.0 wheels.
The problem
Many people only want to run a .pte model, not export one: C++ desktop apps, services in small containers, embedded Linux devices and robots (often with no Python on the device), and bindings for other languages. Today they either install the full Python package or build ExecuTorch themselves:
- The Rust bindings ask every user to build ExecuTorch first.
- anira builds and hosts its own static ExecuTorch libraries for desktop targets. The Flutter bindings host their own native builds for desktop and mobile in executorch_native.
- #10888 asks for an ExecuTorch server program and prebuilt binaries on GitHub releases. #16685 asks for a vcpkg port.
The wheels do contain the SDK, the C++ guide (using-executorch-cpp.md) documents using it, and the wheel CI already builds and runs C++ programs against it. What is missing for native users:
- A file meant for them. Today it is a Python wheel: on Linux the PyPI default is the CUDA 13.2 build, and its metadata pins
torch==2.15.0, sopip install executorchpulls PyTorch and the CUDA runtime even for a C++ app that needs neither. - One stated contract: supported platforms, CMake, glibc and C++ runtime versions, what is inside, third-party license notices, and a manifest of how it was built.
- A check that the SDK works when unpacked on a machine with no Python, and on the oldest supported system.
For comparison, ONNX Runtime attaches SDK archives (headers, shared library, CMake and pkg-config files) to each GitHub release. The ROS 2 package onnxruntime_vendor builds on them: it downloads the upstream archive for the right architecture (ONNX Runtime 1.24.3).
What this unblocks
- C++ apps and Docker images: one download, no Python, no PyTorch.
- Robots on ROS 2: the
executorch_vendorpackage proposed in ros2/rosidl_buffer_backends#36 today downloads the pinned+cpuwheel (SHA-256 checked) and unpacks only its C++ part. With archives it would download a file made for C++, with a stated platform contract, the wayonnxruntime_vendordownloads ONNX Runtime's archive. - Small control policies in C++: reinforcement-learning policies (walking, balance, simple grasping) are tiny networks that run hundreds of times a second inside a C++ control loop. Such a policy fully delegated to XNNPACK needs only a few MB of ExecuTorch libraries. Today getting them means installing a Python wheel that pins PyTorch.
- Bindings in other languages (Rust, Flutter, and others) can download the archive at build time instead of building ExecuTorch, if they can link shared libraries. Bindings that link static libraries today would need changes.
Proposal: the SDK archive
Files (attached to the GitHub release and mirrored on download.pytorch.org, each with a .sha256 file next to it):
executorch-<ver>-linux-x86_64.tar.gz
executorch-<ver>-linux-aarch64.tar.gz
executorch-<ver>-macos-arm64.tar.gz
executorch-<ver>-windows-x86_64.zip
executorch-<ver>-linux-x86_64-cu132.tar.gz
executorch-<ver>-linux-aarch64-cu132.tar.gz
executorch-<ver>-windows-x86_64-cu132.zip
Layout: one top folder named after the archive (for example executorch-1.6.0-linux-aarch64/), holding the same tree as inside today's wheels:
include/ C++ headers
lib/ shared libraries (.so, .dylib, .dll with .lib import libraries)
lib/cmake/executorch/ CMake package
share/cmake/ same CMake package (it locates the SDK root through this folder)
backends/cuda/ CUDA archives only (data/lib/ on Windows): the AOTInductor shim library, loaded at run time
LICENSE, THIRD-PARTY-NOTICES
manifest.json version, git commit, source wheel and its SHA-256, minimum OS, glibc and C++ runtime
Components:
| Component | Linux x86_64 | Linux aarch64 | macOS arm64 | Windows x86_64 |
|---|---|---|---|---|
runtime, threadpool |
✅ | ✅ | ✅ | ✅ |
kernels_optimized, kernels_quantized |
✅ | ✅ | ✅ | ✅ |
backend_xnnpack (CPU) |
✅ | ✅ | ✅ | ✅ |
etdump (profiling) |
✅ | ✅ | ✅ | ✖️ |
kernels_torchao |
✖️ | ✅ | ✅ | ✖️ |
backend_coreml, backend_mlx (+ mlx.metallib) |
✖️ | ✖️ | ✅ | ✖️ |
backend_cuda (-cu132 archives) |
✅ | ✅ | ✖️ | ✅ |
The CPU archives come from the +cpu wheels (Linux and Windows) and the macOS wheel. The -cu132 archives come from the CUDA 13.2 wheels and add the CUDA backend.
The Arm VGF backend is not in the table: in the wheels it is built into the Python extension, not into a library of its own, so a repacked archive cannot carry it. C++ users who need it would need it built as a separate library first.
Requirements, stated in the README and the manifest:
| Platform | Requirements |
|---|---|
| all | CMake 3.28+ for the executorch:: targets. CMake 3.19 to 3.27 works through the EXECUTORCH_* variables. C++17 (C++20 on Windows); the targets set this for you. |
| Linux | glibc 2.28+, libstdc++ from GCC 7+ (the 1.6.0 libraries need GLIBCXX_3.4.22 and CXXABI_1.3.11) |
| macOS | macOS 14+ |
| Windows | MSVC, Release builds, and the latest Visual C++ 2015-2022 Redistributable (x64) on the target machine |
| CUDA archives | an NVIDIA driver for CUDA 13. On Linux, also the CUDA 13 runtime (libcudart.so.13), findable at link time and run time; it is not bundled. On Windows, the 1.6.0 CUDA libraries import no cudart64_13.dll and use the runtime that comes with the driver (found by inspecting the binaries; the archive test in step 4 should confirm it). On Linux, deploy backends/cuda/libaoti_cuda_shims.so next to the app's other libraries. |
On macOS, document the signing and notarization policy, and check a downloaded archive on a clean Mac.
How people use it
C++ app on Linux (on macOS use the macos-arm64 archive):
curl -LO https://github.com/pytorch/executorch/releases/download/v1.6.0/executorch-1.6.0-linux-aarch64.tar.gz
tar xf executorch-1.6.0-linux-aarch64.tar.gz
cmake -S . -B build -DCMAKE_PREFIX_PATH="$PWD/executorch-1.6.0-linux-aarch64"
cmake --build build
cmake_minimum_required(VERSION 3.28)
project(app CXX)
find_package(executorch REQUIRED COMPONENTS kernels_optimized backend_xnnpack)
add_executable(app main.cpp)
target_link_libraries(app PRIVATE executorch::runtime
executorch::kernels_optimized
executorch::backend_xnnpack)
main.cpp and its small model.pte are the example from the C++ guide (export the model once, on any machine with Python). The build machine needs no Python and no pip.
Windows: the same CMake file, plus this step from the C++ guide, which copies the required DLLs next to the program:
add_custom_command(TARGET app POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_RUNTIME_DLLS:app> $<TARGET_FILE_DIR:app>
COMMAND_EXPAND_LISTS)
Embedded Linux device: build on the device, or cross-compile with a toolchain whose sysroot has glibc 2.28 or newer. Copy the program and the libraries it links into one folder, with INSTALL_RPATH $ORIGIN. A model fully delegated to XNNPACK needs only the runtime, XNNPACK and thread pool libraries, a few MB; the optimized CPU kernels add more.
ROS 2: a vendor package downloads the archive for the right architecture, verifies a pinned SHA-256, and exports the ExecuTorch CMake targets.
Plan
- Create the
v1.6.0tag and GitHub release (PyPI has had 1.6.0 since 2026-11-04; the newest tag isv1.6.0-rc4, the commit inside the published wheels). - Build archives for 1.6.0 from the published wheels, test them (step 4), attach them to the release, and mirror them on download.pytorch.org. Repacking has to rewrite each library's search path (RUNPATH): in the wheels they point at
../../nvidia/cu13/liband../src/executorch/lib, which do not exist in an archive. - Add a workflow that builds and attaches the archives when a release is published, the way
build-cmsis-pack.ymldoes for the CMSIS pack. - Extend the C++ SDK test (
.ci/scripts/wheel/test_cpp_sdk.py, which already builds programs against the wheel and runs them after moving them) to run against each unpacked archive with no Python onPATH. On Linux, also run it on the oldest supported glibc; on Windows, on a machine without Visual Studio. - Add a "Download the C++ SDK" section to the C++ guide, including the CUDA deployment note above.
What this promises, and what it does not
- The named platforms above, each tested. Others (Android NDK, macOS x86_64, Windows on Arm, armv7, musl) keep the source build. Android and iOS app developers already have prebuilt packages (the AAR on Maven Central and the Swift Package).
- An app and the SDK should come from the same release. This RFC does not propose a stable binary interface across releases.
- Source builds stay supported for selective builds, custom operators and microcontrollers.
Alternatives considered
- Only document wheel extraction. It works and should be documented. But users still get a Python-shaped file, the CUDA build as the Linux default, and no stated contract or archive test.
- Package managers first (vcpkg, conda-forge, Homebrew). Their recipe authors build from source, which today needs PyTorch build inputs (see related work, item 2). The archive and its manifest help them as a reference.
- A stable C API first. It reduces C++ ABI (binary interface) constraints and helps bindings, but it is a large design. Same-release C++ archives serve most users now.
Related work, each needing its own design
- Running a
.ptefrom Python without PyTorch, for Python apps that pin their own torch, such as robot learning frameworks. #24820 now proposes dropping the PyTorch requirement fromexecutorchand loading the CUDA backend on demand, instead of a separate runtime package. - A source build without full PyTorch. Kernel registration needs
torchgenand PyTorch's operator list files, and the optimized kernels need PyTorch headers. Whentorchgenis missing, the lookup intools/cmake/Codegen.cmakefails silently and the build then scans the whole file system for*.pyfiles; and the source folder must be namedexecutorch(#6475). - Backends as plugins. Backends register themselves through a static initializer when their library loads (see
register_backendinbackends/xnnpack/runtime/XNNPACKBackend.cpp), so an app can load one at run time withdlopen. A supported version needs a public load call, a build check before registration, a reported result for failed registration, and thread-safety rules. Today the registry has 16 fixed slots, and a failed or duplicate registration is dropped silently. Out-of-tree backends, such as the TensorRT delegate in Torch-TensorRT, already depend on this.
Open questions
- Repack the wheel's libraries as they are (unversioned names like
libexecutorch.so, quickest), or build the archive with the versioned library names thattools/cmake/Utils.cmakealready defines for distribution packages (libexecutorch.so.1)? Out-of-tree delegates, such as the TensorRT delegate that Torch-TensorRT ships, link the unversioned names, so those names should stay, for example as symlinks. - Include the OpenVINO and QNN adapters that some CPU wheels ship? They need vendor runtimes from elsewhere.
- Archives for nightlies too, and how long to keep them?
- CUDA 13.4 archives too? The 1.6.0 release also has
cu134wheels. libaoti_cuda_shims.sois not a CMake target on Linux. Should it become one, so CUDA apps deploy it the same way as the other libraries?
- Vorherrschende Sprache
- Python
- Sterne
- 5.2k
- Forks
- 1.3k
- Ø Merge
- 1 T. 7 Std.
- Gemergte PRs (30 T.)
- 644
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus pytorch/executorch
-
to_edge_transform_and_lower ignores some ops_to_not_decompose requests: multi-output ops, and non-core ops without a decompositionEvtl. vergeben @Eureka-Zhang hat das vor 7 Tagen übernommen. Offenmodule: exir
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
pytorch/executorch#25620 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Qualcomm AI Engine Direct - fp16a8w quantization crashes on layer_normEvtl. vergeben @psiddh hat das vor 21 Tagen übernommen. Offenbug module: qnn partner: qualcomm
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
pytorch/executorch#24434 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement triaged
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 68/100
pytorch/executorch#21640 ·
Maintainer antworten meist innerhalb von 1 Tag
-
quantize_per_channel and dequantize_per_tensor.tensor abort the process on a float32 scaleEvtl. vergeben @AxelNoun hat das heute übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
pytorch/executorch#25873 ·
Maintainer antworten meist innerhalb von 1 Tag
-
XNNPACK INT4 linear returns incorrect per-channel outputs and fails groupwise FP16 on Apple M4 MaxEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offenbug module: quantization module: xnnpack
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 43/100
pytorch/executorch#25854 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in pytorch/executorch
Ähnliche Issues
-
Container fails to start when GitHub Releases is unavailable: uv run re-downloads the tvl wheelOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
trezor/trezor-user-env#421 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 91/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
tangentcode/tangentswarm#167 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag