Update flex_attention.py
This commit is contained in:
parent
6b5c599394
commit
1ba9f2ed87
1 changed files with 15 additions and 0 deletions
|
|
@ -40,6 +40,14 @@ pass
|
|||
|
||||
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
|
||||
except:
|
||||
old_compiled_autograd = False
|
||||
pass
|
||||
|
||||
# Logit softcapping
|
||||
@torch.compile(fullgraph = True, dynamic = True, options = torch_compile_options)
|
||||
def slow_attention_softcapping(Q, K, V, causal_mask, self, bsz, q_len):
|
||||
|
|
@ -74,6 +82,13 @@ 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