Skip to content
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

A better fix for #3 to support new flash-attn versions #38

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cm/unet.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def __init__(
from flash_attn.flash_attention import FlashAttention

assert batch_first
factory_kwargs = {"device": device, "dtype": dtype}
# factory_kwargs = {"device": device, "dtype": dtype}
super().__init__()
self.embed_dim = embed_dim
self.num_heads = num_heads
Expand All @@ -357,7 +357,7 @@ def __init__(
assert self.head_dim in [16, 32, 64], "Only support head_dim == 16, 32, or 64"

self.inner_attn = FlashAttention(
attention_dropout=attention_dropout, **factory_kwargs
attention_dropout=attention_dropout, # **factory_kwargs
)
self.rearrange = rearrange

Expand All @@ -366,7 +366,7 @@ def forward(self, qkv, attn_mask=None, key_padding_mask=None, need_weights=False
qkv, "b (three h d) s -> b s three h d", three=3, h=self.num_heads
)
qkv, _ = self.inner_attn(
qkv,
qkv.contiguous(),
key_padding_mask=key_padding_mask,
need_weights=need_weights,
causal=self.causal,
Expand Down