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

Fix: Bad autograd side effects from printing #51364

Closed

Conversation

jbschlosser
Copy link
Contributor

Fixes #49756

Background

Fix applied here is to remove the grad enabled check from collect_next_edges, unconditionally returning the actual collected edges. This pushes the responsibility for determining whether the function should be called without grad mode to its call-sites. With this update, collect_next_edges will no longer incorrectly return an empty list, which caused the problem described in the issue. Three call-sites depended on this behavior and have been updated.

Beyond bad printing side effects, this fix addresses the more general issue of accessing grad_fn with grad mode disabled after an in-place operation on a view. The included test verifies this without the use of print.

Test Plan

python test/test_autograd.py TestAutogradDeviceTypeCPU.test_inplace_view_then_no_grad_cpu

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Jan 29, 2021

💊 CI failures summary and remediations

As of commit c85aee0 (more details on the Dr. CI page):


  • 1/1 failures possibly* introduced in this PR
    • 1/1 non-CircleCI failure(s)

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

@codecov
Copy link

codecov bot commented Jan 30, 2021

Codecov Report

Merging #51364 (c85aee0) into master (cedfa4c) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master   #51364      +/-   ##
==========================================
- Coverage   80.84%   80.84%   -0.01%     
==========================================
  Files        1931     1931              
  Lines      210933   210932       -1     
==========================================
- Hits       170532   170529       -3     
- Misses      40401    40403       +2     

Copy link
Collaborator

@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.

Looks good to me!

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@jbschlosser has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@jbschlosser merged this pull request in 8f0968f.

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.

Printing should not have (bad) autograd side effects
3 participants