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
Coerce TRL's tuple-cached _*_available flags to bool (#5129)
Daniel Han7ef8cde3c22a
diff --git a/unsloth/__init__.py b/unsloth/__init__.pyindex 73a9ce8fef2..52114bb5446 100644--- a/unsloth/__init__.py+++ b/unsloth/__init__.py@@ -137,6 +137,7 @@ from .import_fixes import (fix_vllm_aimv2_issue,check_vllm_torch_sm100_compatibility,fix_vllm_guided_decoding_params,+ fix_trl_vllm_ascend,fix_vllm_pdl_blackwell,fix_triton_compiled_kernel_missing_attrs,patch_trunc_normal_precision_issue,@@ -159,6 +160,7 @@ fix_vllm_aimv2_issue()# Check vLLM + torch < 2.9.0 + SM100 compatibility BEFORE importing vLLMcheck_vllm_torch_sm100_compatibility()fix_vllm_guided_decoding_params()+fix_trl_vllm_ascend()fix_vllm_pdl_blackwell()fix_triton_compiled_kernel_missing_attrs()patch_trunc_normal_precision_issue()@@ -179,6 +181,7 @@ del fix_xformers_performance_issuedel fix_vllm_aimv2_issuedel check_vllm_torch_sm100_compatibilitydel fix_vllm_guided_decoding_params+del fix_trl_vllm_ascenddel fix_vllm_pdl_blackwelldel fix_triton_compiled_kernel_missing_attrsdel patch_trunc_normal_precision_issuediff --git a/unsloth/import_fixes.py b/unsloth/import_fixes.pyindex ca44a0ce7e2..6cebad79398 100644--- a/unsloth/import_fixes.py+++ b/unsloth/import_fixes.py@@ -489,6 +489,32 @@ def fix_vllm_guided_decoding_params():)+def fix_trl_vllm_ascend():+ # transformers >= 4.48's `_is_package_available(name)` returns a tuple+ # (bool, version_or_None). TRL caches that tuple in module-level+ # `_*_available` flags and the matching `is_*_available()` accessors+ # return the tuple directly. A non-empty tuple is always truthy, so+ # `if is_X_available():` fires even when X is absent, triggering an+ # unconditional `import X` that fails. The surfaced case is+ # `vllm_ascend` (blocks `from trl import GRPOConfig, GRPOTrainer`+ # outside Huawei Ascend hosts); `llm_blender`, `deepspeed`, `joblib`+ # share the same shape. Coerce every tuple-cached flag in+ # trl.import_utils to bool; the existing accessors that just return+ # the cached value then naturally yield a bool.+ if importlib.util.find_spec("trl") is None:+ return+ try:+ import trl.import_utils as tiu+ except Exception:+ return+ for attr in list(vars(tiu)):+ if not (attr.startswith("_") and attr.endswith("_available")):+ continue+ cached = getattr(tiu, attr)+ if isinstance(cached, tuple):+ setattr(tiu, attr, bool(cached and cached[0]))++def ignore_logger_messages():# Ignore Environment variable `HF_TOKEN` is settry: