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: show disk space in the same GB as model sizes (#11150)
Nilay0baf72b4b4f6
diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.pyindex e3e78039e41..ead87a21835 100644--- a/studio/backend/core/inference/llama_cpp.py+++ b/studio/backend/core/inference/llama_cpp.py@@ -17653,9 +17653,9 @@ class LlamaCppBackend:Path(download_cache_dir).mkdir(parents = True, exist_ok = True)free_bytes = shutil.disk_usage(download_cache_dir).free- total_gb = total_download_bytes / (1024**3)- free_gb = free_bytes / (1024**3)- cached_gb = already_cached_bytes / (1024**3)+ total_gb = total_download_bytes / 1e9+ free_gb = free_bytes / 1e9+ cached_gb = already_cached_bytes / 1e9logger.info(f"GGUF download: {total_gb:.1f} GB needed "@@ -17686,7 +17686,7 @@ class LlamaCppBackend:notice = (f"Not enough disk space to download {hf_variant} "f"({total_gb:.1f} GB needed, {free_gb:.1f} GB free), so "- f"{fallback_variant} ({fallback_size / (1024**3):.1f} GB) "+ f"{fallback_variant} ({fallback_size / 1e9:.1f} GB) ""was loaded instead.")logger.warning(notice)diff --git a/studio/backend/core/inference/openai_auto_download.py b/studio/backend/core/inference/openai_auto_download.pyindex 37f15e110d0..10719748f77 100644--- a/studio/backend/core/inference/openai_auto_download.py+++ b/studio/backend/core/inference/openai_auto_download.py@@ -372,7 +372,7 @@ def _enough_disk(need_bytes: int) -> tuple[bool, int]:def _gb(num_bytes: int) -> str:- return f"{num_bytes / 1024**3:.1f} GB"+ return f"{num_bytes / 1e9:.1f} GB"async def _job_state(repo_id: str, variant: Optional[str]) -> tuple[str, Optional[str]]:diff --git a/studio/backend/hub/workers/hf_download.py b/studio/backend/hub/workers/hf_download.pyindex 3622963df85..9a2529886d7 100644--- a/studio/backend/hub/workers/hf_download.py+++ b/studio/backend/hub/workers/hf_download.py@@ -311,8 +311,8 @@ def _preflight_disk_space(repo_type: str, repo_id: str, expected_files: list) ->if free < remaining:print(f"Not enough disk space to download {repo_id}: need about "- f"{remaining / (1024 ** 3):.1f} GB free in {root}, but only "- f"{free / (1024 ** 3):.1f} GB is available. Free up space and "+ f"{remaining / 1e9:.1f} GB free in {root}, but only "+ f"{free / 1e9:.1f} GB is available. Free up space and ""try again.",file = sys.stderr,)diff --git a/studio/backend/tests/test_gguf_load_cache_reuse.py b/studio/backend/tests/test_gguf_load_cache_reuse.pyindex 09c583f4bec..307f1b2f6e1 100644--- a/studio/backend/tests/test_gguf_load_cache_reuse.py+++ b/studio/backend/tests/test_gguf_load_cache_reuse.py@@ -595,7 +595,10 @@ class TestLoadReusesCachedCopy:assert out == f"/fake/{REPO}/gemma-test-Q4_K_M.gguf"variant, notice = backend._pending_variant_fallbackassert variant == "Q4_K_M"- assert "Q8_0" in notice and "Q4_K_M (2.0 GB)" in notice+ assert notice == (+ "Not enough disk space to download Q8_0 (8.6 GB needed, 8.1 GB free), "+ "so Q4_K_M (2.1 GB) was loaded instead."+ )def test_low_disk_fallback_keeps_smallest_when_none_leaves_reserve(self, hf_cache):backend = LlamaCppBackend()diff --git a/studio/backend/tests/test_scoped_download_worker.py b/studio/backend/tests/test_scoped_download_worker.pyindex b9ad0ecf229..e8bdb727873 100644--- a/studio/backend/tests/test_scoped_download_worker.py+++ b/studio/backend/tests/test_scoped_download_worker.py@@ -12,8 +12,10 @@ Images page auto-loads as soon as the job completes.from __future__ import annotations+import shutilimport sysfrom pathlib import Path+from types import SimpleNamespaceimport pytest@@ -88,3 +90,20 @@ def test_a_dangling_symlink_does_not_count_as_present(offline, capsys):_run()assert exit_info.value.code == 1assert "incomplete" in capsys.readouterr().err+++def test_disk_space_refusal_reports_decimal_gigabytes(monkeypatch, tmp_path, capsys):+ import hub.utils.download_registry as registry_mod+ import hub.utils.hf_cache_state as cache_state_mod++ monkeypatch.setattr(registry_mod, "existing_blob_bytes", lambda *a, **k: 0)+ monkeypatch.setattr(cache_state_mod, "hf_cache_root", lambda **k: tmp_path)+ monkeypatch.setattr(shutil, "disk_usage", lambda _p: SimpleNamespace(free = 1_500_000_000))+ q8 = SimpleNamespace(size = 1_834_426_944, sha256 = "a" * 64)++ with pytest.raises(SystemExit) as exit_info:+ hf_download._preflight_disk_space("model", "unsloth/Qwen3-1.7B-GGUF", [q8])+ assert exit_info.value.code == 1+ err = capsys.readouterr().err+ assert "need about 1.8 GB free" in err+ assert "only 1.5 GB is available" in errdiff --git a/studio/frontend/src/features/chat/api/chat-adapter.ts b/studio/frontend/src/features/chat/api/chat-adapter.tsindex 197cc5a1491..5603ecdde98 100644--- a/studio/frontend/src/features/chat/api/chat-adapter.ts+++ b/studio/frontend/src/features/chat/api/chat-adapter.ts@@ -2600,10 +2600,10 @@ const DEFAULT_CHAT_MODEL_LABEL = "Gemma 4 E2B";function formatDownloadBytes(bytes: number): string {if (!(bytes > 0)) return "";- const gb = bytes / 1024 ** 3;+ const gb = bytes / 1000 ** 3;return gb >= 1? `${gb.toFixed(1)} GB`- : `${Math.max(1, Math.round(bytes / 1024 ** 2))} MB`;+ : `${Math.max(1, Math.round(bytes / 1000 ** 2))} MB`;}/** Fetch the default through the Hub download manager rather than inline in /load: that givesdiff --git a/studio/frontend/src/features/hub/catalog/on-device-folders-dialog.tsx b/studio/frontend/src/features/hub/catalog/on-device-folders-dialog.tsxindex a2ebb39d7f4..5b524aa2834 100644--- a/studio/frontend/src/features/hub/catalog/on-device-folders-dialog.tsx+++ b/studio/frontend/src/features/hub/catalog/on-device-folders-dialog.tsx@@ -19,6 +19,7 @@ import {import {type ScanFolderInfo,addScanFolder,+ formatBytes,listScanFolders,removeScanFolder,scanFolderStatusCopy,@@ -61,8 +62,7 @@ function formatError(error: unknown): string {function formatFreeSpace(bytes: number | null): string | null {if (bytes === null || !Number.isFinite(bytes)) return null;- const gb = bytes / 1024 ** 3;- return gb >= 10 ? `${Math.round(gb)} GB free` : `${gb.toFixed(1)} GB free`;+ return `${formatBytes(bytes)} free`;}export function OnDeviceFoldersDialog({diff --git a/studio/frontend/src/features/hub/index.ts b/studio/frontend/src/features/hub/index.tsindex b3016d15f02..4ec2baa496f 100644--- a/studio/frontend/src/features/hub/index.ts+++ b/studio/frontend/src/features/hub/index.ts@@ -113,6 +113,7 @@ export {} from "./lib/model-identity";export {formatBytes,+ formatRate,formatRelativeShort,ownerOf,repoOf,diff --git a/studio/frontend/src/features/settings/tabs/resources-tab.tsx b/studio/frontend/src/features/settings/tabs/resources-tab.tsxindex ce40eec7e8a..e2fa569ec54 100644--- a/studio/frontend/src/features/settings/tabs/resources-tab.tsx+++ b/studio/frontend/src/features/settings/tabs/resources-tab.tsx@@ -5,6 +5,7 @@ import { Button } from "@/components/ui/button";import { Input } from "@/components/ui/input";import { Progress } from "@/components/ui/progress";import { Switch } from "@/components/ui/switch";+import { formatBytes } from "@/features/hub";import { FolderBrowser } from "@/features/model-picker";import {openModelsDir,@@ -69,12 +70,6 @@ function formatGb(value: number | null | undefined): string {return `${safe.toFixed(digits)} GB`;}-function formatBytes(value: number | null): string | null {- if (value === null || !Number.isFinite(value)) return null;- const gib = value / 1024 ** 3;- return `${gib >= 10 ? gib.toFixed(1) : gib.toFixed(2)} GiB`;-}-// RAM/VRAM come from the backend in binary units (bytes / 1024**3), matching// nvidia-smi and PyTorch, so label those readouts GiB. Disk stays on formatGb// because the backend reports disk in decimal GB (bytes / 1e9).@@ -412,7 +407,7 @@ export function ResourcesTab() {t("settings.resources.storage.futureDownloads"),hfCache.freeBytes !== null? t("settings.resources.storage.locationFree", {- free: formatBytes(hfCache.freeBytes) ?? "",+ free: formatBytes(hfCache.freeBytes),}): null,]diff --git a/studio/frontend/src/features/studio/training-start-overlay.tsx b/studio/frontend/src/features/studio/training-start-overlay.tsxindex ca962ae4d1e..6eede82d803 100644--- a/studio/frontend/src/features/studio/training-start-overlay.tsx+++ b/studio/frontend/src/features/studio/training-start-overlay.tsx@@ -25,7 +25,8 @@ import {type DownloadProgressResponse,} from "@/features/chat/api/chat-api";import { useTransferStats } from "@/features/chat/hooks/use-transfer-stats";-import { formatEta, formatRate } from "@/features/chat/utils/format-transfer";+import { formatEta } from "@/features/chat/utils/format-transfer";+import { formatBytes, formatRate } from "@/features/hub";import { useHfTokenStore } from "@/features/hub/stores/hf-token-store";import {EMPTY_DOWNLOAD_STATE,@@ -56,14 +57,6 @@ const HF_REPO_REGEX = /^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/;// replay on every return mid-run. Module-level so it survives remounts.const animatedJobs = new Set<string>();-function formatBytes(n: number): string {- if (n <= 0) return "0 B";- if (n < 1024) return `${n} B`;- if (n < 1024 ** 2) return `${(n / 1024).toFixed(1)} KB`;- if (n < 1024 ** 3) return `${(n / 1024 ** 2).toFixed(1)} MB`;- return `${(n / 1024 ** 3).toFixed(2)} GB`;-}-function formatCachePath(path: string): string {return path.replace(/^\/(?:home|Users)\/[^/]+/, "~")@@ -198,7 +191,7 @@ function ResourceRow({}: ResourceRowProps): ReactElement | null {const t = useT();// Rolling-window rate + ETA from the cumulative-byte series the poll hook- // produces, so we show "5.2 / 20.7 GB • 85.3 MB/s • 3m 12s left", not just the pair.+ // produces, so we show "5.2 GB / 21 GB • 85 MB/s • 3m 12s left", not just the pair.const stats = useTransferStats(state.downloadedBytes, state.totalBytes);if (!resourceRowHasContent(state, preparation)) return null;diff --git a/studio/frontend/tests/hub-format.test.ts b/studio/frontend/tests/hub-format.test.tsindex bed24c08289..de98a8e6d7d 100644--- a/studio/frontend/tests/hub-format.test.ts+++ b/studio/frontend/tests/hub-format.test.ts@@ -5,6 +5,7 @@ import assert from "node:assert/strict";import test from "node:test";import { formatEta } from "../src/features/hub/lib/format.ts";+import { readSrcAsync } from "./helpers/kit.ts";const MINUTE = 60;const HOUR = 60 * MINUTE;@@ -51,3 +52,31 @@ test("no ETA is ever reported in days", () => {assert.doesNotMatch(formatEta(s), /\d+d\b/);}});++test("disk free space and download progress use decimal units", async () => {+ const [folders, resources, training, chat] = await Promise.all([+ readSrcAsync("features/hub/catalog/on-device-folders-dialog.tsx"),+ readSrcAsync("features/settings/tabs/resources-tab.tsx"),+ readSrcAsync("features/studio/training-start-overlay.tsx"),+ readSrcAsync("features/chat/api/chat-adapter.ts"),+ ]);+ assert.match(folders, /`\$\{formatBytes\(bytes\)\} free`/);+ assert.match(resources, /free: formatBytes\(hfCache\.freeBytes\)/);+ assert.match(+ training,+ /import \{[^}]*\bformatBytes\b[^}]*\} from "@\/features\/hub"/,+ );+ assert.match(+ training,+ /import \{[^}]*\bformatRate\b[^}]*\} from "@\/features\/hub"/,+ );+ for (const source of [folders, resources, training]) {+ assert.doesNotMatch(source, /function formatBytes\b/);+ }+ for (const source of [folders, training]) {+ assert.doesNotMatch(source, /\/ 1024 \*\* 3/);+ }+ const toast = chat.match(/function formatDownloadBytes[\s\S]*?\n}/);+ assert.ok(toast, "formatDownloadBytes not found");+ assert.doesNotMatch(toast[0], /1024/);+});