From 74ddef1402e79519ee0bbc8662095f4ebfa6fb49 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Thu, 26 Mar 2026 13:42:23 +0530 Subject: [PATCH] fix: skip flex_attention for models with non-zero attention_dropout (#4605) --- unsloth/models/_utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.py index 7540b62328..70d5420f84 100644 --- a/unsloth/models/_utils.py +++ b/unsloth/models/_utils.py @@ -234,6 +234,10 @@ def prefer_flex_attn_if_supported(model_class, config): model_class, "_supports_flex_attn", False ): return None + + attention_dropout = getattr(config, "attention_dropout", 0) or 0 + if attention_dropout > 0: + return None # GPT-OSS, Mllama and Gemma3N use eager/sdpa attention during # inference since flex attention returns incorrect results or errors out. # GPT-OSS: left padding issues cause incorrect outputs.