sub-quadratic attention by Birch-san · Pull Request #1 · Birch-san/diffusers (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation6 Commits35 Checks0 Files changed
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
[ Show hidden characters]({{ revealButtonHref }})
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint.
…hannels_per_head] in order to make use of batched matmuls. fuse multiply into matmul. breaks bias, mask in exchange for massive speedup.
…ghts_calc_fn, calc_fn_data) and unused vars
…ul for SD 2.1. but remove value float32, having established that it works without.
…to prefer fast-path whenever unchunked attention would fit into memory. add kv_chunk_size_min to control the kv_chunk_size=None behaviour, so that sqrt(key_tokens) does not pick too small of a chunk size
…of chunk key size. improve separation of concerns.
…al kv_chunk_size: they can notice when no chunking would happen at all, and use fast-path. note: there's a question of whether that concern belongs inside the algorithm. but it'd feel weird for chunked attention to have a no-chunking-at-all branch.
… equivalent fast-path for 1 query chunk, 1 kv chunk is already supported inside
…ything in one chunk, to re-use an existing fast-path.
starts: List[int], |
---|
sizes: List[int], |
) -> Tensor: |
slicing = [slice(start, start + size) for start, size in zip(starts, sizes)] |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scale: float, |
---|
) -> AttnChunk: |
attn_weights = torch.baddbmm( |
torch.empty(1, 1, 1, device=query.device, dtype=query.dtype), |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't torch.zeros()
be used here instead of torch.empty()
?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope; it's actually an unused tensor (because beta=0
), so we want whatever's the cheapest thing that passes the parameter validation. unfortunately PyTorch complains if you pass None
. bad API design.
Beinsezii added a commit to Beinsezii/diffusers that referenced this pull request
Beinsezii added a commit to Beinsezii/diffusers that referenced this pull request