Update flex_attention.py
This commit is contained in:
parent
93344920a5
commit
10d46493cb
1 changed files with 5 additions and 11 deletions
|
|
@ -42,14 +42,15 @@ if not HAS_FLEX_ATTENTION:
|
|||
|
||||
# Below fails on compiled_autograd, so disable it
|
||||
try:
|
||||
old_compiled_autograd = torch._dynamo.config.compiled_autograd
|
||||
torch._dynamo.config.compiled_autograd = False
|
||||
disable_compiled_autograd = torch._dynamo.compiled_autograd.disable
|
||||
except:
|
||||
old_compiled_autograd = False
|
||||
disable_compiled_autograd = lambda *args, **kwargs: *args, **kwargs
|
||||
pass
|
||||
|
||||
# Logit softcapping
|
||||
@torch.compile(fullgraph = True, dynamic = True, options = torch_compile_options)
|
||||
@disable_compiled_autograd(
|
||||
torch.compile(fullgraph = True, dynamic = True, options = torch_compile_options)
|
||||
)
|
||||
def slow_attention_softcapping(Q, K, V, causal_mask, self, bsz, q_len):
|
||||
n_heads = self.num_heads
|
||||
head_dim = self.head_dim
|
||||
|
|
@ -82,13 +83,6 @@ if not HAS_FLEX_ATTENTION:
|
|||
return A
|
||||
pass
|
||||
|
||||
# Return compiled_autograd back
|
||||
try:
|
||||
torch._dynamo.config.compiled_autograd = old_compiled_autograd
|
||||
except:
|
||||
pass
|
||||
pass
|
||||
|
||||
create_flex_attention_causal_mask = None
|
||||
create_flex_attention_sliding_window_mask = None
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue