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: hide safetensors models that exceed VRAM when the fit filter is on (#13945)
oobabooga6c555fa727d6
diff --git a/studio/frontend/scripts/check-bundle-budget.ts b/studio/frontend/scripts/check-bundle-budget.tsindex c97c88bc006..ebb67d8c43e 100644--- a/studio/frontend/scripts/check-bundle-budget.ts+++ b/studio/frontend/scripts/check-bundle-budget.ts@@ -176,8 +176,12 @@ export const BUDGET = {// 95), with no single import doing it: Deep research under Tools in the + menu (#13959) took main over, and// the connection name and provider menu order (#13964) and the attachment card polish (#13970) add the rest.// Raised by that growth so main's margin stays where it was.- transferBytes: 2_042_593,- rawBytes: 6_791_928,+ // The Hub fit filter sizing safetensors rows the way transformers loads them adds 497 B raw / 184 B transfer+ // (6,791,768 -> 6,792,265 B raw, 2,037,833 -> 2,038,017 B transfer against 23bbee09b1, one machine and build,+ // Node 26, chunk count unchanged at 95). A synchronous predicate in a module already in the startup set, so+ // nothing to lazy-load; raised by that growth.+ transferBytes: 2_042_777,+ rawBytes: 6_792_425,};// The chunk count is reported but not budgeted. Splitting a page out of the entry raises it while lowering thediff --git a/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx b/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsxindex e9ee1a5e99d..da545092e21 100644--- a/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx+++ b/studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx@@ -4031,22 +4031,26 @@ export function HubModelPicker({const rowGpu = loadScopedGpu(gpu, taskScoped);const rowInferenceGpu = loadScopedGpu(inferenceGpu, taskScoped);const pipelineBudget = artifactBudget(rowGpu);- const fits = (r: HfModelResult) =>- // Downloaded models show regardless of fit.- cachedIdFor(r.id) !== null ||- runsCheckpointQuant(r) ||- // The catalog's own verdict where it has one, so this list and the OOM badge cannot disagree:- // hfModelFitsDevice counts RAM toward a load that never leaves the card.- (catalogFit(r.id, pipelineBudget)?.fits ??- hfModelFitsDevice(r, diffusionLoad || !r.isGguf ? rowGpu : rowInferenceGpu, {- budgetFraction,- // Not `&& r.isGguf`: on a task page a safetensors row is placed by the same backend, and this- // rule IS the budget those rows had before the classifiers were merged.- mediaLoad: diffusionLoad,- hostPooledMemory: gpu.loadDeviceSharesHostMemory,- // The scoped inventory's own count, so it always describes rowInferenceGpu's capacity.- gpuCount: rowInferenceGpu.deviceCount,- }));+ const fits = (r: HfModelResult) => {+ const source = diffusionLoad || !r.isGguf ? rowGpu : rowInferenceGpu;+ return (+ // Downloaded models show regardless of fit.+ cachedIdFor(r.id) !== null ||+ runsCheckpointQuant(r) ||+ // The catalog's own verdict where it has one, so this list and the OOM badge cannot disagree:+ // hfModelFitsDevice counts RAM toward a load that never leaves the card.+ (catalogFit(r.id, pipelineBudget)?.fits ??+ hfModelFitsDevice(r, source, {+ budgetFraction,+ // Not `&& r.isGguf`: on a task page a safetensors row is placed by the same backend, and this+ // rule IS the budget those rows had before the classifiers were merged.+ mediaLoad: diffusionLoad,+ hostPooledMemory: gpu.loadDeviceSharesHostMemory,+ // The scoped inventory's own count, so it always describes the capacity beside it.+ gpuCount: source.deviceCount,+ }))+ );+ };const unslothRows = orderRecommendedRows({seeds: catalogSeedRows,results: recommendedSearch.results,@@ -5323,6 +5327,7 @@ export function HubModelPicker({totalParams?: number;estimatedSizeBytes?: number;curatedSizeBytes?: number;+ quantMethod?: string;}) =>catalogFit(row.id, artifactBudget(loadScopedGpu(gpu, Boolean(task))))?.fits ??searchRowFitsDevice(diff --git a/studio/frontend/src/features/model-picker/components/model-selector/recommended-fit.ts b/studio/frontend/src/features/model-picker/components/model-selector/recommended-fit.tsindex 21806327171..61a8098424b 100644--- a/studio/frontend/src/features/model-picker/components/model-selector/recommended-fit.ts+++ b/studio/frontend/src/features/model-picker/components/model-selector/recommended-fit.ts@@ -5,6 +5,11 @@// the device. No React/DOM deps so they are easy to test.import { classifyGgufFit } from "../../../../lib/gguf-fit.ts";+import {+ LOADING_OVERHEAD_GB,+ checkVramFit,+ estimateLoadingVram,+} from "../../../../lib/vram.ts";import {audioCppDisplayName,isAudioCppFolderId,@@ -216,11 +221,35 @@ export function fitsDevice(opts: {return requireKnown ? false : true;}+/** A safetensors load on a discrete GPU: a prequantized checkpoint as stored (Studio rebuilds none+ * of them as bnb), anything else at the row badge's 4-bit estimate. `raise_if_offloaded` refuses+ * CPU offload, except that one CUDA / ROCm card block-swaps 16-bit or bnb layers into host RAM. */+function fitsTransformersLoad(+ model: { totalParams: number; estimatedSizeBytes?: number; quantMethod?: string },+ gpu: { memoryTotalGb: number; systemRamAvailableGb: number; backend?: string },+ gpuCount = 1,+): boolean {+ const quant = model.quantMethod?.toLowerCase();+ const swapGb =+ gpuCount <= 1 && (gpu.backend === "cuda" || gpu.backend === "rocm")+ ? Math.max(0, gpu.systemRamAvailableGb)+ : 0;+ const fits = (requiredGb: number, budgetGb: number) =>+ checkVramFit(requiredGb, budgetGb) !== "exceeds";+ if (!quant)+ return fits(estimateLoadingVram(model.totalParams, "qlora"), gpu.memoryTotalGb + swapGb);+ const storedBytes =+ model.estimatedSizeBytes ?? estimateQuantBytes(model.totalParams);+ return fits(+ storedBytes / 1024 ** 3 + LOADING_OVERHEAD_GB,+ gpu.memoryTotalGb + (quant === "bitsandbytes" ? swapGb : 0),+ );+}+/** Fit predicate for one Hub listing row, shared by the chat model selector and the Hub page- * filter. GGUF repos use metadata size or the smallest-quant estimate. Safetensors / MLX- * always use the params-based estimate, matching the badge's quantized-load assumption,- * since their estimatedSizeBytes is the full-precision checkpoint. `curatedSizeBytes`- * outranks both. Anything still unsizable is hidden; an unknown device budget keeps all. */+ * filter. GGUF repos use metadata size or the smallest-quant estimate, safetensors on a discrete+ * GPU `fitsTransformersLoad`, and MLX / host-pool rows the params-based quant estimate.+ * `curatedSizeBytes` outranks all. Unsizable rows are hidden; an unknown budget keeps all. */export function hfModelFitsDevice(model: {id: string;@@ -228,11 +257,13 @@ export function hfModelFitsDevice(estimatedSizeBytes?: number;curatedSizeBytes?: number;isGguf?: boolean;+ quantMethod?: string;},gpu: {memoryTotalGb: number;systemRamAvailableGb: number;budgetKnown?: boolean;+ backend?: string;},/** `budgetFraction` is the user's saved VRAM Budget: omitted scores against the loader's* default, so a caller that forgets it judges rows on a replaced budget. `mediaLoad` picks@@ -251,10 +282,21 @@ export function hfModelFitsDevice()return true;const params = model.totalParams ?? paramsFromId(model.id);+ const isGguf = isGgufId(model.id, model.isGguf);+ if (+ params &&+ model.curatedSizeBytes == null &&+ !isGguf &&+ !isMlxId(model.id) &&+ !opts.mediaLoad &&+ !opts.hostPooledMemory &&+ gpu.memoryTotalGb > 0+ )+ return fitsTransformersLoad({ ...model, totalParams: params }, gpu, opts.gpuCount);const quantBytes = params ? estimateQuantBytes(params) : undefined;const sizeBytes =model.curatedSizeBytes ??- (isGgufId(model.id, model.isGguf)+ (isGguf? (model.estimatedSizeBytes ?? quantBytes): (quantBytes ?? model.estimatedSizeBytes));return fitsDevice({@@ -333,6 +375,7 @@ export function searchRowFitsDevice<totalParams?: number;estimatedSizeBytes?: number;curatedSizeBytes?: number;+ quantMethod?: string;},opts: {isGguf: boolean;diff --git a/studio/frontend/tests/fit-on-device-setting.test.ts b/studio/frontend/tests/fit-on-device-setting.test.tsindex 0aca94f5745..33eec960aca 100644--- a/studio/frontend/tests/fit-on-device-setting.test.ts+++ b/studio/frontend/tests/fit-on-device-setting.test.ts@@ -82,3 +82,40 @@ test("a model is hidden only when it exceeds GPU memory plus RAM", () => {true,);});++test("a safetensors row on a discrete GPU is sized like its badge, with RAM only where layers swap", () => {+ // 24 GB of VRAM beside 64 GB of RAM.+ const cuda = { memoryTotalGb: 24, systemRamAvailableGb: 64, budgetKnown: true, backend: "cuda" };+ const xpu = { ...cuda, backend: "xpu" };+ const row = (id: string, totalParams: number) => ({ id, totalParams, isGguf: false });+ // Badge estimates (0.9 B/param + 1.4 GB): 24B 23 GB (tight), 32B 30.2, 70B 64.4, 120B 109.4.+ // Several cards, or XPU, cannot offload: VRAM alone, kept unless the badge says exceeds.+ assert.equal(hfModelFitsDevice(row("org/m-24B", 24e9), cuda, { gpuCount: 2 }), true);+ assert.equal(hfModelFitsDevice(row("org/m-32B", 32e9), cuda, { gpuCount: 2 }), false);+ assert.equal(hfModelFitsDevice(row("org/m-32B", 32e9), xpu), false);+ // One CUDA or ROCm card block-swaps layers into host RAM.+ assert.equal(hfModelFitsDevice(row("org/m-70B", 70e9), cuda, { gpuCount: 1 }), true);+ assert.equal(hfModelFitsDevice(row("org/m-70B", 70e9), { ...cuda, backend: "rocm" }), true);+ assert.equal(hfModelFitsDevice(row("org/m-120B", 120e9), cuda, { gpuCount: 1 }), false);+ // A prequantized checkpoint loads as stored (23e9 B is 21.4 GiB), never rebuilt as bnb 4-bit; only+ // a bnb one block-swaps.+ const prequant = (quantMethod: string, bytes: number) => ({+ ...row("org/m-32B", 32e9),+ quantMethod,+ estimatedSizeBytes: bytes,+ });+ assert.equal(hfModelFitsDevice(prequant("mxfp4", 23e9), xpu), true);+ assert.equal(hfModelFitsDevice(prequant("mxfp4", 40e9), cuda), false);+ assert.equal(hfModelFitsDevice(prequant("bitsandbytes", 40e9), cuda), true);+ assert.equal(hfModelFitsDevice(prequant("compressed-tensors", 100e9), cuda), false);+ // With no byte size, a packed checkpoint is sized as the smallest quant, not the bnb rebuild.+ assert.equal(hfModelFitsDevice({ ...row("org/m-32B", 32e9), quantMethod: "gptq" }, xpu), true);+ // Host pools, MLX ids, Images / Video rows and GGUF keep the quant rule.+ assert.equal(hfModelFitsDevice(row("org/m-32B", 32e9), xpu, { hostPooledMemory: true }), true);+ assert.equal(hfModelFitsDevice(row("mlx-community/m-32B", 32e9), xpu), true);+ assert.equal(hfModelFitsDevice(row("org/m-32B", 32e9), xpu, { mediaLoad: true }), true);+ assert.equal(+ hfModelFitsDevice({ id: "org/m-32B-GGUF", totalParams: 32e9, isGguf: true }, xpu),+ true,+ );+});diff --git a/studio/frontend/tests/on-device-dot-and-header-alignment.test.ts b/studio/frontend/tests/on-device-dot-and-header-alignment.test.tsindex 7bbf604ff10..bea3845beac 100644--- a/studio/frontend/tests/on-device-dot-and-header-alignment.test.ts+++ b/studio/frontend/tests/on-device-dot-and-header-alignment.test.ts@@ -374,7 +374,7 @@ test("chat and the Hub answer the fit question with one formula", () => {// once per host GPU against that one card scored an audio quant at 23.28 GiB where the loader// offers the selected card's 23.5.assert.ok(RECOMMENDED.includes("deviceCount: 1,"), "scoped to one device");- assert.ok(PICKERS.includes("gpuCount: rowInferenceGpu.deviceCount"));+ assert.ok(PICKERS.includes("gpuCount: source.deviceCount"));assert.ok(RECOMMENDED.includes("gpuCount: source.deviceCount ?? opts.gpuCount"),);