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: count companion assets in the Hub download size of image and video GGUFs (#12370)
oobaboogaa76ac47c81e6
diff --git a/studio/frontend/src/features/hub/catalog/download-section.tsx b/studio/frontend/src/features/hub/catalog/download-section.tsxindex ce1dd191ce3..4c53b546061 100644--- a/studio/frontend/src/features/hub/catalog/download-section.tsx+++ b/studio/frontend/src/features/hub/catalog/download-section.tsx@@ -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 type { MediaStudioPage } from "../hooks/use-media-companion-bytes";import type { ModelInventoryFormat } from "../inventory";import type { HubModelRunSelection } from "../lib/model-run-selection";import { GgufDownloadCard } from "./gguf-download-card";@@ -30,7 +31,7 @@ export function DownloadSection({runPending = false,onChange,showMemoryBar = true,- mediaRuntime = false,+ mediaPage,}: {repoId: string;isGguf: boolean;@@ -57,7 +58,7 @@ export function DownloadSection({/** False for diffusion / audio / video GGUFs, which do not load through* llama.cpp and so have nothing the KV estimator can say about them. */showMemoryBar?: boolean;- mediaRuntime?: boolean;+ mediaPage?: MediaStudioPage;}) {if (isGguf || preferredGgufFile) {return (@@ -77,7 +78,7 @@ export function DownloadSection({runPending={runPending}onChange={onChange}showMemoryBar={showMemoryBar}- mediaRuntime={mediaRuntime}+ mediaPage={mediaPage}/>);}diff --git a/studio/frontend/src/features/hub/catalog/gguf-download-card.tsx b/studio/frontend/src/features/hub/catalog/gguf-download-card.tsxindex 7468c2cef65..5b845f47299 100644--- a/studio/frontend/src/features/hub/catalog/gguf-download-card.tsx+++ b/studio/frontend/src/features/hub/catalog/gguf-download-card.tsx@@ -22,7 +22,11 @@ import {} from "@/components/ui/tooltip";import { usePlatformStore } from "@/config/env";import { getCachedModelPath, revealCachedModel } from "@/features/chat";-import { pinKey, usePinnedModelsStore } from "@/features/model-picker";+import {+ formatFootprintBytes,+ pinKey,+ usePinnedModelsStore,+} from "@/features/model-picker";import { useVramBudgetFraction } from "@/hooks/use-vram-budget-fraction";import { ChevronDownStandardIcon } from "@/lib/chevron-icons";import { copyToClipboard } from "@/lib/copy-to-clipboard";@@ -35,6 +39,7 @@ import {Delete02Icon,Download01Icon,Folder01Icon,+ HelpCircleIcon,InformationCircleIcon,MoreVerticalIcon,PinIcon,@@ -56,6 +61,12 @@ import {useHttpPartialsResumable,useRepoDownload,} from "../download-manager";+import {+ type GgufVariantFootprint,+ type MediaStudioPage,+ ggufVariantFootprint,+ useMediaCompanionBytes,+} from "../hooks/use-media-companion-bytes";import { useOnlineStatus } from "../hooks/use-online-status";import { type GgufVariantDetail, deleteCachedModel } from "../inventory";import { formatBytes } from "../lib/format";@@ -245,6 +256,48 @@ interface GgufVariantMenuItem {downloaded: boolean;partial: boolean;downloadSizeLabel: string;+ footprint: GgufVariantFootprint | null;+}++/** Model plus uncached companion size, with the breakdown on hover. */+function GgufVariantSizeLabel({+ label,+ footprint,+}: {+ label: string;+ footprint: GgufVariantFootprint | null;+}) {+ if (!footprint) return <>{label}</>;+ return (+ <Tooltip delayDuration={0}>+ <TooltipTrigger asChild={true}>+ <span+ data-model-download-footprint={true}+ className="inline-flex items-center gap-1"+ >+ {formatFootprintBytes(+ footprint.checkpointBytes + footprint.companionBytes,+ )}+ {/* Align the icon with the digits. */}+ <HugeiconsIcon+ icon={HelpCircleIcon}+ aria-hidden={true}+ className="size-3 shrink-0 -translate-y-[0.08em] text-muted-foreground/80"+ strokeWidth={1.8}+ />+ </span>+ </TooltipTrigger>+ <TooltipContent side="top" className="tooltip-compact">+ <span className="font-medium">+ {formatFootprintBytes(footprint.checkpointBytes)} model +{" "}+ {formatFootprintBytes(footprint.companionBytes)} required assets+ </span>+ <span className="ml-1 text-muted-foreground">+ · assets download on Run+ </span>+ </TooltipContent>+ </Tooltip>+ );}function createGgufVariantMenuItems(@@ -255,6 +308,7 @@ function createGgufVariantMenuItems(systemRamGb?: number;budgetFraction?: number;},+ companionBytesByKey: ReadonlyMap<string, number>,): GgufVariantMenuItem[] {if (!variants) return [];return variants.map((variant) => ({@@ -266,6 +320,7 @@ function createGgufVariantMenuItems(downloaded: Boolean(variant.downloaded),partial: Boolean(variant.partial),downloadSizeLabel: ggufVariantTransferLabel(variant),+ footprint: ggufVariantFootprint(variant, companionBytesByKey),}));}@@ -529,7 +584,10 @@ const GgufVariantMenuRow = memo(function GgufVariantMenuRow({</span><span className="ml-auto flex shrink-0 items-center gap-1.5"><span className={cn(CHIP_BASE, CHIP_DEFAULT)}>- {item.downloadSizeLabel}+ <GgufVariantSizeLabel+ label={item.downloadSizeLabel}+ footprint={item.footprint}+ /></span>{/* Options only apply to files on disk; placeholder keeps the sizechips column-aligned across rows. */}@@ -568,7 +626,7 @@ export function GgufDownloadCard({runPending = false,onChange,showMemoryBar = true,- mediaRuntime = false,+ mediaPage,}: {repoId: string;isActive: boolean;@@ -594,12 +652,11 @@ export function GgufDownloadCard({* weights-only verdict anyway, which is a confident number about the wrong* runtime. The picker suppresses these rows for the same reason. */showMemoryBar?: boolean;- /** This repo is placed by the diffusion planner, not llama-server. Suppresses the fit badges- * for the same reason it suppresses the memory bar: the budget and the offload rules here are- * llama.cpp's, and an oversized diffusion model gets told it "still works with offloading"- * when on a host pool the planner refuses the load outright. */- mediaRuntime?: boolean;+ /** Selects the companion download planner and hides llama.cpp fit badges,+ * whose memory and offload rules do not apply to media models. */+ mediaPage?: MediaStudioPage;}) {+ const mediaRuntime = mediaPage !== undefined;const hfToken = useHfTokenStore((s) => s.token);const online = useOnlineStatus();const partialsResumable = useHttpPartialsResumable();@@ -681,17 +738,6 @@ export function GgufDownloadCard({: v,);}, [completedVariantKeys, liveVariantStates, rawSortedVariants]);- const variantMenuItems = useMemo(- () =>- createGgufVariantMenuItems(sortedVariants, {- gpuGb,- gpuCount,- systemRamGb,- budgetFraction,- }),- [gpuGb, gpuCount, sortedVariants, systemRamGb, budgetFraction],- );-const selectedQuant =(selectedQuantOverride? sortedVariants?.find((v) =>@@ -700,6 +746,37 @@ export function GgufDownloadCard({: null) ??sortedVariants?.[0]?.quant ??null;+ const selected =+ sortedVariants?.find((v) => ggufVariantsMatch(v.quant, selectedQuant)) ??+ null;+ const companionBytesByKey = useMediaCompanionBytes(+ mediaPage,+ repoId,+ variants,+ selected?.filename,+ hfToken,+ );+ const variantMenuItems = useMemo(+ () =>+ createGgufVariantMenuItems(+ sortedVariants,+ {+ gpuGb,+ gpuCount,+ systemRamGb,+ budgetFraction,+ },+ companionBytesByKey,+ ),+ [+ gpuGb,+ gpuCount,+ sortedVariants,+ systemRamGb,+ budgetFraction,+ companionBytesByKey,+ ],+ );const job = useRepoDownload({kind: "model",@@ -763,9 +840,6 @@ export function GgufDownloadCard({);}, [loading, error, refreshError, variants]);- const selected =- sortedVariants?.find((v) => ggufVariantsMatch(v.quant, selectedQuant)) ??- null;const selectedLiveState = selectedQuant? liveVariantStates.get(normalizeGgufVariantIdentity(selectedQuant)): undefined;@@ -794,6 +868,9 @@ export function GgufDownloadCard({const selectedDownloadSizeLabel = selected? ggufVariantTransferLabel(selected): null;+ const selectedFootprint = selected+ ? ggufVariantFootprint(selected, companionBytesByKey)+ : null;const updateAvailable =selected?.downloaded === true && selected.update_available === true;const selectedVariantKey = selectedQuant@@ -1091,11 +1168,15 @@ export function GgufDownloadCard({)}{/* Size beats format tag on phones. */}<DotTag tone="gguf" label="GGUF" className="max-sm:hidden" />+ {/* Downloaded quants show a size only while Run still has assets to fetch. */}{selected &&selectedDownloadSizeLabel &&- !selected.downloaded && (+ (!selected.downloaded || selectedFootprint) && (<span className="shrink-0 tabular-nums">- {selectedDownloadSizeLabel}+ <GgufVariantSizeLabel+ label={selectedDownloadSizeLabel}+ footprint={selectedFootprint}+ /></span>)}</span>diff --git a/studio/frontend/src/features/hub/catalog/model-inspector.tsx b/studio/frontend/src/features/hub/catalog/model-inspector.tsxindex 61e0c5f2090..c34e4dfcfb1 100644--- a/studio/frontend/src/features/hub/catalog/model-inspector.tsx+++ b/studio/frontend/src/features/hub/catalog/model-inspector.tsx@@ -704,7 +704,7 @@ export const ModelInspector = memo(function ModelInspector({) : (<DownloadSectionshowMemoryBar={!runsOnMediaRuntime}- mediaRuntime={runsOnMediaRuntime}+ mediaPage={mediaPage}repoId={model.isLocal ? (model.hubRepoId ?? model.id) : model.id}isGguf={model.isGguf}{...downloadState}diff --git a/studio/frontend/src/features/hub/hooks/use-media-companion-bytes.ts b/studio/frontend/src/features/hub/hooks/use-media-companion-bytes.tsnew file mode 100644index 00000000000..70ab4ba51c6--- /dev/null+++ b/studio/frontend/src/features/hub/hooks/use-media-companion-bytes.ts@@ -0,0 +1,172 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++// eslint-disable-next-line no-restricted-imports -- Direct API imports keep the media pages code-split.+import { getDiffusionDownloadPlan } from "@/features/images/api";+// eslint-disable-next-line no-restricted-imports -- Direct API imports keep the media pages code-split.+import { getVideoDownloadPlan } from "@/features/video/api";+import { useEffect, useMemo, useRef, useState } from "react";+import type { GgufVariantDetail } from "../inventory";+import { ggufVariantDownloadSizeBytes } from "../lib/gguf-variant-sort";+import { fingerprintToken } from "../lib/token-fingerprint";+import { hfApiToken } from "../stores/hf-token-store";++export type MediaStudioPage = "images" | "video";++const EMPTY_COMPANION_BYTES: ReadonlyMap<string, number> = new Map();++export interface GgufVariantFootprint {+ checkpointBytes: number;+ companionBytes: number;+}++type CompanionPlanRequest = [+ companionKey: string,+ filename: string,+ sizeBytes: number,+];++/** dependency_key groups variants with identical companions. Without one (video+ * families among them) companions can differ per file, so each file is its own group. */+function companionKey(variant: GgufVariantDetail): string {+ return variant.dependency_key ?? `file:${variant.filename}`;+}++/** One plan per keyed group; an unkeyed file is planned only once selected. */+export function companionPlanRequests(+ page: MediaStudioPage | undefined,+ variants: readonly GgufVariantDetail[] | null,+ selectedFilename: string | null | undefined,+): CompanionPlanRequest[] {+ if (!page || !variants) return [];+ const byKey = new Map<string, CompanionPlanRequest>();+ for (const variant of variants) {+ const key = companionKey(variant);+ if (+ variant.dependency_key == null &&+ variant.filename !== selectedFilename+ ) {+ continue;+ }+ if (!byKey.has(key)) {+ byKey.set(key, [key, variant.filename, variant.size_bytes]);+ }+ }+ return Array.from(byKey.values());+}++/** Companion bytes Run would still download with default load settings, or null for none. */+export async function resolveCompanionBytes(+ page: MediaStudioPage,+ repoId: string,+ filename: string,+ sizeBytes: number,+ hfToken: string | null | undefined,+): Promise<number | null> {+ const request = {+ model_path: repoId,+ gguf_filename: filename,+ model_kind: "gguf" as const,+ hf_token: hfApiToken(hfToken),+ };+ const plan =+ page === "video"+ ? await getVideoDownloadPlan(request)+ : await getDiffusionDownloadPlan(request);+ // Rejected, not null, so the per-card cache drops it and a later rerun retries.+ if (plan.plan_failed) throw new Error("Download plan incomplete");+ // A backend without the per-entry flag cannot say which bytes are the checkpoint's.+ if (plan.entries.some((entry) => entry.checkpoint === undefined)) return null;+ const checkpointBytes = plan.checkpoint_bytes || sizeBytes;+ // Entries hold only uncached files; required_bytes would count cached companions too.+ const companionBytes = plan.entries.reduce(+ (sum, entry) =>+ sum ++ (entry.checkpoint+ ? Math.max(0, entry.bytes - checkpointBytes)+ : entry.bytes),+ 0,+ );+ return companionBytes > 0 ? companionBytes : null;+}++/** Partial rows keep their "X left" size. Downloaded rows still get companions, which Run fetches. */+export function ggufVariantFootprint(+ variant: GgufVariantDetail,+ companionBytesByKey: ReadonlyMap<string, number>,+): GgufVariantFootprint | null {+ if (variant.partial) return null;+ const companionBytes = companionBytesByKey.get(companionKey(variant));+ if (companionBytes === undefined) return null;+ return {+ checkpointBytes: ggufVariantDownloadSizeBytes(variant),+ companionBytes,+ };+}++/** Companion bytes by group. Plans live as long as the card, so returning from Run,+ * which fetches the companions, plans again. */+export function useMediaCompanionBytes(+ page: MediaStudioPage | undefined,+ repoId: string,+ variants: readonly GgufVariantDetail[] | null,+ selectedFilename: string | null | undefined,+ hfToken: string | null | undefined,+): ReadonlyMap<string, number> {+ const identity = page+ ? JSON.stringify([page, repoId, fingerprintToken(hfToken)])+ : "";+ const requests = useMemo(+ () => companionPlanRequests(page, variants, selectedFilename),+ [page, variants, selectedFilename],+ );+ const [resolved, setResolved] = useState<{+ identity: string;+ companionBytes: ReadonlyMap<string, number>;+ }>(() => ({ identity: "", companionBytes: EMPTY_COMPANION_BYTES }));+ // Variant refetches and reselection rerun the effect; this keeps them from re-planning.+ const plans = useRef(new Map<string, Promise<number | null>>());++ useEffect(() => {+ if (!page) return;+ let cancelled = false;+ for (const [key, filename, sizeBytes] of requests) {+ const planKey = JSON.stringify([identity, key, filename]);+ let plan = plans.current.get(planKey);+ if (!plan) {+ plan = resolveCompanionBytes(+ page,+ repoId,+ filename,+ sizeBytes,+ hfToken,+ );+ plans.current.set(planKey, plan);+ plan.catch(() => plans.current.delete(planKey));+ }+ plan+ .then((companionBytes) => {+ if (cancelled || companionBytes === null) return;+ setResolved((previous) => {+ const same = previous.identity === identity;+ if (same && previous.companionBytes.get(key) === companionBytes) {+ return previous;+ }+ const next = new Map(same ? previous.companionBytes : undefined);+ next.set(key, companionBytes);+ return { identity, companionBytes: next };+ });+ })+ .catch(() => {+ // Keep the checkpoint size if the plan is unavailable.+ });+ }+ return () => {+ cancelled = true;+ };+ }, [page, repoId, hfToken, identity, requests]);++ return identity && resolved.identity === identity+ ? resolved.companionBytes+ : EMPTY_COMPANION_BYTES;+}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 72290833128..bcee222dae2 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@@ -494,7 +494,7 @@ function ListLabel({);}-function formatBytes(bytes: number): string {+function formatBytes(bytes: number, unitSeparator = ""): string {// Guard non-positive / non-finite sizes so we never render "NaN undefined".if (!Number.isFinite(bytes) || bytes <= 0) return "0 B";// Decimal (base-1000) units to match Hugging Face's reported sizes; the GPU-fit math stays@@ -508,7 +508,7 @@ function formatBytes(bytes: number): string {i += 1;}// No space: "145MB" reads as one value beside the quant chip.- return `${value.toFixed(value < 10 ? 1 : 0)}${units[i]}`;+ return `${value.toFixed(value < 10 ? 1 : 0)}${unitSeparator}${units[i]}`;}// Most distinguishing first, since only the first MAX_CAPABILITY_BADGES are drawn: what a@@ -863,6 +863,15 @@ function SizeText({ value }: { value: string }) {);}+/** One decimal through GB/TB, so a total and its model + assets breakdown visibly add up. */+export function formatFootprintBytes(bytes: number): string {+ return bytes >= 1_000_000_000 && bytes < 1_000_000_000_000+ ? `${(bytes / 1_000_000_000).toFixed(1)} GB`+ : bytes >= 1_000_000_000_000+ ? `${(bytes / 1_000_000_000_000).toFixed(1)} TB`+ : formatBytes(bytes, " ");+}+/** Keep the row's size treatment consistent with every other model; diffusion GGUFs get one* small explanation affordance, since their checkpoint is only part of what is kept on disk. */export function GgufDownloadFootprint({@@ -872,25 +881,21 @@ export function GgufDownloadFootprint({checkpointBytes: number;companionBytes: number;}) {- const totalBytes = checkpointBytes + companionBytes;- // Whole-GB rounding is too lossy for a sum ("2.6 GB + 8.2 GB = 11 GB" looks contradictory),- // so keep one decimal through GB/TB.- const totalLabel =- totalBytes >= 1_000_000_000 && totalBytes < 1_000_000_000_000- ? `${(totalBytes / 1_000_000_000).toFixed(1)} GB`- : totalBytes >= 1_000_000_000_000- ? `${(totalBytes / 1_000_000_000_000).toFixed(1)} TB`- : formatBytes(totalBytes);+ const totalLabel = formatFootprintBytes(checkpointBytes + companionBytes);return (<spandata-model-download-footprint={true}className="flex items-center gap-1 whitespace-nowrap text-muted-foreground">- <SizeText value={totalLabel} />+ {/* Keep flex gaps out of SizeText's fragments. */}+ <span>+ <SizeText value={totalLabel} />+ </span>+ {/* Align the icon with the digits. */}<spandata-model-download-footprint-help={true}aria-hidden={true}- className="flex size-3.5 shrink-0 items-center justify-center text-muted-foreground/80"+ className="flex size-3.5 shrink-0 -translate-y-[0.25em] items-center justify-center text-muted-foreground/80"><HugeiconsIcon icon={HelpCircleIcon} className="size-3" strokeWidth={1.8} /></span>@@ -910,7 +915,8 @@ export function GgufDownloadFootprintExplanation({<><span className="font-medium">Full required size</span><span className="ml-1 text-muted-foreground">- {formatBytes(checkpointBytes)} model + {formatBytes(companionBytes)} required assets+ {formatFootprintBytes(checkpointBytes)} model +{" "}+ {formatFootprintBytes(companionBytes)} required assets</span></>);diff --git a/studio/frontend/src/features/model-picker/index.ts b/studio/frontend/src/features/model-picker/index.tsindex 4fd64727a63..51fe7584819 100644--- a/studio/frontend/src/features/model-picker/index.ts+++ b/studio/frontend/src/features/model-picker/index.ts@@ -5,6 +5,7 @@ export { ModelSelector } from "./components/model-selector";export { FolderBrowser } from "./components/model-selector/folder-browser";export { invalidateLlamaFlagCatalog } from "./api/llama-flags";export { ModelRowMenu } from "./components/model-selector/model-row-menu";+export { formatFootprintBytes } from "./components/model-selector/pickers";export {makePinRank,pinKey,diff --git a/studio/frontend/tests/hub-media-download-footprint.test.ts b/studio/frontend/tests/hub-media-download-footprint.test.tsnew file mode 100644index 00000000000..c19d1f753c6--- /dev/null+++ b/studio/frontend/tests/hub-media-download-footprint.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++// Hub sizes must include the companion assets Run would still download.++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();++const GGUF_BYTES = 5_390_223_072;+const COMPANION_BYTES = 18_900_000_000;+const GGUF_REPO = "unsloth/Qwen-Image-2.1-GGUF";++let planBody: Record<string, unknown> = {};+const requests: { url: string; body: Record<string, unknown> }[] = [];++globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {+ requests.push({+ url: String(input),+ body: JSON.parse(String(init?.body ?? "{}")),+ });+ return new Response(JSON.stringify(planBody), {+ status: 200,+ headers: { "Content-Type": "application/json" },+ });+}) as typeof fetch;++const { companionPlanRequests, ggufVariantFootprint, resolveCompanionBytes } =+ await import("../src/features/hub/hooks/use-media-companion-bytes.ts");++function entry(repo: string, bytes: number, checkpoint = false) {+ // biome-ignore lint/style/useNamingConvention: API schema+ return { repo_id: repo, files: [], bytes, gguf_filename: null, checkpoint };+}++function plan(+ entries: ({ bytes: number } & Record<string, unknown>)[],+ extra = {},+) {+ return {+ entries,+ // biome-ignore lint/style/useNamingConvention: API schema+ total_bytes: entries.reduce((sum, e) => sum + e.bytes, 0),+ // biome-ignore lint/style/useNamingConvention: API schema+ required_bytes: GGUF_BYTES + COMPANION_BYTES,+ // biome-ignore lint/style/useNamingConvention: API schema+ checkpoint_bytes: GGUF_BYTES,+ ...extra,+ };+}++const resolve = () =>+ resolveCompanionBytes("images", GGUF_REPO, "q5.gguf", GGUF_BYTES, "hf_x");++function variant(+ quant: string,+ overrides: Record<string, unknown> = {},+): Parameters<typeof ggufVariantFootprint>[0] {+ return {+ filename: `qwen-image-2.1-${quant}.gguf`,+ quant,+ // biome-ignore lint/style/useNamingConvention: API schema+ size_bytes: GGUF_BYTES,+ // biome-ignore lint/style/useNamingConvention: API schema+ dependency_key: "qwen-image-2.1",+ ...overrides,+ };+}++test("companions are the uncached plan entries beyond the checkpoint", async () => {+ requests.length = 0;+ planBody = plan([+ entry(GGUF_REPO, GGUF_BYTES, true),+ entry("Qwen/Qwen-Image-2.1", COMPANION_BYTES),+ ]);+ assert.equal(await resolve(), COMPANION_BYTES);+ assert.match(requests[0].url, /\/api\/inference\/images\/download-plan$/);+ assert.deepEqual(requests[0].body, {+ // biome-ignore lint/style/useNamingConvention: API schema+ model_path: GGUF_REPO,+ // biome-ignore lint/style/useNamingConvention: API schema+ gguf_filename: "q5.gguf",+ // biome-ignore lint/style/useNamingConvention: API schema+ model_kind: "gguf",+ // biome-ignore lint/style/useNamingConvention: API schema+ hf_token: "hf_x",+ });++ // A checkpoint entry can also carry companions from the same repo.+ planBody = plan([entry(GGUF_REPO, GGUF_BYTES + 7, true)]);+ assert.equal(await resolve(), 7);+ // A cached checkpoint leaves its repo's missing companions unflagged.+ planBody = plan([entry(GGUF_REPO, 7)]);+ assert.equal(await resolve(), 7);+ // Without the flag (older backend) the bytes cannot be attributed: a scoped+ // file list names the GGUF whether or not it is cached.+ planBody = plan([+ {+ ...entry(GGUF_REPO, GGUF_BYTES + 7),+ files: ["q5.gguf"],+ checkpoint: undefined,+ },+ ]);+ assert.equal(await resolve(), null);+ // The listed size stands in for a checkpoint the planner could not size.+ planBody = plan([entry(GGUF_REPO, GGUF_BYTES + 7, true)], {+ // biome-ignore lint/style/useNamingConvention: API schema+ checkpoint_bytes: 0,+ });+ assert.equal(await resolve(), 7);+});++test("cached companions add nothing, whatever required_bytes says", async () => {+ planBody = plan([entry(GGUF_REPO, GGUF_BYTES, true)]);+ assert.equal(await resolve(), null);+});++test("an incomplete plan is rejected so it is not kept", async () => {+ planBody = plan([entry("Qwen/Qwen-Image-2.1", COMPANION_BYTES)], {+ // biome-ignore lint/style/useNamingConvention: API schema+ plan_failed: true,+ });+ await assert.rejects(resolve());+});++test("a video repo asks the video planner", async () => {+ requests.length = 0;+ planBody = plan([]);+ await resolveCompanionBytes("video", "org/video-GGUF", "v.gguf", 1, null);+ assert.match(requests[0].url, /\/api\/inference\/video\/download-plan$/);+});++test("one plan per companion set, and none outside the media pages", () => {+ const unkeyed = (quant: string) =>+ // biome-ignore lint/style/useNamingConvention: API schema+ variant(quant, { dependency_key: null });+ const variants = [+ variant("Q5_K_M"),+ variant("Q4_K_M"),+ // biome-ignore lint/style/useNamingConvention: API schema+ variant("Q8_0", { dependency_key: "other-base" }),+ unkeyed("F16"),+ unkeyed("BF16"),+ ];+ // Unkeyed files (video) can need different companions, so only the selected one is planned.+ assert.deepEqual(+ companionPlanRequests("images", variants, unkeyed("BF16").filename).map(+ ([key, filename]) => [key, filename],+ ),+ [+ ["qwen-image-2.1", variant("Q5_K_M").filename],+ ["other-base", variant("Q8_0").filename],+ [`file:${unkeyed("BF16").filename}`, unkeyed("BF16").filename],+ ],+ );+ assert.deepEqual(+ companionPlanRequests("images", variants, variant("Q4_K_M").filename)+ .length,+ 2,+ );+ assert.deepEqual(companionPlanRequests(undefined, variants, null), []);+ const resolved = new Map([[`file:${unkeyed("BF16").filename}`, 7]]);+ assert.equal(+ ggufVariantFootprint(unkeyed("BF16"), resolved)?.companionBytes,+ 7,+ );+ assert.equal(ggufVariantFootprint(unkeyed("F16"), resolved), null);+});++test("rows add their own set's companions, except partials", () => {+ const resolved = new Map([["qwen-image-2.1", COMPANION_BYTES]]);+ // Run, offered once the GGUF is on disk, is what fetches companions.+ for (const state of [{}, { downloaded: true }]) {+ assert.deepEqual(ggufVariantFootprint(variant("Q5_K_M", state), resolved), {+ checkpointBytes: GGUF_BYTES,+ companionBytes: COMPANION_BYTES,+ });+ }+ assert.equal(+ ggufVariantFootprint(+ // biome-ignore lint/style/useNamingConvention: API schema+ variant("Q8_0", { dependency_key: "other" }),+ resolved,+ ),+ null,+ );+ assert.equal(+ ggufVariantFootprint(variant("Q4_K_M", { partial: true }), resolved),+ null,+ );+});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 d6176057d93..e525ce2306a 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@@ -308,7 +308,7 @@ test("chat and the Hub answer the fit question with one formula", () => {);assert.match(INSPECTOR,- /showMemoryBar=\{!runsOnMediaRuntime\}\n\s*mediaRuntime=\{runsOnMediaRuntime\}/,+ /showMemoryBar=\{!runsOnMediaRuntime\}\n\s*mediaPage=\{mediaPage\}/,);// Parent rows and the fit gate take the same rule as the quant rows under them, or a media row// reads as fitting while everything inside it reads as oom.