Update llama.py
This commit is contained in:
parent
ed56a1daaa
commit
e635bc4ea2
1 changed files with 3 additions and 4 deletions
|
|
@ -390,7 +390,7 @@ def LlamaAttention_fast_forward(
|
|||
past_key_value = (K, V) if use_cache else None
|
||||
|
||||
# Attention module
|
||||
if (not HAS_FLASH_ATTENTION and attention_mask is None):
|
||||
if False:#(not HAS_FLASH_ATTENTION and attention_mask is None):
|
||||
# Xformers memory efficient attention
|
||||
# Also has Flash Attention v2 dispatching
|
||||
Q = Q.transpose(1, 2)
|
||||
|
|
@ -427,10 +427,10 @@ def LlamaAttention_fast_forward(
|
|||
pass
|
||||
# Must be contiguous or else results are False!
|
||||
# https://github.com/pytorch/pytorch/issues/112577
|
||||
Q, K, V = Q.contiguous(), K.contiguous(), V.contiguous()
|
||||
# Q, K, V = Q.contiguous(), K.contiguous(), V.contiguous()
|
||||
# Needs (batch_size, n_heads, seq_len, head_dim)
|
||||
# is_casual and attention_mask must not be both set!
|
||||
A = scaled_dot_product_attention(Q, K, V, attn_mask = attention_mask, is_causal = False)
|
||||
A = scaled_dot_product_attention(Q, K, V, is_causal = True)
|
||||
# Go back to (batch_size, seq_len, n_heads, head_dim)
|
||||
A = A.transpose(1, 2).contiguous()
|
||||
pass
|
||||
|
|
@ -1028,7 +1028,6 @@ def CausalLM_fast_forward(fast_forward_inference):
|
|||
pass
|
||||
|
||||
|
||||
@torch._disable_dynamo
|
||||
def PeftModelForCausalLM_fast_forward(
|
||||
self,
|
||||
input_ids=None,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue