Skip to content

Docs: more C++ troubleshooting and a GPU input and output example for the pip package - #24649

Open
pytorchbot wants to merge 1 commit into
release/1.6from
cherry-pick-24633-by-pytorch_bot_bot_
Open

pytorchbot wants to merge 1 commit into
release/1.6from
cherry-pick-24633-by-pytorch_bot_bot_

Conversation

@pytorchbot

Copy link
Copy Markdown
Collaborator

Problem

Building a C++ app against the ExecuTorch pip package works well, but some common mistakes give
errors that "Using ExecuTorch with C++" does not explain:

  • Finding the package with os.path.dirname(executorch.__file__) fails with a TypeError. The
    executorch package has no __init__.py, so __file__ is None.
  • A model whose weights are in a separate .ptd file fails to load when only the .pte is passed.
    The CUDA backend reports ... is missing from named data.
  • A GPU model exported with alloc_graph_output=False fails on its first run when the program does
    not give it output buffers.

The C++ guide already shows the right way for the first two, and the Module guide and the CUDA backend
guide cover the third. But the C++ guide never names these errors, so someone who hits one cannot
tell which fix applies.

Change

In docs/source/using-executorch-cpp.md:

  • A new CUDA subsection says that a model can keep its inputs and outputs on the GPU. It links the
    CUDA backend guide for the export side, and shows the C++ side in a few lines: GPU tensors made
    with from_blob, and set_output before the first run.
  • "When something does not work" gets an entry for each error above, with its fix.

Testing

On Linux x86_64 with an NVIDIA A100, in fresh virtual environments with executorch==1.6.0 and
torch==2.15.0, installed from PyPI and from the CPU index:

  • The CPU walkthrough on this page (export, program, CMake, build and run) prints 11 22 33 44 with
    both installs. The
    os.path.dirname(executorch.__file__) form fails as described.
  • With the PyPI install, the CUDA export from this page, loaded with
    Module("model.pte", "aoti_cuda_blob.ptd"), prints 11 22 33 44.
  • A CUDA model with weights fails to load without its .ptd file with the message quoted above, and
    loads with it.
    Saving only program.buffer writes no .ptd and fails the same way.
  • The new snippet, pasted unchanged into a small program that allocates the GPU buffers and prints
    the result, runs a model exported with GPU inputs and outputs and alloc_graph_output=False, and
    prints 11 22 33 44.
  • A model exported with only the input copies skipped writes its output into a host buffer given
    with set_output.
  • A minimal Sphinx build of the page shows no new warnings, and both new links resolve.

… the pip package (#24633)

## Problem

Building a C++ app against the ExecuTorch pip package works well, but
some common mistakes give
errors that "Using ExecuTorch with C++" does not explain:

- Finding the package with `os.path.dirname(executorch.__file__)` fails
with a `TypeError`. The
  `executorch` package has no `__init__.py`, so `__file__` is `None`.
- A model whose weights are in a separate `.ptd` file fails to load when
only the `.pte` is passed.
  The CUDA backend reports `... is missing from named data`.
- A GPU model exported with `alloc_graph_output=False` fails on its
first run when the program does
  not give it output buffers.

The C++ guide already shows the right way for the first two, and the
Module guide and the CUDA backend
guide cover the third. But the C++ guide never names these errors, so
someone who hits one cannot
tell which fix applies.

## Change

In `docs/source/using-executorch-cpp.md`:

- A new CUDA subsection says that a model can keep its inputs and
outputs on the GPU. It links the
CUDA backend guide for the export side, and shows the C++ side in a few
lines: GPU tensors made
  with `from_blob`, and `set_output` before the first run.
- "When something does not work" gets an entry for each error above,
with its fix.

## Testing

On Linux x86_64 with an NVIDIA A100, in fresh virtual environments with
`executorch==1.6.0` and
`torch==2.15.0`, installed from PyPI and from the CPU index:

- The CPU walkthrough on this page (export, program, CMake, build and
run) prints `11 22 33 44` with
  both installs. The
  `os.path.dirname(executorch.__file__)` form fails as described.
- With the PyPI install, the CUDA export from this page, loaded with
  `Module("model.pte", "aoti_cuda_blob.ptd")`, prints `11 22 33 44`.
- A CUDA model with weights fails to load without its `.ptd` file with
the message quoted above, and
  loads with it.
  Saving only `program.buffer` writes no `.ptd` and fails the same way.
- The new snippet, pasted unchanged into a small program that allocates
the GPU buffers and prints
the result, runs a model exported with GPU inputs and outputs and
`alloc_graph_output=False`, and
  prints `11 22 33 44`.
- A model exported with only the input copies skipped writes its output
into a host buffer given
  with `set_output`.
- A minimal Sphinx build of the page shows no new warnings, and both new
links resolve.

(cherry picked from commit 0b8cfc2)
@pytorch-bot

pytorch-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

⏳ No Failures, 1 Pending

As of commit 58d8aef with merge base 4db778e (image):
💚 Looks good so far! There are no failures yet. 💚

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 Nov 5, 2026

This branch was previously deployed

1 inactive deployment
cadence — 58d8aeff Deployed Nov 5, 2026 by pytorchbot
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants