File tree Expand file tree Collapse file tree
backends/mlx/examples/llm Expand file tree Collapse file tree Original file line number Diff line number Diff 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 = {
You can’t perform that action at this time.
0 commit comments