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: remove private helpers and constants that nothing uses (#15696)
Daniel Han1f55d8131c7d
diff --git a/studio/backend/core/inference/chat_template_helpers.py b/studio/backend/core/inference/chat_template_helpers.pyindex 115f6dc2dd3..355bc9f8c27 100644--- a/studio/backend/core/inference/chat_template_helpers.py+++ b/studio/backend/core/inference/chat_template_helpers.py@@ -22,7 +22,6 @@ _UNPARSED = object()_THINK_OPEN = "<think>"_THINK_CLOSE = "</think>"-_GEMMA_CHANNEL_START = "<|channel>"_GEMMA_THOUGHT_OPEN = "<|channel>thought"_GEMMA_THOUGHT_CLOSE = "<channel|>"_GEMMA_TEMPLATE_OPENERS = (diff --git a/studio/backend/core/inference/context_window.py b/studio/backend/core/inference/context_window.pyindex e4b7d362e26..3ae005da261 100644--- a/studio/backend/core/inference/context_window.py+++ b/studio/backend/core/inference/context_window.py@@ -412,16 +412,6 @@ _ARG_COMPACTION_AGGREGATE_LEAF_FLOOR = 256_ARG_COMPACTION_TOTAL_FLOOR_CHARS = 1024-def _largest_leaf(value: Any) -> int:- if isinstance(value, str):- return len(value)- if isinstance(value, dict):- return max((_largest_leaf(item) for item in value.values()), default = 0)- if isinstance(value, list):- return max((_largest_leaf(item) for item in value), default = 0)- return 0--def _total_leaves(value: Any) -> int:if isinstance(value, str):return len(value)diff --git a/studio/backend/core/inference/diffusion_attention.py b/studio/backend/core/inference/diffusion_attention.pyindex 8d0ece10061..b03cf918b9a 100644--- a/studio/backend/core/inference/diffusion_attention.py+++ b/studio/backend/core/inference/diffusion_attention.py@@ -1831,7 +1831,6 @@ def _cudnn_attention_supported() -> bool:_SAGE_PROBE_CACHE: dict[tuple[str, str, int], str] = {}_SAGE_MAX_HEAD_DIM = 128 # sageattn raises above 128-_SAGE_DTYPE_NAMES = ("float16", "bfloat16", "fp16", "bf16", "half")# SageAttention 2 lands near cos 0.9999 / rel-L1 0.01-0.03 vs fp32 here; a wrong-arch or broken build is far outside._SAGE_MIN_COSINE = 0.99_SAGE_MAX_REL_L1 = 0.08diff --git a/studio/backend/core/inference/diffusion_cache.py b/studio/backend/core/inference/diffusion_cache.pyindex cb72d21b42c..3e9b69fa243 100644--- a/studio/backend/core/inference/diffusion_cache.py+++ b/studio/backend/core/inference/diffusion_cache.py@@ -31,7 +31,6 @@ AUTO_STEP_CACHE_TIER = "max"_REDUCTION_FILTER_OPTION = "test_configs.force_filter_reduction_configs"-_TIER_DEFAULT = "default"_TIER_MAX = "max"diff --git a/studio/backend/core/inference/diffusion_cast_cache.py b/studio/backend/core/inference/diffusion_cast_cache.pyindex cadbcb9faca..60dfb32f0e1 100644--- a/studio/backend/core/inference/diffusion_cast_cache.py+++ b/studio/backend/core/inference/diffusion_cast_cache.py@@ -163,10 +163,6 @@ def _cast_bytes(shards: list) -> Optional[int]:return total if seen else None-def _all_wide(shards: list) -> bool:- return _cast_bytes(shards) is not None--def _fit_budget(cands: list, logger: Any = None) -> list:"""A set over the LRU budget would evict its own entries every load. Greedy largest-first, so it is deterministic."""budget = _cache.max_cache_bytes()diff --git a/studio/backend/core/inference/diffusion_layer_split_plan.py b/studio/backend/core/inference/diffusion_layer_split_plan.pyindex 0ef16a29ea4..4c12ad6c215 100644--- a/studio/backend/core/inference/diffusion_layer_split_plan.py+++ b/studio/backend/core/inference/diffusion_layer_split_plan.py@@ -385,14 +385,6 @@ def plan_layer_split()-_BLOCK_LIST_ATTRS: tuple[str, ...] = (- "transformer_blocks",- "single_transformer_blocks",- "blocks",- "layers",-)--def split_blocks(module: Any) -> Optional[list[tuple[str, Any]]]:"""The denoiser's repeated blocks in forward order as ``(qualified name, module)`` (the engine's own list, so aplan's indices name the blocks it places); None when the engine cannot cut this denoiser."""diff --git a/studio/backend/core/inference/diffusion_lora.py b/studio/backend/core/inference/diffusion_lora.pyindex 05b9e396014..9033b08d7fb 100644--- a/studio/backend/core/inference/diffusion_lora.py+++ b/studio/backend/core/inference/diffusion_lora.py@@ -21,9 +21,6 @@ from utils.paths.storage_roots import account_pathfrom .diffusion_families import DIFFUSION_CANCELLED_MSGfrom utils.paths.path_utils import is_appledouble_metadata-# Accepted LoRA formats. safetensors + gguf only (.pt is pickled -> excluded for safety).-_NATIVE_EXTS = (".safetensors", ".gguf")-_DIFFUSERS_EXTS = (".safetensors",)_ALL_EXTS = (".safetensors", ".gguf")# ``kind`` in a ``<stem>.json`` sidecar marking the weight beside it as an image LoRA, not model weights.LORA_SIDECAR_KIND = "diffusion-lora"diff --git a/studio/backend/core/inference/diffusion_prequant_cache.py b/studio/backend/core/inference/diffusion_prequant_cache.pyindex 22edf9d11e2..9cd4bccf69f 100644--- a/studio/backend/core/inference/diffusion_prequant_cache.py+++ b/studio/backend/core/inference/diffusion_prequant_cache.py@@ -292,12 +292,6 @@ def source_shards(return None-def _source_shards_in(base: str, component: str, cache_dir: Optional[str]) -> Optional[list[str]]:- for found in _shard_sets_in(base, component, cache_dir):- return found- return None--def _shard_sets_in(base: str, component: str, cache_dir: Optional[str]):candidates = [str(base)]try:@@ -589,7 +583,6 @@ _REMOTE_MEMO: dict[tuple, tuple] = {}_GONE = "gone"# Shared hub_reachability verdict: after one failure, lookups answer "unknown" (local snapshot stands) for the TTL._UNREACHABLE = _reach._UNREACHABLE-_connection_failed = _reach.connection_failed_endpoint = _reach.endpointdiff --git a/studio/backend/core/inference/diffusion_transformer_quant.py b/studio/backend/core/inference/diffusion_transformer_quant.pyindex a1ba7dfce5b..de00fa9ead0 100644--- a/studio/backend/core/inference/diffusion_transformer_quant.py+++ b/studio/backend/core/inference/diffusion_transformer_quant.py@@ -467,12 +467,6 @@ def _nvfp4_gate_failure(family) -> Optional[str]:return None-_TRAIN_DENY_NVFP4_REASON = (- "nvfp4 is inference-only: the accuracy gate behind it measures a frozen forward at a "- "per-layer policy, and no training run has been measured on 4-bit frozen linears"-)--def _family_train_denied(family,scheme: str,diff --git a/studio/backend/core/inference/diffusion_vae_fused.py b/studio/backend/core/inference/diffusion_vae_fused.pyindex b378ff155c1..fb7ba9bdbc0 100644--- a/studio/backend/core/inference/diffusion_vae_fused.py+++ b/studio/backend/core/inference/diffusion_vae_fused.py@@ -1157,7 +1157,6 @@ def uninstall(vae: Any) -> None:_WAN_VAES = frozenset({"AutoencoderKLWan", "AutoencoderKLQwenImage", "AutoencoderKLQwenImage21"})-_CACHE_T = 2def _is_rms(norm: Any) -> bool:diff --git a/studio/backend/core/inference/diffusion_vae_oom.py b/studio/backend/core/inference/diffusion_vae_oom.pyindex b3cda3c55d7..344db8b5284 100644--- a/studio/backend/core/inference/diffusion_vae_oom.py+++ b/studio/backend/core/inference/diffusion_vae_oom.py@@ -656,11 +656,6 @@ class DecodeSession:return Change(f"moved:{name}", lambda: _return_to(comp, device), settle, defer)- def _component_undo(self, name: str, comp: Any) -> tuple:- """(undo, defer) for a component moved to the host; kept for callers recording a move by hand."""- change = self._component_change(name, comp)- return change.retry, lambda exc: change.defer(change.retry, exc)-def offload_vae(self) -> bool:"""Step (c): the VAE's weights stream per layer from the host (diffusers leaf-level group offload)."""if self.vae_offloaded or getattr(self.device, "type", None) != "cuda" or _hooked(self.vae):diff --git a/studio/backend/core/inference/llama_server_args.py b/studio/backend/core/inference/llama_server_args.pyindex d7200d1bf69..bb58c605e6b 100644--- a/studio/backend/core/inference/llama_server_args.py+++ b/studio/backend/core/inference/llama_server_args.py@@ -584,9 +584,6 @@ MEMORY_ENV_VARS: tuple[str, ...] = ("LLAMA_ARG_NO_DIO",)-_SHADOWING_FLAGS: frozenset[str] = (- _CONTEXT_FLAGS | _CACHE_FLAGS | _SPEC_FLAGS | _TEMPLATE_FLAGS | _SPLIT_SHADOWING_FLAGS-)# Shadowing flags that take no value -- strip the flag only, not the next token._BOOLEAN_SHADOWING_FLAGS: frozenset[str] = frozenset(diff --git a/studio/backend/core/inference/orchestrator.py b/studio/backend/core/inference/orchestrator.pyindex 7edcc9f9a24..414d4e71a98 100644--- a/studio/backend/core/inference/orchestrator.py+++ b/studio/backend/core/inference/orchestrator.py@@ -213,7 +213,6 @@ _STOP_NOTICE_INTERVAL = 0.1_DISPATCH_POLL_INTERVAL = 0.5_DISPATCH_STOP_TIMEOUT = 5.0_DISPATCH_IDLE_TIMEOUT = 30.0-_DISPATCH_DRAIN_TIMEOUT = 5.0_CANCELLED_ROWS_GRACE = 5.0# Transformers TTS only; generous since _ensure_subprocess_alive already catches dead workers.diff --git a/studio/backend/core/inference/passthrough_healing.py b/studio/backend/core/inference/passthrough_healing.pyindex 773f5a9b1b7..7e4c255c75f 100644--- a/studio/backend/core/inference/passthrough_healing.py+++ b/studio/backend/core/inference/passthrough_healing.py@@ -179,17 +179,6 @@ def _promote(return promoted-def _remove_spans(text: str, spans: list) -> str:- """Text with the given non-overlapping, sorted (start, end) ranges removed."""- pieces = []- pos = 0- for start, end in spans:- pieces.append(text[pos:start])- pos = end- pieces.append(text[pos:])- return "".join(pieces)--def heal_openai_message_events(msg: dict,allowed_tools: set,diff --git a/studio/backend/core/training/diffusion_checkpoint.py b/studio/backend/core/training/diffusion_checkpoint.pyindex 6b07bf5691b..15a2e568868 100644--- a/studio/backend/core/training/diffusion_checkpoint.py+++ b/studio/backend/core/training/diffusion_checkpoint.py@@ -117,8 +117,6 @@ _OPTIONAL_IDENTITY_FIELDS = frozenset()# Bundle side only: an incoming None is the route's unresolved pre-trainer identity ("cannot tell")._LEGACY_IDENTITY_DEFAULTS: dict[str, str] = {"bucketing": "off"}-# What source_revision() returns when it cannot resolve a revision offline.-_UNRESOLVED_REVISION = "unresolved"def _revision_is_comparable(value: Any) -> bool:diff --git a/studio/backend/hub/services/models/account_access.py b/studio/backend/hub/services/models/account_access.pyindex ebf0550fcc4..5174fe71fb5 100644--- a/studio/backend/hub/services/models/account_access.py+++ b/studio/backend/hub/services/models/account_access.py@@ -588,13 +588,6 @@ def _public_key(repo_id: str, repo_type: str) -> tuple[str, str, str]:return (hf_constants.ENDPOINT.rstrip("/"), repo_type, repo_id.lower())-def _public_verdict(repo_id: str, repo_type: str) -> bool | None:- key = _public_key(repo_id, repo_type)- with _public_lock:- cached = _public_repos.get(key)- return cached[1] if cached is not None and cached[0] > time.monotonic() else None--def _source_speaks_for_the_cache() -> bool:from utils.hub_settings import MODELSCOPE, active_sourcereturn active_source() != MODELSCOPEdiff --git a/studio/backend/hub/services/models/gguf_variants.py b/studio/backend/hub/services/models/gguf_variants.pyindex 5acfd685588..2d62475827d 100644--- a/studio/backend/hub/services/models/gguf_variants.py+++ b/studio/backend/hub/services/models/gguf_variants.py@@ -783,9 +783,6 @@ def _direct_gguf_split_is_whole(path: Path) -> bool:return found >= set(range(1, total + 1))-# Cache scan's looser grammar (hub.utils.inventory_scan._GGUF_SPLIT_RE), not the five digits above.-_CACHE_SPLIT_RE = re.compile(r"-(\d{3,})-of-(\d{3,})(?=\.gguf$)", re.IGNORECASE)-# Only enumerates candidates for the resolver to adjudicate; drift costs a candidate, not a verdict._KNOWN_QUANT_RE = re.compile(r"(UD-)?"diff --git a/studio/backend/hub/utils/gguf_header_delta.py b/studio/backend/hub/utils/gguf_header_delta.pyindex d15e355a6b9..42953611328 100644--- a/studio/backend/hub/utils/gguf_header_delta.py+++ b/studio/backend/hub/utils/gguf_header_delta.py@@ -37,7 +37,6 @@ _MAX_HEADER_BYTES = 256 << 20_COPY_CHUNK = 16 << 20_DISK_MARGIN = 256 << 20_METADATA_TIMEOUT = 10.0-_RANGE_TIMEOUT = 60.0# "image-diffusion-unsupported" is an image / video family this install cannot run yet; still rebuilt._MEDIA_TASKS = frozenset({"text-to-image", "text-to-video", "image-diffusion-unsupported"})diff --git a/studio/backend/routes/data_recipe/seed.py b/studio/backend/routes/data_recipe/seed.pyindex bf83cc30a29..bc035f1ef28 100644--- a/studio/backend/routes/data_recipe/seed.py+++ b/studio/backend/routes/data_recipe/seed.py@@ -133,11 +133,6 @@ def _list_hf_repo_files(*, dataset_name: str, token: HfTokenArg) -> list[str]:return []-def _list_hf_data_files(*, dataset_name: str, token: HfTokenArg) -> list[str]:- repo_files = _list_hf_repo_files(dataset_name = dataset_name, token = token)- return [file for file in repo_files if file.lower().endswith(DATA_EXTS)]--def _list_hf_dataset_configs(*, dataset_name: str, token: HfTokenArg) -> list[dict[str, Any]]:"""Read configs from the card's configs block; config names need not match folder names."""try:diff --git a/studio/backend/routes/settings.py b/studio/backend/routes/settings.pyindex a9b9239cf23..e993ce2b234 100644--- a/studio/backend/routes/settings.py+++ b/studio/backend/routes/settings.py@@ -3277,14 +3277,6 @@ def _gguf_conversion_name_matches(hit_name: str, base: str) -> bool:return name == base or name in {f"{base}-gguf", f"{base}_gguf", f"{base}.gguf"}-def _gguf_files_for_pick(names: list[str], picked: str) -> Optional[list[str]]:- """The complete downloadable file family for a picked GGUF. llama-server opens split siblings implicitly,- so a single selected shard is not a usable plan, and incomplete published families are rejected.- Deferred to the loader so the plan offered here and the transfer name one set."""- from core.rag.embed_llama_server import LlamaServerBackend- return LlamaServerBackend._split_family(names, picked)--def _pick_downloadable_gguf(names: list[str]) -> Optional[list[str]]:"""Pick the loader's preferred GGUF, skipping torn split families."""from core.rag.embed_llama_server import LlamaServerBackenddiff --git a/studio/backend/storage/chat_generation_runs_db.py b/studio/backend/storage/chat_generation_runs_db.pyindex 376eab8b469..39099d7a58b 100644--- a/studio/backend/storage/chat_generation_runs_db.py+++ b/studio/backend/storage/chat_generation_runs_db.py@@ -149,17 +149,6 @@ def _unregister_locked(entry: _PoolEntry | None) -> None:_pool_registry[:] = surviving-def _discard_pooled() -> None:- """Drop this thread's cached connection, for when it has errored or its database has gone."""- entry = getattr(_pool, "entry", None)- if entry is None:- return- _pool.entry = None- with _pool_lock:- _unregister_locked(entry)- entry.release()--def _discard_all_pooled() -> None:"""Closes every pooled connection, idle ones at once; one in use is closed by its borrower on return, since yanking it would fail that query."""global _pool_generationdiff --git a/studio/backend/utils/worker_stderr.py b/studio/backend/utils/worker_stderr.pyindex b689a87aad1..f35878a17c5 100644--- a/studio/backend/utils/worker_stderr.py+++ b/studio/backend/utils/worker_stderr.py@@ -66,12 +66,6 @@ def _utf8_edge_bounds(data: bytes, *, trim_end: bool = True) -> "tuple[int, int]return start, end-def _without_partial_utf8_edges(data: bytes, *, trim_end: bool = True) -> bytes:- """``trim_end`` is off at EOF, where a trailing 0xC0+ byte is a complete cp1252 character, not a severed one."""- start, end = _utf8_edge_bounds(data, trim_end = trim_end)- return data[start:end]--def decode_worker_stderr(data: bytes, *, ends_at_eof: bool = True) -> str:"""UTF-8 before cp1252: cp1252 has a meaning for almost every byte, so the stricter encoding goes first."""text: str | None = Nonediff --git a/unsloth_cli/commands/start.py b/unsloth_cli/commands/start.pyindex c9b7b82e695..fa5a9d73a66 100644--- a/unsloth_cli/commands/start.py+++ b/unsloth_cli/commands/start.py@@ -1787,20 +1787,6 @@ def _write_private_text(path: Path, text: str) -> None:handle.write(text)-def _read_yaml_object(path: Path) -> Optional[dict]:- import yaml-- if not path.exists():- return {}- try:- data = yaml.safe_load(path.read_text(encoding = "utf-8"))- except (yaml.YAMLError, OSError):- return None- if data is None:- return {}- return data if isinstance(data, dict) else None--def _read_json_object(path: Path) -> Optional[dict]:# {} when missing, None when it cannot be parsed as an object, so the caller leaves a user-managed file untouched rather than clobbering it.if not path.exists():