unsloth/unsloth
Datta Nimmaturi 256c6e4884
Refactor flex attn to prefer flash if possible (#4734)
Replaces prefer_flex_attn_if_supported (which only returned flex_attention or None) with determine_attention_implementation, a centralized hierarchy: FA2 > Flex > SDPA > Eager.

Changes:
- New determine_attention_implementation function in _utils.py with clear priority chain
- _set_attn_impl helper to stamp config consistently
- _FLEX_EXCLUDED_MODELS / _FLEX_EXCLUDED_PREFIXES for model-specific exclusions
- Gemma3N explicit eager override in vision.py (timm vision towers)
- Preserved sdpa fallback for unmapped/remote-code vision configs
- Config re-stamped to eager when supports_sdpa guard fires

Co-authored-by: Datta Nimmaturi <Datta0@users.noreply.github.com>
2026-04-01 00:30:21 -07:00
..
dataprep Guard optional vLLM imports when extension is broken (#4068) 2026-02-15 22:09:29 -08:00
kernels Revert "Initial changes: Refactor Attention" 2026-03-13 22:38:57 -07:00
models Refactor flex attn to prefer flash if possible (#4734) 2026-04-01 00:30:21 -07:00
optimizers feat: Implement Q-GaLore optimizer and custom embedding learning rate… (#4511) 2026-03-25 01:03:10 -07:00
registry Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks" 2025-12-01 07:24:58 -08:00
utils Add check to disable xformers on newer GPUs (#4342) 2026-03-16 22:42:38 -07:00
__init__.py Studio UI 2026-03-17 07:44:54 -07:00
_auto_install.py Add PyTorch 2.10 and xformers 0.0.34 support (#3985) 2026-02-05 05:56:26 -08:00
chat_templates.py Fix regressions from security PRs #4042, #4044, and #4045 (#4062) 2026-02-15 23:16:17 -08:00
device_type.py Conditionally enable 4bit on CDNA for bitsandbytes>=v0.49.2 (#4161) 2026-03-07 01:33:40 -08:00
import_fixes.py Also patch accelerate's is_wandb_available for trl callbacks path (#4148) 2026-03-03 08:28:55 -08:00
ollama_template_mappers.py Refactor Ollama template wiring and harden packing helpers (#3890) 2026-02-09 04:04:48 -08:00
save.py feat: support GGUF export for non-PEFT models + fix venv_t5 switching for local checkpoints (#4455) 2026-03-20 12:13:18 +04:00
tokenizer_utils.py feat(tokenizer): add get_tokenizer_info() diagnostic helper (#4436) 2026-03-25 04:29:01 -07:00
trainer.py feat: Implement Q-GaLore optimizer and custom embedding learning rate… (#4511) 2026-03-25 01:03:10 -07:00