Skip to content

Conversation

@mikaylagawarecki
Copy link
Contributor

@mikaylagawarecki mikaylagawarecki commented Dec 16, 2025

Description

Migrate advanced_source/cpp_custom_ops.rst to libtorch stable ABI/API. Accompanying change to extension-cpp

Checklist

  • The issue that is being fixed is referred in the description (see above "Fixes #ISSUE_NUMBER")
  • Only one issue is addressed in this pull request
  • Labels from the issue that this PR is fixing are added to this pull request
  • No unnecessary issues are included into this pull request.

@pytorch-bot
Copy link

pytorch-bot bot commented Dec 16, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/tutorials/3701

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

❌ 1 New Failure

As of commit 803be71 with merge base 10eefc3 (image):

NEW FAILURE - The following job has failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

Use ``torch.library.register_autograd`` to add training support for an operator. Prefer
this over directly using Python ``torch.autograd.Function`` or C++ ``torch::autograd::Function``;
you must use those in a very specific way to avoid silent incorrectness (see
this over directly using Python ``torch.autograd.Function`` (see
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove reference to torch::autograd::Function since we don't support that in stable API/ABI

@mikaylagawarecki mikaylagawarecki marked this pull request as ready for review December 16, 2025 21:36
Defining the custom op and adding backend implementations
---------------------------------------------------------
First, let's write a C++ function that computes ``mymuladd``:
First, let's write a C++ function that computes ``mymuladd`` using the LibTorch Stable ABI:
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm same question here as on the other PR. Do we have enough in 2.10 to always recommend the libtorch stable APIs? If not, then we're going to want a section with libtorch stable apis and a section with the regular libtorch APIs.

Copy link
Contributor Author

@mikaylagawarecki mikaylagawarecki Dec 29, 2025

Choose a reason for hiding this comment

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

I updated extension-cpp to have both a libtorch stable and an unstable extension and refer the user to them at the top. The snippets in this PR are from the stable variant but I beefed up the section on "Reverting to the Non-Stable LibTorch API" and included 1 code snippet there, referring the user to the non stable extension in extension-cpp otherwise.

Does this sound good to you?

(btw the link check is failing because the extension-cpp pr needs to land first)

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