mistral swa

This commit is contained in:
Daniel Han-Chen 2024-02-05 18:48:40 +11:00
commit e9031ceabe
2 changed files with 5 additions and 5 deletions

View file

@ -132,7 +132,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", None)
sw = isinstance(causal_mask, xformers.attn_bias.BlockDiagonalCausalMask)
sw = kv_seq_len if (sw is None or sw == "null") else sw
window = (-1, -1) if (kv_seq_len <= sw) else (sw, sw)
A = flash_attn_func(Q, K, V, causal = True, window_size = window)

View file

@ -87,10 +87,10 @@ def _merge_lora(layer, name, max_vram):
# First check if memory has been exceeded
# If yes, move over to CPU to do computation.
nbytes = W.numel() * 4 # float32 4 bytes
if (torch.cuda.memory_allocated() + nbytes) >= max_vram:
W = W.to("cpu", non_blocking = True)
out_of_memory = True
pass
# if (torch.cuda.memory_allocated() + nbytes) >= max_vram:
# W = W.to("cpu", non_blocking = True)
# out_of_memory = True
# pass
W = W.to(torch.float32).t()
if A is not None: