Skip to content

Switch to using max for attention slicing in all cases for the time being#2569

Merged
JPPhoto merged 1 commit into
mainfrom
JPPhoto-attn-max
Feb 7, 2023
Merged

Switch to using max for attention slicing in all cases for the time being#2569
JPPhoto merged 1 commit into
mainfrom
JPPhoto-attn-max

Conversation

@JPPhoto
Copy link
Copy Markdown
Collaborator

@JPPhoto JPPhoto commented Feb 7, 2023

Justification of this change is that it enables very large image generation while imposing a slight performance penalty over no attention slicing. The current choice of auto has the same performance characteristics of max, and doesn't give the benefit of large image generation.

Stats on a 12GB CUDA card:

no slicing:
1280x1280
OOM
1024x1024
OOM
768x768
>> 1 image(s) generated in 23.67s
512x512
>> 1 image(s) generated in 8.41s

auto:
1280x1280
OOM
1024x1024
>> 1 image(s) generated in 70.30s
768x768
>> 1 image(s) generated in 23.64s
512x512
>> 1 image(s) generated in 8.55s

max:
1280x1280
>> 1 image(s) generated in 147.21s
1024x1024
>> 1 image(s) generated in 65.62s
768x768
>> 1 image(s) generated in 23.19s
512x512
>> 1 image(s) generated in 9.06s

@JPPhoto JPPhoto requested review from keturn and lstein February 7, 2023 15:05
@JPPhoto JPPhoto enabled auto-merge (squash) February 7, 2023 15:05
@JPPhoto
Copy link
Copy Markdown
Collaborator Author

JPPhoto commented Feb 7, 2023

At a future point in time, we can switch to a dynamic approach that chooses either no slicing or max based on the GPU's available memory at runtime. This would have to be done per-generation as sizes vary.

All of this may be obsoleted by the inclusion of sub-quadratic attention in diffusers or our own implementation.

@JPPhoto JPPhoto requested a review from damian0815 February 7, 2023 17:31
Copy link
Copy Markdown
Contributor

@damian0815 damian0815 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@JPPhoto JPPhoto merged commit f0f3520 into main Feb 7, 2023
@JPPhoto JPPhoto deleted the JPPhoto-attn-max branch February 7, 2023 18:28
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

Successfully merging this pull request may close these issues.

2 participants