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
Repair the two studio test suites #9410 left behind (#9437)
Daniel Han2f9daf4c29cf
diff --git a/tests/studio/test_chat_autoload_failure_gate.py b/tests/studio/test_chat_autoload_failure_gate.pyindex 69277f24e71..a4097e177ae 100644--- a/tests/studio/test_chat_autoload_failure_gate.py+++ b/tests/studio/test_chat_autoload_failure_gate.py@@ -94,6 +94,56 @@ export function sanitizeStoredExtraArgs(return [...tokens];}+// The llama-server tuning group, mirroring+// studio/frontend/src/features/chat/lib/server-tuning-fields.ts. Real logic rather+// than a neutral stub: serverTuningLoadPayload spreads into the /load payload these+// scenarios assert on, so a stub that always returned {} would keep passing if the+// real one started sending a field. These are pure and import nothing, so copying+// them costs only the drift this file already guards against by name.+export function serverTuningLoadPayload(values: any): any {+ return {+ ...(values?.loadMode != null ? { load_mode: values.loadMode } : {}),+ ...(values?.specDraftCacheDtype != null+ ? { spec_draft_cache_type: values.specDraftCacheDtype }+ : {}),+ ...(values?.ctxCheckpoints != null+ ? { ctx_checkpoints: values.ctxCheckpoints }+ : {}),+ ...(values?.cacheRam != null ? { cache_ram: values.cacheRam } : {}),+ };+}+export function clearedServerTuningState(): any {+ return {+ loadMode: null,+ loadedLoadMode: null,+ specDraftCacheDtype: null,+ loadedSpecDraftCacheDtype: null,+ ctxCheckpoints: null,+ loadedCtxCheckpoints: null,+ cacheRam: null,+ loadedCacheRam: null,+ };+}+export function committedServerTuningState(values: any, isDiffusion = false): any {+ if (isDiffusion) {+ return clearedServerTuningState();+ }+ const loadMode = values?.loadMode ?? null;+ const specDraftCacheDtype = values?.specDraftCacheDtype ?? null;+ const ctxCheckpoints = values?.ctxCheckpoints ?? null;+ const cacheRam = values?.cacheRam ?? null;+ return {+ loadMode,+ loadedLoadMode: loadMode,+ specDraftCacheDtype,+ loadedSpecDraftCacheDtype: specDraftCacheDtype,+ ctxCheckpoints,+ loadedCtxCheckpoints: ctxCheckpoints,+ cacheRam,+ loadedCacheRam: cacheRam,+ };+}+export const EVENTS: any[] = [];let SCENARIO: Scenario;export function setScenario(scenario: Scenario) {diff --git a/tests/studio/test_model_picker_contracts.py b/tests/studio/test_model_picker_contracts.pyindex bc80f861762..6529dd0d444 100644--- a/tests/studio/test_model_picker_contracts.py+++ b/tests/studio/test_model_picker_contracts.py@@ -43,6 +43,40 @@ def _split_args(captured: str) -> list[str]:return args+def _code_only(source: str) -> str:+ """``source`` with comments removed and whitespace collapsed.++ A name discussed in prose is not a call. This file's own comments name the+ functions they explain, so a scan that skipped this would match the sentence.+ """+ source = re.sub(r"/\*.*?\*/", " ", source, flags = re.S)+ source = re.sub(r"//[^\n]*", " ", source)+ return " ".join(source.split())+++def _call_arguments(text: str, callee: str) -> list[str]:+ """The argument text of each ``callee(...)`` call in ``text``, parens balanced.++ Per call, so a contract about what every call passes cannot be satisfied by a+ matching property somewhere else in the file, nor broken by one. An optional+ generic parameter list is skipped, since ``f<string>(...)`` is the same call.+ """+ calls = []+ for match in re.finditer(rf"\b{re.escape(callee)}\s*(?:<[^>]*>)?\s*\(", text):+ depth, start = 0, match.end() - 1+ for index in range(start, len(text)):+ if text[index] == "(":+ depth += 1+ elif text[index] == ")":+ depth -= 1+ if depth == 0:+ calls.append(text[start + 1 : index])+ break+ else:+ raise AssertionError(f"unbalanced parentheses after {callee} at {start}")+ return calls++def _read_backend(rel: str) -> str:path = WORKDIR / "studio" / "backend" / relassert path.exists(), f"missing backend source file: {path}"@@ -2218,7 +2252,21 @@ def test_hydration_clears_the_batch_baselines_for_a_batchless_model():# A swap under this tab resets the controls too, but through the seed, not a blanket# null after it: the batch echo is the REQUESTED size, so clearing it here would also# discard the value just adopted from the new model and revert it on the next Reload.- assert status.count("modelChanged: slotsModelChanged,") == 2+ # EVERY seed is told the same thing from the same local, so none of them can drift+ # apart. Checked per call site rather than as a count: the llama-server tuning knobs+ # deliberately reuse this seed, so a hardcoded number fails the next time the group+ # grows while saying nothing about drift, and a whole-file count of `modelChanged`+ # would both break on an unrelated one elsewhere and let an unrelated one stand in+ # for a seed that omitted the property.+ # Comments stripped first: this file discusses `resolveBatchSizeSeed (modelChanged)`+ # in prose, and a scan that counted that sentence as a call site would fail on a+ # wording change.+ seed_args = _call_arguments(_code_only(src), "resolveBatchSizeSeed")+ assert len(seed_args) >= 2, "the batch pair alone should be two seeds"+ for args in seed_args:+ assert (+ "modelChanged: slotsModelChanged," in args+ ), f"a resolveBatchSizeSeed call is not told modelChanged from slotsModelChanged: {args}"assert "{ nBatch: null, nUbatch: null }" not in status# The remembered override is re-adopted only when the echo proves it.assert (