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
Follow #11635's Diffusers prefetch and #11660's responsive classes in the tests (#11680)
Daniel Han66febc7152fb
diff --git a/tests/python/test_windows_arm64_wheelhouse_tags.py b/tests/python/test_windows_arm64_wheelhouse_tags.pyindex 69680f21ade..50ea9dde5b7 100644--- a/tests/python/test_windows_arm64_wheelhouse_tags.py+++ b/tests/python/test_windows_arm64_wheelhouse_tags.py@@ -15,6 +15,7 @@ never found and the entry silently does nothing.from __future__ import annotations+import astimport importlib.utilimport reimport sys@@ -1470,15 +1471,30 @@ class TestTheSkipGateAuditsTheArm64FilteredFile:assert "_windows_arm64_skip_packages(actual)" not in helperdef test_pip_install_and_the_audits_share_it(self, ips):- """Four call sites: both installs, the closure record, and the on-disk skip check.-- The count is the invariant's teeth, not the invariant itself: every path that installs a- requirements file, or reasons about one, has to filter it the same way, or a caller decides- a pin is satisfied against a file different from the one that was installed. ``pip_install``- and ``pip_install_try`` are now both such paths, so a fourth shared call site is the- invariant holding rather than loosening. A caller that grew its own filtering would still- show up here, as a count that moved without a matching call site.+ """Five callers: both installs, the closure record, the on-disk skip check, and #11635's+ Diffusers prefetch, which has to build from the same filtered file the install then reads+ or its cache entry misses.++ Every path that installs a requirements file, or reasons about one, has to filter it the+ same way, or a caller decides a pin is satisfied against a file different from the one+ that was installed. Named by function rather than counted, so a new caller fails with+ its own name and a caller that stops filtering fails by going missing."""- assert (- STACK_SRC.count("_effective_requirements(req)") == 4- ), "a caller that filters its own way can disagree with the file that installs"+ callers = {}+ for node in ast.walk(ast.parse(STACK_SRC)):+ if not isinstance(node, ast.FunctionDef):+ continue+ for sub in ast.walk(node):+ if (+ isinstance(sub, ast.Call)+ and isinstance(sub.func, ast.Name)+ and sub.func.id == "_effective_requirements"+ ):+ callers.setdefault(node.name, []).append(ast.unparse(sub.args[0]))+ assert callers == {+ "pip_install": ["req"],+ "pip_install_try": ["req"],+ "_closure_record": ["req"],+ "_requirements_satisfied": ["req"],+ "_prefetch_diffusers_main": ["req"],+ }, "a caller that filters its own way can disagree with the file that installs"diff --git a/tests/studio/install/test_torch_probe_memoization.py b/tests/studio/install/test_torch_probe_memoization.pyindex af497bd761c..b8bf66a6a35 100644--- a/tests/studio/install/test_torch_probe_memoization.py+++ b/tests/studio/install/test_torch_probe_memoization.py@@ -278,7 +278,9 @@ class TestMemoization:cannot be added without either invalidating or failing this.The two that exist route through _build_pip_cmd / _build_uv_cmd, which is what- makes a function an installer rather than a probe.+ makes a function an installer rather than a probe. The one exemption builds into a+ scratch --target and installs nothing; `TestScratchPrefetch` runs it to prove that,+ rather than trusting how its source reads."""tree = ast.parse(Path(stack_mod.__file__).read_text(encoding = "utf-8"))installers = {}@@ -292,12 +294,13 @@ class TestMemoization:}if called & {"_build_pip_cmd", "_build_uv_cmd"}:installers[node.name] = called- assert set(installers) == {"pip_install", "pip_install_try"}, (+ assert SCRATCH_PREFETCHERS <= set(installers), "an exempted prefetcher no longer builds"+ assert set(installers) - SCRATCH_PREFETCHERS == {"pip_install", "pip_install_try"}, (f"a new installer entry point appeared: {sorted(installers)}. It has to drop ""the torch classification too, or it will answer for the build it replaced")- for name, called in installers.items():- assert "_invalidate_torch_runtime_probe" in called, (+ for name in set(installers) - SCRATCH_PREFETCHERS:+ assert "_invalidate_torch_runtime_probe" in installers[name], (f"{name}() installs packages without dropping the memoized torch " "classification")@@ -309,6 +312,56 @@ class TestMemoization:assert mock_run.call_count == 2+# Builds a command without dropping the torch classification, which is only safe because it+# installs nothing into the environment. TestScratchPrefetch runs each one to hold it to that.+SCRATCH_PREFETCHERS = {"_prefetch_diffusers_main"}+++class TestScratchPrefetch:+ """#11635's prefetch warms uv's cache by building into a throwaway --target. Run it with the+ subprocess stubbed and read the command it actually issues: exactly one --target, naming a+ directory it made under the temp root, and removed afterwards."""++ @pytest.mark.parametrize("git", [True, False], ids = ["from-git", "from-archive"])+ def test_the_prefetch_builds_only_into_a_scratch_target(self, git, tmp_path):+ req_root = tmp_path / "requirements"+ req_root.mkdir()+ (req_root / "diffusers-main.txt").write_text(+ "diffusers @ git+https://github.com/huggingface/diffusers@abc\n", encoding = "utf-8"+ )+ commands = []++ def run(cmd, **kwargs):+ commands.append(list(cmd))+ return subprocess.CompletedProcess(cmd, 0, stdout = "")++ with (+ patch.object(stack_mod, "REQ_ROOT", req_root),+ patch.object(stack_mod, "_diffusers_main_requested", return_value = True),+ patch.object(stack_mod, "_diffusers_main_needs_dependency_pass", return_value = True),+ patch.object(stack_mod, "_startup_repair_failed", return_value = False),+ patch.object(stack_mod, "_bootstrap_uv", return_value = True),+ patch.object(stack_mod, "_has_working_git", return_value = git),+ patch.object(+ stack_mod, "_diffusers_main_archive", return_value = "https://example/d.tar.gz"+ ),+ patch.object(stack_mod, "_pinned_cmd_and_env", side_effect = lambda cmd: (cmd, None)),+ patch.object(stack_mod.subprocess, "run", side_effect = run),+ ):+ assert stack_mod._prefetch_diffusers_main() == 0++ assert len(commands) == 1, commands+ cmd = commands[0]+ targets = [+ i for i, arg in enumerate(cmd) if arg == "--target" or arg.startswith("--target=")+ ]+ assert len(targets) == 1 and cmd[targets[0]] == "--target", cmd+ target = Path(cmd[targets[0] + 1])+ assert target.parent == Path(stack_mod.tempfile.gettempdir()), target+ assert target.name.startswith(stack_mod._PREFETCH_SCRATCH_PREFIX), target+ assert not target.exists(), "the scratch target was left behind"++class TestConsumersShareTheProbe:def test_probe_installed_torch_version_uses_the_shared_result(self):with patch.object(stack_mod.subprocess, "run", return_value = _probe_result()) as mock_run:diff --git a/tests/studio/test_desktop_reliability_frontend_contract.py b/tests/studio/test_desktop_reliability_frontend_contract.pyindex 4ba65944934..fd1e53235ac 100644--- a/tests/studio/test_desktop_reliability_frontend_contract.py+++ b/tests/studio/test_desktop_reliability_frontend_contract.py@@ -841,7 +841,8 @@ def test_mac_chat_header_controls_share_the_titlebar_row():assert padding is not None and padding > 0, (name, values)assert header is not None and control is not None, (name, values)assert padding + control <= header, (name, padding, control, header)- assert "pt-[var(--studio-content-top-inset,0px)] md:flex-row" in source+ # #11660 moved the chat split from md to lg, so tablets stack.+ assert "pt-[var(--studio-content-top-inset,0px)] lg:flex-row" in sourceassert "absolute top-[var(--studio-content-top-inset,0px)]" in source@@ -2375,9 +2376,10 @@ def test_image_page_structural_panes_share_the_container_breakpoint():# -action mask, which is why the two are asserted together -- the small padding is# only correct while the fade is there to dissolve the last control into the footer.assert "panel-scroll-fade-action" in section- assert "gap-4 px-10 pt-9 pb-6 @[50rem]:overflow-y-auto" in section+ # max-sm:px-5 since #11660: a phone gives the controls the 40px the gutter took.+ assert "gap-4 px-10 max-sm:px-5 pt-9 pb-6 @[50rem]:overflow-y-auto" in sectionassert "p-6 px-10 @[50rem]:pt-[60px]" in section- assert "border-t border-foreground/10 px-10 py-3" in section+ assert "border-t border-foreground/10 px-10 max-sm:px-5 py-3" in sectiondef test_audio_page_matches_the_image_rail_header_and_action_footer():@@ -2408,7 +2410,7 @@ def test_audio_page_matches_the_image_rail_header_and_action_footer():assert RAIL_WIDTH in layoutassert RAIL_WIDTH_SCALED in AUDIO_PAGE.read_text(encoding = "utf-8"), "the rail stopped scaling"assert "@[50rem]:border-r @[50rem]:border-b-0" in layout- assert "gap-4 px-10 pt-9 pb-6 @[50rem]:overflow-y-auto" in layout+ assert "gap-4 px-10 max-sm:px-5 pt-9 pb-6 @[50rem]:overflow-y-auto" in layoutassert 'mode === "speak"' in layoutassert '"panel-scroll-fade-action"' in layoutassert '"panel-scroll-fade"' in layout@@ -2423,7 +2425,7 @@ def test_image_train_rail_matches_create_and_header():layout = source.split("overflow-x-hidden: an unset overflow-x", 1)[1]assert "@[50rem]:flex-row @[50rem]:overflow-hidden" in layout- assert "pl-10 @[50rem]:w-[408px]" in layout+ assert "pl-10 max-sm:pl-5 @[50rem]:w-[408px]" in layoutassert "@[50rem]:border-r @[50rem]:border-b-0" in layoutassert "@container hover-scrollbar" in layoutassert "@[50rem]:pt-[42px]" in layout