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.

fix for casual mask (#3011)

Lei Zhenyuanf3e41d0b1e3d
diff --git a/unsloth/models/llama.py b/unsloth/models/llama.py
index 8d985aa9d24..27b92282c30 100644
--- a/unsloth/models/llama.py
+++ b/unsloth/models/llama.py
@@ -342,9 +342,9 @@ def LlamaAttention_fast_forward_inference(
A = torch_matmul(A, Vnn, out = Qn)
else:
if SDPA_HAS_GQA:
- A = scaled_dot_product_attention(Qn, Knn, Vnn, attn_mask = attention_mask, is_causal = False, enable_gqa = True)
+ A = scaled_dot_product_attention(Qn, Knn, Vnn, attn_mask = attention_mask, is_causal = is_causal, enable_gqa = True)
else:
- A = scaled_dot_product_attention(Qn, Knn, Vnn, attn_mask = attention_mask, is_causal = False)
+ A = scaled_dot_product_attention(Qn, Knn, Vnn, attn_mask = attention_mask, is_causal = is_causal)
pass
A = A.transpose(1, 2)
A = A.reshape(bsz, 1, attention_size)