Skip to content

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

Merged
svekars merged 6 commits into
pytorch:mainfrom
harshaljanjani:update-autograd-doc-comment
Jun 4, 2025
Merged

docs: Fix incorrect usage description of ctx.save_for_backward#3377
svekars merged 6 commits into
pytorch:mainfrom
harshaljanjani:update-autograd-doc-comment

Conversation

@harshaljanjani

@harshaljanjani harshaljanjani commented Jun 3, 2025

Copy link
Copy Markdown
Contributor

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

@pytorch-bot

pytorch-bot Bot commented Jun 3, 2025

Copy link
Copy Markdown

🔗 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
Copy Markdown
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 cla@meta.com. 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

@jbschlosser or @albanD Does this look good?

cc: @svekars

Comment thread beginner_source/examples_autograd/polynomial_custom_function.py Outdated

@svekars svekars left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Comment thread beginner_source/examples_autograd/polynomial_custom_function.py Outdated
Co-authored-by: Svetlana Karslioglu <svekars@meta.com>

@albanD albanD left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@harshaljanjani

Copy link
Copy Markdown
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
Comment thread beginner_source/examples_autograd/polynomial_custom_function.py Outdated
@svekars svekars merged commit 0f312df into pytorch:main Jun 4, 2025
18 checks passed
@harshaljanjani harshaljanjani deleted the update-autograd-doc-comment branch August 27, 2025 07:16
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