Skip to content

Commit 545789b

Browse files
committed
Disable custom SDPA for Gemma 4 MLX export
1 parent 533b14f commit 545789b

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

backends/mlx/examples/llm/export_llm_hf.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,20 @@ def _export_with_custom_components(
215215
}
216216
torch_dtype = torch_dtype_map.get(dtype, torch.bfloat16)
217217

218-
if use_custom_sdpa:
218+
effective_use_custom_sdpa = use_custom_sdpa
219+
if model_id == _GEMMA4_MODEL_ID and use_custom_sdpa:
220+
logger.info(
221+
"Disabling custom SDPA for Gemma 4 while keeping the custom cache path"
222+
)
223+
effective_use_custom_sdpa = False
224+
225+
if effective_use_custom_sdpa:
219226
from executorch.backends.mlx.llm.hf_attention import register_mlx_attention
220227

221228
register_mlx_attention()
222229
logger.info("Registered MLX custom SDPA attention")
223230

224-
attn_implementation = "mlx" if use_custom_sdpa else None
231+
attn_implementation = "mlx" if effective_use_custom_sdpa else None
225232

226233
logger.info(f"Loading HuggingFace model: {model_id}")
227234
load_kwargs = {

0 commit comments

Comments
 (0)