diff --git a/unsloth/models/mistral.py b/unsloth/models/mistral.py index bc00e7a982..4f69484dde 100644 --- a/unsloth/models/mistral.py +++ b/unsloth/models/mistral.py @@ -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) diff --git a/unsloth/save.py b/unsloth/save.py index 70242eaa7b..c516ed2365 100644 --- a/unsloth/save.py +++ b/unsloth/save.py @@ -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: