Skip to content

docs: Fix incorrect usage description of ctx.save_for_backward #3377

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

Merged
merged 6 commits into from
Jun 4, 2025

Conversation

harshaljanjani
Copy link
Contributor

@harshaljanjani harshaljanjani commented Jun 3, 2025

Fixes #2797

Description

  • This PR corrects the misleading explanation of ctx.save_for_backward in the two_layer_net_custom_function.py tutorial. The original text incorrectly stated that arbitrary objects can be cached using ctx.save_for_backward, whereas only tensors are supported.
  • The updated docstring now accurately reflects PyTorch’s autograd API.

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.

cc @albanD @jbschlosser

Copy link

pytorch-bot bot commented Jun 3, 2025

🔗 Helpful Links

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

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

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

@facebook-github-bot
Copy link
Contributor

Hi @harshaljanjani!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@github-actions github-actions bot added core Tutorials of any level of difficulty related to the core pytorch functionality docathon-h1-2025 A label for the docathon in H1 2025 medium labels Jun 3, 2025
@harshaljanjani
Copy link
Contributor Author

I’ve signed the Facebook CLA. I believe re-running the tests should reflect that. Thank you very much!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@sekyondaMeta
Copy link
Contributor

@jbschlosser or @albanD Does this look good?

cc: @svekars

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.

LGTM

Co-authored-by: Svetlana Karslioglu <[email protected]>
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.

@harshaljanjani
Copy link
Contributor Author

@albanD @svekars @sekyondaMeta
The changes should be done. If there are any remaining nits, I'll be quick to address them!
Additionally, I've left comments on other issues tagged with docathon-2025. I believe a few are outdated/not reproducible anymore, and for others, I've requested clarification.
Please review them when time permits, thanks!

@sekyondaMeta sekyondaMeta removed the request for review from jbschlosser June 4, 2025 17:14
@svekars svekars merged commit 0f312df into pytorch:main Jun 4, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed core Tutorials of any level of difficulty related to the core pytorch functionality docathon-h1-2025 A label for the docathon in H1 2025 medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Contradiction in save_for_backward, what is permitted to be saved
5 participants