Repository navigation
[PyBindings] Remove ATen dependency from portable bindings - #23089
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/23089
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 Cancelled JobAs of commit b46ff5e with merge base f83da98 ( CANCELLED JOB - The following job was cancelled. Please retry:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
ef50af1 to
2700b02
Compare
05d3daa to
040f3b5
Compare
040f3b5 to
3f0257f
Compare
2700b02 to
cbfeb13
Compare
3f0257f to
2d97243
Compare
2d97243 to
61b2ceb
Compare
cbfeb13 to
851b305
Compare
61b2ceb to
cad11be
Compare
This comment has been minimized.
This comment has been minimized.
851b305 to
b9c0b0e
Compare
cad11be to
84fe370
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Resolve overlap with the landed Python buffer support and preserve input ownership. Validate portable Torch tensor strides against exported dimension order, including channels last and equivalent singleton layouts, while preserving native ATen stride behavior. Authored with OpenAI Codex.
This PR needs a
|
Restore CPU and CUDA Torch tensor interchange through Python metadata and a private DLPack output bridge without a C++ ATen dependency. Validate serialized input devices and retain native backing storage through output conversion and cloning. Remove borrowed-output Python ownership cycles, preserve empty output strides and devices, and honor NumPy array copy semantics. Add coverage for these fixes and CUDA identity interchange. Authored with OpenAI Codex.
…ests Reuse original backing storage for borrowed Torch and buffer results so recurrent input aliases do not retain prior result wrappers. Release source exports after copying read-only buffers and inspect NumPy types only when NumPy is already imported. Isolate standalone import and linkage checks in fresh processes and respect the configured tensor output type. Add coverage for repeated output reuse, offsets, layouts, gradients, read-only copies, and Python buffers without Torch or NumPy. Authored with OpenAI Codex.
Keep inline C++ helpers local to the portable GNU/Linux bindings so LTO retains definitions required by the manylinux libstdc++ compatibility archive. Preserve automatic LTO, release optimization and stripping without restoring the ATen dependency. Authored with OpenAI Codex.
Skip the internal module-locality check when core bindings are unavailable, preserve runtime error codes when loading methods for Torch input validation, and use the public loader in ownership subprocess tests so Windows DLL search paths are configured. Add a regression test for method-load error codes with Torch and NumPy inputs. Authored with OpenAI Codex.
Serialize calls on each method and module while releasing the GIL during lock acquisition. Keep Torch as the default when it imports successfully, fall back to ExecuTorchResult when the output environment variable is unset and Torch is unavailable, and preserve failures for an explicit Torch request. Cover shared-object concurrency and wrapper/native import policies. Authored with OpenAI Codex.
Exercise automatic ExecuTorch outputs without Torch and explicit Torch import failures, and update the standalone CI test reference. Authored with OpenAI Codex.
Stack
Builds on the Python buffer support from #23088, relanded in #23535.
Summary
Remove the portable bindings' C++ ATen and PyTorch dependency. Inspect CPU and CUDA Torch inputs through their Python API, and accept NumPy arrays and other dense CPU buffers while checking strides against the exported ExecuTorch dimension order.
Torch remains the default input/output experience when it is installed. Set
EXECUTORCH_PYBINDINGS_TENSOR_OUTPUT=executorchbefore importing the bindings to avoid importing Torch and receive CPUExecuTorchResultbuffers. When the variable is unset and Torch cannot be imported, both the Python wrapper and native extension fall back toExecuTorchResult. An explicittorchsetting still requires Torch to import successfully. The output policy remains fixed after import.Serialize calls on each shared method and module, releasing the GIL while waiting for the object lock. Preserve borrowed result ownership and the existing Python Torch CUDA path without a C++ ATen dependency.
Validation
Portable compilation and linking with LTO passed. Regression checks cover shared methods and modules across eight threads, both output modes, wrapper/native import policies, late Torch import, and method-load runtime error codes. The stacked implementation also executes successfully in a Torch-free interpreter with the environment variable unset. Formatting and diff checks passed. Updated CI will validate the published head.
Authored with OpenAI Codex.