Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new Python and C++/CUDA Custom Op tutorials #2888

Merged
merged 7 commits into from
Jun 18, 2024
Merged

Add new Python and C++/CUDA Custom Op tutorials #2888

merged 7 commits into from
Jun 18, 2024

Conversation

zou3519
Copy link
Contributor

@zou3519 zou3519 commented May 29, 2024

I want to land this before PyTorch 2.4 (so we can link to these in PyTorch's nightly documentation) and then have a follow-up PR for 2.4 that actually runs the scripts (so that they can generate outputs).

pytorch/pytorch#127443 to remind myself of the above.

NB: These two tutorials replace all of the existing custom ops (and cpp extensions) tutorials:

  • advanced/cpp_extension
  • advanced/torch_script_custom_ops
  • advanced/torch_script_custom_classes
  • advanced/dispatcher

In a follow-up PR we will add warnings to all of those tutorials stating that they are deprecated but we will preserve the text just in case people still need them (e.g. if they are not using PyTorch 2.4).

Test Plan:

  • I tested these locally.

Fixes #ISSUE_NUMBER

Description

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.

Copy link

pytorch-bot bot commented May 29, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit af4fbe5 with merge base 63f987d (image):
💚 Looks good so far! There are no failures yet. 💚

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

@zou3519
Copy link
Contributor Author

zou3519 commented May 29, 2024

@svekars is there a way to bypass the pyspelling check?

index.rst Outdated Show resolved Hide resolved
advanced_source/python_custom_ops.py Outdated Show resolved Hide resolved
advanced_source/python_custom_ops.py Outdated Show resolved Hide resolved
advanced_source/python_custom_ops.py Outdated Show resolved Hide resolved
advanced_source/python_custom_ops.py Outdated Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Outdated Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Outdated Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Show resolved Hide resolved
This does not test that the gradients are mathematically correct; please write
separate tests for that (either manual ones or torch.autograd.gradcheck).

.. code-block:: python
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting that this is not the same as the one from the python tutorial

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wrote them at different times. I can make them the same if we want.

advanced_source/cpp_custom_ops.rst Outdated Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Outdated Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Outdated Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Outdated Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Outdated Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Outdated Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Outdated Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Outdated Show resolved Hide resolved
advanced_source/python_custom_ops.py Outdated Show resolved Hide resolved
advanced_source/python_custom_ops.py Outdated Show resolved Hide resolved
advanced_source/python_custom_ops.py Outdated Show resolved Hide resolved
advanced_source/python_custom_ops.py Outdated Show resolved Hide resolved
advanced_source/python_custom_ops.py Outdated Show resolved Hide resolved
advanced_source/python_custom_ops.py Outdated Show resolved Hide resolved
advanced_source/python_custom_ops.py Outdated Show resolved Hide resolved
advanced_source/python_custom_ops.py Show resolved Hide resolved
advanced_source/python_custom_ops.py Outdated Show resolved Hide resolved
advanced_source/python_custom_ops.py Show resolved Hide resolved
@svekars
Copy link
Contributor

svekars commented Jun 5, 2024

@svekars is there a way to bypass the pyspelling check?

@zou3519 Please fix what's fixable. Words like PIL's you can add to en-wordlist.txt. Things like FakeTensor should be put in backticks (FakeTensor) as a class (intersphinx should work too) or you could write fake tensor or Fake Tensor.

@zou3519
Copy link
Contributor Author

zou3519 commented Jun 10, 2024

@svekars, @albanD -- thank you for the detailed reviews and suggestions! This should be ready for another pass through now.

@zou3519 zou3519 requested review from svekars and albanD June 10, 2024 15:21
@svekars svekars added the 2.4 label Jun 12, 2024
Copy link
Contributor

@svekars svekars left a comment

Choose a reason for hiding this comment

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

Looks good overall, asking to add what you will learn and prerequisites.

advanced_source/cpp_custom_ops.rst Outdated Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Show resolved Hide resolved
advanced_source/python_custom_ops.py Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Outdated Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Outdated Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Outdated Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Outdated Show resolved Hide resolved
advanced_source/cpp_custom_ops.rst Outdated Show resolved Hide resolved
advanced_source/custom_ops_landing_page.rst Outdated Show resolved Hide resolved
advanced_source/custom_ops_landing_page.rst Outdated Show resolved Hide resolved
Copy link
Contributor

@albanD albanD left a comment

Choose a reason for hiding this comment

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

SGTM

advanced_source/cpp_custom_ops.rst Show resolved Hide resolved
index.rst Show resolved Hide resolved
zou3519 added 7 commits June 17, 2024 23:02
I want to land this before PyTorch 2.4 (so we can link to these in
PyTorch's nightly documentation) and then have a follow-up PR for 2.4
that actually runs the scripts (so that they can generate outputs).

pytorch/pytorch#127443 to remind myself of the
above.

NB: These two tutorials replace all of the existing custom ops (and cpp
extensions) tutorials:
- advanced/cpp_extension
- advanced/torch_script_custom_ops
- advanced/torch_script_custom_classes
- advanced/dispatcher

In a follow-up PR we will add warnings to all of those tutorials stating
that they are deprecated but we will preserve the text just in case
people still need them (e.g. if they are not using PyTorch 2.4).

Test Plan:
- I tested these locally.
@zou3519 zou3519 merged commit 91540a8 into main Jun 18, 2024
20 checks passed
@svekars svekars deleted the custom_ops branch June 18, 2024 15:12
ignaciobartol pushed a commit to ignaciobartol/tutorials that referenced this pull request Jun 24, 2024
* Add new Python and C++/CUDA Custom Op tutorials

I want to land this before PyTorch 2.4 (so we can link to these in
PyTorch's nightly documentation) and then have a follow-up PR for 2.4
that actually runs the scripts (so that they can generate outputs).

pytorch/pytorch#127443 to remind myself of the
above.

NB: These two tutorials replace all of the existing custom ops (and cpp
extensions) tutorials:
- advanced/cpp_extension
- advanced/torch_script_custom_ops
- advanced/torch_script_custom_classes
- advanced/dispatcher

In a follow-up PR we will add warnings to all of those tutorials stating
that they are deprecated but we will preserve the text just in case
people still need them (e.g. if they are not using PyTorch 2.4).

Test Plan:
- I tested these locally.

* Fix cpp custom ops tutorial per review

* update

* update index.rst

* Update

* update

* update
ignaciobartol pushed a commit to ignaciobartol/tutorials that referenced this pull request Jun 24, 2024
* Add new Python and C++/CUDA Custom Op tutorials

I want to land this before PyTorch 2.4 (so we can link to these in
PyTorch's nightly documentation) and then have a follow-up PR for 2.4
that actually runs the scripts (so that they can generate outputs).

pytorch/pytorch#127443 to remind myself of the
above.

NB: These two tutorials replace all of the existing custom ops (and cpp
extensions) tutorials:
- advanced/cpp_extension
- advanced/torch_script_custom_ops
- advanced/torch_script_custom_classes
- advanced/dispatcher

In a follow-up PR we will add warnings to all of those tutorials stating
that they are deprecated but we will preserve the text just in case
people still need them (e.g. if they are not using PyTorch 2.4).

Test Plan:
- I tested these locally.

* Fix cpp custom ops tutorial per review

* update

* update index.rst

* Update

* update

* update
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.

4 participants