Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Update llama.py

Daniel Han1a0f18e5984d
diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py
index 579376cdd04..4d8ec1367ea 100644
--- a/unsloth/models/llama.py
+++ b/unsloth/models/llama.py
@@ -449,12 +449,12 @@ def LlamaAttention_fast_forward(
else:
# Grouped query attention
if SDPA_HAS_GQA:
- print(attention_mask)
# Needs (batch_size, n_heads, seq_len, head_dim)
# is_casual and attention_mask must not be both set!
+ Q, K, V = Q.contiguous(), K.contiguous(), V.contiguous()
A = scaled_dot_product_attention(Q, K, V, attn_mask = attention_mask, is_causal = False, enable_gqa = n_groups != 1)
# Go back to (batch_size, seq_len, n_heads, head_dim)
- A = A.transpose(1, 2)#.contiguous()
+ A = A.transpose(1, 2).contiguous()
else:
if n_groups != 1:
K = K[:, :, None, :, :].expand(bsz, n_kv_heads, n_groups, kv_seq_len, head_dim)