-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Martinobettucci memory efficient patch for xformers on ldm #431
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
Closed
Conversation
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
Run attention in a loop to allow for much higher resolutions (over 1920x1920 on a 3090)
Correction to comment
Better memory handling for model.decode_first_stage so it doesn't crash anymore after 100% rendering
Old version gave incorrect free memory results causing in crashes on edge cases.
Set model to half in txt2img and img2img for less memory usage.
Forgot to comment out debug info
Technically you could run at higher steps as long as the resolution is dividable by the steps but you're going to run into memory issues later on anyhow.
Improves performance and is no longer needed.
Significant performance boost at higher resolutions when running in auto_cast or half mode on 3090 went from 1.13it/s to 1.63it/s at 1024x1024 Will also allow for higher resolutions due to sigmoid fix and using half memory
Performance boost and fix sigmoid for higher resolutions
Only need to wrap the model now with PromptGuidanceModelWrapper, and call prepare_prompts. No need to change samplers anymore, for example see changes in txt2img.py
special format inside prompts:
[sentence1:sentence2:step] will swap sentence1 (or sentence) for sentence2 at step
[sentence:step] will add sentence at step
[:sentence:step] will remove sentence at step
[sentence] will add sentence at step 0 (only useful for negative prompts)
when a sentence starts with - it will be seen as a negative prompt
{scale:step} will switch to defined guidance scale at step, does not work if initial guidance scale was 1.0
Changed attention to code like used in diffusers
* Update attention.py Run attention in a loop to allow for much higher resolutions (over 1920x1920 on a 3090) * Update attention.py Correction to comment * Update attention.py * Fixed memory handling for model.decode_first_stage Better memory handling for model.decode_first_stage so it doesn't crash anymore after 100% rendering * Fixed free memory calculation Old version gave incorrect free memory results causing in crashes on edge cases. * Set model to half Set model to half in txt2img and img2img for less memory usage. * Commented out debug info Forgot to comment out debug info * Raise error when steps too high Technically you could run at higher steps as long as the resolution is dividable by the steps but you're going to run into memory issues later on anyhow. * Added max. res info to memory exception * Reverted in place tensor functions back to CompVis version Improves performance and is no longer needed. * Missed one function to revert * Update README.md * Performance boost and fix sigmoid for higher resolutions Significant performance boost at higher resolutions when running in auto_cast or half mode on 3090 went from 1.13it/s to 1.63it/s at 1024x1024 Will also allow for higher resolutions due to sigmoid fix and using half memory Co-authored-by: Doggettx <Doggettpm@protonmail.com> Co-authored-by: Doggettx <110817577+Doggettx@users.noreply.github.com>
Doggettx fork merge
prompt2prompt easier to implement, more options
Update attention.py
Signed-off-by: Martino Bettucci <martinobettucci@users.noreply.github.com>
Signed-off-by: Martino Bettucci <martinobettucci@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.