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: paint the image and video pickers from the curated catalog (#7896)
Daniel Hande1d0f8f2a0c
diff --git a/studio/frontend/src/features/hub/hooks/use-hub-model-search.ts b/studio/frontend/src/features/hub/hooks/use-hub-model-search.tsindex 304a6c7027f..f3f6d24384e 100644--- a/studio/frontend/src/features/hub/hooks/use-hub-model-search.ts+++ b/studio/frontend/src/features/hub/hooks/use-hub-model-search.ts@@ -106,6 +106,8 @@ export interface HfModelResult {gated?: false | "auto" | "manual";totalParams?: number;estimatedSizeBytes?: number;+ /** Catalog size for a row painted before the listing reports it, never from a Hub response. */+ curatedSizeBytes?: number;isGguf: boolean;baseModel?: string | null;tags?: string[];diff --git a/studio/frontend/src/features/model-picker/components/model-selector/model-catalog.ts b/studio/frontend/src/features/model-picker/components/model-selector/model-catalog.tsindex 2d408072bb3..e630bf8fd79 100644--- a/studio/frontend/src/features/model-picker/components/model-selector/model-catalog.ts+++ b/studio/frontend/src/features/model-picker/components/model-selector/model-catalog.ts@@ -499,6 +499,17 @@ export function artifactForRepoId(return group ? { group, artifact } : null;}+const BYTES_PER_GB = 1024 ** 3;++/** Curated size (bytes) of an exact artifact id; undefined when unsized (every GGUF entry: its quant ladder self-fits). */+export function curatedSizeBytesFor(+ repoId: string,+ catalog: CatalogGroup[],+): number | undefined {+ const gb = artifactForRepoId(repoId, catalog)?.artifact.approxSizeGb;+ return gb && gb > 0 ? gb * BYTES_PER_GB : undefined;+}+/** Back-compat: the flat ModelOption list the ModelSelector `models` prop expects, one option per ARTIFACT. */export function catalogToModelOptions(catalog: CatalogGroup[]): ModelOption[] {const options: ModelOption[] = [];diff --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 cbbce676304..d2d09b7b7d4 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@@ -119,8 +119,11 @@ import {isMlxId,isMobileVariant,isRecommendableFormat,+ loadScopedGpu,matchesFormatFilter,+ orderRecommendedRows,paramsFromId,+ searchRowFitsDevice,} from "./recommended-fit";import {ggufVariantsMatchForPicker,@@ -149,7 +152,11 @@ import type {ModelOption,ModelSelectorChangeMeta,} from "./types";-import { type CatalogGroup, artifactForRepoId } from "./model-catalog";+import {+ type CatalogGroup,+ artifactForRepoId,+ curatedSizeBytesFor,+} from "./model-catalog";import { describeVariantListingError } from "./variant-listing-error";import {shouldMountVariantExpander,@@ -2351,39 +2358,67 @@ export function HubModelPicker({const hubRowsShowSize =formatFilter === "mlx" || formatFilter === "safetensors";+ // Paint curated rows before any request, so a task-scoped picker whose models+ // are already in memory does not sit on a spinner for a round trip.+ const catalogSeedRows = useMemo<HfModelResult[]>(() => {+ if (!task) return [];+ return dedupe(models.map((model) => model.id))+ .filter((id) => !isHiddenModelId(id))+ .filter((id) => !isMobileVariant(id))+ .filter((id) => !isImageEditModel(id))+ .filter((id) => {+ const isG = isKnownGgufRepo(id);+ return formatFilter === "all"+ ? isRecommendableFormat(id, isG, isMac)+ : matchesFormatFilter(id, isG, formatFilter);+ })+ .map((id) => ({+ id,+ downloads: 0,+ likes: 0,+ isGguf: isKnownGgufRepo(id),+ // Size from the catalog, not an id "<n>B" guess: the guess is missing for+ // most curated ids and wrong for others (Wan2.2-TI2V-5B is 30 GB, not 2),+ // and non-unsloth ids never get a listing row to correct it.+ curatedSizeBytes: catalog ? curatedSizeBytesFor(id, catalog) : undefined,+ }));+ }, [catalog, models, formatFilter, isKnownGgufRepo, isMac, task]);+// Recommended suggests GGUF anywhere; on Mac also MLX and safetensors. The// "recommended" sort also drops models too big for the device. Already-// downloaded models stay visible (badged), never hidden.const recommendedRows = useMemo(() => {- // Never list mobile-targeted builds in the Unsloth section.- let rows = recommendedSearch.results- .filter((r) => !isHiddenModelId(r.id))- .filter((r) => !isMobileVariant(r.id));- // Drop models Unsloth can't run for chat (diffusion / image / video / etc.).- rows = rows.filter(isChatSupported);- // With no explicit format, show the device-recommended formats (GGUF, plus- // MLX on Mac). When the user picks a format, honor it instead so Safetensors- // is not dropped by the recommendation default.- rows =- formatFilter === "all"- ? rows.filter((r) => isRecommendableFormat(r.id, r.isGguf, isMac))- : rows.filter((r) => matchesFormatFilter(r.id, r.isGguf, formatFilter));- // Task-scoped pages load single-file GGUF only. As with recommendedIds, a curated artifact is loadable whatever its format, so GGUF-only here hid the catalog's bf16 / bnb-4bit / fp8 models from Hub search.- if (task) {- rows = rows.filter(- (r) => r.isGguf || Boolean(catalog && artifactForRepoId(r.id, catalog)),- );- }- // Members would render under their canonical group row, which does not exist yet (see recommendedIds): filtering here removed curated models from Hub- // search too. The "recommended" sort always applies the device-fit filter; the shared "Fits on device" tick extends it to the other sorts.- if (recommendedSort !== "recommended" && !fitOnDeviceOnly) return rows;- return rows.filter((r) => {- // Downloaded models always show, regardless of device fit.- if (downloadedSet.has(r.id.toLowerCase())) return true;- return hfModelFitsDevice(r, r.isGguf ? inferenceGpu : gpu);+ const keep = (r: HfModelResult) =>+ !isHiddenModelId(r.id) &&+ !isMobileVariant(r.id) &&+ isChatSupported(r) &&+ // No pick: device-recommended formats (GGUF, plus MLX on Mac). A pick wins.+ (formatFilter === "all"+ ? isRecommendableFormat(r.id, r.isGguf, isMac)+ : matchesFormatFilter(r.id, r.isGguf, formatFilter)) &&+ // Task pages load single-file GGUF, plus curated artifacts in any format.+ (!task || r.isGguf || Boolean(catalog && artifactForRepoId(r.id, catalog)));+ // Members are not filtered here (see recommendedIds): it dropped them from+ // Hub search too. "recommended" always device-filters; the "Fits on device"+ // tick extends that to the other sorts.+ const deviceFiltered = recommendedSort === "recommended" || fitOnDeviceOnly;+ const taskScoped = Boolean(task);+ const rowGpu = loadScopedGpu(gpu, taskScoped);+ const rowInferenceGpu = loadScopedGpu(inferenceGpu, taskScoped);+ const fits = (r: HfModelResult) =>+ // Downloaded models show regardless of fit.+ downloadedSet.has(r.id.toLowerCase()) ||+ hfModelFitsDevice(r, r.isGguf ? rowInferenceGpu : rowGpu);+ return orderRecommendedRows({+ seeds: catalogSeedRows,+ results: recommendedSearch.results,+ keep,+ deviceFiltered,+ fits,});}, [recommendedSearch.results,+ catalogSeedRows,downloadedSet,recommendedSort,fitOnDeviceOnly,@@ -2513,11 +2548,7 @@ export function HubModelPicker({// Task-scoped loads put the whole pipeline on ONE device, so quant fit uses the device the load lands on (the lowest visible ordinal), not the multi-GPU sum or the largest card: sizing against the bigger card OOMs the smaller one. Chat keeps the sum.// The source is picked per row (a GGUF row sizes against the inference GPU, anything else against the system view); this only decides how much of it a row may claim.const expanderGpuGbFrom = (info: typeof inferenceGpu) =>- info.available- ? task- ? info.loadDeviceMemoryGb || info.maxDeviceMemoryGb- : info.memoryTotalGb- : undefined;+ info.available ? loadScopedGpu(info, Boolean(task)).memoryTotalGb : undefined;const expanderGpuGb = expanderGpuGbFrom(inferenceGpu);const expanderSystemGpuGb = expanderGpuGbFrom(gpu);@@ -2840,6 +2871,40 @@ export function HubModelPicker({return map;}, [results, recommendedSearch.results]);+ // Shared by both search lists so a curated id one drops cannot return via the+ // other as a raw Hub row.+ const searchRowFits = useCallback(+ (row: {+ id: string;+ totalParams?: number;+ estimatedSizeBytes?: number;+ curatedSizeBytes?: number;+ }) =>+ searchRowFitsDevice(+ {+ ...row,+ totalParams: row.totalParams ?? recommendedParamCountById.get(row.id),+ },+ {+ isGguf: isKnownGgufRepo(row.id),+ curatedSizeBytes: catalog+ ? curatedSizeBytesFor(row.id, catalog)+ : undefined,+ gpu,+ inferenceGpu,+ taskScoped: Boolean(task),+ },+ ),+ [+ catalog,+ gpu,+ inferenceGpu,+ isKnownGgufRepo,+ recommendedParamCountById,+ task,+ ],+ );+// Recommended models that match the current search queryconst filteredRecommendedIds = useMemo(() => {if (!showHfSection) return [];@@ -2856,14 +2921,7 @@ export function HubModelPicker({(id) =>!fitOnDeviceOnly ||downloadedSet.has(id.toLowerCase()) ||- hfModelFitsDevice(- {- id,- totalParams: recommendedParamCountById.get(id),- isGguf: isKnownGgufRepo(id),- },- isKnownGgufRepo(id) ? inferenceGpu : gpu,- ),+ searchRowFits({ id }),));}, [@@ -2874,9 +2932,7 @@ export function HubModelPicker({isKnownGgufRepo,fitOnDeviceOnly,downloadedSet,- recommendedParamCountById,- gpu,- inferenceGpu,+ searchRowFits,]);const recommendedSet = useMemo(@@ -2894,7 +2950,7 @@ export function HubModelPicker({(r) =>!fitOnDeviceOnly ||downloadedSet.has(r.id.toLowerCase()) ||- hfModelFitsDevice(r, r.isGguf ? inferenceGpu : gpu),+ searchRowFits(r),).map((result) => result.id).filter((id) => !isHiddenModelId(id))@@ -2922,8 +2978,7 @@ export function HubModelPicker({formatFilter,fitOnDeviceOnly,downloadedSet,- gpu,- inferenceGpu,+ searchRowFits,isMac,]);@@ -4769,9 +4824,12 @@ export function HubModelPicker({{recommendedSearch.hasMore && (<><div ref={recommendedSentinelRef} className="h-px" />- <div className="flex items-center justify-center py-2">- <Spinner className="size-3.5 text-muted-foreground" />- </div>+ {/* Only while a page is in flight; on hasMore it sat under a usable list. */}+ {recommendedSearch.isLoadingMore ? (+ <div className="flex items-center justify-center py-2">+ <Spinner className="size-3.5 text-muted-foreground" />+ </div>+ ) : null}</>)}</>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 b7abe063131..177109567ce 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@@ -127,14 +127,15 @@ export function fitsDevice(opts: {* MLX repos: always the params-based smallest-quant estimate, matching the* VRAM badge's quantized-load assumption; their estimatedSizeBytes is the* full-precision checkpoint and would wrongly hide models the quantized load- * path can run. Anything unsizable is hidden (requireKnown) so over-budget- * models with no metadata don't slip through. An unknown device budget keeps- * everything. */+ * path can run. `curatedSizeBytes` outranks both: real data over estimates.+ * Anything still unsizable is hidden (requireKnown) so over-budget models with+ * no metadata don't slip through. An unknown device budget keeps everything. */export function hfModelFitsDevice(model: {id: string;totalParams?: number;estimatedSizeBytes?: number;+ curatedSizeBytes?: number;isGguf?: boolean;},gpu: {@@ -151,9 +152,11 @@ export function hfModelFitsDevice(return true;const params = model.totalParams ?? paramsFromId(model.id);const quantBytes = params ? estimateQuantBytes(params) : undefined;- const sizeBytes = isGgufId(model.id, model.isGguf)- ? (model.estimatedSizeBytes ?? quantBytes)- : (quantBytes ?? model.estimatedSizeBytes);+ const sizeBytes =+ model.curatedSizeBytes ??+ (isGgufId(model.id, model.isGguf)+ ? (model.estimatedSizeBytes ?? quantBytes)+ : (quantBytes ?? model.estimatedSizeBytes));return fitsDevice({sizeBytes,gpuGb: gpu.memoryTotalGb,@@ -162,3 +165,96 @@ export function hfModelFitsDevice(requireKnown: true,});}++/** The budget a task-scoped (Images / Video) row may claim. Those loads put the+ * whole pipeline on ONE device (a bare "cuda", the lowest visible ordinal), so+ * fit is judged against that card, never the multi-GPU sum, which would+ * recommend a checkpoint that OOMs where the load lands. Chat keeps the sum. */+export function loadScopedGpu<+ T extends {+ available: boolean;+ memoryTotalGb: number;+ maxDeviceMemoryGb: number;+ loadDeviceMemoryGb: number;+ },+>(gpu: T, taskScoped: boolean): T {+ if (!taskScoped || !gpu.available) return gpu;+ const deviceGb = gpu.loadDeviceMemoryGb || gpu.maxDeviceMemoryGb;+ return deviceGb > 0 ? { ...gpu, memoryTotalGb: deviceGb } : gpu;+}++/** One fit predicate for both search lists (curated matches and the Hub rows+ * below them). The curated list only suppresses ids it kept, so a row it drops+ * reappears from the Hub list: judge both on the same size and budget, or the+ * toggle leaks an oversized row. */+export function searchRowFitsDevice<+ G extends {+ available: boolean;+ memoryTotalGb: number;+ maxDeviceMemoryGb: number;+ loadDeviceMemoryGb: number;+ systemRamAvailableGb: number;+ budgetKnown?: boolean;+ },+>(+ row: {+ id: string;+ totalParams?: number;+ estimatedSizeBytes?: number;+ curatedSizeBytes?: number;+ },+ opts: {+ isGguf: boolean;+ curatedSizeBytes?: number;+ gpu: G;+ inferenceGpu: G;+ taskScoped: boolean;+ },+): boolean {+ const source = opts.isGguf ? opts.inferenceGpu : opts.gpu;+ return hfModelFitsDevice(+ {+ ...row,+ isGguf: opts.isGguf,+ curatedSizeBytes: row.curatedSizeBytes ?? opts.curatedSizeBytes,+ },+ loadScopedGpu(source, opts.taskScoped),+ );+}++/** Order Recommended: curated seeds first in catalog order, then the rest of the+ * listing, each id once. A seed hands off only to a row that survived `keep`, so+ * a painted curated row does not vanish when the listing reports it with+ * metadata the filters reject. Fit is judged on whichever row renders, and the+ * taking-over row inherits the seed's curated size: a Hub listing carries none,+ * so a prequantized artifact would otherwise flip to the params guess (which+ * assumes a quant still to come). */+export function orderRecommendedRows<+ T extends { id: string; curatedSizeBytes?: number },+>(opts: {+ seeds: readonly T[];+ results: readonly T[];+ keep: (row: T) => boolean;+ deviceFiltered: boolean;+ fits: (row: T) => boolean;+}): T[] {+ const { seeds, results, keep, deviceFiltered, fits } = opts;+ const seedById = new Map(seeds.map((s) => [s.id, s]));+ const rows = results.filter(keep).map((row) => {+ const curatedSizeBytes = seedById.get(row.id)?.curatedSizeBytes;+ return curatedSizeBytes != null && row.curatedSizeBytes == null+ ? { ...row, curatedSizeBytes }+ : row;+ });+ const byId = new Map(rows.map((r) => [r.id, r]));+ const curated: T[] = [];+ for (const seed of seeds) {+ const row = byId.get(seed.id) ?? seed;+ if (!deviceFiltered || fits(row)) curated.push(row);+ }+ const curatedIds = new Set(curated.map((r) => r.id));+ const rest = (deviceFiltered ? rows.filter(fits) : rows).filter(+ (r) => !curatedIds.has(r.id),+ );+ return [...curated, ...rest];+}diff --git a/studio/frontend/tests/recommended-catalog-seeds.test.ts b/studio/frontend/tests/recommended-catalog-seeds.test.tsnew file mode 100644index 00000000000..e0e25a33116--- /dev/null+++ b/studio/frontend/tests/recommended-catalog-seeds.test.ts@@ -0,0 +1,321 @@+// 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 {+ IMAGE_CATALOG,+ VIDEO_CATALOG,+ curatedSizeBytesFor,+} from "../src/features/model-picker/components/model-selector/model-catalog.ts";+import {+ hfModelFitsDevice,+ loadScopedGpu,+ orderRecommendedRows,+ searchRowFitsDevice,+} from "../src/features/model-picker/components/model-selector/recommended-fit.ts";++interface Row {+ id: string;+ isGguf?: boolean;+ totalParams?: number;+ curatedSizeBytes?: number;+ pipelineTag?: string;+}++// Two Video catalog seeds, in catalog order.+const LTX = "unsloth/LTX-2.3-GGUF";+const KLEIN = "unsloth/FLUX.2-klein-9B-GGUF";+const SEEDS: Row[] = [+ { id: LTX, isGguf: true },+ { id: KLEIN, isGguf: true },+];+// What the listing reports for those repos (HF `expand=gguf` totals).+const LTX_PARAMS = 21_005_004_544;+const KLEIN_PARAMS = 9_078_581_248;+const OTHER = "unsloth/Wan2.2-T2V-A14B-GGUF";++// The Video picker's task gate: no usable pipeline tag means dropped.+const VIDEO_TASKS = ["text-to-video", "image-to-video"];+const keepVideo = (r: Row) =>+ r.pipelineTag != null && VIDEO_TASKS.includes(r.pipelineTag);++const ids = (rows: Row[]) => rows.map((r) => r.id);++test("a curated row the listing reports but the filters drop keeps its seed", () => {+ // The task gate rejects LTX-2.3 (no pipeline tag), so its painted row stays.+ const results: Row[] = [+ { id: LTX, isGguf: true, totalParams: LTX_PARAMS },+ { id: OTHER, isGguf: true, pipelineTag: "text-to-video" },+ ];+ assert.deepEqual(+ ids(+ orderRecommendedRows({+ seeds: SEEDS,+ results,+ keep: keepVideo,+ deviceFiltered: false,+ fits: () => true,+ }),+ ),+ [LTX, KLEIN, OTHER],+ );+});++test("a listing row that passes the filters takes over its seed, in catalog order", () => {+ const listedLtx: Row = {+ id: LTX,+ isGguf: true,+ totalParams: LTX_PARAMS,+ pipelineTag: "image-to-video",+ };+ const extra: Row = { id: OTHER, isGguf: true, pipelineTag: "text-to-video" };+ const out = orderRecommendedRows({+ seeds: SEEDS,+ results: [extra, listedLtx],+ keep: keepVideo,+ deviceFiltered: false,+ fits: () => true,+ });+ assert.deepEqual(ids(out), [LTX, KLEIN, OTHER]);+ // The listing's row, not the bare seed.+ assert.equal(out[0], listedLtx);+});++test("device fit is judged on whichever row renders", () => {+ const small = { memoryTotalGb: 6, systemRamAvailableGb: 0, budgetKnown: true };+ const big = { memoryTotalGb: 80, systemRamAvailableGb: 0, budgetKnown: true };+ const listedLtx: Row = {+ id: LTX,+ isGguf: true,+ totalParams: LTX_PARAMS,+ pipelineTag: "image-to-video",+ };+ const listedKlein: Row = {+ id: KLEIN,+ isGguf: true,+ totalParams: KLEIN_PARAMS,+ pipelineTag: "text-to-video",+ };+ const results = [listedLtx, listedKlein];+ // 21B -> 8.4 GB smallest quant, past a 6 GB card's 4.2 GB budget; 9B -> 3.6 GB.+ assert.equal(hfModelFitsDevice(listedLtx, small), false);+ assert.equal(hfModelFitsDevice(listedKlein, small), true);+ assert.deepEqual(+ ids(+ orderRecommendedRows({+ seeds: SEEDS,+ results,+ keep: keepVideo,+ deviceFiltered: true,+ fits: (r: Row) => hfModelFitsDevice(r, small),+ }),+ ),+ [KLEIN],+ );+ assert.deepEqual(+ ids(+ orderRecommendedRows({+ seeds: SEEDS,+ results,+ keep: keepVideo,+ deviceFiltered: true,+ fits: (r: Row) => hfModelFitsDevice(r, big),+ }),+ ),+ [LTX, KLEIN],+ );+});++test("an unlisted seed is sized from its id, and hidden when it cannot be", () => {+ const small = { memoryTotalGb: 6, systemRamAvailableGb: 0, budgetKnown: true };+ // "LTX-2.3" has no "<n>B" token, so requireKnown hides it; "klein-9B" reads+ // as 9B -> 3.6 GB, inside the 4.2 GB budget.+ assert.equal(hfModelFitsDevice(SEEDS[0], small), false);+ assert.equal(hfModelFitsDevice(SEEDS[1], small), true);+ assert.deepEqual(+ ids(+ orderRecommendedRows({+ seeds: SEEDS,+ results: [],+ keep: keepVideo,+ deviceFiltered: true,+ fits: (r: Row) => hfModelFitsDevice(r, small),+ }),+ ),+ [KLEIN],+ );+});++// Neither is unsloth-owned, and Recommended lists `owner: unsloth` only, so+// their seed is the only row they ever get.+const SDXL = "stabilityai/sdxl-turbo";+const WAN = "Wan-AI/Wan2.2-TI2V-5B-Diffusers";+// A seed row as the picker builds it: catalog size, no listing metadata.+const seed = (id: string, catalog = IMAGE_CATALOG): Row => ({+ id,+ isGguf: false,+ curatedSizeBytes: curatedSizeBytesFor(id, catalog),+});++test("a catalog-sized seed is judged on the catalog size, not on its id", () => {+ // 24 GB card -> 16.8 GB budget.+ const card = { memoryTotalGb: 24, systemRamAvailableGb: 0, budgetKnown: true };+ const sdxl = seed(SDXL);+ const wan = seed(WAN, VIDEO_CATALOG);+ // SDXL Turbo is 8 GB but its id has no "<n>B" token to guess from; Wan 2.2+ // TI2V is 30 GB, and its "5B" reads as 2 GB.+ assert.equal(sdxl.curatedSizeBytes, 8 * 1024 ** 3);+ assert.equal(wan.curatedSizeBytes, 30 * 1024 ** 3);+ assert.equal(hfModelFitsDevice(sdxl, card), true);+ assert.equal(hfModelFitsDevice(wan, card), false);+ assert.deepEqual(+ ids(+ orderRecommendedRows({+ seeds: [sdxl, wan],+ results: [],+ keep: () => true,+ deviceFiltered: true,+ fits: (r: Row) => hfModelFitsDevice(r, card),+ }),+ ),+ [SDXL],+ );+});++test("a listing row still overrides the catalog size it seeded with", () => {+ const card = { memoryTotalGb: 24, systemRamAvailableGb: 0, budgetKnown: true };+ // GGUF groups carry no catalog size, so an unsized GGUF seed stays hidden.+ assert.equal(curatedSizeBytesFor(LTX, VIDEO_CATALOG), undefined);+ assert.equal(hfModelFitsDevice({ id: LTX, isGguf: true }, card), false);+ // Where a row arrives it is the one measured: klein-9B seeds as a fit, then+ // its listing row cuts it on real metadata.+ const listedKlein: Row = {+ id: KLEIN,+ isGguf: true,+ totalParams: 200e9,+ pipelineTag: "text-to-video",+ };+ assert.deepEqual(+ ids(+ orderRecommendedRows({+ seeds: SEEDS,+ results: [listedKlein],+ keep: keepVideo,+ deviceFiltered: true,+ fits: (r: Row) => hfModelFitsDevice(r, card),+ }),+ ),+ [],+ );+});++// unsloth owns this one, so the listing DOES report it, and the seed hands off.+const BNB = "unsloth/Z-Image-Turbo-unsloth-bnb-4bit";++test("a listing row inherits the curated size of the seed it takes over", () => {+ // 8 GB card -> 5.6 GB budget.+ const card = { memoryTotalGb: 8, systemRamAvailableGb: 0, budgetKnown: true };+ const bnbSeed = seed(BNB);+ assert.equal(bnbSeed.curatedSizeBytes, 8 * 1024 ** 3);+ // The Hub row carries params only, and the quant guess assumes a quant still to+ // come: 6B -> 2.4 GB for a repo already 4-bit and 8 GB resident, so without the+ // handoff it would flip to fitting.+ const listed: Row = { id: BNB, isGguf: false, totalParams: 6e9 };+ assert.equal(hfModelFitsDevice(listed, card), true);+ assert.equal(hfModelFitsDevice(bnbSeed, card), false);+ assert.deepEqual(+ ids(+ orderRecommendedRows({+ seeds: [bnbSeed],+ results: [listed],+ keep: () => true,+ deviceFiltered: true,+ fits: (r: Row) => hfModelFitsDevice(r, card),+ }),+ ),+ [],+ );+});++test("a task row is sized against the device the load lands on", () => {+ const twoCards = {+ available: true,+ budgetKnown: true,+ memoryTotalGb: 16,+ maxDeviceMemoryGb: 8,+ loadDeviceMemoryGb: 8,+ systemRamAvailableGb: 0,+ };+ // Chat may split across both cards; an image/video pipeline lands on one.+ assert.equal(loadScopedGpu(twoCards, false).memoryTotalGb, 16);+ assert.equal(loadScopedGpu(twoCards, true).memoryTotalGb, 8);+ // SDXL Turbo is 8 GB: inside the 11.2 GB aggregate budget, past the 5.6 GB+ // one card offers, so only the load-scoped budget hides the OOM.+ const sdxl = seed(SDXL);+ assert.equal(hfModelFitsDevice(sdxl, twoCards), true);+ assert.equal(hfModelFitsDevice(sdxl, loadScopedGpu(twoCards, true)), false);+});++test("both search lists judge a curated id the same way", () => {+ const oneCard = {+ available: true,+ budgetKnown: true,+ memoryTotalGb: 8,+ maxDeviceMemoryGb: 8,+ loadDeviceMemoryGb: 8,+ systemRamAvailableGb: 0,+ };+ const opts = {+ isGguf: false,+ curatedSizeBytes: curatedSizeBytesFor(BNB, IMAGE_CATALOG),+ gpu: oneCard,+ inferenceGpu: oneCard,+ taskScoped: true,+ };+ // The curated list has the id alone, the Hub list the row with its 6B params.+ // Both size to the catalog's 8 GB, past the 5.6 GB budget, so an id one drops+ // cannot return through the other.+ assert.equal(searchRowFitsDevice({ id: BNB }, opts), false);+ assert.equal(searchRowFitsDevice({ id: BNB, totalParams: 6e9 }, opts), false);+});++test("a search row is sized against the device a task load lands on", () => {+ const twoCards = {+ available: true,+ budgetKnown: true,+ memoryTotalGb: 16,+ maxDeviceMemoryGb: 8,+ loadDeviceMemoryGb: 8,+ systemRamAvailableGb: 0,+ };+ const opts = {+ isGguf: false,+ curatedSizeBytes: curatedSizeBytesFor(SDXL, IMAGE_CATALOG),+ gpu: twoCards,+ inferenceGpu: twoCards,+ };+ // 8 GB fits the 11.2 GB aggregate a chat load may split across, but not the+ // 5.6 GB of the single card an image pipeline lands on.+ assert.equal(+ searchRowFitsDevice({ id: SDXL }, { ...opts, taskScoped: false }),+ true,+ );+ assert.equal(+ searchRowFitsDevice({ id: SDXL }, { ...opts, taskScoped: true }),+ false,+ );+});++test("a GPU-less host keeps its unified-memory budget", () => {+ const mac = {+ available: false,+ budgetKnown: true,+ memoryTotalGb: 0,+ maxDeviceMemoryGb: 0,+ loadDeviceMemoryGb: 0,+ systemRamAvailableGb: 64,+ };+ assert.equal(loadScopedGpu(mac, true), mac);+});diff --git a/tests/studio/test_model_picker_catalog_first_paint.py b/tests/studio/test_model_picker_catalog_first_paint.pynew file mode 100644index 00000000000..2e8956e9628--- /dev/null+++ b/tests/studio/test_model_picker_catalog_first_paint.py@@ -0,0 +1,66 @@+# SPDX-License-Identifier: AGPL-3.0-only+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++"""First-paint contract for the Images / Video model pickers.++Recommended used to render the Hugging Face listing alone, so a task-scoped+picker sat on a spinner for a round trip with its curated models already in+memory, and the bottom spinner stayed up while pages remained rather than while+one was in flight.+"""++from pathlib import Path+++REPO = Path(__file__).resolve().parents[2]+PICKERS_TSX = (+ REPO / "studio/frontend/src/features/model-picker/components/model-selector/pickers.tsx"+)+++def _source() -> str:+ return PICKERS_TSX.read_text(encoding = "utf-8")+++def test_curated_catalog_becomes_rows_without_a_request():+ source = _source()+ seed_start = source.index("const catalogSeedRows = useMemo<HfModelResult[]>(")+ seed_end = source.index("const recommendedRows = useMemo(", seed_start)+ seed = source[seed_start:seed_end]++ # Built from the `models` prop, never from a fetch result.+ assert "dedupe(models.map((model) => model.id))" in seed+ assert "recommendedSearch" not in seed+ # Chat has no catalog: leave it on the listing.+ assert "if (!task) return [];" in seed+ # Same format policy as the listing rows, so nothing vanishes when one lands.+ assert "isRecommendableFormat(id, isG, isMac)" in seed+ assert "matchesFormatFilter(id, isG, formatFilter)" in seed+ # Device fit reads the catalog size, not an id "<n>B" guess.+ assert "curatedSizeBytes: catalog ? curatedSizeBytesFor(id, catalog) : undefined," in seed+++def test_listing_takes_over_each_id_once_it_reports_it():+ source = _source()+ rows_start = source.index("const recommendedRows = useMemo(")+ rows_end = source.index("const recommendedMeta = useMemo(", rows_start)+ rows = source[rows_start:rows_end]++ # orderRecommendedRows hands a seed over only to a row that survived `keep`:+ # keying on the raw result set dropped curated rows the filters rejected.+ assert "return orderRecommendedRows({" in rows+ assert "seeds: catalogSeedRows," in rows+ assert "results: recommendedSearch.results," in rows+ assert "keep,\n deviceFiltered,\n fits,\n });" in rows+ assert "recommendedSearch.results.map((r) => r.id)" not in rows+++def test_bottom_spinner_shows_only_while_a_page_is_in_flight():+ source = _source()+ start = source.index("{recommendedSearch.hasMore && (")+ block = source[start : start + 700]++ # The sentinel still mounts on hasMore, so paging continues...+ assert '<div ref={recommendedSentinelRef} className="h-px" />' in block+ # ...but the spinner is gated on the in-flight flag.+ assert "{recommendedSearch.isLoadingMore ? (" in block