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(studio): remember per-GPU layer ratios (#12774)
Lee Jackson2b212ca3d2e4
diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.pyindex d4dd6dcb377..4c788dafa18 100644--- a/studio/backend/routes/inference.py+++ b/studio/backend/routes/inference.py@@ -11546,6 +11546,7 @@ async def _maybe_auto_switch_model(# Stale pin (GPU removed, another host, or a backend change# renumbering these ids): drop it rather than 400 the load.load_kwargs.pop("gpu_ids", None)+ load_kwargs.pop("tensor_split", None)logger.warning("Dropping saved gpu_ids %s for %s: not available here.",saved_gpu_ids,@@ -11606,6 +11607,7 @@ async def _maybe_auto_switch_model(exc.detail,)load_kwargs.pop("gpu_ids", None)+ load_kwargs.pop("tensor_split", None)load_request = LoadRequest(**load_kwargs)load_request._gguf_companion_roots = gguf_companion_rootsload_request._gguf_companion_roots_set = Truediff --git a/studio/backend/routes/settings.py b/studio/backend/routes/settings.pyindex 7fb94839b2e..cb5e5a2cb0f 100644--- a/studio/backend/routes/settings.py+++ b/studio/backend/routes/settings.py@@ -1020,6 +1020,7 @@ class ModelOverridePayload(BaseModel):# -1 is Auto (llama.cpp --fit sizes the offload); the normalizer treats it as unset.gpu_layers: Optional[int] = Field(default = None, ge = -1, le = 1024)n_cpu_moe: Optional[int] = Field(default = None, ge = 0, le = 1024)+ tensor_split: Optional[list[float]] = Field(default = None, min_length = 2, max_length = MAX_GPU_IDS)gpu_ids: Optional[list[int]] = Field(default = None, max_length = MAX_GPU_IDS)# Which index space gpu_ids is in. Absent means physical, the only thing a client# written before this field could have meant.@@ -1029,6 +1030,27 @@ class ModelOverridePayload(BaseModel):# Fill in, don't replace: the backfill reads the map once then writes each model.fill_absent_fields: bool = False+ @model_validator(mode = "after")+ def _tensor_split_matches_gpu_ids(self):+ if self.tensor_split is not None:+ from utils.openai_auto_switch_settings import normalize_tensor_split+ if normalize_tensor_split(self.tensor_split, self.gpu_ids) is None:+ raise ValueError(+ "tensor_split must match an ordered selection of at least two unique GPUs"+ )+ return self++ @field_validator("tensor_split")+ @classmethod+ def _valid_tensor_split(cls, value: Optional[list[float]]) -> Optional[list[float]]:+ if value is None:+ return None+ from utils.openai_auto_switch_settings import normalize_tensor_split++ if normalize_tensor_split(value, list(range(len(value)))) is None:+ raise ValueError("tensor_split must be finite, non-negative, and have a positive total")+ return value+@field_validator("chat_template_override")@classmethoddef _limit_chat_template_bytes(cls, value: Optional[str]) -> Optional[str]:@@ -1059,6 +1081,7 @@ class ModelOverridePayload(BaseModel):"gpu_layers","n_cpu_moe","gpu_ids",+ "tensor_split",mode = "before",)@classmethod@@ -2628,6 +2651,13 @@ def update_openai_auto_switch_override(max_seq_length = explicit_ctxif custom_context_length is not None:custom_context_length = explicit_ctx+ tensor_split = payload.tensor_split+ if "tensor_split" not in fields_set:+ previous = get_model_override(target_id)+ if previous.get("gpu_ids") == payload.gpu_ids and previous.get(+ "gpu_index_kind", "physical"+ ) == (payload.gpu_index_kind or "physical"):+ tensor_split = previous.get("tensor_split")set_model_override(target_id,llama_extra_args = extra_args,@@ -2672,6 +2702,7 @@ def update_openai_auto_switch_override(gpu_layers = payload.gpu_layers,n_cpu_moe = payload.n_cpu_moe,gpu_ids = payload.gpu_ids,+ tensor_split = tensor_split,gpu_index_kind = payload.gpu_index_kind,fill_absent_fields = payload.fill_absent_fields,)diff --git a/studio/backend/tests/test_openai_auto_switch.py b/studio/backend/tests/test_openai_auto_switch.pyindex 0a16be9fde1..39b7ac42598 100644--- a/studio/backend/tests/test_openai_auto_switch.py+++ b/studio/backend/tests/test_openai_auto_switch.py@@ -7945,7 +7945,7 @@ def test_stale_gpu_ids_are_dropped_not_fatal(monkeypatch):monkeypatch.setattr(settings,"get_model_override",- lambda mid: {"gpu_ids": [0, 1], "max_seq_length": 4096},+ lambda mid: {"gpu_ids": [0, 1], "tensor_split": [3, 1], "max_seq_length": 4096},)async def _unusable(ids, index_kind = "physical"):@@ -7956,6 +7956,7 @@ def test_stale_gpu_ids_are_dropped_not_fatal(monkeypatch):_run_hook("unsloth/B-GGUF")req = rec.calls[0]assert not req.gpu_ids+ assert req.tensor_split is None# The rest of the config still applies.assert req.max_seq_length == 4096@@ -7964,12 +7965,15 @@ def test_usable_gpu_ids_are_kept(monkeypatch):backend, rec = _wired(monkeypatch, _FakeBackend(None), ("unsloth/B-GGUF", "Q4_K_M", "unsloth/B-GGUF"))- monkeypatch.setattr(settings, "get_model_override", lambda mid: {"gpu_ids": [0, 1]})+ monkeypatch.setattr(+ settings, "get_model_override", lambda mid: {"gpu_ids": [0, 1], "tensor_split": [3, 1]}+ )monkeypatch.setattr(inference_route, "_override_gpu_ids_still_resolve", _usable)_run_hook("unsloth/B-GGUF")assert rec.calls[0].gpu_ids == [0, 1]+ assert rec.calls[0].tensor_split == [3, 1]def test_override_gpu_ids_probe_never_raises(monkeypatch):@@ -8248,7 +8252,9 @@ def test_load_retries_without_gpu_ids_when_the_loader_rejects_the_pin(monkeypatcmonkeypatch, _FakeBackend(None), ("unsloth/B-GGUF", "Q4_K_M", "unsloth/B-GGUF"))monkeypatch.setattr(- settings, "get_model_override", lambda mid: {"gpu_ids": [0], "max_seq_length": 4096}+ settings,+ "get_model_override",+ lambda mid: {"gpu_ids": [0, 1], "tensor_split": [3, 1], "max_seq_length": 4096},)monkeypatch.setattr(inference_route, "_override_gpu_ids_still_resolve", _usable)@@ -8270,6 +8276,7 @@ def test_load_retries_without_gpu_ids_when_the_loader_rejects_the_pin(monkeypatcassert calls["n"] == 2served = rec.calls[-1]assert not served.gpu_ids+ assert served.tensor_split is Noneassert served.max_seq_length == 4096@@ -12256,3 +12263,70 @@ def test_the_legacy_bare_delete_clears_a_managed_engine_choice(override_store):_put("org/Model")assert settings.get_model_override("org/Model") == {}+++def test_tensor_split_survives_the_settings_route_and_reaches_a_gguf_load(override_store):+ _put(+ "org/split-GGUF",+ gpu_memory_mode = "manual",+ gpu_layers = 66,+ gpu_ids = [1, 2, 0],+ tensor_split = [30, 20, 16],+ )+ stored = settings.get_model_override("org/split-GGUF")+ assert stored["gpu_ids"] == [1, 2, 0]+ assert stored["tensor_split"] == [30, 20, 16]+ kwargs = settings.model_override_load_kwargs(stored, is_gguf = True)+ assert kwargs["tensor_split"] == [30, 20, 16]+ LoadRequest(model_path = "org/split-GGUF", **kwargs)+ assert "tensor_split" not in settings.model_override_load_kwargs(stored, is_gguf = False)+++def test_an_older_client_keeps_a_split_only_with_the_same_gpu_order(override_store):+ _put("org/split-GGUF", gpu_ids = [1, 2, 0], tensor_split = [30, 20, 16])+ _put("org/split-GGUF", gpu_ids = [1, 2, 0], gpu_layers = 66)+ assert settings.get_model_override("org/split-GGUF")["tensor_split"] == [30, 20, 16]+ _put("org/split-GGUF", gpu_ids = [0, 1, 2], gpu_layers = 66)+ assert "tensor_split" not in settings.get_model_override("org/split-GGUF")+++def test_explicit_tensor_split_reset_clears_the_server_copy(override_store):+ _put("org/split-GGUF", gpu_ids = [1, 2, 0], tensor_split = [30, 20, 16])+ _put("org/split-GGUF", gpu_ids = [1, 2, 0], tensor_split = None)+ assert "tensor_split" not in settings.get_model_override("org/split-GGUF")+++ "split", [[0, 0], [-1, 2], [float("nan"), 1], [float("inf"), 1], [True, 1], [1e308, 1e308]]+)+def test_invalid_tensor_split_is_rejected_at_the_settings_boundary(split):+ from pydantic import ValidationError+ with pytest.raises(ValidationError):+ settings_route.ModelOverridePayload(model_id = "org/split-GGUF", tensor_split = split)+++def test_tensor_split_is_dropped_if_normalizing_gpu_ids_changes_its_mapping():+ for ids in ([0, 0], [0, -1], [0], None):+ stored = settings.normalize_model_override({"gpu_ids": ids, "tensor_split": [2, 1]})+ assert "tensor_split" not in stored+ stored = settings.normalize_model_override({"gpu_ids": [1, 0], "tensor_split": [0, 2.5]})+ assert stored["tensor_split"] == [0, 2.5]+++def test_fill_never_attaches_a_tensor_split_to_an_existing_other_gpu_order(override_store):+ settings.set_model_override("org/split-GGUF", gpu_ids = [0, 1])+ settings.set_model_override(+ "org/split-GGUF", gpu_ids = [1, 0], tensor_split = [3, 1], fill_absent_fields = True+ )+ stored = settings.get_model_override("org/split-GGUF")+ assert stored["gpu_ids"] == [0, 1]+ assert "tensor_split" not in stored++[email protected]("ids", [None, [0], [0, 0], [0, -1], [0, 1, 2]])+def test_tensor_split_requires_matching_gpu_ids_at_the_settings_boundary(ids):+ from pydantic import ValidationError+ with pytest.raises(ValidationError):+ settings_route.ModelOverridePayload(+ model_id = "org/split-GGUF", gpu_ids = ids, tensor_split = [3, 1]+ )diff --git a/studio/backend/tests/test_pr10884_upgrade_compat.py b/studio/backend/tests/test_pr10884_upgrade_compat.pyindex 63ea42280c0..51dd9ba5708 100644--- a/studio/backend/tests/test_pr10884_upgrade_compat.py+++ b/studio/backend/tests/test_pr10884_upgrade_compat.py@@ -14,10 +14,8 @@ and what ``model_override_load_kwargs`` emits on the way out. So the upgradequestion is answerable exactly, without a database: put a saved overridethrough both and see whether a ratio can come out the other side.-Forwards compatibility is the same argument run backwards. The change persists-nothing new, so a settings row written by this version is byte-identical to one-written before it, and an older install reading it finds nothing it does not-already understand.+Forwards compatibility is the same argument run backwards. #12774 later began+persisting a validated ratio beside its GPU pin; a row without one is unchanged."""from __future__ import annotations@@ -63,7 +61,6 @@ def test_a_saved_setting_can_never_carry_a_tensor_split():@pytest.mark.parametrize("smuggled",[- {"tensor_split": [3, 1]},{"tensor_split": None},{"tensorSplit": [3, 1]},{"tensor_split": "3,1"},@@ -78,6 +75,15 @@ def test_a_ratio_written_into_the_settings_row_by_hand_is_dropped(smuggled):assert "tensorSplit" not in stored[email protected]("ids", [None, [0], [1, 0, 2], [0, 0]])+def test_a_saved_ratio_needs_the_exact_gpu_ids_it_was_written_for(ids):+ """Since #12774 a ratio is stored, but only beside the ordered pin it indexes."""+ row = {**LEGACY_OVERRIDE, "tensor_split": [3, 1]}+ assert normalize_model_override(row)["tensor_split"] == [3, 1]+ row["gpu_ids"] = ids+ assert "tensor_split" not in normalize_model_override(row)++@pytest.mark.parametrize("is_gguf", [True, False])def test_the_replayed_load_asks_for_no_ratio(is_gguf):"""The other end of the same path: what the replay actually sends."""diff --git a/studio/backend/utils/openai_auto_switch_settings.py b/studio/backend/utils/openai_auto_switch_settings.pyindex 51a3d0c6997..ecfeb4c01c2 100644--- a/studio/backend/utils/openai_auto_switch_settings.py+++ b/studio/backend/utils/openai_auto_switch_settings.py@@ -5,6 +5,7 @@from __future__ import annotations+import mathimport osimport reimport threading@@ -567,9 +568,36 @@ def normalize_model_override(if index_kind and index_kind != LEGACY_GPU_INDEX_KIND:entry["gpu_index_kind"] = index_kind+ tensor_split = normalize_tensor_split(payload.get("tensor_split"), gpu_ids)+ if tensor_split is not None and entry.get("gpu_ids") == list(gpu_ids):+ entry["tensor_split"] = tensor_split+return entry+def normalize_tensor_split(value: Any, gpu_ids: Any) -> Optional[list[float]]:+ """Keep a finite positive ratio only with its unmodified ordered GPU IDs."""+ if not isinstance(gpu_ids, (list, tuple)) or len(gpu_ids) < 2:+ return None+ if any(+ isinstance(gid, bool) or not isinstance(gid, int) or not 0 <= gid <= MAX_GPU_ID+ for gid in gpu_ids+ ):+ return None+ if len(set(gpu_ids)) != len(gpu_ids):+ return None+ if not isinstance(value, (list, tuple)) or len(value) != len(gpu_ids):+ return None+ if any(isinstance(v, bool) or not isinstance(v, (int, float)) or v < 0 for v in value):+ return None+ try:+ total = sum(value)+ valid = all(math.isfinite(v) for v in value) and math.isfinite(total) and total > 0+ except OverflowError:+ return None+ return list(value) if valid else None++def stored_gpu_index_kind(override: Mapping[str, Any]) -> str:"""The index space ``override["gpu_ids"]`` was written in. Absent means physical, the only thing any writer before the field could have meant; anything unrecognised means the same, since a row this build cannot read is not evidence of a Vulkan pin."""kind = override.get("gpu_index_kind")@@ -656,6 +684,9 @@ def model_override_load_kwargs(override: dict[str, Any], *, is_gguf: bool) -> dikwargs["n_cpu_moe"] = override["n_cpu_moe"]if override.get("gpu_ids") is not None:kwargs["gpu_ids"] = override["gpu_ids"]+ tensor_split = normalize_tensor_split(override.get("tensor_split"), override["gpu_ids"])+ if tensor_split is not None:+ kwargs["tensor_split"] = tensor_splitif kwargs.get("llama_extra_args"):# One entry can hold a pass-through flag AND the field it shadows, and llama.cpp's last-wins parse would hand the load the stale flag, so the /load stripper (_resolve_inherited_extra_args) is imported, not mirrored. The settings page has no control for flags, so a save carries the stored ones over (routes/settings.py); the allow-list this module stays out of is validate_extra_args.@@ -939,7 +970,7 @@ def set_model_override(fill_absent_fields = fill_absent_fields,coupled_fields = (# The pin and its index space are one value: filling the qualifier onto ids this browser did not write relabels them.- ("gpu_ids", "gpu_index_kind"),+ ("gpu_ids", "gpu_index_kind", "tensor_split"),("mlx_kv_quant", "mlx_kv_bits"),),)diff --git a/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts b/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.tsindex 12cd24c3473..9427ef5c1b7 100644--- a/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts+++ b/studio/frontend/src/features/chat/hooks/use-chat-model-runtime.ts@@ -153,6 +153,7 @@ import { recordLastLocalModelLoad } from "../utils/last-local-model-load";import { loadFallbackNotice } from "../utils/mmproj-fallback";import { resolveQwenThinkingParams } from "../utils/qwen-sampling-table";import { refreshContextUsage } from "../utils/refresh-context-usage";+import { reconcileTensorSplit } from "@/hooks/gpu-tensor-split";import { defaultEngineGpuIds, ensureGpuDeviceCache } from "@/hooks/use-gpu-info";import {type CpuFallbackReason,@@ -2231,6 +2232,13 @@ export function useChatModelRuntime() {stateBeforeUnload.selectedGpuIndexKind,targetIsDiffusion,);+ loadSplitRatio = reconcileTensorSplit(+ loadSplitRatio,+ pendingLoadConfig?.selectedGpuIds !== undefined+ ? pendingLoadConfig.selectedGpuIds+ : stateBeforeUnload.selectedGpuIds,+ loadSelectedGpuIds,+ );let loadSpeculativeType =pendingLoadConfig?.speculativeType != null? normalizeSpeculativeType(pendingLoadConfig.speculativeType)@@ -2554,7 +2562,11 @@ export function useChatModelRuntime() {loadSelectedGpuIds = stagedGpuIds;loadGpuLayers = pendingLoadConfig?.gpuLayers ?? GPU_LAYERS_AUTO;loadNCpuMoe = pendingLoadConfig?.nCpuMoe ?? 0;- loadSplitRatio = pendingLoadConfig?.tensorSplit ?? null;+ loadSplitRatio = reconcileTensorSplit(+ pendingLoadConfig?.tensorSplit,+ pendingLoadConfig?.selectedGpuIds,+ stagedGpuIds,+ );}// The Context Length the USER set for this load, captured before the clamp below can stand in fordiff --git a/studio/frontend/src/features/chat/lib/resident-config-match.ts b/studio/frontend/src/features/chat/lib/resident-config-match.tsindex 52bf70527f9..2834e824b80 100644--- a/studio/frontend/src/features/chat/lib/resident-config-match.ts+++ b/studio/frontend/src/features/chat/lib/resident-config-match.ts@@ -9,6 +9,7 @@ import {resolveTensorParallel,stripManagedOffloadFlags,} from "./llama-extra-args-normalize";+import { reconcileTensorSplit } from "@/hooks/gpu-tensor-split";import type { GpuIndexKind } from "@/hooks/gpu-selection";import type { InferenceStatusResponse } from "../types/api";@@ -105,8 +106,7 @@ export type StandingConfigDefaults = {* `_resolve_parallel_slots` stores the server-wide default as `requested_parallel_slots`, so* an unset ask is never null on the status side and comparing directly reloaded every pick. */parallelSlots: number | null;- /** `splitRatio` as the store holds it now, which is what the load sends. Never a config field:- * `applyPerModelConfigToRuntime` clears it, so any remembered config asks for the default. */+ /** Current store ratio, used only when a staged config does not state its own. */splitRatio: number[] | null;/** `normalizeSpeculativeType`, passed rather than imported: it lives on the chat runtime store,* which reaches React, and this module is a leaf so the node suite can drive it. A copy here@@ -464,29 +464,20 @@ const SETTING_CHECKS: SettingCheck[] = [},},{- // The split is placement the config cannot carry: the applier clears splitRatio, so a remembered- // config asks for the default distribution while a resident manual load may run a custom one.- //- // Judged on the mode the RESIDENT server ran, not the one this pick would send. Since- // unslothai/unsloth#10884 an auto tensor-parallel load reports a split of its own, chosen by- // the planner, and the store never holds one in auto -- applyInferenceStatusToStore nulls it- // unless the mode is manual. Comparing the two sides there compares a field the applier- // cleared against a server legitimately running the planner's ratio, and declines to adopt a- // resident model that is exactly what was asked for. A manual load's custom ratio is still a- // real disagreement, and a server too old to report its mode is still compared, so nothing- // that used to reload stops reloading.- //- // Only when the store is holding NO ratio, though. applyInferenceStatusToStore keeps- // prevState.splitRatio whenever a gpu-memory edit is pending, so a ratio set under Manual- // survives the switch to Auto, and the load path sends store.splitRatio in either mode. Since- // this PR the backend honours that ratio in auto too, so adopting on the mode alone would drop- // a placement change the user had made and the server would have applied.+ // A remembered split is dropped with its GPU pick; auto loads may report a planner split unasked.placement: true,ggufPlacement: true,pinned: () => true,- agrees: (_c, s, standing) =>- (s.gpu_memory_mode === "auto" && standing.splitRatio == null) ||- sameList(standing.splitRatio, s.tensor_split),+ agrees: (c, s, standing) => {+ const split = c.tensorSplit !== undefined+ ? reconcileTensorSplit(+ c.tensorSplit,+ c.selectedGpuIds,+ standing.reconcileGpuIds(c.selectedGpuIds ?? null, c.selectedGpuIndexKind),+ )+ : standing.splitRatio;+ return (s.gpu_memory_mode === "auto" && split == null) || sameList(split, s.tensor_split);+ },},{// A managed override the backend would reject outright. Folding it into "no override" here woulddiff --git a/studio/frontend/src/features/model-picker/api/model-overrides.ts b/studio/frontend/src/features/model-picker/api/model-overrides.tsindex 7a45374e452..e189f93c732 100644--- a/studio/frontend/src/features/model-picker/api/model-overrides.ts+++ b/studio/frontend/src/features/model-picker/api/model-overrides.ts@@ -5,6 +5,7 @@// localStorage, so an API auto-switch load came up with none of the user's settings.// routes/inference.py reads this map and rebuilds the picker's LoadRequest.+import { normalizeTensorSplit, reconcileTensorSplit } from "@/hooks/gpu-tensor-split";import { authFetch } from "@/features/auth";import type { GpuIndexKind } from "@/hooks/gpu-selection";import { readFastApiError } from "@/lib/format-fastapi-error";@@ -76,6 +77,8 @@ export interface ApiModelOverride {// biome-ignore lint/style/useNamingConvention: API scheman_cpu_moe?: number;// biome-ignore lint/style/useNamingConvention: API schema+ tensor_split?: number[] | null;+ // biome-ignore lint/style/useNamingConvention: API schemagpu_ids?: number[];// Which index space gpu_ids is in. Absent means "physical", all an older row could mean.// biome-ignore lint/style/useNamingConvention: API schema@@ -310,6 +313,14 @@ export function fromApiOverride(: local.llamaExtraArgs;// A row without ids says nothing about placement, so the local pin keeps its namespace.const serverGpuIds = override.gpu_ids?.length ? override.gpu_ids : null;+ const tensorSplit = "tensor_split" in override+ ? normalizeTensorSplit(override.tensor_split, serverGpuIds)+ : serverGpuIds+ ? (override.gpu_index_kind ?? "physical") === (local.selectedGpuIndexKind ?? "physical")+ ? reconcileTensorSplit(local.tensorSplit, local.selectedGpuIds, serverGpuIds)+ : null+ : local.tensorSplit;+// The pin is ONE setting in one of two fields, and an edit clears the other// (contextPinPatch). Filling them from different sources mints a record that loads at// two lengths, since the picker reads customContextLength first and the API's@@ -358,6 +369,7 @@ export function fromApiOverride(gpuLayers: override.gpu_layers ?? local.gpuLayers,nCpuMoe: override.n_cpu_moe ?? local.nCpuMoe,selectedGpuIds: serverGpuIds ?? local.selectedGpuIds ?? null,+ tensorSplit,// reconcileGpuSelection drops the pin if this host numbers its devices the other way.selectedGpuIndexKind: serverGpuIds? (override.gpu_index_kind ?? "physical")@@ -470,6 +482,9 @@ export function toApiOverride(config: PerModelConfig | null): ApiModelOverride {const gpuIndexKind = config.selectedGpuIndexKind ?? "physical";if (config.selectedGpuIds && config.selectedGpuIds.length > 0) {payload.gpu_ids = config.selectedGpuIds;+ const tensorSplit = normalizeTensorSplit(config.tensorSplit, config.selectedGpuIds);+ // Explicit null clears a saved split; an older client omitting it keeps its value.+ payload.tensor_split = tensorSplit;// Sent only when it is not the legacy default, so a physical pin's payload is// unchanged from before this field.if (gpuIndexKind !== "physical") {diff --git a/studio/frontend/src/features/model-picker/components/model-config-page.tsx b/studio/frontend/src/features/model-picker/components/model-config-page.tsxindex e4e0a0c984e..77fc9801c5e 100644--- a/studio/frontend/src/features/model-picker/components/model-config-page.tsx+++ b/studio/frontend/src/features/model-picker/components/model-config-page.tsx@@ -208,6 +208,7 @@ import {import { ChatTemplateEditorDialog } from "./chat-template-editor-dialog";import { MemoryEstimateRow } from "./memory-estimate-row";import type { ModelPickTarget } from "./model-selector/types";+import { reconcileTensorSplit } from "@/hooks/gpu-tensor-split";import {NumericValueInput,type NumericValueInputHandle,@@ -346,6 +347,7 @@ function withoutUnsupportedDiffusionSettings((config.gpuMemoryMode ?? "auto") === "auto" &&config.gpuLayers == null &&config.nCpuMoe == null &&+ config.tensorSplit == null &&config.reasoningBudget === -1 &&config.reasoningBudgetMessage === "" &&!config.tensorParallel &&@@ -362,6 +364,7 @@ function withoutUnsupportedDiffusionSettings(gpuMemoryMode: "auto",gpuLayers: undefined,nCpuMoe: undefined,+ tensorSplit: null,reasoningBudget: -1,reasoningBudgetMessage: "",tensorParallel: false,@@ -403,6 +406,7 @@ function reconcileConfigGpuSelection(const next = {...supported,selectedGpuIds: reconciled.ids ?? undefined,+ tensorSplit: reconcileTensorSplit(supported.tensorSplit, supported.selectedGpuIds, reconciled.ids),selectedGpuIndexKind:reconciled.ids === null ? undefined : reconciled.indexKind,};@@ -855,7 +859,12 @@ function GpuMemorySettings({const setSplitShare = (id: number, value: number) => {const k = orderedGpuIds.indexOf(id);if (k < 0) return;- update({ tensorSplit: rebalanceSplit(splitScale, splitShares, k, value) });+ update({+ // Bind even an all-GPU split to the exact ordered set before it can be saved.+ selectedGpuIds: [...orderedGpuIds],+ selectedGpuIndexKind: gpuIndexKind,+ tensorSplit: rebalanceSplit(splitScale, splitShares, k, value),+ });};const commitGpuIds = (next: number[], nextSplit: number[] | null = null) => {if (next.length === 0) return; // keep at least one GPU selecteddiff --git a/studio/frontend/src/features/model-picker/model-config/apply-per-model-config.ts b/studio/frontend/src/features/model-picker/model-config/apply-per-model-config.tsindex b9a367368c9..f13223e8e61 100644--- a/studio/frontend/src/features/model-picker/model-config/apply-per-model-config.ts+++ b/studio/frontend/src/features/model-picker/model-config/apply-per-model-config.ts@@ -9,6 +9,7 @@ import {reconcilePersistedGpuSelection,useChatRuntimeStore,} from "@/features/chat/stores/chat-runtime-store";+import { reconcileTensorSplit } from "@/hooks/gpu-tensor-split";import { defaultInferenceParams } from "@/features/chat/presets/preset-policy";// Its own module so hosts needing only the signature skip the chat runtime store.import { gpuFieldsSignature } from "./config-signature";@@ -24,16 +25,6 @@ function cleanTemplate(value: string | null | undefined): string | null {return value?.trim() ? value : null;}-function cleanTensorSplit(value: number[] | null | undefined): number[] | null {- if (!value || value.length < 2) {- return null;- }- if (!value.every((v) => Number.isFinite(v) && v >= 0)) {- return null;- }- return value.some((v) => v > 0) ? value : null;-}-export function applyPerModelConfigToRuntime(config: PerModelConfig,options: { isDiffusion?: boolean } = {},@@ -96,8 +87,8 @@ export function applyPerModelConfigToRuntime(: (config.disableVision ?? false),chatTemplateOverride: cleanTemplate(config.chatTemplateOverride),// GPU Memory knobs are per-model (GGUF-only). Absent = defaults; the mode is a standing- // preference so an absent mode falls back to the persisted one. The per-GPU split is never- // stored. The GPU pick is reconciled against the GPUs present now. A diffusion+ // preference so an absent mode falls back to the persisted one. The per-GPU split is restored+ // only when the ordered GPU pick survives reconciliation. A diffusion// config is sanitized to gpuMemoryMode "auto" because the mode does not apply, not because// the user chose Auto: writing that into the live standing preference would strand the session// on Auto, since the load skips saveGpuMemoryMode for diffusion and the next ordinary GGUF@@ -107,7 +98,9 @@ export function applyPerModelConfigToRuntime(: (config.gpuMemoryMode ?? readPersistedGpuMemoryMode()),gpuLayers: config.gpuLayers ?? GPU_LAYERS_AUTO,nCpuMoe: config.nCpuMoe ?? 0,- splitRatio: options.isDiffusion ? null : cleanTensorSplit(config.tensorSplit),+ splitRatio: options.isDiffusion+ ? null+ : reconcileTensorSplit(config.tensorSplit, config.selectedGpuIds, gpuSelection.ids),selectedGpuIds: gpuSelection.ids,selectedGpuIndexKind: gpuSelection.indexKind,});@@ -158,7 +151,7 @@ export function currentRuntimePerModelConfig(disableVision: s.disableVision ?? false,chatTemplateOverride: cleanTemplate(s.chatTemplateOverride),// Snapshot the live GPU knobs too so a failed switch rolls the previous model's GPU Memory- // settings back, split included (never stored).+ // settings back, split included.gpuMemoryMode: s.gpuMemoryMode,gpuLayers: s.gpuLayers,nCpuMoe: s.nCpuMoe,diff --git a/studio/frontend/src/features/model-picker/model-config/per-model-config.ts b/studio/frontend/src/features/model-picker/model-config/per-model-config.tsindex a9b8ee4972c..63ff51aea6a 100644--- a/studio/frontend/src/features/model-picker/model-config/per-model-config.ts+++ b/studio/frontend/src/features/model-picker/model-config/per-model-config.ts@@ -1,6 +1,7 @@// SPDX-License-Identifier: AGPL-3.0-only// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0+import { normalizeTensorSplit } from "@/hooks/gpu-tensor-split";import type { GpuIndexKind } from "@/hooks/use-gpu-info";import {cachedRepoConfigId,@@ -61,7 +62,7 @@ export interface PerModelConfig {nCpuMoe?: number;selectedGpuIds?: number[] | null;selectedGpuIndexKind?: GpuIndexKind | null;- /** --tensor-split in picker order, never stored. `undefined` defers to the store, `null` = default. */+ /** --tensor-split bound to selectedGpuIds in picker order. `undefined` defers to the store, `null` = default. */tensorSplit?: number[] | null;}@@ -389,9 +390,10 @@ const LEGACY_MIGRATION_FLAG = "unsloth_model_configs_migrated";// would normalize the unknown field straight back out of the record.// v2 added nBatch/nUbatch, v3 llamaExtraArgs, v4 disableVision, v5 the llama-server tuning group// (loadMode / specDraftCacheDtype / ctxCheckpoints / cacheRam), v6 the reasoning budget pair,-// v7 mlxKvQuant, v9 mlxInt8Prefill. v8 is skipped: nightly builds stamped it for the reverted custom+// v7 mlxKvQuant, v9 mlxInt8Prefill, v10 the per-GPU split. v8 is skipped: nightly builds stamped it for the reverted custom// llama.cpp config (#12725), so a v8 client must not claim to understand an int8 prefill record.-const STORAGE_SCHEMA_VERSION = 9;+const STORAGE_SCHEMA_VERSION = 10;+const PRE_TENSOR_SPLIT_SCHEMA_VERSION = 9;const PRE_MLX_INT8_PREFILL_SCHEMA_VERSION = 7;const PRE_MLX_KV_QUANT_SCHEMA_VERSION = 6;const PRE_REASONING_BUDGET_SCHEMA_VERSION = 5;@@ -455,6 +457,7 @@ const STORED_CONFIG_FIELDS = new Set(["nCpuMoe","selectedGpuIds","selectedGpuIndexKind",+ "tensorSplit",]);/** Keep only a list of strings, preserving the three states above. Anything that is not an array is "not loaded"@@ -1101,6 +1104,7 @@ function normalizeV1(partial: RawConfig): PerModelConfig {: null,llamaExtraArgs: normalizeLlamaExtraArgs(partial.llamaExtraArgs),...normalizeGpuFields(partial),+ tensorSplit: normalizeTensorSplit(partial.tensorSplit, partial.selectedGpuIds),};}@@ -1128,9 +1132,12 @@ function normalize(raw: unknown): PerModelConfig {* client reconstructs anyway, and stamping every record v4 would put the whole store out of reach.* The tuning group and the reasoning pair follow the same rule. */function storedSchemaVersion(normalized: PerModelConfig): number {- if (normalized.mlxInt8Prefill) {+ if (normalized.tensorSplit != null) {return STORAGE_SCHEMA_VERSION;}+ if (normalized.mlxInt8Prefill) {+ return PRE_TENSOR_SPLIT_SCHEMA_VERSION;+ }if (normalized.mlxKvQuant != null) {return PRE_MLX_INT8_PREFILL_SCHEMA_VERSION;}@@ -1344,7 +1351,8 @@ function gpuFieldsAtDefault(config: PerModelConfig): boolean {(config.gpuMemoryMode ?? "auto") === "auto" &&(config.gpuLayers == null || config.gpuLayers < 0) &&(config.nCpuMoe == null || config.nCpuMoe === 0) &&- config.selectedGpuIds == null+ config.selectedGpuIds == null &&+ config.tensorSplit == null);}diff --git a/studio/frontend/src/hooks/gpu-tensor-split.ts b/studio/frontend/src/hooks/gpu-tensor-split.tsnew file mode 100644index 00000000000..de431f2f624--- /dev/null+++ b/studio/frontend/src/hooks/gpu-tensor-split.ts@@ -0,0 +1,51 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++/** A positional ratio is only reusable with the ordered GPU IDs it was written for. */+export function normalizeTensorSplit(+ value: unknown,+ gpuIds: number[] | null | undefined,+): number[] | null {+ if (+ !Array.isArray(value) ||+ !gpuIds ||+ gpuIds.length < 2 ||+ value.length !== gpuIds.length+ )+ return null;+ if (+ !gpuIds.every((id) => Number.isInteger(id) && id >= 0) ||+ new Set(gpuIds).size !== gpuIds.length+ )+ return null;+ if (+ !value.every(+ (weight) =>+ typeof weight === "number" && Number.isFinite(weight) && weight >= 0,+ )+ )+ return null;+ const total = value.reduce((sum, weight) => sum + weight, 0);+ return Number.isFinite(total) && total > 0 ? [...value] : null;+}++export function reconcileTensorSplit(+ value: unknown,+ savedIds: number[] | null | undefined,+ resolvedIds: number[] | null | undefined,+): number[] | null {+ // Unpinned on both sides: the ratio spans every visible GPU, as a resident unpinned manual load reports it.+ if (savedIds == null && resolvedIds == null) {+ return Array.isArray(value)+ ? normalizeTensorSplit(value, value.map((_, index) => index))+ : null;+ }+ if (+ !savedIds ||+ !resolvedIds ||+ savedIds.length !== resolvedIds.length ||+ !savedIds.every((id, index) => id === resolvedIds[index])+ )+ return null;+ return normalizeTensorSplit(value, savedIds);+}diff --git a/studio/frontend/tests/active-model-baseline.test.ts b/studio/frontend/tests/active-model-baseline.test.tsindex ace723ff696..e3632b5b982 100644--- a/studio/frontend/tests/active-model-baseline.test.ts+++ b/studio/frontend/tests/active-model-baseline.test.ts@@ -5,6 +5,7 @@ import assert from "node:assert/strict";import test from "node:test";import type { ActiveModelConfigState } from "../src/features/model-picker/hooks/use-active-model-config.ts";import type { PerModelConfig } from "../src/features/model-picker/model-config/per-model-config.ts";+import * as gpuTensorSplit from "../src/hooks/gpu-tensor-split.ts";import { loadWithStubs } from "./helpers/module-stubs.ts";function useActiveConfigFor(patch: Record<string, unknown>, gguf = true) {@@ -60,6 +61,7 @@ function configsEqual(persistedMode: string) {readPersistedSpeculativeType: () => persistedMode,},"@/features/chat/presets/preset-policy": {},+ "@/hooks/gpu-tensor-split": gpuTensorSplit,"./config-signature": { gpuFieldsSignature: () => "" },"./per-model-config": {normalizeMaxSeqLength: (value: number | null | undefined) =>diff --git a/studio/frontend/tests/active-reasoning-intent.test.ts b/studio/frontend/tests/active-reasoning-intent.test.tsindex 98ecd8f1053..dc5f7cee8a8 100644--- a/studio/frontend/tests/active-reasoning-intent.test.ts+++ b/studio/frontend/tests/active-reasoning-intent.test.ts@@ -4,6 +4,7 @@import assert from "node:assert/strict";import test from "node:test";import type { ActiveModelConfigState } from "../src/features/model-picker/hooks/use-active-model-config.ts";+import * as gpuTensorSplit from "../src/hooks/gpu-tensor-split.ts";import { loadWithStubs } from "./helpers/module-stubs.ts";function activeConfig(patch: Record<string, unknown> = {}) {@@ -60,6 +61,7 @@ function activeConfig(patch: Record<string, unknown> = {}) {"@/features/chat/presets/preset-policy": {},"./config-signature": {},"./per-model-config": {},+ "@/hooks/gpu-tensor-split": gpuTensorSplit,},);const snapshot = currentRuntimePerModelConfig();diff --git a/studio/frontend/tests/gpu-tensor-split-persistence.test.ts b/studio/frontend/tests/gpu-tensor-split-persistence.test.tsnew file mode 100644index 00000000000..0199c5b410e--- /dev/null+++ b/studio/frontend/tests/gpu-tensor-split-persistence.test.ts@@ -0,0 +1,196 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import assert from "node:assert/strict";+import test from "node:test";+import {+ installLocalStorageFake,+ registerStoreStubResolver,+} from "./helpers/kit.ts";++registerStoreStubResolver();+const { store } = installLocalStorageFake();+const {+ DEFAULT_PER_MODEL_CONFIG,+ normalizePerModelConfig,+ resolveInitialConfig,+ savePerModelConfig,+} = await import(+ "../src/features/model-picker/model-config/per-model-config.ts"+);+const { fromApiOverride, toApiOverride } = await import(+ "../src/features/model-picker/api/model-overrides.ts"+);++const MODEL = "unsloth/split-GGUF";+const VARIANT = "Q4_K_M";+const configured = () => ({+ ...DEFAULT_PER_MODEL_CONFIG,+ gpuMemoryMode: "manual" as const,+ gpuLayers: 66,+ selectedGpuIds: [1, 2, 0],+ selectedGpuIndexKind: "physical" as const,+ tensorSplit: [30, 20, 16],+});++test("saving and reopening keeps the split in GPU order", () => {+ store.clear();+ assert.equal(savePerModelConfig(MODEL, VARIANT, configured()), true);+ const restored = resolveInitialConfig(MODEL, VARIANT);+ assert.equal(restored.remembered, true);+ assert.deepEqual(restored.config.selectedGpuIds, [1, 2, 0]);+ assert.deepEqual(restored.config.tensorSplit, [30, 20, 16]);+ assert.equal(restored.config.gpuLayers, 66);+});++test("a stored split is protected from clients that do not understand it", () => {+ store.clear();+ savePerModelConfig(MODEL, VARIANT, configured());+ const [entry] = Object.values(+ JSON.parse(store.get("unsloth_model_configs")!),+ ) as { version: number }[];+ assert.ok(entry.version > 9);+ store.clear();+ savePerModelConfig(MODEL, VARIANT, { ...configured(), tensorSplit: null });+ const [withoutSplit] = Object.values(+ JSON.parse(store.get("unsloth_model_configs")!),+ ) as { version: number }[];+ assert.equal(withoutSplit.version, 1);+});++test("the API mirror preserves the ratio and GPU order", () => {+ const payload = toApiOverride(configured());+ assert.deepEqual(payload.gpu_ids, [1, 2, 0]);+ assert.deepEqual(+ (payload as Record<string, unknown>).tensor_split,+ [30, 20, 16],+ );+ assert.deepEqual(fromApiOverride(payload).tensorSplit, [30, 20, 16]);+});++test("hydration never attaches a local ratio to another server GPU order", () => {+ const local = configured();+ const restored = fromApiOverride({ gpu_ids: [0, 1, 2] }, local);+ assert.deepEqual(restored.selectedGpuIds, [0, 1, 2]);+ assert.equal(restored.tensorSplit ?? null, null);+ assert.deepEqual(fromApiOverride({}, local).tensorSplit, local.tensorSplit);+ assert.equal(+ fromApiOverride({ gpu_ids: [1, 2, 0], tensor_split: null }, local)+ .tensorSplit,+ null,+ );+ assert.equal(+ fromApiOverride({ gpu_ids: [1, 2, 0], gpu_index_kind: "vulkan" }, local)+ .tensorSplit,+ null,+ );+});++test("a server ratio cannot attach to unrelated local GPU IDs", () => {+ assert.equal(+ fromApiOverride({ tensor_split: [3, 2, 1] }, configured()).tensorSplit,+ null,+ );+ assert.equal(+ fromApiOverride({ tensor_split: null }, configured()).tensorSplit,+ null,+ );+});++test("default and malformed ratios are not persisted", () => {+ for (const tensorSplit of [+ null,+ [],+ [0, 0, 0],+ [-1, 20, 47],+ [NaN, 20, 16],+ [Infinity, 20, 16],+ [30, 36],+ [Number.MAX_VALUE, Number.MAX_VALUE, 1],+ ]) {+ assert.equal(+ normalizePerModelConfig({ ...configured(), tensorSplit }).tensorSplit ??+ null,+ null,+ );+ }+ for (const selectedGpuIds of [+ null,+ undefined,+ [1, 1, 0],+ [1.5, 2, 0],+ [-1, 2, 0],+ ]) {+ assert.equal(+ normalizePerModelConfig({ ...configured(), selectedGpuIds })+ .tensorSplit ?? null,+ null,+ );+ }+});++test("zero shares and fractional ratios survive storage", () => {+ store.clear();+ const value = { ...configured(), tensorSplit: [0, 2.5, 1] };+ savePerModelConfig(MODEL, VARIANT, value);+ assert.deepEqual(+ resolveInitialConfig(MODEL, VARIANT).config.tensorSplit,+ value.tensorSplit,+ );+});++test("clearing the ratio removes it from the next saved config", () => {+ store.clear();+ savePerModelConfig(MODEL, VARIANT, configured());+ savePerModelConfig(MODEL, VARIANT, { ...configured(), tensorSplit: null });+ assert.equal(+ resolveInitialConfig(MODEL, VARIANT).config.tensorSplit ?? null,+ null,+ );+ assert.equal(+ toApiOverride({ ...configured(), tensorSplit: null }).tensor_split,+ null,+ );+});++test("a removed GPU, changed order, or backend namespace discards the saved split", async () => {+ const { reconcileTensorSplit } = await import(+ "../src/hooks/gpu-tensor-split.ts"+ );+ const { reconcileGpuSelection } = await import(+ "../src/hooks/gpu-selection.ts"+ );+ const value = configured();+ const savedIds = value.selectedGpuIds;+ assert.deepEqual(+ reconcileTensorSplit(value.tensorSplit, savedIds, savedIds),+ value.tensorSplit,+ );+ for (const current of [null, [1, 2], [0, 1, 2]]) {+ assert.equal(+ reconcileTensorSplit(value.tensorSplit, savedIds, current),+ null,+ );+ }+ const otherBackend = reconcileGpuSelection(+ savedIds,+ "physical",+ "vulkan",+ savedIds,+ );+ assert.equal(+ reconcileTensorSplit(value.tensorSplit, savedIds, otherBackend.ids),+ null,+ );+});++test("an unpinned split survives a reload that stays unpinned", async () => {+ const { reconcileTensorSplit } = await import(+ "../src/hooks/gpu-tensor-split.ts"+ );+ assert.deepEqual(reconcileTensorSplit([3, 1], null, null), [3, 1]);+ assert.deepEqual(reconcileTensorSplit([3, 1], undefined, null), [3, 1]);+ assert.equal(reconcileTensorSplit([3, 1], null, [0, 1]), null);+ assert.equal(reconcileTensorSplit([0, 0], null, null), null);+ assert.equal(reconcileTensorSplit([3], null, null), null);+});diff --git a/studio/frontend/tests/gpu-tensor-split.test.ts b/studio/frontend/tests/gpu-tensor-split.test.tsindex d3f560b2880..82650431afa 100644--- a/studio/frontend/tests/gpu-tensor-split.test.ts+++ b/studio/frontend/tests/gpu-tensor-split.test.ts@@ -41,15 +41,6 @@ test("no split, whether unset or cleared, reads as the default distribution", as);});-test("the split is never stored with the model's config", () => {- const src = readSrc("features/model-picker/model-config/per-model-config.ts");- const stored = src.slice(- src.indexOf("const STORED_CONFIG_FIELDS"),- src.indexOf("]);", src.indexOf("const STORED_CONFIG_FIELDS")),- );- assert.doesNotMatch(stored, /tensorSplit/);-});-test("the picker drops the split when the set changes and carries it on a reorder", () => {const src = readSrc("features/model-picker/components/model-config-page.tsx");const commit = src.slice(src.indexOf("const commitGpuIds"));@@ -81,11 +72,11 @@ test("the load sends the editor's split, and the dedupe compares it", () => {src,/let loadSplitRatio =\s*pendingLoadConfig\?\.tensorSplit !== undefined\s*\? pendingLoadConfig\.tensorSplit/,);- assert.match(src, /loadSplitRatio = pendingLoadConfig\?\.tensorSplit \?\? null;/);+ assert.match(src, /loadSplitRatio = reconcileTensorSplit\(/);assert.match(src,/splitRatio:\s*pendingConfig\?\.tensorSplit !== undefined\s*\? pendingConfig\.tensorSplit/,);const apply = readSrc("features/model-picker/model-config/apply-per-model-config.ts");- assert.match(apply, /splitRatio: options\.isDiffusion \? null : cleanTensorSplit\(config\.tensorSplit\)/);+ assert.match(apply, /reconcileTensorSplit\(config\.tensorSplit, config\.selectedGpuIds, gpuSelection\.ids\)/);});diff --git a/studio/frontend/tests/mlx-context-pin-record-compat.test.ts b/studio/frontend/tests/mlx-context-pin-record-compat.test.tsindex ac02ba4eea3..35f71c60b34 100644--- a/studio/frontend/tests/mlx-context-pin-record-compat.test.ts+++ b/studio/frontend/tests/mlx-context-pin-record-compat.test.ts@@ -208,8 +208,8 @@ const ROWS: Row[] = ["and reads normally.",},{- name: "version 10 (genuinely future)",- raw: { version: 10, customContextLength: 32768 },+ name: "version 11 (genuinely future)",+ raw: { version: 11, customContextLength: 32768 },normalizedPin: null,rawPin: 32768,isDefault: true,@@ -330,7 +330,7 @@ test("a patched pin round-trips through storage on both backends", () => {test("both pin shapes are stamped version 1, so neither is distinguishable by version", () => {assert.equal(stampedVersion({ customContextLength: 32768 }), 1);assert.equal(stampedVersion({ maxSeqLength: 32768 }), 1);- // The current client's forwards guard is `version > 9`, and v1 invites any client+ // The current client's forwards guard is `version > 10`, and v1 invites any client// back to v1 to rewrite the record.assert.equal(stage({ version: 1, customContextLength: 32768 }).remembered,@@ -354,6 +354,10 @@ test("both pin shapes are stamped version 1, so neither is distinguishable by ve);assert.equal(stage({ version: 10, customContextLength: 32768 }).remembered,+ true,+ );+ assert.equal(+ stage({ version: 11, customContextLength: 32768 }).remembered,false,);});diff --git a/studio/frontend/tests/resident-config-match.test.ts b/studio/frontend/tests/resident-config-match.test.tsindex 9724c9ab4d4..f1788aa6fe7 100644--- a/studio/frontend/tests/resident-config-match.test.ts+++ b/studio/frontend/tests/resident-config-match.test.ts@@ -2025,3 +2025,31 @@ test("reloading one of several stays in its own slot; a new pick with the settinassert.doesNotMatch(USE_CHAT_MODEL_RUNTIME, /replacesOneOfSeveral/);assert.match(USE_CHAT_MODEL_RUNTIME, /const touchesOnlySelected =\s*forceReload &&/);});+++test("a remembered split matches the resident without relying on another model's store ratio", () => {+ const config = {+ ...BLANK,+ gpuMemoryMode: "manual" as const,+ gpuLayers: 66,+ selectedGpuIds: [1, 2, 0],+ selectedGpuIndexKind: "physical" as const,+ tensorSplit: [30, 20, 16],+ };+ const running = {+ ...DEFAULTS,+ gpu_memory_mode: "manual" as const,+ gpu_layers: 66,+ gpu_ids: [1, 2, 0],+ requested_gpu_ids: [1, 2, 0],+ tensor_split: [30, 20, 16],+ };+ assert.equal(matches(running, config), true);+ assert.equal(matches({ ...running, tensor_split: [22, 22, 22] }, config), false);+ assert.equal(matches(running, { ...config, tensorSplit: null }), false);+ assert.equal(matches(+ { ...running, gpu_ids: null, requested_gpu_ids: null, tensor_split: null },+ config,+ { ...STANDING, reconcileGpuIds: () => null },+ ), true);+});diff --git a/studio/frontend/tests/server-tuning-settings.test.ts b/studio/frontend/tests/server-tuning-settings.test.tsindex d7b6b79d66c..204ffad93df 100644--- a/studio/frontend/tests/server-tuning-settings.test.ts+++ b/studio/frontend/tests/server-tuning-settings.test.ts@@ -113,14 +113,15 @@ test("a record only claims the new schema version when it carries one", () => {// toStoredConfig stamps the OLDEST version that understands every field// present, so an older client can still rewrite a record it fully knows.const source = readSrc("features/model-picker/model-config/per-model-config.ts");- assert.match(source, /const STORAGE_SCHEMA_VERSION = 9;/);+ assert.match(source, /const STORAGE_SCHEMA_VERSION = 10;/);+ assert.match(source, /const PRE_TENSOR_SPLIT_SCHEMA_VERSION = 9;/);assert.match(source, /const PRE_MLX_INT8_PREFILL_SCHEMA_VERSION = 7;/);assert.match(source, /const PRE_MLX_KV_QUANT_SCHEMA_VERSION = 6;/);assert.match(source, /const PRE_REASONING_BUDGET_SCHEMA_VERSION = 5;/);assert.match(source, /const PRE_SERVER_TUNING_SCHEMA_VERSION = 4;/);assert.match(source,- /normalized\.mlxInt8Prefill\)\s*\{\s*return STORAGE_SCHEMA_VERSION;/,+ /normalized\.mlxInt8Prefill\)\s*\{\s*return PRE_TENSOR_SPLIT_SCHEMA_VERSION;/,);assert.match(source,diff --git a/studio/frontend/tests/switch-validate-gpu-ids.test.ts b/studio/frontend/tests/switch-validate-gpu-ids.test.tsindex bd9c587479a..b944b0d75da 100644--- a/studio/frontend/tests/switch-validate-gpu-ids.test.ts+++ b/studio/frontend/tests/switch-validate-gpu-ids.test.ts@@ -18,7 +18,9 @@ const pick = new Function("targetIsDiffusion","reconcilePersistedGpuIds","resetsPerModelSettings",- `${slice("const stagedGpuIds =", "let loadSpeculativeType")}+ "reconcileTensorSplit",+ `let loadSplitRatio = null;+ ${slice("const stagedGpuIds =", "let loadSpeculativeType")}${slice("const validateGpuIds =", "// The reset below")}if (resetsPerModelSettings) {${slice("loadSelectedGpuIds = stagedGpuIds;", "loadGpuLayers =")}@@ -42,6 +44,7 @@ test("a switch validates the GPUs the load will use", () => {false,reconcile,resets,+ () => null,);assert.deepEqual(validateGpuIds, loadSelectedGpuIds, JSON.stringify([pending, resets]));}