This commit is contained in:
Daniel Han-Chen 2024-01-19 23:15:38 +11:00
commit 1a19c38675
2 changed files with 3 additions and 3 deletions

View file

@ -460,7 +460,7 @@ def LlamaModel_fast_forward(
(batch_size, seq_length),
inputs_embeds,
past_key_values_length,
sliding_window = getattr(self.config, "sliding_window"),
sliding_window = getattr(self.config, "sliding_window", None),
)
pass

View file

@ -131,7 +131,7 @@ def MistralAttention_fast_forward(
Q = Q.transpose(1, 2)
K = K.transpose(1, 2)
V = V.transpose(1, 2)
sw = getattr(self.config, "sliding_window")
sw = getattr(self.config, "sliding_window", None)
sw = q_len if sw is None else sw
window = (-1, -1) if (q_len <= sw) else (sw, sw)
A = flash_attn_func(Q, K, V, causal = True, window_size = window)
@ -175,7 +175,7 @@ def MistralForCausalLM_fast_forward(
if causal_mask is None:
bsz, q_len = input_ids.shape
sliding_window = getattr(self.config, "sliding_window")
sliding_window = getattr(self.config, "sliding_window", None)
if sliding_window is None or sliding_window <= 0:
causal_mask = xformers.attn_bias.LowerTriangularMask()
elif q_len <= sliding_window: