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
Studio fine-tuning queue: run the batch model probe behind the account's path guard (#15727)
Daniel Han70ff76c5bf13
diff --git a/studio/backend/routes/openai_fine_tuning.py b/studio/backend/routes/openai_fine_tuning.pyindex 511b3838ae4..b8df3a862ba 100644--- a/studio/backend/routes/openai_fine_tuning.py+++ b/studio/backend/routes/openai_fine_tuning.py@@ -672,6 +672,13 @@ async def _trains_alone(request: TrainingStartRequest) -> bool:from utils.models.model_config import _read_raw_config_json, get_base_model_from_lora_identifierdef probe() -> bool:+ from core.training.account_jobs import account_path++ # Path guard first: a managed account's share path must not be touched (SMB sign-in); start_training refuses it.+ try:+ account_path(request.model_name, reference = True)+ except HTTPException:+ return Trueif diffusion_lm_profile_for_model(request.model_name, request.hf_token):return Trueif get_base_model_from_lora_identifier(request.model_name, request.hf_token) is not None:@@ -729,7 +736,7 @@ async def _start_queued(entry: _Queued) -> bool:if _training_busy():return Falsegroup = _batch_for(entry)- if len(group) > 1 and await _trains_alone(entry.request):+ if len(group) > 1 and await arun_as(entry.account, _trains_alone(entry.request)):group = [entry]if len(group) > 1:outcome = await _start_batch(group)diff --git a/studio/backend/tests/test_openai_fine_tuning.py b/studio/backend/tests/test_openai_fine_tuning.pyindex 2a899f9ac19..d81d7457a3f 100644--- a/studio/backend/tests/test_openai_fine_tuning.py+++ b/studio/backend/tests/test_openai_fine_tuning.py@@ -1435,3 +1435,72 @@ def test_start_training_batch_refuses_resume_and_reports_a_busy_gpu_per_member(massert [(r.status, r.error, r.job_id) for r in responses] == [("error", "Training already active", "job_running")] * 2+++ "model", ["//attacker.example/share/model", "\\\\attacker.example\\share\\model"]+)+def test_batch_probe_never_touches_a_managed_share_path(batch_queue, monkeypatch, model):+ """A managed account's UNC model never reaches the batch probe; the single start refuses it."""+ import utils.models.diffusion_lm as diffusion_lm+ import utils.models.model_config as model_config+ from utils.account_context import AccountContext++ client, calls, _live, gpu, _backend = batch_queue+ monkeypatch.setattr(openai_fine_tuning, "_trains_alone", _REAL_TRAINS_ALONE)+ touched = []++ def record(name):+ def probe(model_name, *a, **k):+ touched.append((name, model_name))+ return {"model_type": "qwen3"} if name == "config" else None++ return probe++ monkeypatch.setattr(diffusion_lm, "diffusion_lm_profile_for_model", record("diffusion"))+ monkeypatch.setattr(model_config, "get_base_model_from_lora_identifier", record("lora"))+ monkeypatch.setattr(model_config, "_read_raw_config_json", record("config"))+ managed = AccountContext("acct-managed-1", "alice")+ monkeypatch.setattr(openai_fine_tuning, "current_account", lambda: managed)++ async def flow():+ uploaded = await client.files.create(file = ("chats.jsonl", CHATS), purpose = "fine-tune")+ for s in "ab":+ await client.fine_tuning.jobs.create(+ model = model,+ training_file = uploaded.id,+ suffix = s,+ extra_body = {"packing": False},+ )+ gpu["busy"] = False+ await openai_fine_tuning._drain_once()++ _run(flow())+ assert touched == []+ assert calls["batch"] == []+++def test_batch_probe_unchanged_for_the_owner(batch_queue, monkeypatch):+ import utils.models.diffusion_lm as diffusion_lm+ import utils.models.model_config as model_config++ client, calls, _live, gpu, _backend = batch_queue+ monkeypatch.setattr(openai_fine_tuning, "_trains_alone", _REAL_TRAINS_ALONE)+ touched = []+ monkeypatch.setattr(+ diffusion_lm, "diffusion_lm_profile_for_model", lambda m, *a, **k: touched.append(m)+ )+ monkeypatch.setattr(model_config, "get_base_model_from_lora_identifier", lambda *a, **k: None)+ monkeypatch.setattr(+ model_config, "_read_raw_config_json", lambda *a, **k: {"model_type": "qwen3"}+ )++ async def flow():+ uploaded = await client.files.create(file = ("chats.jsonl", CHATS), purpose = "fine-tune")+ for s in "ab":+ await _create(client, uploaded.id, suffix = s, extra_body = {"packing": False})+ gpu["busy"] = False+ await openai_fine_tuning._drain_once()++ _run(flow())+ assert touched and len(calls["batch"]) == 1