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

Why is the default use_reentrant=True when no kwargs were set? #29638

Closed
simon-lund opened this issue Mar 13, 2024 · 2 comments
Closed

Why is the default use_reentrant=True when no kwargs were set? #29638

simon-lund opened this issue Mar 13, 2024 · 2 comments

Comments

@simon-lund
Copy link

if gradient_checkpointing_kwargs is None:
gradient_checkpointing_kwargs = {"use_reentrant": True}

Here use_reentrant=True is set when no kwargs are provided. From the docs of pytorch this seems to be the legacy variant.

Does this have any performance or other advantages that I am not aware of?

@amyeroberts
Copy link
Collaborator

Hi @simon-lund, thanks for opening an issue!

You can check the git blame to find the PRs which add certain lines - which should normally give you the reasons for the code logic.

In this case, this line was added in #28538 - according to the PR it's for preparation of an upcoming torch release, where it's necessary for us to explicitly pass the use_reentrant kwarg.

The value is set to true based on the current default PT behaviour c.f. this comment

@simon-lund
Copy link
Author

Ah. I'm sorry, I only searched the issues and found several discussion about this, but I didn't search through the PRs
Thank you very much for the link as well as the hint with the PRs (I was not aware of that) 👍

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

No branches or pull requests

2 participants