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 / Desktop: show a cached image GGUF as Partial until Run has its text encoder and VAE (#12557)

Leo Borcherding8e2ab33d0269
diff --git a/studio/frontend/src/features/hub/catalog/gguf-download-card.tsx b/studio/frontend/src/features/hub/catalog/gguf-download-card.tsx
index 9330b383603..cf85a921796 100644
--- a/studio/frontend/src/features/hub/catalog/gguf-download-card.tsx
+++ b/studio/frontend/src/features/hub/catalog/gguf-download-card.tsx
@@ -67,6 +67,7 @@ import {
import {
type GgufVariantFootprint,
type MediaStudioPage,
+ awaitsCompanions,
ggufVariantFootprint,
useMediaCompanionBytes,
} from "../hooks/use-media-companion-bytes";
@@ -303,6 +304,33 @@ function GgufVariantSizeLabel({
);
}
+function CompanionsPendingTag({
+ companionBytes,
+ compact = false,
+}: {
+ companionBytes: number;
+ compact?: boolean;
+}) {
+ return (
+ <Tooltip>
+ <TooltipTrigger asChild={true}>
+ <span className="inline-flex">
+ <DotTag
+ tone="warning"
+ label="Partial"
+ className={compact ? "max-sm:border-0 max-sm:px-0" : undefined}
+ labelClassName={compact ? "max-sm:sr-only" : undefined}
+ />
+ </span>
+ </TooltipTrigger>
+ <TooltipContent side="top" sideOffset={4}>
+ Model on device. {formatFootprintBytes(companionBytes)} of required
+ assets download on Run.
+ </TooltipContent>
+ </Tooltip>
+ );
+}
+
function createGgufVariantMenuItems(
variants: readonly GgufVariantDetail[] | null,
resources: {
@@ -564,7 +592,13 @@ const GgufVariantMenuRow = memo(function GgufVariantMenuRow({
variant="menu"
tooltipMode="lazy"
/>
- {item.downloaded && <DotTag tone="success" label="On device" />}
+ {awaitsCompanions(item.downloaded, item.footprint) ? (
+ <CompanionsPendingTag
+ companionBytes={item.footprint?.companionBytes ?? 0}
+ />
+ ) : (
+ item.downloaded && <DotTag tone="success" label="On device" />
+ )}
{!item.downloaded && item.partial && (
<Tooltip>
<TooltipTrigger asChild={true}>
@@ -880,6 +914,10 @@ export function GgufDownloadCard({
const selectedFootprint = selected
? ggufVariantFootprint(selected, companionBytesByKey)
: null;
+ const selectedAwaitsCompanions = awaitsCompanions(
+ selected?.downloaded,
+ selectedFootprint,
+ );
const updateAvailable =
selected?.downloaded === true && selected.update_available === true;
const selectedVariantKey = selectedQuant
@@ -1147,14 +1185,21 @@ export function GgufDownloadCard({
Select quantization
</span>
)}
- {selected?.downloaded && (
- // Dot only on phones.
- <DotTag
- tone="success"
- label="On device"
- className="max-sm:border-0 max-sm:px-0"
- labelClassName="max-sm:sr-only"
+ {selectedAwaitsCompanions ? (
+ <CompanionsPendingTag
+ companionBytes={selectedFootprint?.companionBytes ?? 0}
+ compact={true}
/>
+ ) : (
+ selected?.downloaded && (
+ // Dot only on phones.
+ <DotTag
+ tone="success"
+ label="On device"
+ className="max-sm:border-0 max-sm:px-0"
+ labelClassName="max-sm:sr-only"
+ />
+ )
)}
{selected && !selected.downloaded && selected.partial && (
<Tooltip>
diff --git a/studio/frontend/src/features/hub/download-manager/download-manager-panel.tsx b/studio/frontend/src/features/hub/download-manager/download-manager-panel.tsx
index 9be5a225a0a..27a2371b37c 100644
--- a/studio/frontend/src/features/hub/download-manager/download-manager-panel.tsx
+++ b/studio/frontend/src/features/hub/download-manager/download-manager-panel.tsx
@@ -33,6 +33,7 @@ import {
} from "./download-manager-controller";
import { DownloadProgressBar } from "./download-progress-bar";
import { presentedProgress } from "./download-presentation";
+import { assetLabel } from "./required-assets";
function createOrderedJobKeysSelector(): (state: {
jobs: Record<string, ManagedDownload>;
@@ -94,7 +95,14 @@ function variantSuffix(job: ManagedDownload): string {
const isModelFile =
job.checkpoint ??
job.scopedFiles?.some((file) => file.toLowerCase().endsWith(".gguf"));
- return ` · ${isModelFile ? "Model file" : "Required assets"}`;
+ return ` · ${
+ isModelFile
+ ? "Model file"
+ : assetLabel(
+ { repoId: job.repoId, files: job.scopedFiles, bytes: 0 },
+ "Required assets",
+ )
+ }`;
}
return job.variant ? ` · ${job.variant}` : "";
}
@@ -297,7 +305,7 @@ export function DownloadManagerPanel({
<DownloadRow key={jobKey} jobKey={jobKey} />
))}
{queued.map((entry, i) => <li key={`${entry.planId}:${i}`} className="flex flex-col gap-1.5 py-2.5 pl-4 pr-3">
- <span className="truncate text-ui-12p5 font-medium">{entry.repoId}<span className="text-muted-foreground"> · {entry.checkpoint !== false ? "Model file" : "Required assets"}</span></span>
+ <span className="truncate text-ui-12p5 font-medium">{entry.repoId}<span className="text-muted-foreground"> · {entry.checkpoint !== false ? "Model file" : assetLabel(entry, "Required assets")}</span></span>
<span className="text-ui-11 text-muted-foreground">Queued</span>
</li>)}
</ul>
diff --git a/studio/frontend/src/features/hub/download-manager/required-assets.ts b/studio/frontend/src/features/hub/download-manager/required-assets.ts
index 0c1a3b79623..a0af2ab3f40 100644
--- a/studio/frontend/src/features/hub/download-manager/required-assets.ts
+++ b/studio/frontend/src/features/hub/download-manager/required-assets.ts
@@ -32,7 +32,10 @@ export function formatDownloadBytes(bytes: number): string {
if (bytes >= 1e6) return `${(bytes / 1e6).toFixed(1)} MB`;
return `${Math.ceil(bytes / 1e3)} KB`;
}
-export function assetLabel(entry: PlannedDownloadEntry): string {
+export function assetLabel(
+ entry: PlannedDownloadEntry,
+ fallback: string = entry.repoId.split("/").pop() || "Required files",
+): string {
const files = entry.files ?? [];
const weights = files.filter((f) =>
/\.(safetensors|gguf|bin|pt|pth|ckpt)$/i.test(f),
@@ -42,7 +45,7 @@ export function assetLabel(entry: PlannedDownloadEntry): string {
if (encoder && decoder) return "Encoder & decoder";
if (encoder) return "Text encoder";
if (decoder) return "Decoder & configuration";
- return entry.repoId.split("/").pop() || "Required files";
+ return fallback;
}
/** Preserve dependency order while presenting and transferring checkpoints first. */
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.ts
index 70ab4ba51c6..efad5ebe318 100644
--- a/studio/frontend/src/features/hub/hooks/use-media-companion-bytes.ts
+++ b/studio/frontend/src/features/hub/hooks/use-media-companion-bytes.ts
@@ -10,6 +10,7 @@ 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";
+import { useInventoryVersion } from "../stores/inventory-events";
export type MediaStudioPage = "images" | "video";
@@ -104,8 +105,27 @@ export function ggufVariantFootprint(
};
}
-/** Companion bytes by group. Plans live as long as the card, so returning from Run,
- * which fetches the companions, plans again. */
+export function awaitsCompanions(
+ downloaded: boolean | undefined,
+ footprint: GgufVariantFootprint | null,
+): boolean {
+ return Boolean(downloaded) && (footprint?.companionBytes ?? 0) > 0;
+}
+
+/** null (nothing left to fetch) drops the group's stale entry. */
+export function withCompanionBytes(
+ previous: ReadonlyMap<string, number>,
+ key: string,
+ companionBytes: number | null,
+): ReadonlyMap<string, number> {
+ if ((companionBytes ?? undefined) === previous.get(key)) return previous;
+ const next = new Map(previous);
+ if (companionBytes === null) next.delete(key);
+ else next.set(key, companionBytes);
+ return next;
+}
+
+/** Companion bytes by group; re-planned on inventory changes so Partial clears in place. */
export function useMediaCompanionBytes(
page: MediaStudioPage | undefined,
repoId: string,
@@ -116,6 +136,7 @@ export function useMediaCompanionBytes(
const identity = page
? JSON.stringify([page, repoId, fingerprintToken(hfToken)])
: "";
+ const inventoryVersion = useInventoryVersion();
const requests = useMemo(
() => companionPlanRequests(page, variants, selectedFilename),
[page, variants, selectedFilename],
@@ -131,7 +152,12 @@ export function useMediaCompanionBytes(
if (!page) return;
let cancelled = false;
for (const [key, filename, sizeBytes] of requests) {
- const planKey = JSON.stringify([identity, key, filename]);
+ const planKey = JSON.stringify([
+ identity,
+ inventoryVersion,
+ key,
+ filename,
+ ]);
let plan = plans.current.get(planKey);
if (!plan) {
plan = resolveCompanionBytes(
@@ -146,15 +172,16 @@ export function useMediaCompanionBytes(
}
plan
.then((companionBytes) => {
- if (cancelled || companionBytes === null) return;
+ if (cancelled) 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 };
+ const current =
+ previous.identity === identity
+ ? previous.companionBytes
+ : EMPTY_COMPANION_BYTES;
+ const next = withCompanionBytes(current, key, companionBytes);
+ return next === previous.companionBytes
+ ? previous
+ : { identity, companionBytes: next };
});
})
.catch(() => {
@@ -164,7 +191,7 @@ export function useMediaCompanionBytes(
return () => {
cancelled = true;
};
- }, [page, repoId, hfToken, identity, requests]);
+ }, [page, repoId, hfToken, identity, inventoryVersion, requests]);
return identity && resolved.identity === identity
? resolved.companionBytes
diff --git a/studio/frontend/tests/hub-media-download-footprint.test.ts b/studio/frontend/tests/hub-media-download-footprint.test.ts
index c19d1f753c6..abe3f53be43 100644
--- a/studio/frontend/tests/hub-media-download-footprint.test.ts
+++ b/studio/frontend/tests/hub-media-download-footprint.test.ts
@@ -30,8 +30,13 @@ globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
});
}) as typeof fetch;
-const { companionPlanRequests, ggufVariantFootprint, resolveCompanionBytes } =
- await import("../src/features/hub/hooks/use-media-companion-bytes.ts");
+const {
+ awaitsCompanions,
+ companionPlanRequests,
+ ggufVariantFootprint,
+ resolveCompanionBytes,
+ withCompanionBytes,
+} = 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
@@ -194,3 +199,41 @@ test("rows add their own set's companions, except partials", () => {
null,
);
});
+
+test("a cached GGUF reads as partial until Run has its companions", () => {
+ const pending = new Map([["qwen-image-2.1", COMPANION_BYTES]]);
+ const cached = new Map([["qwen-image-2.1", 0]]);
+ const done = variant("Q5_K_M", { downloaded: true });
+ assert.equal(
+ awaitsCompanions(true, ggufVariantFootprint(done, pending)),
+ true,
+ );
+ assert.equal(
+ awaitsCompanions(true, ggufVariantFootprint(done, cached)),
+ false,
+ );
+ // No plan yet (or a non-media page): keep the plain On device badge.
+ assert.equal(awaitsCompanions(true, null), false);
+ assert.equal(
+ awaitsCompanions(false, ggufVariantFootprint(variant("Q5_K_M"), pending)),
+ false,
+ );
+});
+
+test("a re-plan with nothing left clears the group's pending companions", () => {
+ const pending = new Map([["qwen-image-2.1", COMPANION_BYTES]]);
+ assert.equal(
+ withCompanionBytes(pending, "qwen-image-2.1", COMPANION_BYTES),
+ pending,
+ );
+ const done = withCompanionBytes(pending, "qwen-image-2.1", null);
+ assert.equal(done.has("qwen-image-2.1"), false);
+ assert.equal(
+ awaitsCompanions(
+ true,
+ ggufVariantFootprint(variant("Q5_K_M", { downloaded: true }), done),
+ ),
+ false,
+ );
+ assert.equal(pending.get("qwen-image-2.1"), COMPANION_BYTES);
+});
diff --git a/studio/frontend/tests/required-assets.test.ts b/studio/frontend/tests/required-assets.test.ts
index d6b68c2dbef..88654c0b1b9 100644
--- a/studio/frontend/tests/required-assets.test.ts
+++ b/studio/frontend/tests/required-assets.test.ts
@@ -75,3 +75,40 @@ test("encoder-first plans download the checkpoint first without mutating the pla
assert.deepEqual(original, [assets, model, decoder]);
assert.deepEqual(checkpointFirst([assets, decoder]), [assets, decoder]);
});
+
+test("the download manager names companion files, falling back to required assets", () => {
+ assert.equal(
+ assetLabel(
+ {
+ repoId: "Qwen/Qwen-Image-2.1",
+ bytes: 0,
+ files: [
+ "text_encoder/model-00001-of-00004.safetensors",
+ "vae/diffusion_pytorch_model.safetensors",
+ ],
+ },
+ "Required assets",
+ ),
+ "Encoder & decoder",
+ );
+ assert.equal(
+ assetLabel(
+ {
+ repoId: "Qwen/Qwen-Image-2.1",
+ bytes: 0,
+ files: ["scheduler/config.json"],
+ },
+ "Required assets",
+ ),
+ "Required assets",
+ );
+ assert.equal(
+ assetLabel({ repoId: "Qwen/Qwen-Image-2.1", bytes: 0 }, "Required assets"),
+ "Required assets",
+ );
+ // Without a fallback the dialog keeps naming the repo.
+ assert.equal(
+ assetLabel({ repoId: "Qwen/Qwen-Image-2.1", bytes: 0 }),
+ "Qwen-Image-2.1",
+ );
+});
diff --git a/tests/studio/playwright_image_download_cancel_retry.py b/tests/studio/playwright_image_download_cancel_retry.py
index f39f3accba9..71b1cca668b 100644
--- a/tests/studio/playwright_image_download_cancel_retry.py
+++ b/tests/studio/playwright_image_download_cancel_retry.py
@@ -494,7 +494,7 @@ def main() -> None:
companion_row = page.locator(".hub-download-panel").filter(has_text = COMPANION_REPO)
companion_row.wait_for(state = "visible", timeout = 10_000)
panel_text = companion_row.inner_text()
- assert "Required assets" in panel_text
+ assert "Encoder & decoder" in panel_text
assert "@diffusion" not in panel_text
if not CHECKPOINT_CACHED:
assert "Model file" in panel_text
diff --git a/tests/studio/test_model_picker_contracts.py b/tests/studio/test_model_picker_contracts.py
index 0ef31cc6fa1..859003c500f 100644
--- a/tests/studio/test_model_picker_contracts.py
+++ b/tests/studio/test_model_picker_contracts.py
@@ -2145,7 +2145,8 @@ def test_staged_downloads_use_one_actionable_download_surface():
panel = _read("features/hub/download-manager/download-manager-panel.tsx")
assert 'job.variant?.startsWith("@")' in panel
- assert '"Model file" : "Required assets"' in panel
+ assert '"Model file"' in panel
+ assert "assetLabel(" in panel and '"Required assets"' in panel
def test_staged_plans_label_the_checkpoint_without_guessing_from_the_extension():