Skip to content

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.

Unsloth Studio: explain why Model Memory skips the RAM lock when a model is fully on the GPU (#9571)

Daniel Han03ecc3be4f97
diff --git a/studio/backend/routes/settings.py b/studio/backend/routes/settings.py
index cf91d5b0639..5a2e7185627 100644
--- a/studio/backend/routes/settings.py
+++ b/studio/backend/routes/settings.py
@@ -756,6 +756,9 @@ class ModelMemoryResponse(BaseModel):
# Whether --mlock is passed on the next load. False when no_ram_reserve
# vetoes it; the UI surfaces that rather than failing silently.
mlock_active: bool
+ # False when the running llama.cpp child has no host copy to lock (full offload to a discrete GPU),
+ # so a keep-resident user is told why no lock is taken. True with nothing loaded.
+ mlock_applicable: bool = True
reload_required: bool
# Soft RLIMIT_MEMLOCK when finite. mlock cannot exceed it, so the UI warns that residency will not
# fully pin a larger model. None means unlimited (macOS) or not applicable (Windows).
@@ -1169,6 +1172,13 @@ def _model_memory_mlock_active(want_mlock: bool) -> bool:
return bool(state and state[0])
+def _model_memory_mlock_applicable() -> bool:
+ state, _policy_active, applicable, _direct_io, _dio_applicable, _dio_managed, _pending = (
+ _active_launch_placement()
+ )
+ return state is _NO_LAUNCH or bool(applicable)
+
+
def _model_memory_response() -> ModelMemoryResponse:
keep_resident, no_ram_reserve = get_model_memory_settings()
mlock_active = _model_memory_mlock_active(should_mlock())
@@ -1176,6 +1186,7 @@ def _model_memory_response() -> ModelMemoryResponse:
keep_resident = keep_resident,
no_ram_reserve = no_ram_reserve,
mlock_active = mlock_active,
+ mlock_applicable = _model_memory_mlock_applicable(),
reload_required = _model_memory_reload_required(),
memlock_limit_bytes = memlock_limit_bytes() if mlock_active else None,
)
diff --git a/studio/backend/tests/test_model_memory_settings.py b/studio/backend/tests/test_model_memory_settings.py
index 5fe558a5c59..5add3f76d38 100644
--- a/studio/backend/tests/test_model_memory_settings.py
+++ b/studio/backend/tests/test_model_memory_settings.py
@@ -1039,6 +1039,27 @@ class TestMlockActiveReflectsWhatWillActuallyBePassed:
},
)()
+ def test_a_discrete_full_offload_reports_not_applicable(self, monkeypatch):
+ backend = self._backend(True, False, state = (False, True))
+ resp = self._response(True, False, backend, monkeypatch)
+ assert resp.mlock_applicable is False
+ assert resp.mlock_active is False
+ assert resp.reload_required is False
+
+ def test_a_host_resident_load_reports_applicable(self, monkeypatch):
+ resp = self._response(True, False, self._backend(True, True), monkeypatch)
+ assert resp.mlock_applicable is True
+ assert resp.mlock_active is True
+
+ def test_nothing_loaded_reports_applicable(self, monkeypatch):
+ resp = self._response(True, False, self._backend(False, False), monkeypatch)
+ assert resp.mlock_applicable is True
+
+ def test_applicability_is_reported_with_residency_off(self, monkeypatch):
+ resp = self._response(False, False, self._backend(True, False), monkeypatch)
+ assert resp.mlock_applicable is False
+ assert resp.mlock_active is False
+
def test_a_gated_load_reports_no_active_lock_and_no_limit(self, monkeypatch):
resp = self._response(True, False, self._backend(True, False), monkeypatch)
assert resp.mlock_active is False
diff --git a/studio/frontend/src/features/settings/api/model-memory.ts b/studio/frontend/src/features/settings/api/model-memory.ts
index c24fde9a092..2735304ffd2 100644
--- a/studio/frontend/src/features/settings/api/model-memory.ts
+++ b/studio/frontend/src/features/settings/api/model-memory.ts
@@ -16,6 +16,8 @@ export type ModelMemorySettings = {
defaultNoRamReserve: boolean;
/** Whether --mlock applies; false when noRamReserve vetoes it. */
mlockActive: boolean;
+ /** False when the loaded model is fully on a discrete GPU, so there is nothing in host RAM to lock. */
+ mlockApplicable: boolean;
/** A model is loaded whose --mlock state differs from the saved one. */
reloadRequired: boolean;
/** Soft RLIMIT_MEMLOCK when finite; null means unlimited or N/A. */
@@ -34,6 +36,8 @@ type ApiModelMemorySettings = {
// biome-ignore lint/style/useNamingConvention: API schema
mlock_active: boolean;
// biome-ignore lint/style/useNamingConvention: API schema
+ mlock_applicable?: boolean;
+ // biome-ignore lint/style/useNamingConvention: API schema
reload_required: boolean;
// biome-ignore lint/style/useNamingConvention: API schema
memlock_limit_bytes: number | null;
@@ -61,6 +65,8 @@ function fromApi(settings: ApiModelMemorySettings): ModelMemorySettings {
defaultKeepResident: settings.default_keep_resident,
defaultNoRamReserve: settings.default_no_ram_reserve,
mlockActive: settings.mlock_active,
+ // Absent from an older backend: keep today's behaviour rather than claim nothing is lockable.
+ mlockApplicable: settings.mlock_applicable ?? true,
reloadRequired: settings.reload_required,
memlockLimitBytes: settings.memlock_limit_bytes,
};
diff --git a/studio/frontend/src/features/settings/components/model-memory-section.tsx b/studio/frontend/src/features/settings/components/model-memory-section.tsx
index dd54ca5d710..1c00cd09580 100644
--- a/studio/frontend/src/features/settings/components/model-memory-section.tsx
+++ b/studio/frontend/src/features/settings/components/model-memory-section.tsx
@@ -4,7 +4,8 @@
import { Switch } from "@/components/ui/switch";
import { formatBytes } from "@/features/hub/lib/format";
import { useT } from "@/i18n";
-import { useEffect, useState } from "react";
+import { subscribeModelLifecycle } from "@/lib/model-lifecycle-events";
+import { useEffect, useRef, useState } from "react";
import {
type ModelMemorySettings,
loadModelMemorySettings,
@@ -13,30 +14,74 @@ import {
import { SettingsRow } from "./settings-row";
import { SettingsSection } from "./settings-section";
+// Residency asked for, but the loaded model has no copy in system RAM to lock.
+function MlockNotApplicableNote({
+ settings,
+}: { settings: ModelMemorySettings | null }) {
+ const t = useT();
+ if (
+ !settings?.keepResident ||
+ settings.noRamReserve ||
+ settings.mlockActive ||
+ settings.mlockApplicable
+ ) {
+ return null;
+ }
+ return (
+ <p className="pb-1 text-xs text-muted-foreground">
+ {t("settings.resources.modelMemory.mlockNotApplicable")}
+ </p>
+ );
+}
+
+// Forced: the response describes the running model, which may have changed since the last read.
+async function refreshModelMemory(
+ isCancelled: () => boolean,
+ setSettings: (settings: ModelMemorySettings) => void,
+ setError: (error: string | null) => void,
+ fallbackError: string,
+): Promise<void> {
+ try {
+ const loaded = await loadModelMemorySettings({ force: true });
+ if (!isCancelled()) {
+ setSettings(loaded);
+ setError(null);
+ }
+ } catch (loadError) {
+ if (!isCancelled()) {
+ setError(loadError instanceof Error ? loadError.message : fallbackError);
+ }
+ }
+}
+
export function ModelMemorySection() {
const t = useT();
const [settings, setSettings] = useState<ModelMemorySettings | null>(null);
const [error, setError] = useState<string | null>(null);
const [isSaving, setIsSaving] = useState(false);
+ // Bumped by every refresh and save: a read that resolves after either no longer describes the panel.
+ const latestRef = useRef(0);
useEffect(() => {
let cancelled = false;
- void loadModelMemorySettings()
- .then((loaded) => {
- if (cancelled) return;
- setSettings(loaded);
- setError(null);
- })
- .catch((loadError) => {
- if (cancelled) return;
- setError(
- loadError instanceof Error
- ? loadError.message
- : t("settings.resources.modelMemory.loadError"),
- );
- });
+ const refresh = () => {
+ const id = ++latestRef.current;
+ refreshModelMemory(
+ () => cancelled || id !== latestRef.current,
+ setSettings,
+ setError,
+ t("settings.resources.modelMemory.loadError"),
+ );
+ };
+ refresh();
+ const unsubscribe = subscribeModelLifecycle(({ loading }) => {
+ if (!loading) {
+ refresh();
+ }
+ });
return () => {
cancelled = true;
+ unsubscribe();
};
}, [t]);
@@ -45,6 +90,7 @@ export function ModelMemorySection() {
) => {
setIsSaving(true);
setError(null);
+ latestRef.current += 1;
try {
setSettings(await updateModelMemorySettings(patch));
} catch (saveError) {
@@ -109,6 +155,7 @@ export function ModelMemorySection() {
{t("settings.resources.modelMemory.mlockVetoed")}
</p>
) : null}
+ <MlockNotApplicableNote settings={settings} />
{memlockCap !== null ? (
<p className="pb-1 text-xs text-amber-600 dark:text-amber-400">
{t("settings.resources.modelMemory.memlockCapped", {
diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.ts
index cd068358ac7..69267555089 100644
--- a/studio/frontend/src/i18n/locales/ar.ts
+++ b/studio/frontend/src/i18n/locales/ar.ts
@@ -1551,6 +1551,7 @@ export const ar = {
noRamReserveDescription: "يقلل ذاكرة النظام المحجوزة لأوزان النموذج.",
noRamReserveHint: "يتخطى التحميل المعتمد على تعيين الذاكرة في إصدارات ويندوز المدعومة عندما يكون النموذج محمّلاً بالكامل على كرت الرسوميات، فلا تبقى صفحاته مقيمة. وإلا يُبقي التحميل المعتمد على تعيين الذاكرة. قد تستهلك مخازن المعالج المطلوبة ذاكرة النظام. ويحذف ‎--no-mmap‎ و‎--mlock‎.",
mlockVetoed: "يبقى ‎--mlock‎ معطَّلاً: تثبيت النموذج سيحجز ذاكرة تكفي حجمه كاملاً. ولا يزال التفريغ التلقائي عند الخمول معطَّلاً.",
+ mlockNotApplicable: "بالكامل على وحدة GPU: لا شيء في ذاكرة النظام لقفله. يبقى التفريغ التلقائي عند الخمول معطَّلاً.",
memlockCapped: "يحدّ هذا النظام الذاكرة المقفلة عند {limit}. لن يُثبَّت نموذج أكبر بالكامل؛ ارفع الحد باستخدام ulimit -l.",
reloadRequired: "أعد تحميل النموذج لتطبيق خيارات الذاكرة الجديدة.",
loadError: "تعذّر تحميل إعدادات ذاكرة النموذج",
diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.ts
index 0122201580d..85feaeb5086 100644
--- a/studio/frontend/src/i18n/locales/de.ts
+++ b/studio/frontend/src/i18n/locales/de.ts
@@ -1580,6 +1580,7 @@ export const de = {
noRamReserveDescription: "Weniger RAM für die Modellgewichte belegen.",
noRamReserveHint: "Überspringt auf unterstützten Windows-Builds das speicherabgebildete Laden, wenn das Modell vollständig auf die GPU ausgelagert ist, sodass dessen Seiten nicht im Speicher gehalten werden. Andernfalls bleibt das speicherabgebildete Laden erhalten. Erforderliche CPU-Puffer können weiterhin RAM belegen. Entfernt --no-mmap und --mlock.",
mlockVetoed: "--mlock bleibt aus: das Fixieren des Modells würde RAM für das gesamte Modell reservieren. Das automatische Entladen im Leerlauf bleibt deaktiviert.",
+ mlockNotApplicable: "Vollständig auf der GPU: nichts im System-RAM zu sperren. Automatisches Entladen im Leerlauf bleibt aus.",
memlockCapped: "Dieses System begrenzt gesperrten Speicher auf {limit}. Ein größeres Modell wird nicht vollständig fixiert; erhöhen Sie das Limit mit ulimit -l.",
reloadRequired: "Modell neu laden, um die neuen Speicheroptionen anzuwenden.",
loadError: "Modellspeicher-Einstellungen konnten nicht geladen werden",
diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.ts
index c94050fa6ba..b93bbce42d6 100644
--- a/studio/frontend/src/i18n/locales/en.ts
+++ b/studio/frontend/src/i18n/locales/en.ts
@@ -1552,6 +1552,7 @@ export const en = {
noRamReserveDescription: "Reduce host RAM held for model weights.",
noRamReserveHint: "Skips memory-mapped loading on supported Windows builds when the model is fully offloaded to the GPU, so its pages are not held resident. Otherwise keeps memory-mapped loading. Required CPU buffers can still use RAM. Drops --no-mmap and --mlock.",
mlockVetoed: "--mlock stays off: pinning the model in place would reserve RAM for all of it. Idle auto-unload is still disabled.",
+ mlockNotApplicable: "Fully on the GPU: nothing in system RAM to lock. Idle auto-unload stays off.",
memlockCapped: "This system caps locked memory at {limit}. A larger model will not be fully pinned; raise the limit with ulimit -l.",
reloadRequired: "Reload the model to apply the new memory flags.",
loadError: "Failed to load model memory settings",
diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.ts
index d2b13fb6f31..1aefacc8576 100644
--- a/studio/frontend/src/i18n/locales/es.ts
+++ b/studio/frontend/src/i18n/locales/es.ts
@@ -1575,6 +1575,7 @@ export const es = {
noRamReserveDescription: "Reduce la RAM ocupada por los pesos del modelo.",
noRamReserveHint: "Omite la carga mapeada en memoria en las compilaciones de Windows compatibles cuando el modelo está totalmente descargado en la GPU, de modo que sus páginas no quedan residentes. En caso contrario conserva la carga mapeada en memoria. Los búferes de CPU necesarios pueden seguir usando RAM. Elimina --no-mmap y --mlock.",
mlockVetoed: "--mlock permanece desactivado: fijar el modelo reservaría RAM para todo él. La descarga automática por inactividad sigue desactivada.",
+ mlockNotApplicable: "Totalmente en la GPU: nada que bloquear en la RAM del sistema. La descarga automática por inactividad sigue desactivada.",
memlockCapped: "Este sistema limita la memoria bloqueada a {limit}. Un modelo mayor no quedará fijado por completo; aumenta el límite con ulimit -l.",
reloadRequired: "Vuelve a cargar el modelo para aplicar las nuevas opciones de memoria.",
loadError: "No se pudieron cargar los ajustes de memoria del modelo",
diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.ts
index b7cd657e18b..642e14ad1ee 100644
--- a/studio/frontend/src/i18n/locales/fr.ts
+++ b/studio/frontend/src/i18n/locales/fr.ts
@@ -1579,6 +1579,7 @@ export const fr = {
noRamReserveDescription: "Réduit la RAM occupée par les poids du modèle.",
noRamReserveHint: "Ignore le chargement mappé en mémoire sur les versions Windows compatibles lorsque le modèle est entièrement déchargé sur le GPU, afin que ses pages ne restent pas résidentes. Sinon, conserve le chargement mappé en mémoire. Les tampons CPU nécessaires peuvent toujours occuper de la RAM. Supprime --no-mmap et --mlock.",
mlockVetoed: "--mlock reste désactivé : épingler le modèle réserverait de la RAM pour l'intégralité de celui-ci. Le déchargement automatique en veille reste désactivé.",
+ mlockNotApplicable: "Entièrement sur le GPU : rien à verrouiller en RAM système. Le déchargement automatique en veille reste désactivé.",
memlockCapped: "Ce système limite la mémoire verrouillée à {limit}. Un modèle plus grand ne sera pas entièrement épinglé ; augmentez la limite avec ulimit -l.",
reloadRequired: "Rechargez le modèle pour appliquer les nouvelles options de mémoire.",
loadError: "Impossible de charger les paramètres de mémoire du modèle",
diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.ts
index 1045086904f..e218188c8a2 100644
--- a/studio/frontend/src/i18n/locales/hi.ts
+++ b/studio/frontend/src/i18n/locales/hi.ts
@@ -1554,6 +1554,7 @@ export const hi = {
noRamReserveDescription: "मॉडल वेट्स के लिए रखी गई RAM घटाता है।",
noRamReserveHint: "जब मॉडल पूरी तरह GPU पर ऑफ़लोड हो, तो समर्थित Windows बिल्ड पर मेमोरी-मैप्ड लोडिंग छोड़ देता है, ताकि उसके पेज रेज़िडेंट न रहें। अन्यथा मेमोरी-मैप्ड लोडिंग बनाए रखता है। आवश्यक CPU बफ़र अब भी RAM ले सकते हैं। --no-mmap तथा --mlock हटा देता है।",
mlockVetoed: "--mlock बंद ही रहता है: मॉडल को पिन करने से उसकी पूरी मात्रा के लिए RAM आरक्षित हो जाएगी। निष्क्रिय होने पर स्वतः अनलोड अब भी अक्षम है।",
+ mlockNotApplicable: "पूरी तरह GPU पर: सिस्टम RAM में लॉक करने के लिए कुछ नहीं। निष्क्रिय होने पर स्वतः अनलोड बंद रहता है।",
memlockCapped: "यह सिस्टम लॉक की गई मेमोरी को {limit} तक सीमित करता है। इससे बड़ा मॉडल पूरी तरह पिन नहीं होगा; ulimit -l से सीमा बढ़ाएँ।",
reloadRequired: "नई मेमोरी सेटिंग्स लागू करने के लिए मॉडल दोबारा लोड करें।",
loadError: "मॉडल मेमोरी सेटिंग्स लोड नहीं हो सकीं",
diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.ts
index f4ef4228b51..18f93665580 100644
--- a/studio/frontend/src/i18n/locales/it.ts
+++ b/studio/frontend/src/i18n/locales/it.ts
@@ -1541,6 +1541,7 @@ export const it = {
noRamReserveDescription: "Riduce la RAM occupata dai pesi del modello.",
noRamReserveHint: "Salta il caricamento mappato in memoria sulle build Windows supportate quando il modello è interamente scaricato sulla GPU, così le sue pagine non restano residenti. Altrimenti mantiene il caricamento mappato in memoria. I buffer CPU necessari possono comunque occupare RAM. Rimuove --no-mmap e --mlock.",
mlockVetoed: "--mlock resta disattivato: bloccare il modello riserverebbe RAM per l'intero modello. Lo scaricamento automatico in inattività resta disattivato.",
+ mlockNotApplicable: "Interamente sulla GPU: nulla da bloccare nella RAM di sistema. Lo scaricamento automatico in inattività resta disattivato.",
memlockCapped: "Questo sistema limita la memoria bloccata a {limit}. Un modello più grande non verrà bloccato del tutto; aumenta il limite con ulimit -l.",
reloadRequired: "Ricarica il modello per applicare le nuove opzioni di memoria.",
loadError: "Impossibile caricare le impostazioni di memoria del modello",
diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.ts
index d72c4fa07dc..73a1dea0a14 100644
--- a/studio/frontend/src/i18n/locales/ja.ts
+++ b/studio/frontend/src/i18n/locales/ja.ts
@@ -1532,6 +1532,7 @@ export const ja = {
noRamReserveDescription: "モデルの重みが占有する RAM を減らします。",
noRamReserveHint: "モデルが GPU に完全にオフロードされている場合、対応する Windows ビルドではメモリマップ読み込みを行わず、ファイルのページが常駐しないようにします。それ以外ではメモリマップ読み込みを維持します。必要な CPU バッファは RAM を使用することがあります。--no-mmap と --mlock を除去します。",
mlockVetoed: "--mlock は無効のままです。モデルを固定するとモデル全体分の RAM を確保することになります。アイドル時の自動アンロードは引き続き無効です。",
+ mlockNotApplicable: "すべて GPU 上にあるため、システム RAM に固定するものはありません。アイドル時の自動アンロードは無効のままです。",
memlockCapped: "このシステムはロック可能なメモリを {limit} に制限しています。これより大きいモデルは完全には固定されません。ulimit -l で上限を引き上げてください。",
reloadRequired: "新しいメモリ設定を適用するにはモデルを再読み込みしてください。",
loadError: "モデルメモリ設定の読み込みに失敗しました",
diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.ts
index 619b02688c3..927bb20bfb3 100644
--- a/studio/frontend/src/i18n/locales/ko.ts
+++ b/studio/frontend/src/i18n/locales/ko.ts
@@ -1547,6 +1547,7 @@ export const ko = {
noRamReserveDescription: "모델 가중치가 차지하는 RAM을 줄입니다.",
noRamReserveHint: "모델이 GPU에 완전히 오프로드된 경우 지원되는 Windows 빌드에서 메모리 매핑 로딩을 건너뛰어 파일 페이지가 상주하지 않도록 합니다. 그렇지 않으면 메모리 매핑 로딩을 유지합니다. 필요한 CPU 버퍼는 여전히 RAM을 사용할 수 있습니다. --no-mmap과 --mlock을 제거합니다.",
mlockVetoed: "--mlock은 꺼진 상태로 유지됩니다. 모델을 고정하면 모델 전체 크기만큼 RAM을 예약하게 됩니다. 유휴 시 자동 언로드는 계속 비활성화됩니다.",
+ mlockNotApplicable: "모두 GPU에 있어 시스템 RAM에 고정할 것이 없습니다. 유휴 시 자동 언로드는 계속 꺼져 있습니다.",
memlockCapped: "이 시스템은 잠금 메모리를 {limit}로 제한합니다. 더 큰 모델은 완전히 고정되지 않습니다. ulimit -l로 한도를 늘리세요.",
reloadRequired: "새 메모리 옵션을 적용하려면 모델을 다시 로드하세요.",
loadError: "모델 메모리 설정을 불러오지 못했습니다",
diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.ts
index ea031f294dd..88517f52b88 100644
--- a/studio/frontend/src/i18n/locales/pt-br.ts
+++ b/studio/frontend/src/i18n/locales/pt-br.ts
@@ -1563,6 +1563,7 @@ export const ptBR = {
noRamReserveDescription: "Reduz a RAM ocupada pelos pesos do modelo.",
noRamReserveHint: "Ignora o carregamento mapeado em memória nas versões compatíveis do Windows quando o modelo está totalmente descarregado na GPU, para que suas páginas não fiquem residentes. Caso contrário, mantém o carregamento mapeado em memória. Buffers de CPU necessários ainda podem usar RAM. Remove --no-mmap e --mlock.",
mlockVetoed: "--mlock continua desativado: fixar o modelo reservaria RAM para todo ele. A descarga automática por inatividade continua desativada.",
+ mlockNotApplicable: "Totalmente na GPU: nada para bloquear na RAM do sistema. A descarga automática por inatividade continua desativada.",
memlockCapped: "Este sistema limita a memória bloqueada a {limit}. Um modelo maior não será totalmente fixado; aumente o limite com ulimit -l.",
reloadRequired: "Recarregue o modelo para aplicar as novas opções de memória.",
loadError: "Falha ao carregar as configurações de memória do modelo",
diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.ts
index e705577d5bf..6ba3ff30fdf 100644
--- a/studio/frontend/src/i18n/locales/ru.ts
+++ b/studio/frontend/src/i18n/locales/ru.ts
@@ -1558,6 +1558,7 @@ export const ru = {
noRamReserveDescription: "Уменьшает объём ОЗУ, занятый весами модели.",
noRamReserveHint: "Пропускает загрузку через отображение файла в память в поддерживаемых сборках Windows, когда модель полностью выгружена на видеокарту, чтобы её страницы не оставались в памяти. В остальных случаях сохраняет загрузку через отображение файла в память. Необходимые буферы ЦП всё равно могут занимать ОЗУ. Убирает --no-mmap и --mlock.",
mlockVetoed: "--mlock остаётся выключенным: закрепление модели зарезервировало бы ОЗУ под неё целиком. Автовыгрузка по простою по-прежнему отключена.",
+ mlockNotApplicable: "Полностью на GPU: в системной памяти нечего закреплять. Автовыгрузка по простою остаётся выключенной.",
memlockCapped: "Система ограничивает блокируемую память значением {limit}. Модель большего размера не будет закреплена полностью; увеличьте лимит через ulimit -l.",
reloadRequired: "Перезагрузите модель, чтобы применить новые параметры памяти.",
loadError: "Не удалось загрузить настройки памяти модели",
diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.ts
index e9edcb7c131..034dcee7934 100644
--- a/studio/frontend/src/i18n/locales/zh-CN.ts
+++ b/studio/frontend/src/i18n/locales/zh-CN.ts
@@ -1522,6 +1522,7 @@ export const zhCN = {
noRamReserveDescription: "减少模型权重占用的内存。",
noRamReserveHint: "当模型完全卸载到 GPU 时,在受支持的 Windows 版本上跳过内存映射加载,使其页面不再常驻;否则保持内存映射加载。必要的 CPU 缓冲区仍可能占用内存。移除 --no-mmap 和 --mlock。",
mlockVetoed: "--mlock 保持关闭:锁定模型会为其全部内容预留内存。空闲自动卸载仍处于禁用状态。",
+ mlockNotApplicable: "已完全位于 GPU 上:系统内存中没有需要锁定的内容。空闲自动卸载保持关闭。",
memlockCapped: "本系统将锁定内存限制为 {limit}。更大的模型无法被完全锁定;请使用 ulimit -l 提高上限。",
reloadRequired: "重新加载模型以应用新的内存选项。",
loadError: "加载模型内存设置失败",
diff --git a/studio/frontend/tests/model-memory-applicable.test.ts b/studio/frontend/tests/model-memory-applicable.test.ts
new file mode 100644
index 00000000000..79e0154e307
--- /dev/null
+++ b/studio/frontend/tests/model-memory-applicable.test.ts
@@ -0,0 +1,70 @@
+// 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 { register } from "node:module";
+import test from "node:test";
+
+import { installLocalStorageFake } from "./helpers/kit.ts";
+
+register("./helpers/settings-api-resolver.mjs", import.meta.url);
+installLocalStorageFake();
+
+type Listener = (event: Event) => void;
+const listeners = new Map<string, Set<Listener>>();
+Object.assign(globalThis.window as object, {
+ addEventListener: (type: string, fn: Listener) => {
+ if (!listeners.has(type)) listeners.set(type, new Set());
+ listeners.get(type)?.add(fn);
+ },
+ removeEventListener: (type: string, fn: Listener) => {
+ listeners.get(type)?.delete(fn);
+ },
+ dispatchEvent: (event: Event) => {
+ for (const fn of listeners.get(event.type) ?? []) fn(event);
+ return true;
+ },
+});
+
+const BASE = {
+ keep_resident: true,
+ no_ram_reserve: false,
+ default_keep_resident: false,
+ default_no_ram_reserve: false,
+ mlock_active: false,
+ reload_required: false,
+ memlock_limit_bytes: null as number | null,
+};
+
+let nextBody: Record<string, unknown> = { ...BASE };
+
+globalThis.fetch = (async () =>
+ new Response(JSON.stringify(nextBody), {
+ status: 200,
+ headers: { "Content-Type": "application/json" },
+ })) as typeof fetch;
+
+const { loadModelMemorySettings } = await import(
+ "../src/features/settings/api/model-memory.ts"
+);
+
+test("a discrete full offload maps through as not applicable", async () => {
+ nextBody = { ...BASE, mlock_applicable: false };
+ const settings = await loadModelMemorySettings({ force: true });
+ assert.equal(settings.mlockApplicable, false);
+ assert.equal(settings.keepResident, true);
+ assert.equal(settings.mlockActive, false);
+ assert.equal(settings.reloadRequired, false);
+});
+
+test("a host-resident launch maps through as applicable", async () => {
+ nextBody = { ...BASE, mlock_applicable: true, mlock_active: true };
+ const settings = await loadModelMemorySettings({ force: true });
+ assert.equal(settings.mlockApplicable, true);
+});
+
+test("a backend that does not send the field is treated as applicable", async () => {
+ nextBody = { ...BASE };
+ const settings = await loadModelMemorySettings({ force: true });
+ assert.equal(settings.mlockApplicable, true);
+});