Skip to content

Update augmented_forward+backward implementation to attach residuals to all outputs #1834

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

IvanYashchuk
Copy link
Collaborator

@IvanYashchuk IvanYashchuk commented Mar 4, 2025

This PR fixes the residuals/saved_for_backward saving and retrieving so that that backward function generation works correctly in the case when the first output of a bound symbol is unused.

The current code assumes that the first output of all BoundSymbols will be a Proxy with a .name attribute. It's not always the case when DCE might replace unused outputs with None or some other objects are returned from Symbols.

The important changes are:

  • skipping symbols with no proxies in the output to attach additional metadata for propagation (using is_literal, the approach is similar to the attempt in Grad transform patch #1712)
  • instead of specialing on the assumption that the first output of bound symbols is always a proxy object we actually find the first output, if all outputs are non-proxies they should have been skipped due to changes from the previous bullet point

@IvanYashchuk IvanYashchuk changed the title Update vjp implementation to attach residuals to all outputs Update augmented_forward+backward implementation to attach residuals to all outputs Mar 5, 2025
@IvanYashchuk
Copy link
Collaborator Author

@t-vi, could you please review this PR?

@IvanYashchuk IvanYashchuk enabled auto-merge (squash) March 7, 2025 13:18
@IvanYashchuk
Copy link
Collaborator Author

@t-vi, could you please review this PR?

@jjsjann123 jjsjann123 mentioned this pull request Mar 12, 2025
@IvanYashchuk
Copy link
Collaborator Author

@t-vi, could you please review this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant