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
Fix the exec-literal, encoding and formatter gates #13520, #13534 and #13536 left red on main (#13543)
Daniel Han428ac984258c
diff --git a/scripts/exec_literals_baseline.json b/scripts/exec_literals_baseline.jsonindex b5f77d707e3..8ad1adad238 100644--- a/scripts/exec_literals_baseline.json+++ b/scripts/exec_literals_baseline.json@@ -9,6 +9,20 @@"unsloth-cli.py"],"entries": [+ {+ "file": "studio/backend/core/inference/diffusion_autoopt/patches.py",+ "sink": "compile",+ "digest": "5ae0e330a5c3c7ad",+ "count": 1,+ "reason": "splice_function: compiles an AST parsed from the library function's own inspect.getsource, edited only by exact-once literal needle replacements, checked to be one function whose globals all resolve"+ },+ {+ "file": "studio/backend/core/inference/diffusion_autoopt/patches.py",+ "sink": "exec",+ "digest": "1c33653a1d0bca74",+ "count": 1,+ "reason": "splice_function: executes the code object compiled on the line above into a copy of the original function's globals; never sees user or model input"+ },{"file": "studio/backend/core/inference/diffusion_capture_safe.py","sink": "compile",diff --git a/studio/backend/core/inference/diffusion_cache.py b/studio/backend/core/inference/diffusion_cache.pyindex e1e83d58350..fc993b2ac3e 100644--- a/studio/backend/core/inference/diffusion_cache.py+++ b/studio/backend/core/inference/diffusion_cache.py@@ -47,13 +47,13 @@ _REDUCTION_FILTER_OPTION = "test_configs.force_filter_reduction_configs"_TIER_DEFAULT = "default"_TIER_MAX = "max"+# Per-model interval on each tier ("default" also covers max), measured vs the no-skip render (PR #12652): default# needs mean LPIPS <= 0.05, max <= 0.10. "steps" = the step count it was measured at: fewer steps compute every step.# Keyed by the UPSTREAM repo id so distilled / unmeasured siblings never match.# The rows are ``FamilyProfile.auto_static_skip`` on the registry; the registries are torch-free, so this stays light.def _auto_static_skip_table() -> dict:from .family_profile import profile_table-return {repo.strip().lower(): dict(entry)for rows in profile_table("auto_static_skip").values()diff --git a/studio/backend/core/inference/diffusion_content.py b/studio/backend/core/inference/diffusion_content.pyindex 892c848cb49..fd06bca0cfa 100644--- a/studio/backend/core/inference/diffusion_content.py+++ b/studio/backend/core/inference/diffusion_content.py@@ -43,9 +43,9 @@ SAME_ARCH_VARIANTS: dict[str, frozenset[str]] = {"wan2.2-t2v-a14b": frozenset({"wan2.2-t2v-a14b", "wan2.1-t2v-14b"}),}+def _video_family_names() -> frozenset[str]:from .video_families import _FAMILIES-return frozenset(fam.name for fam in _FAMILIES)diff --git a/studio/backend/core/inference/diffusion_families.py b/studio/backend/core/inference/diffusion_families.pyindex 9caa2817351..d14237c76c3 100644--- a/studio/backend/core/inference/diffusion_families.py+++ b/studio/backend/core/inference/diffusion_families.py@@ -279,11 +279,17 @@ _QWENIMAGE_TRAIN_SCHEME_DENY = frozenset({"fp8"})# seeding). A family without one has no schedule clearing the bar, so int8 falls back to fp8._QWENIMAGE_TE_INT8_SKIP = (6, 6)# Gated NVFP4 auto head (int8 first; nvfp4 only with a passing gate record for this base and device).-_GATED_AUTO_PREFER = AutoPrefer(floor = (10, 0), schemes = ("int8", "fp8", "nvfp4", "mxfp8"), gated = True)+_GATED_AUTO_PREFER = AutoPrefer(+ floor = (10, 0), schemes = ("int8", "fp8", "nvfp4", "mxfp8"), gated = True+)# AUTO keeps bf16 while it fits for these (measured with both sides compiled: INT8 was at most ~5% faster and failed# the default-on LPIPS bar); when bf16 would offload, INT8 is still picked.-_LUMINA2_BF16_WHEN_RESIDENT = "INT8 is no faster than compiled bf16 on a card that holds bf16 and changes image detail"-_HIDREAM_BF16_WHEN_RESIDENT = "INT8 is barely faster than compiled bf16 on a card that holds bf16 and changes image detail"+_LUMINA2_BF16_WHEN_RESIDENT = (+ "INT8 is no faster than compiled bf16 on a card that holds bf16 and changes image detail"+)+_HIDREAM_BF16_WHEN_RESIDENT = (+ "INT8 is barely faster than compiled bf16 on a card that holds bf16 and changes image detail"+)# Keyed by architecture, not per variant: the base repo is read from the HF base_model tag at load time, so one entry# covers Turbo/full, schnell/dev.@@ -358,7 +364,10 @@ _FAMILIES: tuple[DiffusionFamily, ...] = (profile = FamilyProfile(preview_factors = "flux2",auto_static_skip = (- ("black-forest-labs/flux.2-klein-base-4b", (("default", 2), ("max", 3), ("steps", 50))),+ (+ "black-forest-labs/flux.2-klein-base-4b",+ (("default", 2), ("max", 3), ("steps", 50)),+ ),),),pipeline_class = "Flux2KleinPipeline",@@ -646,7 +655,9 @@ _FAMILIES: tuple[DiffusionFamily, ...] = (),auto_prefer = _GATED_AUTO_PREFER,preview_factors = "qwen_image_21",- auto_static_skip = (("qwen/qwen-image-2.1", (("default", 3), ("max", 3), ("steps", 25))),),+ auto_static_skip = (+ ("qwen/qwen-image-2.1", (("default", 3), ("max", 3), ("steps", 25))),+ ),),# ComfyUI QwenImage21: ModelSamplingFlux fixed mu 0.69, no terminal stretch.comfy_flow_shift = flux_mu_shift(0.69),diff --git a/studio/backend/core/inference/family_profile.py b/studio/backend/core/inference/family_profile.pyindex 3cf1aacbcc7..59f2aab71a1 100644--- a/studio/backend/core/inference/family_profile.py+++ b/studio/backend/core/inference/family_profile.py@@ -112,7 +112,6 @@ DEFAULT_PROFILE = FamilyProfile()def _families() -> tuple[Any, ...]:from .diffusion_families import _FAMILIES as imagefrom .video_families import _FAMILIES as video-return (*image, *video)diff --git a/studio/backend/core/inference/video_families.py b/studio/backend/core/inference/video_families.pyindex b9e9f9cad77..bf01a9804d2 100644--- a/studio/backend/core/inference/video_families.py+++ b/studio/backend/core/inference/video_families.py@@ -807,7 +807,10 @@ _FAMILIES: tuple[VideoFamily, ...] = (nvfp4_zero_row_tokens = _HUNYUAN15_NVFP4_ZERO_ROW_TOKENS,preview_factors = "hv15",auto_static_skip = (- ("hunyuanvideo-community/hunyuanvideo-1.5-diffusers-480p_t2v", (("max", 2), ("steps", 50))),+ (+ "hunyuanvideo-community/hunyuanvideo-1.5-diffusers-480p_t2v",+ (("max", 2), ("steps", 50)),+ ),),),comfy_flow_shift = 7.0, # ComfyUI model default and template shift 7diff --git a/studio/backend/core/training/diffusion_train_common.py b/studio/backend/core/training/diffusion_train_common.pyindex 38b25e0d94d..27525596d80 100644--- a/studio/backend/core/training/diffusion_train_common.py+++ b/studio/backend/core/training/diffusion_train_common.py@@ -542,9 +542,7 @@ def train_defaults(family: str) -> dict[str, Any]:# Display labels (the registries' ``label``) + a short VRAM/access note per trainable family, surfaced by the Train UI# so users pick a base with realistic expectations.-_FAMILY_LABELS = {- fam.name: fam.label for fam in (*_IMAGE_REGISTRY, *_VIDEO_REGISTRY) if fam.label-}+_FAMILY_LABELS = {fam.name: fam.label for fam in (*_IMAGE_REGISTRY, *_VIDEO_REGISTRY) if fam.label}# params is the transformer size (SDXL is not quoted that way); note is the rest._FAMILY_TRAIN_SPECS: dict[str, dict[str, Any]] = {"sdxl": {"params": "", "qlora_vram_gb": 12, "gated": False, "note": "The lightest option."},diff --git a/studio/backend/tests/test_diffusion_autoopt_parity.py b/studio/backend/tests/test_diffusion_autoopt_parity.pyindex afb244c9ba5..fd3b39b1c60 100644--- a/studio/backend/tests/test_diffusion_autoopt_parity.py+++ b/studio/backend/tests/test_diffusion_autoopt_parity.py@@ -487,7 +487,7 @@ def snapshot(entry: Callable) -> dict:def captured() -> dict:if not FIXTURE.exists():pytest.fail(f"missing parity fixture {FIXTURE}")- return json.loads(FIXTURE.read_text())+ return json.loads(FIXTURE.read_text(encoding = "utf-8"))def test_fixture_covers_every_registered_family(captured):diff --git a/studio/backend/tests/test_diffusion_family_data_freeze.py b/studio/backend/tests/test_diffusion_family_data_freeze.pyindex 1ffd0e243a5..18a9d4f5867 100644--- a/studio/backend/tests/test_diffusion_family_data_freeze.py+++ b/studio/backend/tests/test_diffusion_family_data_freeze.py@@ -64,7 +64,9 @@ def _snapshot() -> dict:repos.add(row[-1])for row in getattr(fam, "prequant_variant_repos", ()):repos.update((row[0], row[-1]))- repos.update(("unsloth/Qwen-Image-2.1-Turbo-FP8", "unsloth/qwen-image-2.1-turbo-fp8", "", "x/y"))+ repos.update(+ ("unsloth/Qwen-Image-2.1-Turbo-FP8", "unsloth/qwen-image-2.1-turbo-fp8", "", "x/y")+ )repos = sorted(repos)per_family = {}@@ -188,7 +190,7 @@ def _clean_env(monkeypatch):def test_family_data_resolves_identically(_clean_env):snapshot = json.loads(json.dumps(_snapshot()))if os.environ.get("UNSLOTH_FREEZE_UPDATE") == "1":- FIXTURE.write_text(json.dumps(snapshot, indent = 1, sort_keys = True) + "\n")- frozen = json.loads(FIXTURE.read_text())+ FIXTURE.write_text(json.dumps(snapshot, indent = 1, sort_keys = True) + "\n", encoding = "utf-8")+ frozen = json.loads(FIXTURE.read_text(encoding = "utf-8"))for section in sorted(set(frozen) | set(snapshot)):assert snapshot.get(section) == frozen.get(section), sectiondiff --git a/tests/studio/playwright_chat_ui.py b/tests/studio/playwright_chat_ui.pyindex 6ec7484f91d..d9c461b9cb9 100644--- a/tests/studio/playwright_chat_ui.py+++ b/tests/studio/playwright_chat_ui.py@@ -2823,7 +2823,7 @@ with sync_playwright() as p:os.kill(int(studio_pid), 0)if Path("/proc/self").exists(): # Linux: exited but not yet reaped is donetry:- stat = Path(f"/proc/{studio_pid}/stat").read_text()+ stat = Path(f"/proc/{studio_pid}/stat").read_text(encoding = "utf-8")except FileNotFoundError: # reaped between the probe and the readraise ProcessLookupError from Noneif stat.rsplit(")", 1)[1].split()[0] == "Z":