Skip to content

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.

Fix inference failing for transformers 5.x models (trust_remote_code) (#4652)

Daniel Hana7c43bc46d0f
diff --git a/studio/backend/core/inference/worker.py b/studio/backend/core/inference/worker.py
index 2eb46f32173..afe0ecc458b 100644
--- a/studio/backend/core/inference/worker.py
+++ b/studio/backend/core/inference/worker.py
@@ -156,12 +156,28 @@ def _handle_load(backend, config: dict, resp_queue: Any) -> None:
except Exception as e:
logger.warning("Could not read adapter_config.json: %s", e)
+ # Auto-enable trust_remote_code for unsloth/* transformers 5.x models
+ # (matches the training worker logic in core/training/worker.py)
+ trust_remote_code = config.get("trust_remote_code", False)
+ if not trust_remote_code:
+ from utils.transformers_version import needs_transformers_5
+
+ model_name = config["model_name"]
+ if needs_transformers_5(model_name) and model_name.lower().startswith(
+ "unsloth/"
+ ):
+ trust_remote_code = True
+ logger.info(
+ "Auto-enabled trust_remote_code for unsloth/* transformers 5.x model: %s",
+ model_name,
+ )
+
success = backend.load_model(
config = mc,
max_seq_length = config.get("max_seq_length", 2048),
load_in_4bit = load_in_4bit,
hf_token = hf_token,
- trust_remote_code = config.get("trust_remote_code", False),
+ trust_remote_code = trust_remote_code,
)
if success: