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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
fix(_utils): coerce _is_package_available tuple to bool for flash_attn/vllm checks (#6168)
Tai An73eed19ce4b3
diff --git a/unsloth/models/_utils.py b/unsloth/models/_utils.pyindex 1a86ff8eb66..a2ab3149f1f 100644--- a/unsloth/models/_utils.py+++ b/unsloth/models/_utils.py@@ -1264,6 +1264,18 @@ if is_openai_available():from transformers import AutoTokenizerfrom transformers.utils.import_utils import _is_package_available++def _package_available(pkg_name: str) -> bool:+ # transformers >= 5.x makes `_is_package_available` always return a+ # `(exists, version)` tuple, which is truthy even when the package is+ # absent; older versions returned a plain bool. Normalise to a bool so+ # callers don't take "package present" branches for missing packages.+ result = _is_package_available(pkg_name)+ if isinstance(result, tuple):+ return bool(result[0])+ return bool(result)++SUPPORTS_BFLOAT16 = FalseHAS_FLASH_ATTENTION = FalseHAS_FLASH_ATTENTION_SOFTCAPPING = False@@ -1274,7 +1286,7 @@ if DEVICE_TYPE == "cuda":if major_version >= 8:SUPPORTS_BFLOAT16 = True- if _is_package_available("flash_attn"):+ if _package_available("flash_attn"):# Check for CUDA linking errors "undefined symbol: _ZNK3c106SymIntltEl"try:try:@@ -1319,7 +1331,7 @@ if DEVICE_TYPE == "cuda":HAS_FLASH_ATTENTION = Falseelif DEVICE_TYPE == "hip":SUPPORTS_BFLOAT16 = True- if _is_package_available("flash_attn"):+ if _package_available("flash_attn"):# Check for CUDA linking errors "undefined symbol: _ZNK3c106SymIntltEl"try:try:@@ -1981,7 +1993,7 @@ def is_bfloat16_supported():def is_vLLM_available():- return _is_package_available("vllm")+ return _package_available("vllm")# Patches models to add RoPE Scaling