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
Merge nightly into feature/transformers-v5-support
Roland Tannous81b4928e99e5
diff --cc setup.shindex 1fee994a561,07ea131125b..f1622ed7a77--- a/setup.sh+++ b/setup.sh@@@ -175,24 -179,9 +179,10 @@@ if [ "$IS_COLAB" = true ]; theelse# Local: create venv (always start fresh to preserve correct install order)rm -rf .venv+ rm -rf .venv_overlay # Clean up stale transformers version overlay"$BEST_PY" -m venv .venvsource .venv/bin/activate- run_quiet "pip upgrade" pip install --upgrade pip- echo " Installing unsloth-zoo + unsloth..."- run_quiet "pip install unsloth" pip install -r "$SCRIPT_DIR/studio/backend/requirements/base.txt"- echo " Installing additional unsloth dependencies..."- run_quiet "pip install extras" pip install --no-cache-dir -r "$SCRIPT_DIR/studio/backend/requirements/extras.txt"- run_quiet "pip install extras" pip install --no-deps --no-cache-dir -r "$SCRIPT_DIR/studio/backend/requirements/extras-no-deps.txt"- run_quiet "pip install torchao+transformers" pip install --force-reinstall --no-cache-dir -r "$SCRIPT_DIR/studio/backend/requirements/overrides.txt"- run_quiet "pip install triton_kernels" pip install --no-deps -r "$SCRIPT_DIR/studio/backend/requirements/triton-kernels.txt"- # Patch: override llama_cpp.py with fix from unsloth-zoo branch- LLAMA_CPP_DST="$(pip show unsloth-zoo | grep -i '^Location:' | awk '{print $2}')/unsloth_zoo/llama_cpp.py"- curl -sSL "https://raw.githubusercontent.com/unslothai/unsloth-zoo/refs/heads/main/unsloth_zoo/llama_cpp.py" \- -o "$LLAMA_CPP_DST"- echo " Installing studio dependencies..."- run_quiet "pip install studio" pip install -r "$SCRIPT_DIR/studio/backend/requirements/studio.txt"- echo "✅ Python dependencies installed"+ install_python_stack# ── 7. WSL: pre-install GGUF build dependencies ──# On WSL, sudo requires a password and can't be entered during GGUF exportdiff --cc studio/backend/routes/inference.pyindex 63fe246008f,512eb05526e..7e1cff7a7d9--- a/studio/backend/routes/inference.py+++ b/studio/backend/routes/inference.py@@@ -70,14 -82,10 +82,14 @@@ async def load_modelThe model_path should be a clean identifier from GET /models/list.Returns inference configuration parameters (temperature, top_p, top_k, min_p)from the model's YAML config, falling back to default.yaml for missing values.++ GGUF models are loaded via llama-server (llama.cpp) instead of Unsloth."""try:+ # Ensure correct transformers version for this model architecture+ from utils.transformers_version import ensure_transformers_version+ ensure_transformers_version(request.model_path)+- backend = get_inference_backend()-# Create config using clean factory method# is_lora is auto-detected from adapter_config.json on disk/HFconfig = ModelConfig.from_identifier(@@@ -90,54 -99,74 +103,114 @@@status_code=400,detail=f"Invalid model identifier: {request.model_path}")-++ # ── GGUF path: load via llama-server ──────────────────────+ if config.is_gguf:+ llama_backend = get_llama_cpp_backend()+ unsloth_backend = get_inference_backend()++ # Unload any active Unsloth model first to free VRAM+ if unsloth_backend.active_model_name:+ logger.info(f"Unloading Unsloth model '{unsloth_backend.active_model_name}' before loading GGUF")+ unsloth_backend.unload_model(unsloth_backend.active_model_name)++ # Route to HF mode or local mode based on config+ if config.gguf_hf_repo:+ # HF mode: llama-server downloads via -hf "repo:quant"+ success = llama_backend.load_model(+ hf_repo=config.gguf_hf_repo,+ hf_variant=config.gguf_variant,+ hf_token=request.hf_token,+ model_identifier=config.identifier,+ is_vision=config.is_vision,+ n_ctx=request.max_seq_length,+ )+ else:+ # Local mode: llama-server loads via -m <path>+ success = llama_backend.load_model(+ gguf_path=config.gguf_file,+ mmproj_path=config.gguf_mmproj_file,+ model_identifier=config.identifier,+ is_vision=config.is_vision,+ n_ctx=request.max_seq_length,+ )++ if not success:+ raise HTTPException(+ status_code=500,+ detail=f"Failed to load GGUF model: {config.display_name}"+ )++ logger.info(f"Loaded GGUF model via llama-server: {config.identifier}")++ inference_config = load_inference_config(config.identifier)++ return LoadResponse(+ status="loaded",+ model=config.identifier,+ display_name=config.display_name,+ is_vision=config.is_vision,+ is_lora=False,+ is_gguf=True,+ inference=inference_config,+ )++ # ── Standard path: load via Unsloth/transformers ──────────+ backend = get_inference_backend()++ # Unload any active GGUF model first+ llama_backend = get_llama_cpp_backend()+ if llama_backend.is_loaded:+ logger.info("Unloading GGUF model before loading Unsloth model")+ llama_backend.unload_model()++ # Auto-detect quantization for LoRA adapters from adapter_config.json+ # The training pipeline patches this file with "unsloth_training_method"+ # which is 'qlora' or 'lora'. Only LoRA (16-bit) needs load_in_4bit=False.+ load_in_4bit = request.load_in_4bit+ if config.is_lora and config.path:+ import json+ from pathlib import Path+ adapter_cfg_path = Path(config.path) / "adapter_config.json"+ if adapter_cfg_path.exists():+ try:+ with open(adapter_cfg_path) as f:+ adapter_cfg = json.load(f)+ training_method = adapter_cfg.get("unsloth_training_method")+ if training_method == "lora" and load_in_4bit:+ logger.info(+ f"adapter_config.json says unsloth_training_method='lora' — "+ f"setting load_in_4bit=False to match 16-bit training"+ )+ load_in_4bit = False+ elif training_method == "qlora" and not load_in_4bit:+ logger.info(+ f"adapter_config.json says unsloth_training_method='qlora' — "+ f"setting load_in_4bit=True to match QLoRA training"+ )+ load_in_4bit = True+ elif training_method:+ logger.info(f"Training method: {training_method}, load_in_4bit={load_in_4bit}")+ else:+ # No unsloth_training_method — fallback to base model name+ if config.base_model and "-bnb-4bit" not in config.base_model.lower() and load_in_4bit:+ logger.info(+ f"No unsloth_training_method in adapter_config.json. "+ f"Base model '{config.base_model}' has no -bnb-4bit suffix — "+ f"setting load_in_4bit=False"+ )+ load_in_4bit = False+ except Exception as e:+ logger.warning(f"Could not read adapter_config.json: {e}")-+++ # Load the modelsuccess = backend.load_model(config=config,max_seq_length=request.max_seq_length,- load_in_4bit=request.load_in_4bit,+ load_in_4bit=load_in_4bit,hf_token=request.hf_token,)-+if not success:raise HTTPException(status_code=500,