Skip to content

fix(executorch): register device copy kernels in the packaged runner - #4581

Merged
lanluo-nvidia merged 2 commits into
pytorch:mainfrom
shoumikhin:fix/packaged-runner-device-copy-kernels
Aug 26, 2026
Merged

fix(executorch): register device copy kernels in the packaged runner#4581
lanluo-nvidia merged 2 commits into
pytorch:mainfrom
shoumikhin:fix/packaged-runner-device-copy-kernels

Conversation

@shoumikhin

Copy link
Copy Markdown
Contributor

What is broken

The executorch-runtime-build jobs are red on main, 10 of them. The example runner builds fine and then fails at run time:

kernel 'et_copy::_h2d_copy.out' not found
load_method('forward') failed with error 0x14

Why

An exported program that is fully delegated to TensorRT still runs two operators outside the delegate: the host to device copy of its inputs and the device to host copy of its outputs. The device placement pass inserts them at export time.

The Bazel build of the example runner links the core ExecuTorch runtime only, and the core runtime carries no kernels, so those two operators have nothing to dispatch to and loading any exported program fails. The CMake build does not hit this because it links ExecuTorch's own kernel library.

Fix

Compile the two kernel implementations from the pinned ExecuTorch tree and register them from a small registration-only library that executables depend on directly.

Two deliberate choices:

  • only these two kernels are registered, not the whole portable kernel set, because a fully delegated program never calls the rest;
  • registration lives in its own library rather than in the backend library, because the kernel registry aborts when the same kernel is registered twice and the backend can be linked into both a shared library and an executable. It is also kept out of the CMake source list, since that build already links a kernel library and would hit exactly that double registration.

Verification

No GPU was available for an end to end run, so this was checked at the symbol level: both translation units compile against the pinned ExecuTorch headers, the registration object's undefined symbols match the kernel object's defined symbols, and the registered names are exactly et_copy::_h2d_copy.out and et_copy::_d2h_copy.out.

The end to end path is covered by the CI job that runs the example runner, which is the job that is currently failing.

@meta-cla meta-cla Bot added the cla signed label Aug 26, 2026
@github-actions github-actions Bot added the component: api [C++] Issues re: C++ API label Aug 26, 2026
@github-actions
github-actions Bot requested a review from narendasan August 26, 2026 01:23
An exported program that is fully delegated to TensorRT still runs two
operators outside the delegate: the host to device copy of its inputs and
the device to host copy of its outputs. The device placement pass inserts
them at export time.

The Bazel build of the example ExecuTorch runner links the core runtime
only, and the core runtime carries no kernels, so loading any exported
program fails:

  kernel 'et_copy::_h2d_copy.out' not found
  load_method('forward') failed with error 0x14

Compile the two kernel implementations from the pinned ExecuTorch tree and
register them from a small registration-only library that executables
depend on directly. Only these two are registered, not the whole portable
kernel set, since a fully delegated program never calls the rest.

Registration is kept out of the backend library because the kernel registry
aborts when the same kernel is registered twice, and the backend can be
linked into both a shared library and an executable. It is also kept out of
the CMake source list, since that build already links ExecuTorch's own
kernel library.

Tested by compiling both translation units against the pinned ExecuTorch
headers and checking that the registration object's undefined symbols match
the kernel object's defined symbols, and that the registered names are
exactly et_copy::_h2d_copy.out and et_copy::_d2h_copy.out. The end to end
run is covered by the existing CI job that runs the example runner.
@shoumikhin
shoumikhin force-pushed the fix/packaged-runner-device-copy-kernels branch from 596dd81 to 058c53d Compare August 26, 2026 01:38
@lanluo-nvidia lanluo-nvidia added this to the v2.14.0 milestone Aug 26, 2026
The repository lint job runs `black --check .` across the whole tree, so any
file that does not match the formatter fails CI for every open pull request,
not only the one that touched it. `tests/py/dynamo/conversion/test_cumsum_aten.py`
is currently not black-conformant on main, which turns the Python Linting check
red here.

Reformat that one file with black. This is a formatting-only change: two
statements that fit on a single line are un-wrapped. No test logic changes.

Verified by running `black --check .` on the full tree: all files pass.

@lanluo-nvidia lanluo-nvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@lanluo-nvidia
lanluo-nvidia merged commit 625639f into pytorch:main Aug 26, 2026
116 of 145 checks passed
lanluo-nvidia pushed a commit that referenced this pull request Aug 26, 2026
…4581)

Co-authored-by: shoumikhin <shoumikhin@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants