-
Notifications
You must be signed in to change notification settings - Fork 88
Gradient checkpointing fix #1043
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
base: main
Are you sure you want to change the base?
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
| from torch_xla.utils.checkpoint import checkpoint | ||
|
|
||
| fn_with_kwargs = partial(fn, **kwargs) | ||
| return checkpoint(fn_with_kwargs, *args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be the other way around:
| return checkpoint(fn_with_kwargs, *args) | |
| return checkpoint(*args, fn_with_kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the first argument must be the function we checkpoint, check here.
tengomucho
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need this function? Can you provide a test that shows its usage and tests that it works?
It is just a wrapper around the original checkpoint function. The goal is to make it possible to pass keyword arguments to the function we are wrapping with I can add a test, but you mentioned many times that the CI was too long. For such a small change I was not considering it, please confirm you want a test. |
| if self.gradient_checkpointing and self.training: | ||
| hidden_states = checkpoint( | ||
| decoder_layer.__call__, | ||
| hidden_states = checkpoint_with_kwargs( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you change this here, only for granite, but not for the other models. I think you should change it everywhere, or nowhere, or explain why you only changed it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont undertsand? We change it "everywhere".
What does this PR do?
XLA-friendly gradient checkpointing function that accept keyword arguments.