-
Notifications
You must be signed in to change notification settings - Fork 135
Reduce peak memory usage #248
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
Draft
GMNGeoffrey
wants to merge
8
commits into
aqlaboratory:main
Choose a base branch
from
GMNGeoffrey:mem-reduction
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5867955
Use `torch.cdist` in `get_token_frame_atoms`
GMNGeoffrey c817813
Use inplace bool masks in `get_token_frame_atoms`
GMNGeoffrey 042e14d
Only move zij to GPU in slices for PAE/PDE computation
GMNGeoffrey f545f20
Defer PDE/PAE/distogram move-to-GPU until consumed
GMNGeoffrey 0e74aad
template_embedders: fold linear projections in-place
GMNGeoffrey dabfb38
Chunk diffusion_conditioning embedding
GMNGeoffrey 85c30fc
Guard inplace adds with inplace_safe
GMNGeoffrey 137fa73
Mark large model test as slow
GMNGeoffrey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
this should only run if inplace_safe=True, similar to other places in the code. we have a function
from openfold3.core.utils.tensor_utils import addthat passes the flag likea = add(a, self.pseudo_beta_mask_linear(pseudo_beta_pair_mask), inplace=inplace_safe). it's always true for inference, not trainingThere 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.
Ah sorry, I didn't look closely enough at how inplace_safe was being used. I think these particular inplace adds are safe and that test_of3_model.py would catch if they weren't. But it looks like the convention in the project is to guard all inplace operations within the model proper behind
inplace_safeto avoid having to reason about each individual usage site. Is that right? I don't think the usage is here is special enough to be worth breaking that if so. But there could be potential memory savings during training by relaxing this constraint (and I think it's something that would be caught by unit tests, so not super dangerous). That's dependent on what the particular layers hang on to for the backward pass, but at least with linear layers there should be a training-time memory savings.This would potentially affect the
masked_fill_I used as well. I think that one is safe by construction given that we're only using it to compute topk indices, which we can't differentiate through anyways (could actually wrap it intorch.no_grad(), I think).I'll go ahead and change this to plumb through the flag and use the utility