Compute size of buffer required to fit q_proj @ k_proj.T attention scores
This file contains 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
float_width=2 # float16 | |
cond_count=2 # uncond and cond for 1 sample | |
attn_heads=8 # SD1.5 isn't optimized for flash attn, so all layers have 8 heads, lol | |
vae_scale_factor=8 | |
px_height=px_width=768 | |
latent_height=px_height/vae_scale_factor | |
latent_width=px_width/vae_scale_factor | |
q_proj_tokens=k_proj_tokens=latent_height*latent_width | |
qk_bytes = cond_count*attn_heads*float_width*q_proj_tokens*k_proj_tokens | |
qk_mb = qk_bytes/1024**2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment