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
Also patch accelerate's is_wandb_available for trl callbacks path (#4148)
Daniel Hana665c9b57d86
diff --git a/unsloth/import_fixes.py b/unsloth/import_fixes.pyindex 06322a9396d..ca44a0ce7e2 100644--- a/unsloth/import_fixes.py+++ b/unsloth/import_fixes.py@@ -1294,12 +1294,17 @@ def disable_broken_wandb():"""Disable wandb if it's installed but cannot actually import.wandb can fail to import when there's a protobuf version mismatch- (e.g., wandb < 0.19.11 with protobuf >= 6.0). This causes a cascading- import failure through trl -> transformers -> wandb that crashes- unsloth's import chain.+ (e.g., wandb < 0.19.11 with protobuf >= 6.0). This causes cascading+ import failures through trl -> transformers/accelerate -> wandb that+ crash unsloth's import chain.- This function tests if wandb can actually import and if not, patches- transformers' is_wandb_available() to return False.+ There are two separate is_wandb_available() functions used by trl:+ - transformers.integrations.integration_utils.is_wandb_available+ (used by most trl trainers)+ - accelerate.utils.imports.is_wandb_available+ (used by trl/trainer/callbacks.py)++ Both must be patched to fully prevent broken wandb imports."""if importlib.util.find_spec("wandb") is None:return # wandb not installed, nothing to do@@ -1307,18 +1312,36 @@ def disable_broken_wandb():try:import wandbexcept Exception:- # wandb is installed but broken - patch transformers to skip it+ # wandb is installed but broken - patch all checkers to skip itlogger.info("Unsloth: wandb is installed but broken (likely a protobuf version mismatch). ""Disabling wandb to prevent import errors. To fix, run: pip install --upgrade wandb")+ _wandb_false = lambda: False+ # Patch transformers' is_wandb_available (used by most trl trainers)try:import transformers.integrations.integration_utils as tf_integration- tf_integration.is_wandb_available = lambda: False+ tf_integration.is_wandb_available = _wandb_false+ except (ImportError, AttributeError):+ pass+ # Patch accelerate's is_wandb_available (used by trl/trainer/callbacks.py).+ # Must patch both the source module AND the re-export namespace since+ # `from accelerate.utils import is_wandb_available` reads from+ # accelerate.utils, not accelerate.utils.imports.+ try:+ import accelerate.utils.imports as acc_imports++ acc_imports.is_wandb_available = _wandb_false+ except (ImportError, AttributeError):+ pass+ try:+ import accelerate.utils as acc_utils++ acc_utils.is_wandb_available = _wandb_falseexcept (ImportError, AttributeError):pass- # Also set env var as fallback for any other code path+ # Set env var as additional fallbackos.environ["WANDB_DISABLED"] = "true"