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: stop the KV cache type following the last model to the next one (#15819)
Nilay1f5d2580839b
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 48fd257f8e7..d7e44bbc1fd 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@@ -1519,7 +1519,6 @@ export function useChatModelRuntime() {(resetsPerModelSettings? {...DEFAULT_PER_MODEL_CONFIG,- kvCacheDtype: live.kvCacheDtype ?? null,tensorParallel: live.tensorParallel ?? false,gpuMemoryMode: live.gpuMemoryMode,}@@ -2051,7 +2050,7 @@ export function useChatModelRuntime() {pendingLoadConfig?.chatTemplateOverride?.trim()? pendingLoadConfig.chatTemplateOverride: stateBeforeUnload.chatTemplateOverride;- const loadKvCacheDtype =+ let loadKvCacheDtype =pendingLoadConfig?.kvCacheDtype ?? stateBeforeUnload.kvCacheDtype;let loadMlxKvQuant =pendingLoadConfig@@ -2230,6 +2229,7 @@ export function useChatModelRuntime() {ctxCheckpoints: pendingLoadConfig?.ctxCheckpoints ?? null,cacheRam: pendingLoadConfig?.cacheRam ?? null,};+ loadKvCacheDtype = pendingLoadConfig?.kvCacheDtype ?? null;loadMlxKvQuant = pendingLoadConfig?.mlxKvQuant ?? null;loadMlxInt8Prefill = pendingLoadConfig?.mlxInt8Prefill ?? false;loadMlxPleOffload = pendingLoadConfig?.mlxPleOffload ?? null;diff --git a/studio/frontend/tests/model-switch-kv-cache-type.test.ts b/studio/frontend/tests/model-switch-kv-cache-type.test.tsnew file mode 100644index 00000000000..46a4bfe9a26--- /dev/null+++ b/studio/frontend/tests/model-switch-kv-cache-type.test.ts@@ -0,0 +1,29 @@+// 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 { readFileSync } from "node:fs";+import test from "node:test";+import { fileURLToPath } from "node:url";++const RUNTIME = readFileSync(+ fileURLToPath(new URL("../src/features/chat/hooks/use-chat-model-runtime.ts", import.meta.url)),+ "utf8",+);+const section = (start: string, end: string) => {+ const from = RUNTIME.indexOf(start);+ assert.notEqual(from, -1, `expected to find ${start}`);+ const to = RUNTIME.indexOf(end, from + start.length);+ assert.notEqual(to, -1, `expected to find ${end} after ${start}`);+ return RUNTIME.slice(from, to);+};++test("switching to a model with no saved settings loads it with the default KV cache type", () => {+ const reset = section("if (resetsPerModelSettings) {\n loadSpeculativeType =", "\n }\n");+ assert.match(reset, /loadKvCacheDtype = pendingLoadConfig\?\.kvCacheDtype \?\? null;/);+});++test("the already-loaded check compares a switch against the default KV cache type", () => {+ const mirror = section("const comparedConfig =", ": currentRuntimePerModelConfig());");+ assert.doesNotMatch(mirror, /kvCacheDtype/);+});