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.

Studio: size more audio.cpp music models from measured peaks and show the load estimate in the picker (#16726)

oobaboogadcdff7c3325c
diff --git a/studio/backend/core/inference/audio_cpp_catalog.py b/studio/backend/core/inference/audio_cpp_catalog.py
index c11a1e5bd10..716a2938120 100644
--- a/studio/backend/core/inference/audio_cpp_catalog.py
+++ b/studio/backend/core/inference/audio_cpp_catalog.py
@@ -290,7 +290,7 @@ def _row(
display = _text(spec.get("display_name"), 120) or folder or repo_id.split("/")[-1]
names = (model_id, folder, *(Path(f.path).name for f in files if f.path.endswith(".gguf")))
workflows: list[str] = []
- task, size, reason = "", None, _NO_FAMILY
+ task, size, smallest, reason = "", None, None, _NO_FAMILY
if family:
try:
policy = acm.family_policy(family, spec or None, names, display)
@@ -306,8 +306,31 @@ def _row(
reason = reason or _NOT_AUDIO_CPP
wanted = set(recommended_gguf_files(spec or None))
picked = [f for f in files if Path(f.path).name in wanted]
+ if picked and policy.package:
+ # A package loads and downloads every file it lists (YuE2's VAE and sidecars too).
+ package = next(
+ (
+ v
+ for v in acm._package_variants(policy, files, folder)
+ if any(f in v.files for f in picked)
+ ),
+ None,
+ )
+ picked = list(package.files) if package is not None else picked
variant = None if picked else _ranked(files, folder, policy)
size = sum(f.size for f in picked) if picked else (variant and variant.size_bytes)
+ smallest = min(
+ (
+ v.size_bytes
+ for v in (
+ acm._package_variants(policy, files, folder)
+ if policy.package
+ else acm._single_file_variants(files, folder)
+ )
+ if acm.quant_label(v.main_file) not in acm.CPU_ONLY_QUANTS
+ ),
+ default = None,
+ )
except Exception as exc: # noqa: BLE001 - a malformed spec refuses its row, not the list
logger.debug("audio.cpp catalog: policy of %s failed: %s", family, exc)
reason = "Unsloth Studio could not read this model's spec."
@@ -330,6 +353,7 @@ def _row(
languages = None if languages == ["auto"] else languages,
status = status if status in _STATUSES else None,
size_bytes = size or None,
+ smallest_size_bytes = smallest or None,
unsupported_reason = reason or None,
)
diff --git a/studio/backend/core/inference/audio_cpp_failures.py b/studio/backend/core/inference/audio_cpp_failures.py
index a7395444a75..58f99981bf6 100644
--- a/studio/backend/core/inference/audio_cpp_failures.py
+++ b/studio/backend/core/inference/audio_cpp_failures.py
@@ -136,17 +136,50 @@ def attach_failure(exc: BaseException, failure: Optional[AudioCppFailure]) -> Ba
# GiB; resident = weights * per_weight + fixed. Generic matches Qwen3-TTS at its 8192-token cap.
_GENERIC_PROFILE = (2.5, 1.5)
-# family -> (per_weight, fixed, largest package measured): audio.cpp v0.9.3 CUDA peak plus at least
+# family -> (per_weight, fixed, largest package measured): audio.cpp v0.9.3 peak plus at least
# 0.9 GiB. Families whose peak grows with the input (VibeVoice) must stay on the generic formula.
_MEASURED_PROFILES = {
- # Peak is a 240 s cover (the longest edit), above a 240 s song.
- "ace_step": (1.0, 6.4, 9.4),
+ # Peak is a 240 s cover (the longest edit), above a 240 s song; BF16 highest on Vulkan.
+ "ace_step": (1.15, 5.55, 9.4),
"chatterbox": (1.0, 3.5, 3.5),
+ # Peak is a 240 s song with 20,000 characters of lyrics, above the generic formula on Vulkan.
+ "heartmula": (2.5, 2.7, 7.2),
"higgs_audio_tts": (1.0, 2.0, 4.8),
"kokoro_tts": (1.0, 3.5, 0.2),
+ # Flat in length: 10 s and the 80 s cap peak the same.
+ "midashenglm_gen": (1.0, 2.25, 3.2),
+ # Peak is 4 batched takes at the cap (Small 120 s, Medium 240 s); F16 highest on Vulkan.
+ "stable_audio": (1.8, 0.65, 5.5),
"voxcpm2": (2.2, 4.7, 4.5),
"voxtral_tts": (1.0, 2.0, 4.4),
+ # Peak is 20,000 characters of lyrics run to the 9000-token (360 s) cap, highest on Vulkan.
+ "yue2": (1.2, 4.45, 7.1),
}
+# Families measured far higher on pre-Ampere NVIDIA cards (YuE2 on a T4): the generic formula there.
+_NOT_BEFORE_AMPERE = frozenset({"yue2"})
+
+
+def _may_have_pre_ampere_nvidia_card() -> bool:
+ """Uncached (gpu_query caches); unreadable NVIDIA capabilities count as pre-Ampere."""
+ from utils.hardware import nvidia
+
+ capabilities = nvidia.get_compute_capabilities()
+ if not capabilities:
+ return nvidia.has_nvidia_driver()
+ return any(capability < (8, 0) for capability in capabilities.values())
+
+
+def gpu_estimate_applies(audio_type: Optional[str]) -> bool:
+ """Whether the placement check sizes an Auto load of ``audio_type`` with its estimate."""
+ import utils.hardware as hardware
+ from core.inference.audio_cpp_models import AUDIO_CPP_AUDIO_TYPES
+ from core.inference.audio_device import audio_load_runs_on_cpu
+
+ return (
+ audio_type in AUDIO_CPP_AUDIO_TYPES
+ and hardware.get_device() in (hardware.DeviceType.CUDA, hardware.DeviceType.XPU)
+ and not audio_load_runs_on_cpu(audio_type, "auto")
+ )
def estimate_resident_gb(size_bytes: int, family: Optional[str] = None) -> float:
@@ -156,7 +189,7 @@ def estimate_resident_gb(size_bytes: int, family: Optional[str] = None) -> float
weights_gb = size_bytes / (1024**3)
generic = weights_gb * _GENERIC_PROFILE[0] + _GENERIC_PROFILE[1]
profile = _MEASURED_PROFILES.get(family or "")
- if profile is None:
+ if profile is None or (family in _NOT_BEFORE_AMPERE and _may_have_pre_ampere_nvidia_card()):
return round(generic, 2)
per_weight, fixed, measured_up_to_gb = profile
measured = weights_gb * per_weight + fixed
@@ -249,9 +282,10 @@ def classify_audio_cpp_failure(
key = f"{key}_cpu" if on_cpu and key in ("out_of_memory", "capacity") else key
need = ""
if placement and required_gb is not None:
- need = f" It needs about {required_gb:.1f} GB of GPU memory while running"
+ digits = 2 if free_gb is not None and f"{required_gb:.1f}" == f"{free_gb:.1f}" else 1
+ need = f" It needs about {required_gb:.{digits}f} GB of GPU memory while running"
need += (
- f", and the most free on one GPU is {free_gb:.1f} GB."
+ f", and the most free on one GPU is {free_gb:.{digits}f} GB."
if free_gb is not None
else "."
)
diff --git a/studio/backend/core/inference/audio_cpp_models.py b/studio/backend/core/inference/audio_cpp_models.py
index 7e91cd498cf..90b91aee4c1 100644
--- a/studio/backend/core/inference/audio_cpp_models.py
+++ b/studio/backend/core/inference/audio_cpp_models.py
@@ -43,6 +43,16 @@ AUDIO_CPP_SEP_AUDIO_TYPE = "audiocpp_sep"
AUDIO_CPP_AUDIO_TYPES = frozenset(
(AUDIO_CPP_TTS_AUDIO_TYPE, AUDIO_CPP_MUSIC_AUDIO_TYPE, AUDIO_CPP_SEP_AUDIO_TYPE)
)
+_AUDIO_TYPE_BY_TASK = {
+ "tts": AUDIO_CPP_TTS_AUDIO_TYPE,
+ "music": AUDIO_CPP_MUSIC_AUDIO_TYPE,
+ "sep": AUDIO_CPP_SEP_AUDIO_TYPE,
+}
+
+
+def audio_type_for_task(task: Optional[str]) -> Optional[str]:
+ return _AUDIO_TYPE_BY_TASK.get(task or "")
+
# Studio task -> the Hub pipeline task its rows carry.
HUB_TASKS = {
@@ -2164,13 +2174,7 @@ class AudioCppModel:
@property
def audio_type(self) -> Optional[str]:
- if self.task == "tts":
- return AUDIO_CPP_TTS_AUDIO_TYPE
- if self.task == "music":
- return AUDIO_CPP_MUSIC_AUDIO_TYPE
- if self.task == "sep":
- return AUDIO_CPP_SEP_AUDIO_TYPE
- return None
+ return audio_type_for_task(self.task)
@property
def hub_task(self) -> Optional[str]:
diff --git a/studio/backend/hub/schemas/inventory.py b/studio/backend/hub/schemas/inventory.py
index a544f03e73c..e0bc08b1c5b 100644
--- a/studio/backend/hub/schemas/inventory.py
+++ b/studio/backend/hub/schemas/inventory.py
@@ -43,6 +43,10 @@ class GgufVariantDetail(BaseModel):
)
size_bytes: int = Field(0, description = "File size in bytes")
download_size_bytes: int = Field(0, description = "Total bytes needed to download this variant")
+ estimated_resident_gb: Optional[float] = Field(
+ None,
+ description = "audio.cpp only: GiB of GPU memory the load check requires for this variant",
+ )
lookup_table_bytes: int = Field(
0,
description = "Bytes of lazily read lookup tables (per-layer embeddings / Engram) "
diff --git a/studio/backend/hub/services/models/gguf_variants.py b/studio/backend/hub/services/models/gguf_variants.py
index 2d62475827d..efba9145ec3 100644
--- a/studio/backend/hub/services/models/gguf_variants.py
+++ b/studio/backend/hub/services/models/gguf_variants.py
@@ -996,6 +996,7 @@ async def _audio_cpp_variants_answer(
) -> Optional[VariantsAnswer]:
"""group audio.cpp umbrella and package components; generic single-file repos return None."""
from core.inference import audio_cpp_models
+ from core.inference.audio_cpp_failures import estimate_resident_gb, gpu_estimate_applies
text = (repo_id or "").strip()
umbrella = audio_cpp_models.is_umbrella_id(text)
@@ -1055,6 +1056,7 @@ async def _audio_cpp_variants_answer(
for variant in model.variants:
for path in {f.path for f in variant.files}:
counts[path] = counts.get(path, 0) + 1
+ gpu_placed = gpu_estimate_applies(model.audio_type)
rows = []
for variant in model.variants:
row_model = model.with_variant(variant)
@@ -1101,6 +1103,11 @@ async def _audio_cpp_variants_answer(
display_label = variant.label,
size_bytes = variant.size_bytes,
download_size_bytes = variant.size_bytes + companion_bytes,
+ estimated_resident_gb = (
+ estimate_resident_gb(variant.size_bytes, model.family)
+ if gpu_placed and not row_model.cpu_only
+ else None
+ ),
download_remaining_bytes = remaining,
downloaded = downloaded,
partial = partial,
@@ -1604,8 +1611,9 @@ async def get_gguf_variants_answer(
hf_token = account_access.account_hf_token(hf_token)
from core.inference.audio_cpp_models import is_umbrella_id
- # An umbrella folder row is never a directory: its On Device row sends the row id as local_path.
- if not local_path or is_umbrella_id(repo_id):
+ # Umbrella folder and package repo (YuE2) On Device rows send their row id as local_path.
+ row_id = bool(local_path) and local_path.strip().lower() == (repo_id or "").strip().lower()
+ if not local_path or is_umbrella_id(repo_id) or row_id:
audio_cpp_answer = await _audio_cpp_variants_answer(repo_id, hf_token, offline)
if audio_cpp_answer is not None:
return audio_cpp_answer
diff --git a/studio/backend/models/inference.py b/studio/backend/models/inference.py
index 55a47279bb6..df862be7710 100644
--- a/studio/backend/models/inference.py
+++ b/studio/backend/models/inference.py
@@ -7010,6 +7010,11 @@ class AudioCatalogModel(BaseModel):
languages: Optional[List[str]] = None
status: Optional[Literal["supported", "community", "experimental", "testing", "wip"]] = None
size_bytes: Optional[int] = None
+ # GiB of GPU memory the load check requires for size_bytes; set per request (it reads the GPUs).
+ estimated_resident_gb: Optional[float] = None
+ # The smallest variant a GPU runs: a row fits a card when that variant does.
+ smallest_size_bytes: Optional[int] = None
+ smallest_estimated_resident_gb: Optional[float] = None
downloaded: bool = False
unsupported_reason: Optional[str] = None
diff --git a/studio/backend/models/models.py b/studio/backend/models/models.py
index daaf86754d5..08a098d3273 100644
--- a/studio/backend/models/models.py
+++ b/studio/backend/models/models.py
@@ -192,6 +192,10 @@ class GgufVariantDetail(BaseModel):
)
size_bytes: int = Field(0, description = "File size in bytes")
download_size_bytes: int = Field(0, description = "Total bytes needed to download this variant")
+ estimated_resident_gb: Optional[float] = Field(
+ None,
+ description = "audio.cpp only: GiB of GPU memory the load check requires for this variant",
+ )
lookup_table_bytes: int = Field(
0,
description = "Bytes of lazily read lookup tables (per-layer embeddings / Engram) "
diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py
index 10064d2b33b..557efeddbd5 100644
--- a/studio/backend/routes/inference.py
+++ b/studio/backend/routes/inference.py
@@ -15718,6 +15718,25 @@ class _NativeAudioAvailability(NamedTuple):
return self.credited_owner or self.owner_snapshot[0]
+def _visible_gpu_memory_gb() -> dict[int, tuple[float, float]]:
+ """(free, total) GiB per visible GPU, read fresh, keyed as GPU selection keys them."""
+ import utils.hardware as hardware
+ from utils.hardware import gpu_query
+
+ with gpu_query.fresh_reads():
+ utilization = hardware.get_visible_gpu_utilization()
+ live: dict[int, tuple[float, float]] = {}
+ for device in utilization.get("devices", []):
+ try:
+ index = int(device["index"])
+ total = float(device["vram_total_gb"])
+ used = float(device["vram_used_gb"])
+ except (KeyError, TypeError, ValueError):
+ continue
+ live[index] = (max(total - used, 0.0), total)
+ return live
+
+
def _native_audio_post_handoff_free_gb(
outgoing: Optional[str] = None,
) -> Optional[_NativeAudioAvailability]:
@@ -15746,19 +15765,8 @@ def _native_audio_post_handoff_free_gb(
reclaimable: dict[int, float] = {}
def _read_live() -> bool:
- from utils.hardware import gpu_query
-
- with gpu_query.fresh_reads():
- utilization = hardware.get_visible_gpu_utilization()
live.clear()
- for device in utilization.get("devices", []):
- try:
- index = int(device["index"])
- total = float(device["vram_total_gb"])
- used = float(device["vram_used_gb"])
- except (KeyError, TypeError, ValueError):
- continue
- live[index] = (max(total - used, 0.0), total)
+ live.update(_visible_gpu_memory_gb())
return bool(live)
def _merge_report(reported) -> bool:
@@ -16319,7 +16327,11 @@ async def _preflight_native_audio_placement(
classify_audio_cpp_failure,
)
- free_by_gpu = availability.effective_free_gb if availability is not None else {}
+ # With nothing to unload, the cards' free memory as it is now.
+ if availability is not None:
+ free_by_gpu = availability.effective_free_gb
+ else:
+ free_by_gpu = {i: free for i, (free, _) in _visible_gpu_memory_gb().items()}
free = [gb for index, gb in free_by_gpu.items() if index in candidates]
failure = classify_audio_cpp_failure(
str(refusal),
@@ -50236,6 +50248,27 @@ async def audio_catalog(current_subject: str = Depends(get_current_subject)):
status_code = 503,
detail = "Unsloth Studio could not list audio models right now.",
) from None
+
+ def _estimate_rows() -> None:
+ from core.inference.audio_cpp_failures import gpu_estimate_applies
+ from core.inference.audio_cpp_models import audio_type_for_task
+
+ # Off the event loop: YuE2's estimate reads the cards through nvidia-smi.
+ applies = {
+ task: gpu_estimate_applies(audio_type_for_task(task))
+ for task in {row.get("task") for row in rows}
+ }
+ for row in rows:
+ if not applies[row.get("task")]:
+ continue
+ for size_key, estimate_key in (
+ ("size_bytes", "estimated_resident_gb"),
+ ("smallest_size_bytes", "smallest_estimated_resident_gb"),
+ ):
+ if row.get(size_key):
+ row[estimate_key] = audio_cpp_resident_gb(row[size_key], row.get("family"))
+
+ await asyncio.to_thread(_estimate_rows)
return payload.model_copy(update = {"models": [AudioCatalogModel(**r) for r in rows]})
diff --git a/studio/backend/routes/models.py b/studio/backend/routes/models.py
index 0fab0a35c1b..e75b03ee48e 100644
--- a/studio/backend/routes/models.py
+++ b/studio/backend/routes/models.py
@@ -4670,6 +4670,7 @@ async def get_gguf_variants(
download_size_bytes = int(
getattr(v, "download_size_bytes", v.size_bytes) or v.size_bytes
),
+ estimated_resident_gb = getattr(v, "estimated_resident_gb", None),
lookup_table_bytes = int(getattr(v, "lookup_table_bytes", 0) or 0),
pending_drafter_filename = getattr(v, "pending_drafter_filename", None),
pending_drafter_size_bytes = int(
diff --git a/studio/backend/tests/test_audio_catalog_route.py b/studio/backend/tests/test_audio_catalog_route.py
index 19a7cc046b5..25291da3169 100644
--- a/studio/backend/tests/test_audio_catalog_route.py
+++ b/studio/backend/tests/test_audio_catalog_route.py
@@ -79,3 +79,75 @@ def test_a_builder_failure_answers_503_without_its_text(client, monkeypatch):
assert response.status_code == 503
assert "Unsloth Studio could not list audio models right now." in response.text
assert "exploded" not in response.text and "/home/me" not in response.text
+
+
+def _sized_host(
+ monkeypatch,
+ device = "CUDA",
+ cpu_runtime = False,
+):
+ import utils.hardware as hardware
+ from core.inference import audio_cpp_server
+
+ monkeypatch.setattr(hardware, "get_device", lambda: hardware.DeviceType[device])
+ monkeypatch.setattr(audio_cpp_server, "runtime_runs_on_cpu", lambda: cpu_runtime)
+
+
+def test_a_sized_row_carries_the_load_checks_estimate(client, monkeypatch):
+ from core.inference.audio_cpp_failures import estimate_resident_gb
+
+ _sized_host(monkeypatch)
+ sized = dict(
+ KOKORO, family = "kokoro_tts", size_bytes = 189_000_000, smallest_size_bytes = 90_000_000
+ )
+ catalog = AudioCatalogResponse(**{**CATALOG.model_dump(), "models": [sized, DRAMA]})
+ _builder(monkeypatch, lambda: catalog)
+ rows = {r["id"]: r for r in client.get("/api/inference/audio/catalog").json()["models"]}
+ assert rows[KOKORO["id"]]["estimated_resident_gb"] == estimate_resident_gb(
+ 189_000_000, "kokoro_tts"
+ )
+ assert rows[KOKORO["id"]]["smallest_estimated_resident_gb"] == estimate_resident_gb(
+ 90_000_000, "kokoro_tts"
+ )
+ assert rows[DRAMA["id"]]["estimated_resident_gb"] is None
+ assert rows[DRAMA["id"]]["smallest_estimated_resident_gb"] is None
+
+
+def test_the_estimates_read_the_gpus_off_the_event_loop(client, monkeypatch):
+ import asyncio
+
+ from utils.hardware import nvidia
+
+ _sized_host(monkeypatch)
+ on_loop = []
+
+ def capabilities():
+ try:
+ asyncio.get_running_loop()
+ except RuntimeError:
+ on_loop.append(False)
+ else:
+ on_loop.append(True)
+ return {0: (8, 6)}
+
+ monkeypatch.setattr(nvidia, "get_compute_capabilities", capabilities)
+ yue2 = dict(KOKORO, family = "yue2", size_bytes = 4531978293, smallest_size_bytes = 2933424181)
+ catalog = AudioCatalogResponse(**{**CATALOG.model_dump(), "models": [yue2]})
+ _builder(monkeypatch, lambda: catalog)
+ assert client.get("/api/inference/audio/catalog").status_code == 200
+ assert on_loop == [False, False]
+
+
+ "task, device, cpu_runtime",
+ [("tts", "CUDA", True), ("asr", "CUDA", False), ("tts", "MLX", False)],
+)
+def test_a_load_the_check_never_sizes_lists_no_gpu_estimate(
+ client, monkeypatch, task, device, cpu_runtime
+):
+ _sized_host(monkeypatch, device, cpu_runtime)
+ sized = dict(KOKORO, task = task, family = "kokoro_tts", size_bytes = 189_000_000)
+ catalog = AudioCatalogResponse(**{**CATALOG.model_dump(), "models": [sized]})
+ _builder(monkeypatch, lambda: catalog)
+ (row,) = client.get("/api/inference/audio/catalog").json()["models"]
+ assert row["estimated_resident_gb"] is None
diff --git a/studio/backend/tests/test_audio_cpp_catalog.py b/studio/backend/tests/test_audio_cpp_catalog.py
index afbe2778b1a..3db07472b3c 100644
--- a/studio/backend/tests/test_audio_cpp_catalog.py
+++ b/studio/backend/tests/test_audio_cpp_catalog.py
@@ -430,3 +430,31 @@ def test_a_build_with_a_late_family_probe_is_retried_sooner(env, monkeypatch):
clock[0] += catalog._DEGRADED_TTL_SECONDS + 1
catalog.audio_catalog_payload()
assert env["calls"]["hub"] == hub_calls + 1
+
+
+def test_a_package_row_is_sized_by_every_file_it_loads():
+ sizes = {
+ "sidecars/yue2-model-config.json": 1_000,
+ "sidecars/yue2-generation-config.json": 1_000,
+ "sidecars/yue2-qwen.tiktoken": 2_000_000,
+ "sidecars/yue2-vae-config.json": 1_000,
+ "yue2-3b-q8_0.gguf": 4_264_195_616,
+ "yue2-3b-q4_0.gguf": 2_666_000_000,
+ "yue2-vae-f16.gguf": 265_000_000,
+ }
+ files = [RepoFile(path, size) for path, size in sizes.items()]
+ q8 = {"id": "q8", "format": "gguf", "default": True, "files": ["yue2-3b-q8_0.gguf"]}
+ q4 = {"id": "q4", "format": "gguf", "files": ["yue2-3b-q4_0.gguf"]}
+ repo = "audio-cpp/Yue2-3B-GGUF"
+ row = catalog._row(repo, repo, "", "yue2", {"packages": [q8, q4]}, files)
+ assert row.size_bytes == sum(size for path, size in sizes.items() if "q4_0" not in path)
+ assert row.smallest_size_bytes == sum(
+ size for path, size in sizes.items() if "q8_0" not in path
+ )
+
+
+def test_the_smallest_variant_skips_quants_a_gpu_cannot_run():
+ files = [RepoFile("kitten-tq2_1.gguf", 10_000_000), RepoFile("kitten-q8_0.gguf", 40_000_000)]
+ repo = "someone/Kitten-GGUF"
+ row = catalog._row(repo, repo, "", "kokoro_tts", {}, files)
+ assert row.smallest_size_bytes == 40_000_000
diff --git a/studio/backend/tests/test_audio_cpp_failure_routes.py b/studio/backend/tests/test_audio_cpp_failure_routes.py
index 0f7535ca420..ea5aa1ac562 100644
--- a/studio/backend/tests/test_audio_cpp_failure_routes.py
+++ b/studio/backend/tests/test_audio_cpp_failure_routes.py
@@ -146,6 +146,16 @@ def test_placement_refusal_lists_variants_that_fit(monkeypatch):
)
+def test_with_nothing_to_unload_the_refusal_reads_the_cards_free_memory(monkeypatch):
+ monkeypatch.setattr(af, "offload_options", lambda model: [])
+ monkeypatch.setattr(ri, "_visible_gpu_memory_gb", lambda: {0: (7.0, 8.0), 1: (5.0, 8.0)})
+ with pytest.raises(HTTPException) as raised:
+ _preflight(None, availability = None, prepared = ([0, 1], {"selection_mode": "fallback_all"}))
+ detail = raised.value.detail
+ assert [row["label"] for row in detail["smaller_variants"]] == ["Q2", "Q1"]
+ assert "and the most free on one GPU is 7.0 GB." in detail["message"]
+
+
@pytest.mark.parametrize(
"family, size_gb, free_gb, fits",
[
@@ -183,6 +193,38 @@ def test_placement_uses_the_family_estimate(monkeypatch, family, size_gb, free_g
assert placement.native_required_gb == af.estimate_resident_gb(size, family) < free_gb
+ "capabilities, driver, free_gb, fits",
+ [
+ ({0: (8, 6)}, True, 9.6, True),
+ ({}, False, 9.6, True),
+ ({0: (8, 6)}, True, 9.4, False),
+ ({0: (7, 5)}, True, 9.6, False),
+ ({}, True, 9.6, False),
+ ],
+)
+def test_yue2_q8_on_a_10gb_card(monkeypatch, capabilities, driver, free_gb, fits):
+ from utils.hardware import nvidia
+
+ monkeypatch.setattr(af, "offload_options", lambda model: [])
+ monkeypatch.setattr(nvidia, "get_compute_capabilities", lambda: dict(capabilities))
+ monkeypatch.setattr(nvidia, "has_nvidia_driver", lambda: driver)
+ base = _model(sizes = (3,))
+ variant = dataclasses.replace(
+ base.variant, files = (dataclasses.replace(base.variant.files[0], size = 4531978293),)
+ )
+ model = dataclasses.replace(base, family = "yue2", variant = variant, variants = (variant,))
+ availability = ri._NativeAudioAvailability({0: free_gb}, {0: 0.0})
+ prepared = ([0], {"selection_mode": "fallback_all"})
+ if not fits:
+ with pytest.raises(HTTPException) as raised:
+ _preflight(None, availability = availability, prepared = prepared, model = model)
+ assert raised.value.detail["code"] == "out_of_memory"
+ return
+ placement = _preflight(None, availability = availability, prepared = prepared, model = model)
+ assert placement.resolved_gpu_ids == [0] and placement.native_required_gb == 9.51
+
+
def test_generation_crash_oom_maps_to_out_of_memory(monkeypatch):
tail = "ggml_gallocr_reserve_n: failed to allocate CUDA0 buffer of size 9663676416"
crash = af.attach_failure(
diff --git a/studio/backend/tests/test_audio_cpp_failures.py b/studio/backend/tests/test_audio_cpp_failures.py
index 5aaa2e1b0fa..6ad5d08d4a5 100644
--- a/studio/backend/tests/test_audio_cpp_failures.py
+++ b/studio/backend/tests/test_audio_cpp_failures.py
@@ -138,9 +138,83 @@ def test_estimate_uses_the_measured_family_profile():
assert af.estimate_resident_gb(int(0.1765 * gb), "kokoro_tts") == 3.68 > 2.7
assert af.estimate_resident_gb(int(2.7521 * gb), "voxcpm2") == 10.75 > 9.7
assert af.estimate_resident_gb(int(4.4445 * gb), "voxcpm2") == 14.48 > 13.3
- # ACE-Step1.5 turbo Q8_0 / BF16 (Hub bytes): 240 s cover peaks at 11.2 GB / 14.7 GB.
- assert af.estimate_resident_gb(6185468096, "ace_step") == 12.16 > 11.2
- assert af.estimate_resident_gb(10090406336, "ace_step") == 15.8 > 14.7
+ # ACE-Step1.5 turbo Q8_0 / BF16 (Hub bytes): a 240 s cover peaks at 11.22 / 15.31 GiB.
+ assert af.estimate_resident_gb(6185468096, "ace_step") == 12.17 > 11.22 + 0.9
+ assert af.estimate_resident_gb(10090406336, "ace_step") == 16.36 > 15.31 + 0.9
+
+
+ "family, size_bytes, peak_gib, expected",
+ [
+ ("stable_audio", 1683576608, 2.24, 3.47),
+ ("stable_audio", 2358473088, 2.80, 4.60),
+ ("stable_audio", 3582601408, 5.34, 6.66),
+ ("stable_audio", 5834365856, 9.48, 10.43),
+ ("midashenglm_gen", 3381370752, 4.42, 5.40),
+ ("heartmula", 7659762592, 19.58, 20.53),
+ ],
+)
+def test_music_profiles_cover_their_measured_peak(family, size_bytes, peak_gib, expected):
+ estimate = af.estimate_resident_gb(size_bytes, family)
+ assert estimate == expected and estimate >= peak_gib + 0.9
+
+
+# YuE2 package bytes on the Hub (model + VAE + sidecars): Q4_0, Q8_0, BF16.
+YUE2_BYTES = (2933424181, 4531978293, 7529267253)
+MEASURED = (7.73, 9.51, 12.86)
+GENERIC = (8.33, 12.05, 19.03)
+
+
+def _cards(
+ monkeypatch,
+ *answers,
+ driver = True,
+):
+ from utils.hardware import nvidia
+
+ queue = [answer for answer in answers for _ in YUE2_BYTES]
+ monkeypatch.setattr(nvidia, "get_compute_capabilities", lambda: dict(queue.pop(0)))
+ monkeypatch.setattr(nvidia, "has_nvidia_driver", lambda: driver)
+
+
+def _yue2():
+ return tuple(af.estimate_resident_gb(size, "yue2") for size in YUE2_BYTES)
+
+
+ "capabilities, driver, expected",
+ [
+ ({0: (8, 6)}, True, MEASURED),
+ ({0: (8, 9)}, True, MEASURED),
+ ({0: (12, 0)}, True, MEASURED),
+ ({}, False, MEASURED),
+ ({0: (7, 5)}, True, GENERIC),
+ ({0: (8, 9), 1: (7, 5)}, True, GENERIC),
+ ({}, True, GENERIC),
+ ],
+)
+def test_yue2_uses_its_profile_unless_a_pre_ampere_nvidia_card_may_be_present(
+ monkeypatch, capabilities, driver, expected
+):
+ _cards(monkeypatch, capabilities, driver = driver)
+ assert _yue2() == expected
+
+
+ "smi, procfs_gpus, expected",
+ [(None, 0, False), ("/usr/bin/nvidia-smi", 0, True), (None, 1, True)],
+)
+def test_an_nvidia_host_is_told_from_one_without_nvidia(monkeypatch, smi, procfs_gpus, expected):
+ from utils.hardware import nvidia
+
+ monkeypatch.setattr(nvidia.shutil, "which", lambda name: smi)
+ monkeypatch.setattr(nvidia, "_linux_nvidia_procfs_gpu_count", lambda: procfs_gpus)
+ assert nvidia.has_nvidia_driver() is expected
+
+
+def test_the_yue2_estimate_follows_the_current_inventory(monkeypatch):
+ _cards(monkeypatch, {0: (8, 6)}, {0: (8, 6), 1: (7, 5)}, {0: (8, 6)})
+ assert (_yue2(), _yue2(), _yue2()) == (MEASURED, GENERIC, MEASURED)
def test_past_the_measured_sizes_the_estimate_never_drops_below_either_profile():
@@ -201,6 +275,11 @@ def test_placement_refusal_states_the_estimate_and_the_free_memory(monkeypatch):
assert "It needs about 11.5 GB of GPU memory while running. Free GPU memory," in unknown.message
bare = af.classify_audio_cpp_failure(text, model = model)
assert bare.message.startswith("No single GPU has enough free memory for Model M. Free GPU")
+ close = af.classify_audio_cpp_failure(text, model = model, free_gb = 9.5, required_gb = 9.51)
+ assert (
+ "It needs about 9.51 GB of GPU memory while running, and the most free on one GPU is 9.50 GB."
+ in close.message
+ )
def test_oom_lists_smaller_variants_and_offload_options(monkeypatch):
diff --git a/studio/backend/tests/test_audio_cpp_models.py b/studio/backend/tests/test_audio_cpp_models.py
index 19f4151649f..7eb0d926faf 100644
--- a/studio/backend/tests/test_audio_cpp_models.py
+++ b/studio/backend/tests/test_audio_cpp_models.py
@@ -3239,3 +3239,59 @@ def test_seed_option_and_ignored_options(monkeypatch, keys, options, sent, ignor
if "bogus" in options:
assert body["options"] == {"speed": 1.5}
assert b.last_generation_stats == {"seed": sent and int(sent), "ignored_options": ignored}
+
+
+def _sized_host(
+ monkeypatch,
+ device = "CUDA",
+ cpu_runtime = False,
+):
+ import utils.hardware as hardware
+ from core.inference import audio_cpp_server
+
+ monkeypatch.setattr(hardware, "get_device", lambda: hardware.DeviceType[device])
+ monkeypatch.setattr(audio_cpp_server, "runtime_runs_on_cpu", lambda: cpu_runtime)
+
+
+def test_every_umbrella_row_carries_the_load_checks_estimate(hub, monkeypatch):
+ from core.inference.audio_cpp_failures import estimate_resident_gb
+
+ _sized_host(monkeypatch)
+ names = ["Kokoro-82M-GGUF/kokoro-82m-q8_0.gguf", "Kokoro-82M-GGUF/kokoro-82m-bf16.gguf"]
+ _online(monkeypatch, *names, size = 189_000_000)
+ rows = _rows(f"{AUDIO_CPP_REPO}/Kokoro-82M-GGUF")
+ model = acm.resolve(f"{AUDIO_CPP_REPO}/Kokoro-82M-GGUF", network = True)
+ assert model.family == "kokoro_tts" and len(model.variants) == 2
+ for variant in model.variants:
+ expected = estimate_resident_gb(variant.size_bytes, model.family)
+ assert rows[variant.key].estimated_resident_gb == expected
+ assert expected != estimate_resident_gb(variant.size_bytes)
+
+
[email protected]("cpu_runtime", [False, True])
+def test_a_load_that_runs_on_the_cpu_lists_no_gpu_estimate(hub, monkeypatch, cpu_runtime):
+ _sized_host(monkeypatch, cpu_runtime = cpu_runtime)
+ names = ["Kokoro-82M-GGUF/kokoro-82m-q8_0.gguf", "Kokoro-82M-GGUF/kokoro-82m-tq2_1.gguf"]
+ _online(monkeypatch, *names, size = 189_000_000)
+ rows = _rows(f"{AUDIO_CPP_REPO}/Kokoro-82M-GGUF")
+ assert {quant: row.estimated_resident_gb is None for quant, row in rows.items()} == {
+ "Q8_0": cpu_runtime,
+ "TQ2_1": True,
+ }
+
+
+def test_a_dictation_model_lists_no_gpu_estimate(hub, monkeypatch):
+ _sized_host(monkeypatch)
+ _online(monkeypatch, "Moonshine-Streaming-GGUF/moonshine-streaming-tiny-q8_0.gguf")
+ row = f"{AUDIO_CPP_REPO}/Moonshine-Streaming-GGUF"
+ rows = _rows(row)
+ assert acm.resolve(row, network = True).task == "asr"
+ assert rows and all(listed.estimated_resident_gb is None for listed in rows.values())
+
+
[email protected]("device", ["MLX", "CPU"])
+def test_a_host_the_check_never_sizes_lists_no_gpu_estimate(hub, monkeypatch, device):
+ _sized_host(monkeypatch, device)
+ _online(monkeypatch, "Kokoro-82M-GGUF/kokoro-82m-q8_0.gguf", size = 189_000_000)
+ rows = _rows(f"{AUDIO_CPP_REPO}/Kokoro-82M-GGUF")
+ assert rows and all(listed.estimated_resident_gb is None for listed in rows.values())
diff --git a/studio/backend/tests/test_audio_cpp_umbrella_ids.py b/studio/backend/tests/test_audio_cpp_umbrella_ids.py
index b985bd497fd..c5880f87ce9 100644
--- a/studio/backend/tests/test_audio_cpp_umbrella_ids.py
+++ b/studio/backend/tests/test_audio_cpp_umbrella_ids.py
@@ -843,3 +843,29 @@ def test_cached_path_of_a_folder_skips_a_newer_snapshot_missing_voice_files(hub)
_add_snapshot(hub, "a" * 40, {rel: "pocket_tts"}, main = True)
acm.forget()
assert acm.folder_snapshot_dir(f"{AUDIO_CPP_REPO}/PocketTTS-GGUF") == older / "PocketTTS-GGUF"
+
+
[email protected]("local_path, packaged", [("audio-cpp/Yue2-3B-GGUF", True), ("dir", False)])
+def test_a_package_repo_row_lists_its_packages(hub, tmp_path, monkeypatch, local_path, packaged):
+ from hub.services.models import gguf_variants
+
+ sentinel = object()
+ seen = []
+
+ async def packages(repo_id, hf_token, offline):
+ seen.append(repo_id)
+ return sentinel
+
+ monkeypatch.setattr(gguf_variants, "_audio_cpp_variants_answer", packages)
+ if local_path == "dir":
+ local_path = str(tmp_path / "my-models")
+ (tmp_path / "my-models").mkdir()
+ try:
+ answer = asyncio.run(
+ gguf_variants.get_gguf_variants_answer(
+ "audio-cpp/Yue2-3B-GGUF", offline = True, local_path = local_path
+ )
+ )
+ except Exception:
+ answer = None
+ assert (answer is sentinel) is packaged and bool(seen) is packaged
diff --git a/studio/backend/utils/hardware/nvidia.py b/studio/backend/utils/hardware/nvidia.py
index 776b550c890..9f3a21121b7 100644
--- a/studio/backend/utils/hardware/nvidia.py
+++ b/studio/backend/utils/hardware/nvidia.py
@@ -571,6 +571,12 @@ def _linux_nvidia_procfs_gpu_count() -> int:
return len(entries)
+def has_nvidia_driver() -> bool:
+ return (
+ shutil.which(_nvidia_smi_executable()) is not None or _linux_nvidia_procfs_gpu_count() > 0
+ )
+
+
# Native tensor-core support: FP8 from Ada / Hopper (sm_89), NVFP4 from Blackwell (sm_100, sm_120).
_CHECKPOINT_QUANT_MIN_CAPABILITY = (("fp8", (8, 9)), ("nvfp4", (10, 0)))
diff --git a/studio/frontend/src/features/audio/audio-catalog-rows.ts b/studio/frontend/src/features/audio/audio-catalog-rows.ts
index a9989525c05..9122835d035 100644
--- a/studio/frontend/src/features/audio/audio-catalog-rows.ts
+++ b/studio/frontend/src/features/audio/audio-catalog-rows.ts
@@ -33,6 +33,8 @@ export interface AudioCatalogRow {
languages: readonly string[] | null;
status: AudioCatalogStatus | null;
size_bytes: number | null;
+ estimated_resident_gb?: number | null;
+ smallest_estimated_resident_gb?: number | null;
downloaded: boolean;
unsupported_reason: string | null;
}
@@ -119,9 +121,11 @@ export function catalogMoreRows(
}
/** A "More models" row; the picker reads `sizeBytes` for its size column. */
-export function catalogModelOption(
- row: AudioCatalogRow,
-): ModelOption & { sizeBytes: number | null } {
+export function catalogModelOption(row: AudioCatalogRow): ModelOption & {
+ sizeBytes: number | null;
+ estimatedResidentGb: number | null;
+ smallestResidentGb: number | null;
+} {
// Named by folder like the seed rows, and a Community repo by its full id: two repos can
// share one spec display name, or one repo name.
const name = row.folder || row.id;
@@ -135,6 +139,8 @@ export function catalogModelOption(
? [row.display_name, about].filter(Boolean).join(" · ")
: about,
sizeBytes: row.size_bytes,
+ estimatedResidentGb: row.estimated_resident_gb ?? null,
+ smallestResidentGb: row.smallest_estimated_resident_gb ?? null,
};
}
diff --git a/studio/frontend/src/features/audio/audio-page.tsx b/studio/frontend/src/features/audio/audio-page.tsx
index 72769e4b273..c674f42fbad 100644
--- a/studio/frontend/src/features/audio/audio-page.tsx
+++ b/studio/frontend/src/features/audio/audio-page.tsx
@@ -123,6 +123,7 @@ import { type GenerateBlocker, TtsFooter } from "./pages/tts-workspace";
import { TranscribeFooter, TranscribeOutput, TranscribeRail } from "./pages/transcribe-page";
import type { SendTarget } from "./components/stem-mixer-types";
import { AUDIO_CPP_REPO, audioCppModelFor } from "./audio-cpp-catalog";
+import { AUDIO_DEVICE_KEY } from "./audio-workspace-constants";
import { selectionExpired } from "./audio-run-request";
import type { AudioSourceInputHandle } from "./components/audio-source-input";
import type { AudioSourceStatus } from "./hooks/audio-source-state";
@@ -330,7 +331,7 @@ export function AudioPage({
);
// Read at load time; the handler below ejects so a change takes effect.
const [audioDevice, setAudioDeviceState] = usePersistedChoice(
- "unsloth_audio_device",
+ AUDIO_DEVICE_KEY,
"auto",
);
@@ -1942,6 +1943,7 @@ export function AudioPage({
// Separate runs audio-to-audio models, which the speak picker's tasks leave out.
hubTask={pageWorkflow === "separate" ? "audio-to-audio" : undefined}
catalog={AUDIO_CATALOG}
+ cpuLoad={audioDevice === "cpu"}
// TTS/ASR use the checkpoint's own tokenizer, so any publisher's audio repo loads.
communityModelPolicy="search-only"
hubCapability="audio"
diff --git a/studio/frontend/src/features/audio/audio-workspace-constants.ts b/studio/frontend/src/features/audio/audio-workspace-constants.ts
index 73328f0969f..f89ad443593 100644
--- a/studio/frontend/src/features/audio/audio-workspace-constants.ts
+++ b/studio/frontend/src/features/audio/audio-workspace-constants.ts
@@ -9,3 +9,4 @@ export const RECORDING_MAX_SECONDS = 30 * 60;
export const TTS_MAX_TOKENS = 8192;
// Max tokens caps output only and the prompt shares the context, so TTS_MAX_TOKENS itself is unreachable.
export const TTS_PROMPT_CONTEXT_RESERVE = 2048;
+export const AUDIO_DEVICE_KEY = "unsloth_audio_device";
diff --git a/studio/frontend/src/features/chat/types/api.ts b/studio/frontend/src/features/chat/types/api.ts
index 1ba75018502..e538f6e795a 100644
--- a/studio/frontend/src/features/chat/types/api.ts
+++ b/studio/frontend/src/features/chat/types/api.ts
@@ -165,6 +165,7 @@ export interface GgufVariantDetail {
display_label?: string | null;
size_bytes: number;
download_size_bytes?: number;
+ estimated_resident_gb?: number | null;
/** Streamed lookup-table bytes inside `size_bytes`; 0 when none or on an older backend. */
lookup_table_bytes?: number;
pending_drafter_filename?: string | null;
diff --git a/studio/frontend/src/features/hub/catalog/download-section.tsx b/studio/frontend/src/features/hub/catalog/download-section.tsx
index a8272d8ac29..e4fe5802446 100644
--- a/studio/frontend/src/features/hub/catalog/download-section.tsx
+++ b/studio/frontend/src/features/hub/catalog/download-section.tsx
@@ -26,6 +26,7 @@ export function DownloadSection({
isLoadingThisModel,
gpuGb,
gpuCount,
+ audioCppCardGb,
systemRamGb,
unifiedLoadBudgetGb,
cachePath,
@@ -55,6 +56,7 @@ export function DownloadSection({
isLoadingThisModel: boolean;
gpuGb?: number;
gpuCount?: number;
+ audioCppCardGb?: number;
systemRamGb?: number;
unifiedLoadBudgetGb?: number | null;
cachePath?: string | null;
@@ -80,6 +82,7 @@ export function DownloadSection({
isLoadingThisModel={isLoadingThisModel}
gpuGb={gpuGb}
gpuCount={gpuCount}
+ audioCppCardGb={audioCppCardGb}
systemRamGb={systemRamGb}
unifiedLoadBudgetGb={unifiedLoadBudgetGb}
cachePath={cachePath}
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 bc3f1de2126..e6576fd51e2 100644
--- a/studio/frontend/src/features/hub/catalog/gguf-download-card.tsx
+++ b/studio/frontend/src/features/hub/catalog/gguf-download-card.tsx
@@ -361,6 +361,7 @@ function createGgufVariantMenuItems(
resources: {
gpuGb?: number;
gpuCount?: number;
+ audioCppCardGb?: number;
systemRamGb?: number;
budgetFraction?: number;
unifiedLoadBudgetGb?: number | null;
@@ -676,6 +677,7 @@ export function GgufDownloadCard({
isLoadingThisModel,
gpuGb,
gpuCount,
+ audioCppCardGb,
systemRamGb,
unifiedLoadBudgetGb,
cachePath,
@@ -696,6 +698,7 @@ export function GgufDownloadCard({
isLoadingThisModel: boolean;
gpuGb?: number;
gpuCount?: number;
+ audioCppCardGb?: number;
systemRamGb?: number;
unifiedLoadBudgetGb?: number | null;
cachePath?: string | null;
@@ -760,6 +763,7 @@ export function GgufDownloadCard({
return sortDownloadableGgufVariants(variants, {
gpuGb,
gpuCount,
+ audioCppCardGb,
systemRamGb,
budgetFraction,
unifiedLoadBudgetGb,
@@ -768,6 +772,7 @@ export function GgufDownloadCard({
variants,
gpuGb,
gpuCount,
+ audioCppCardGb,
systemRamGb,
budgetFraction,
unifiedLoadBudgetGb,
@@ -822,6 +827,7 @@ export function GgufDownloadCard({
{
gpuGb,
gpuCount,
+ audioCppCardGb,
systemRamGb,
budgetFraction,
unifiedLoadBudgetGb,
@@ -831,6 +837,7 @@ export function GgufDownloadCard({
[
gpuGb,
gpuCount,
+ audioCppCardGb,
sortedVariants,
systemRamGb,
budgetFraction,
@@ -926,6 +933,7 @@ export function GgufDownloadCard({
? classifyGgufVariantFit(selected, {
gpuGb,
gpuCount,
+ audioCppCardGb,
systemRamGb,
budgetFraction,
unifiedLoadBudgetGb,
diff --git a/studio/frontend/src/features/hub/catalog/local-on-device-card.tsx b/studio/frontend/src/features/hub/catalog/local-on-device-card.tsx
index 6c4b23e1254..37a4df5324f 100644
--- a/studio/frontend/src/features/hub/catalog/local-on-device-card.tsx
+++ b/studio/frontend/src/features/hub/catalog/local-on-device-card.tsx
@@ -100,6 +100,7 @@ interface LocalOnDeviceCardProps {
gpuGb?: number;
gpuCount?: number;
+ audioCppCardGb?: number;
systemRamGb?: number;
unsupportedReason?: string | null;
onRun?: (selection: HubModelRunSelection) => void;
@@ -249,6 +250,7 @@ export function LocalOnDeviceCard({
gpuGb,
gpuCount,
+ audioCppCardGb,
systemRamGb,
unsupportedReason,
onRun,
@@ -372,6 +374,7 @@ export function LocalOnDeviceCard({
defaultVariant: currentVariantState.defaultVariant,
gpuGb,
gpuCount,
+ audioCppCardGb,
systemRamGb,
budgetFraction,
})
@@ -381,6 +384,7 @@ export function LocalOnDeviceCard({
currentVariantState.defaultVariant,
gpuGb,
gpuCount,
+ audioCppCardGb,
systemRamGb,
budgetFraction,
],
diff --git a/studio/frontend/src/features/hub/catalog/model-inspector.tsx b/studio/frontend/src/features/hub/catalog/model-inspector.tsx
index bea0b2baf96..3e2218f2de2 100644
--- a/studio/frontend/src/features/hub/catalog/model-inspector.tsx
+++ b/studio/frontend/src/features/hub/catalog/model-inspector.tsx
@@ -423,6 +423,7 @@ export type ModelInspectorRuntime = {
} | null;
gpuGb?: number;
gpuCount?: number;
+ audioCppCardGb?: number;
systemRamGb?: number;
unifiedLoadBudgetGb?: number | null;
};
@@ -464,6 +465,7 @@ export const ModelInspector = memo(function ModelInspector({
vramInfo,
gpuGb,
gpuCount,
+ audioCppCardGb,
systemRamGb,
unifiedLoadBudgetGb,
} = runtime;
@@ -741,6 +743,7 @@ export const ModelInspector = memo(function ModelInspector({
isLoading={isLoadingThisModel}
gpuGb={gpuGb}
gpuCount={gpuCount}
+ audioCppCardGb={audioCppCardGb}
systemRamGb={systemRamGb}
preferredFile={preferredGgufFile}
preferredFileIntent={preferredGgufFileIntent}
@@ -771,6 +774,7 @@ export const ModelInspector = memo(function ModelInspector({
isLoadingThisModel={isLoadingThisModel}
gpuGb={gpuGb}
gpuCount={gpuCount}
+ audioCppCardGb={audioCppCardGb}
systemRamGb={systemRamGb}
unifiedLoadBudgetGb={
runsOnMediaRuntime ? null : unifiedLoadBudgetGb
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.ts
index 7b846bee262..8f7c30c7c7d 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
@@ -109,6 +109,8 @@ export interface HfModelResult {
gated?: false | "auto" | "manual";
totalParams?: number;
estimatedSizeBytes?: number;
+ estimatedResidentGb?: number;
+ smallestResidentGb?: number;
curatedSizeBytes?: number;
isGguf: boolean;
baseModel?: string | null;
diff --git a/studio/frontend/src/features/hub/hub-page.tsx b/studio/frontend/src/features/hub/hub-page.tsx
index 69a7c6b7eee..2e3e01cbf81 100644
--- a/studio/frontend/src/features/hub/hub-page.tsx
+++ b/studio/frontend/src/features/hub/hub-page.tsx
@@ -14,6 +14,7 @@ import {
resolveInferenceCheckpointId,
useChatRuntimeStore,
} from "@/features/chat";
+import { AUDIO_DEVICE_KEY } from "@/features/audio/audio-workspace-constants";
import { audioPickSearch } from "@/features/audio/route-search";
import { useHubInfiniteScroll } from "@/features/hub";
import { useOnlineStatus } from "@/features/hub/hooks/use-online-status";
@@ -32,8 +33,10 @@ import { GuidedTour, useGuidedTourController } from "@/features/tour";
import { useDebouncedValue } from "@/hooks/use-debounced-value";
import { useGpuInfo, useInferenceGpuInfo } from "@/hooks/use-gpu-info";
import { useIsCompact } from "@/hooks/use-mobile";
+import { usePersistedChoice } from "@/hooks/use-persisted-choice";
import { useVramBudgetFraction } from "@/hooks/use-vram-budget-fraction";
import { diffusionRouteSearch } from "@/lib/diffusion-route-search";
+import { audioCppCardGb } from "@/lib/gguf-fit";
import { subscribeModelLifecycle } from "@/lib/model-lifecycle-events";
import { cn } from "@/lib/utils";
import { useNavigate, useSearch } from "@tanstack/react-router";
@@ -419,6 +422,9 @@ export function ModelsPage() {
// Use the saved VRAM budget so the fit filter matches the badges.
const budgetFraction = useVramBudgetFraction() ?? undefined;
const inferenceGpu = useInferenceGpuInfo();
+ // Audio runs load on the Audio page, so its placement decides how audio.cpp quants are judged.
+ const [audioDevice] = usePersistedChoice(AUDIO_DEVICE_KEY, "auto");
+ const hubAudioCardGb = audioCppCardGb(gpu, audioDevice === "cpu");
// Judge fit by the runtime that places the row: media repos use the diffusion planner's rule,
// everything else the GGUF backend's inventory.
const rowFitsDevice = useCallback(
@@ -1835,6 +1841,7 @@ export function ModelsPage() {
vramInfo,
gpuGb: inferenceGpu.available ? inferenceGpu.memoryTotalGb : undefined,
gpuCount: inferenceGpu.deviceCount,
+ audioCppCardGb: hubAudioCardGb,
systemRamGb:
inferenceGpu.systemRamAvailableGb > 0
? inferenceGpu.systemRamAvailableGb
@@ -1852,6 +1859,7 @@ export function ModelsPage() {
inferenceGpu.available,
inferenceGpu.memoryTotalGb,
inferenceGpu.deviceCount,
+ hubAudioCardGb,
inferenceGpu.systemRamAvailableGb,
inferenceGpu.unifiedLoadBudgetGb,
inferenceGpu.unifiedLoadCeilingGb,
diff --git a/studio/frontend/src/features/hub/inventory/api.ts b/studio/frontend/src/features/hub/inventory/api.ts
index 9f78a2c37a1..5a9fddc05b3 100644
--- a/studio/frontend/src/features/hub/inventory/api.ts
+++ b/studio/frontend/src/features/hub/inventory/api.ts
@@ -200,6 +200,7 @@ export interface GgufVariantDetail {
display_label?: string | null;
size_bytes: number;
download_size_bytes?: number;
+ estimated_resident_gb?: number | null;
/** Streamed lookup-table bytes inside `size_bytes`; 0 when none or on an older backend. */
lookup_table_bytes?: number;
pending_drafter_filename?: string | null;
diff --git a/studio/frontend/src/features/model-picker/components/model-selector.tsx b/studio/frontend/src/features/model-picker/components/model-selector.tsx
index c3473b257a6..6522e42f471 100644
--- a/studio/frontend/src/features/model-picker/components/model-selector.tsx
+++ b/studio/frontend/src/features/model-picker/components/model-selector.tsx
@@ -147,6 +147,8 @@ interface ModelSelectorProps {
/** The one opaque on-device artifact kind this task runtime may load. */
opaqueKind?: "diffusers_pipeline" | "diffusers_modular_pipeline";
rowFilter?: ModelPickerRowFilter;
+ /** Audio's "Load model into: CPU RAM": audio.cpp variants skip their GPU estimate. */
+ cpuLoad?: boolean;
/** A second Recommended group under its own label, e.g. "More models". */
moreModels?: {
label: string;
@@ -387,6 +389,7 @@ function ModelSelectorContent({
communityModelPolicy,
opaqueKind,
rowFilter,
+ cpuLoad,
moreModels,
}: {
open: boolean;
@@ -421,6 +424,7 @@ function ModelSelectorContent({
communityModelPolicy?: CommunityModelPolicy;
opaqueKind?: "diffusers_pipeline" | "diffusers_modular_pipeline";
rowFilter?: ModelPickerRowFilter;
+ cpuLoad?: boolean;
moreModels?: {
label: string;
models: (ModelOption & { sizeBytes?: number | null })[];
@@ -731,6 +735,7 @@ function ModelSelectorContent({
communityModelPolicy={communityModelPolicy}
opaqueKind={opaqueKind}
rowFilter={rowFilter}
+ cpuLoad={cpuLoad}
moreModels={moreModels}
npu={npu}
onDeviceInventoryChange={setHasDeviceModels}
@@ -799,6 +804,7 @@ export function ModelSelector({
communityModelPolicy = "none",
opaqueKind,
rowFilter,
+ cpuLoad,
moreModels,
hubCapability,
hubTask,
@@ -1019,6 +1025,7 @@ export function ModelSelector({
communityModelPolicy={communityModelPolicy}
opaqueKind={opaqueKind}
rowFilter={rowFilter}
+ cpuLoad={cpuLoad}
moreModels={moreModels}
/>
</Popover>
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.ts
index 0cf6cf0ae0b..8b6366e624f 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
@@ -15,7 +15,7 @@ import {
type GgufFitClass,
type GgufVariantSizes,
classifyGgufFit as classifyGgufFitForDevice,
- classifyGgufFitWithLookupTables,
+ classifyVariantFitOnCard,
ggufVariantFitSizeBytes,
} from "../../../../lib/gguf-fit.ts";
import {
@@ -1348,11 +1348,12 @@ export function recommendedQuantForDevice<T extends GgufVariantSizes>(
variants: readonly T[],
fitOf: (sizeBytes: number) => GgufFitClass,
preferred: T | null = null,
+ gpuGb = 0,
): T | null {
// Judged on the download footprint, which includes companion GGUFs (mmproj, drafter).
// A `streamed` quant (tables left on disk) runs but never outranks one that fits fully resident.
const fitOfVariant = (variant: T) =>
- classifyGgufFitWithLookupTables(fitOf, variant);
+ classifyVariantFitOnCard(fitOf, variant, gpuGb);
// Zero size means unknown (old backend or stat error) and must not compete as comfortable.
const sized = variants.filter((variant) => ggufVariantFitSizeBytes(variant) > 0);
if (sized.length === 0) return null;
@@ -1388,6 +1389,7 @@ export interface QuantVariant {
size_bytes: number;
downloaded?: boolean;
lookup_table_bytes?: number;
+ estimated_resident_gb?: number | null;
}
/** The quant a bare group/repo click loads: largest downloaded non-OOM quant, else the repo default
@@ -1401,9 +1403,14 @@ export function pickDefaultQuant(
const anyBudget = (budget.gpuGb || 0) > 0 || (budget.systemRamGb || 0) > 0;
const runs = (v: QuantVariant) =>
ggufFitRuns(
- classifyGgufFitWithLookupTables(
+ classifyVariantFitOnCard(
(bytes) => classifyGgufFit(bytes, budget),
- { size_bytes: v.size_bytes, lookup_table_bytes: v.lookup_table_bytes },
+ {
+ size_bytes: v.size_bytes,
+ lookup_table_bytes: v.lookup_table_bytes,
+ estimated_resident_gb: v.estimated_resident_gb,
+ },
+ budget.gpuGb || 0,
),
);
const downloadedFitting = variants
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.tsx
index 6c2b10c7798..79048b069b7 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
@@ -118,7 +118,9 @@ import { copyToClipboard } from "@/lib/copy-to-clipboard";
import { diffusionRouteSearch } from "@/lib/diffusion-route-search";
import {
type GgufFitClass,
- classifyGgufFitWithLookupTables,
+ audioCppCardGb,
+ audioCppRowFit,
+ classifyVariantFitOnCard,
ggufVariantLookupTableBytes,
requiredGgufMemoryGb,
} from "@/lib/gguf-fit";
@@ -671,6 +673,9 @@ const CapabilityScope = createContext<readonly (keyof ModelCapabilities)[] | nul
* MLX host, where `marginal` means past the loader's unified budget rather than the VRAM Budget. */
const UnifiedLoadBudget = createContext<number | null>(null);
+/** `audioCppCardGb` of the picker's load, which audio.cpp variants are judged on; 0 judges none. */
+const AudioCppCard = createContext(0);
+
/** audio.cpp GGUFs load through the audio runtime, not under llama.cpp's Metal budget; Mac TTS
* GGUFs (Orpheus and the like) do load through llama.cpp, so the Audio task alone decides nothing. */
function loadsOnAudioCpp(repoId: string): boolean {
@@ -680,16 +685,20 @@ function loadsOnAudioCpp(repoId: string): boolean {
function PickerScopes({
capabilityScope,
unifiedLoadBudgetGb,
+ audioCppCardGb,
children,
}: {
capabilityScope: readonly (keyof ModelCapabilities)[] | null;
unifiedLoadBudgetGb: number | null;
+ audioCppCardGb: number;
children: ReactNode;
}) {
return (
<CapabilityScope.Provider value={capabilityScope}>
<UnifiedLoadBudget.Provider value={unifiedLoadBudgetGb}>
- {children}
+ <AudioCppCard.Provider value={audioCppCardGb}>
+ {children}
+ </AudioCppCard.Provider>
</UnifiedLoadBudget.Provider>
</CapabilityScope.Provider>
);
@@ -976,6 +985,42 @@ function VramBadge({
const SIZE_PARTS_RE = /^(~?)([\d.]+)\s*([A-Za-z]+)$/;
+function residentGbLabel(gb: number): string {
+ return `${gb.toFixed(1)} GB`;
+}
+
+// Fixed widths ("99.9GB to run", "99.9GB") keep the estimate and fit mark aligned across rows.
+const RESIDENT_COLUMN = "mr-1.5 min-w-[13ch] text-right";
+const RESIDENT_SIZE_COLUMN = "min-w-[6ch] text-right";
+
+function ResidentText({
+ value,
+ className,
+}: {
+ value: string;
+ className?: string;
+}) {
+ const t = useT();
+ return (
+ <Tooltip delayDuration={0}>
+ <TooltipTrigger asChild={true}>
+ <span
+ className={cn(
+ "shrink-0 whitespace-nowrap font-mono text-ui-10 text-muted-foreground tabular-nums",
+ className,
+ )}
+ >
+ <SizeText value={value} />
+ <span className="ml-1 font-sans">{t("picker.residentToRun")}</span>
+ </span>
+ </TooltipTrigger>
+ <TooltipContent side="top" className="tooltip-compact">
+ {t("picker.residentToRunHint")}
+ </TooltipContent>
+ </Tooltip>
+ );
+}
+
function SizeText({ value }: { value: string }) {
const parts = SIZE_PARTS_RE.exec(value);
if (!parts) {
@@ -1576,6 +1621,9 @@ function ModelRow({
{text}
</span>
))}
+ {parsed.resident ? (
+ <ResidentText value={parsed.resident} className="mr-1.5" />
+ ) : null}
{/* GGUF repos hold several quants, so their size shows only once expanded. */}
{alignMeta === "device" || showSize ? (
<span
@@ -1972,6 +2020,7 @@ const SoleQuantGgufDeviceRow = memo(function SoleQuantGgufDeviceRow({
expander: DeviceRowExpanderProps;
}) {
const callbacks = useDeviceExpanderCallbacks(actions, optionKey);
+ const audioCardGb = useContext(AudioCppCard);
const variant = sole.variant;
const expectedBytes = ggufVariantExpectedBytes(variant);
// Should never be partial, but if it is, state what is on disk rather than load a torn file.
@@ -2002,7 +2051,15 @@ const SoleQuantGgufDeviceRow = memo(function SoleQuantGgufDeviceRow({
c.cache_path,
ggufQuantDetailLabel(variant.quant),
)}
- meta={`GGUF · ${formatBytes(variant.size_bytes)}`}
+ meta={[
+ "GGUF",
+ formatBytes(variant.size_bytes),
+ variant.estimated_resident_gb && audioCardGb > 0
+ ? `${residentGbLabel(variant.estimated_resident_gb)} to run`
+ : null,
+ ]
+ .filter(Boolean)
+ .join(" · ")}
quantChip={ggufQuantChipLabel(variant.quant)}
partial={isPartial}
// Only for llama.cpp loads: diffusion GGUFs run on a different planner and the estimate would be wrong.
@@ -2876,10 +2933,12 @@ function GgufVariantExpander({
);
// One verdict per variant from the download footprint (incl. companions), so badge, order and star agree.
+ const audioCardGb = useContext(AudioCppCard);
+ const cardGb = anyBudgetGb ? audioCardGb : 0;
const getVariantFit = useCallback(
(variant: GgufVariantDetail): GgufFitClass =>
- classifyGgufFitWithLookupTables(getGgufFit, variant),
- [getGgufFit],
+ classifyVariantFitOnCard(getGgufFit, variant, cardGb),
+ [getGgufFit, cardGb],
);
const variantGroups = useMemo(
@@ -2900,12 +2959,12 @@ function GgufVariantExpander({
continue;
}
const pick =
- recommendedQuantForDevice(group.variants, getGgufFit, preferred) ??
+ recommendedQuantForDevice(group.variants, getGgufFit, preferred, cardGb) ??
preferred;
if (pick) recommended.set(group.key, pick.quant);
}
return recommended;
- }, [variantGroups, preferredByGroup, anyBudgetGb, budgetKnown, getGgufFit]);
+ }, [variantGroups, preferredByGroup, anyBudgetGb, budgetKnown, getGgufFit, cardGb]);
// Keyed by presentation group while footprints bucket by dependency_key, so ask via the variant.
const recommendedQuantForVariant = useMemo(() => {
const byVariant = new Map<GgufVariantDetail, string>();
@@ -3154,6 +3213,7 @@ function GgufVariantExpander({
effectiveRecommendedByGroup.get(group.key) === v.quant;
const fit = getVariantFit(v);
const oom = fit === "oom";
+ const residentGb = audioCardGb > 0 ? v.estimated_resident_gb : null;
const expectedBytes = ggufVariantExpectedBytes(v);
const variantContext = ggufVariantContextLength(v, nativeContext);
// This row's own dependency group, never the listing's.
@@ -3225,7 +3285,18 @@ function GgufVariantExpander({
diffusionLoad ? mediaGgufPickerStatus(fit) : fit
}
/>
- <span className="font-mono text-ui-10 text-muted-foreground tabular-nums">
+ {residentGb ? (
+ <ResidentText
+ value={residentGbLabel(residentGb)}
+ className={RESIDENT_COLUMN}
+ />
+ ) : null}
+ <span
+ className={cn(
+ "font-mono text-ui-10 text-muted-foreground tabular-nums",
+ residentGb ? RESIDENT_SIZE_COLUMN : null,
+ )}
+ >
{companionBytes === null ? (
<SizeText value={formatBytes(v.size_bytes)} />
) : (
@@ -3754,6 +3825,7 @@ export function HubModelPicker({
npu,
rowFilter,
moreModels,
+ cpuLoad = false,
}: {
open: boolean;
models: ModelOption[];
@@ -3794,11 +3866,17 @@ export function HubModelPicker({
/** A second Recommended group under its own ListLabel; rows reuse the recommended renderer. */
moreModels?: {
label: string;
- models: (ModelOption & { sizeBytes?: number | null })[];
+ models: (ModelOption & {
+ sizeBytes?: number | null;
+ estimatedResidentGb?: number | null;
+ smallestResidentGb?: number | null;
+ })[];
};
+ cpuLoad?: boolean;
}) {
const gpu = useGpuInfo();
const inferenceGpu = useInferenceGpuInfo();
+ const audioCardGb = audioCppCardGb(gpu, cpuLoad);
// Threaded into every fit call, not only the quant rows.
const budgetFraction = useVramBudgetFraction() ?? undefined;
// FP8 / NVFP4 checkpoints every GPU here runs natively: chat lists them past the GGUF-only rule and
@@ -4701,6 +4779,7 @@ export function HubModelPicker({
(catalogFit(r.id, pipelineBudget)?.fits ??
hfModelFitsDevice(r, source, {
budgetFraction,
+ audioCppCardGb: audioCardGb,
// 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,
@@ -4755,6 +4834,7 @@ export function HubModelPicker({
isTaskRuntimeSupported,
gpu,
inferenceGpu,
+ audioCardGb,
isChatSupported,
task,
catalog,
@@ -4792,6 +4872,8 @@ export function HubModelPicker({
likes: 0,
isGguf: model.isGguf ?? true,
estimatedSizeBytes: model.sizeBytes ?? undefined,
+ estimatedResidentGb: model.estimatedResidentGb ?? undefined,
+ smallestResidentGb: model.smallestResidentGb ?? undefined,
}))
.filter(
(row) =>
@@ -4799,6 +4881,7 @@ export function HubModelPicker({
cachedIdFor(row.id) !== null ||
hfModelFitsDevice(row, source, {
budgetFraction,
+ audioCppCardGb: audioCardGb,
mediaLoad: diffusionLoad,
hostPooledMemory: gpu.loadDeviceSharesHostMemory,
gpuCount: source.deviceCount,
@@ -4812,6 +4895,7 @@ export function HubModelPicker({
fitOnDeviceOnly,
cachedIdFor,
inferenceGpu,
+ audioCardGb,
gpu,
task,
budgetFraction,
@@ -4888,6 +4972,9 @@ export function HubModelPicker({
ggufParams ? formatCompact(ggufParams) : null,
"GGUF",
r.estimatedSizeBytes ? formatBytes(r.estimatedSizeBytes) : null,
+ r.estimatedResidentGb && audioCardGb > 0
+ ? `${residentGbLabel(r.estimatedResidentGb)} to run`
+ : null,
]
.filter(Boolean)
.join(" · ")
@@ -4906,6 +4993,16 @@ export function HubModelPicker({
const sizeBytes =
r.estimatedSizeBytes ??
(params ? estimateQuantBytes(params) : undefined);
+ const resident = r.estimatedResidentGb;
+ const residentFit = audioCppRowFit(r, audioCardGb);
+ if (resident && residentFit) {
+ map.set(r.id, {
+ meta,
+ status: residentFit === "fits" ? null : "oom",
+ est: resident,
+ });
+ continue;
+ }
map.set(r.id, {
meta,
// The classifier's own verdict, so a GGUF row never borrows the torch-only "exceeds", scoped
@@ -4954,6 +5051,7 @@ export function HubModelPicker({
isKnownGgufRepo,
gpu,
inferenceGpu,
+ audioCardGb,
loadFreesResident,
]);
@@ -7686,6 +7784,7 @@ export function HubModelPicker({
return (
<PickerScopes
capabilityScope={capabilityScope}
+ audioCppCardGb={audioCardGb}
unifiedLoadBudgetGb={
(loadFreesResident
? inferenceGpu.unifiedLoadCeilingGb
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.ts
index 71ea89abe90..91277af3fa9 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
@@ -1,7 +1,10 @@
// 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 { classifyGgufFit } from "../../../../lib/gguf-fit.ts";
+import {
+ audioCppRowFit,
+ classifyGgufFit,
+} from "../../../../lib/gguf-fit.ts";
import {
LOADING_OVERHEAD_GB,
checkVramFit,
@@ -237,6 +240,8 @@ export function hfModelFitsDevice(
id: string;
totalParams?: number;
estimatedSizeBytes?: number;
+ estimatedResidentGb?: number;
+ smallestResidentGb?: number;
curatedSizeBytes?: number;
isGguf?: boolean;
quantMethod?: string;
@@ -253,6 +258,8 @@ export function hfModelFitsDevice(
gpuCount?: number;
mediaLoad?: boolean;
hostPooledMemory?: boolean;
+ /** `audioCppCardGb` of the load; absent means memoryTotalGb is one card. */
+ audioCppCardGb?: number;
} = {},
): boolean {
if (
@@ -261,6 +268,11 @@ export function hfModelFitsDevice(
!gpu.budgetKnown
)
return true;
+ const resident = audioCppRowFit(
+ model,
+ opts.audioCppCardGb ?? gpu.memoryTotalGb,
+ );
+ if (resident) return resident === "fits";
const params = model.totalParams ?? paramsFromId(model.id);
const isGguf = isGgufId(model.id, model.isGguf);
if (
diff --git a/studio/frontend/src/features/model-picker/components/model-selector/row-meta.ts b/studio/frontend/src/features/model-picker/components/model-selector/row-meta.ts
index 624385b2fa9..caaf914027b 100644
--- a/studio/frontend/src/features/model-picker/components/model-selector/row-meta.ts
+++ b/studio/frontend/src/features/model-picker/components/model-selector/row-meta.ts
@@ -68,10 +68,12 @@ export type MetaToken =
| { kind: "format"; label: string; tone: FormatTone }
| { kind: "size"; label: string }
| { kind: "param"; label: string }
+ | { kind: "resident"; label: string }
| { kind: "text"; label: string };
const META_SIZE_RE = /(?:KB|MB|GB|TB)\b/i;
const META_APPROX_RE = /^~/;
+const META_RUN_RE = /\bto run$/i;
const META_PARAM_RE = /^\d+(?:\.\d+)?[MB]$/i;
const META_WHITESPACE_RE = /\s+/;
@@ -80,6 +82,10 @@ const META_WHITESPACE_RE = /\s+/;
export function classifyMetaToken(raw: string): MetaToken | null {
const t = raw.trim();
if (!t) return null;
+ // Before the size test, which "12.2 GB to run" (an audio.cpp estimate) also matches.
+ if (META_RUN_RE.test(t)) {
+ return { kind: "resident", label: t.replace(META_RUN_RE, "").trim() };
+ }
if (META_SIZE_RE.test(t) || META_APPROX_RE.test(t)) {
return { kind: "size", label: t };
}
@@ -99,12 +105,14 @@ export function parseMetaTokens(meta?: string | null): {
formats: { label: string; tone: FormatTone }[];
param?: string;
size?: string;
+ resident?: string;
texts: string[];
} {
const formats: { label: string; tone: FormatTone }[] = [];
const texts: string[] = [];
let param: string | undefined;
let size: string | undefined;
+ let resident: string | undefined;
if (!meta) return { formats, texts };
for (const part of meta.split("·")) {
const token = classifyMetaToken(part);
@@ -115,9 +123,11 @@ export function parseMetaTokens(meta?: string | null): {
size ??= token.label;
} else if (token.kind === "param") {
param ??= token.label;
+ } else if (token.kind === "resident") {
+ resident ??= token.label;
} else {
texts.push(token.label);
}
}
- return { formats, param, size, texts };
+ return { formats, param, size, resident, texts };
}
diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.ts
index 65ad7299a46..503afec6c51 100644
--- a/studio/frontend/src/i18n/locales/ar.ts
+++ b/studio/frontend/src/i18n/locales/ar.ts
@@ -792,6 +792,8 @@ export const ar = {
picker: {
unifiedTightFit: "ملاءمة محدودة",
unifiedTightFitHint: "قد يُحمَّل بسياق أقصر أو يعمل بشكل أبطأ على جهاز Mac هذا.",
+ residentToRun: "للتشغيل",
+ residentToRunHint: "ذاكرة GPU التي يتطلبها فحص التحميل أثناء التشغيل",
onDevice: "على الجهاز",
huggingFace: "Hugging Face",
retry: "إعادة المحاولة",
diff --git a/studio/frontend/src/i18n/locales/cs.ts b/studio/frontend/src/i18n/locales/cs.ts
index 4e66d07c720..3b4d69a8468 100644
--- a/studio/frontend/src/i18n/locales/cs.ts
+++ b/studio/frontend/src/i18n/locales/cs.ts
@@ -893,6 +893,8 @@ export const cs = {
unifiedTightFit: "Těsně se vejde",
unifiedTightFitHint:
"Na tomto Macu se model může načíst s kratším kontextem nebo běžet pomaleji.",
+ residentToRun: "ke spuštění",
+ residentToRunHint: "Paměť GPU, kterou kontrola načtení vyžaduje za běhu",
onDevice: "V zařízení",
huggingFace: "Hugging Face",
retry: "Zkusit znovu",
diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.ts
index 3f71ba42528..18f04857fbc 100644
--- a/studio/frontend/src/i18n/locales/de.ts
+++ b/studio/frontend/src/i18n/locales/de.ts
@@ -793,6 +793,8 @@ export const de = {
picker: {
unifiedTightFit: "Knapp",
unifiedTightFitHint: "Lädt auf diesem Mac eventuell nur mit kürzerem Kontext oder läuft langsamer.",
+ residentToRun: "zum Ausführen",
+ residentToRunHint: "GPU-Speicher, den die Ladeprüfung während der Ausführung verlangt",
onDevice: "Auf dem Gerät",
huggingFace: "Hugging Face",
retry: "Erneut versuchen",
diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.ts
index 41a70c75ff6..c1af60714cd 100644
--- a/studio/frontend/src/i18n/locales/en.ts
+++ b/studio/frontend/src/i18n/locales/en.ts
@@ -798,6 +798,8 @@ export const en = {
picker: {
unifiedTightFit: "Tight fit",
unifiedTightFitHint: "May load with a shorter context or run slower on this Mac.",
+ residentToRun: "to run",
+ residentToRunHint: "GPU memory the load check needs while running",
onDevice: "On Device",
huggingFace: "Hugging Face",
retry: "Retry",
diff --git a/studio/frontend/src/i18n/locales/es-419.ts b/studio/frontend/src/i18n/locales/es-419.ts
index 8293d7f862b..02c7e20be5d 100644
--- a/studio/frontend/src/i18n/locales/es-419.ts
+++ b/studio/frontend/src/i18n/locales/es-419.ts
@@ -898,6 +898,9 @@ export const es419 = {
unifiedTightFit: "Ajuste justo",
unifiedTightFitHint:
"Puede cargarse con un contexto más corto o funcionar más lento en esta Mac.",
+ residentToRun: "para ejecutar",
+ residentToRunHint:
+ "Memoria de GPU que la comprobación de carga requiere durante la ejecución",
onDevice: "En el dispositivo",
huggingFace: "Hugging Face",
retry: "Reintentar",
diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.ts
index bfbe75b2727..30c2d798e37 100644
--- a/studio/frontend/src/i18n/locales/es.ts
+++ b/studio/frontend/src/i18n/locales/es.ts
@@ -793,6 +793,8 @@ export const es = {
picker: {
unifiedTightFit: "Ajuste justo",
unifiedTightFitHint: "Puede cargarse con un contexto más corto o ir más lento en este Mac.",
+ residentToRun: "para ejecutar",
+ residentToRunHint: "Memoria de GPU que la comprobación de carga requiere durante la ejecución",
onDevice: "En el dispositivo",
huggingFace: "Hugging Face",
retry: "Reintentar",
diff --git a/studio/frontend/src/i18n/locales/fa.ts b/studio/frontend/src/i18n/locales/fa.ts
index 0b1c9ca63f6..49dcd514a9b 100644
--- a/studio/frontend/src/i18n/locales/fa.ts
+++ b/studio/frontend/src/i18n/locales/fa.ts
@@ -889,6 +889,8 @@ export const fa = {
unifiedTightFit: "جای تنگ",
unifiedTightFitHint:
"ممکن است با زمینهٔ کوتاه‌تر بارگذاری شود یا روی این Mac کندتر اجرا شود.",
+ residentToRun: "برای اجرا",
+ residentToRunHint: "حافظه GPU که بررسی بارگذاری هنگام اجرا لازم دارد",
onDevice: "روی دستگاه",
huggingFace: "Hugging Face",
retry: "تلاش دوباره",
diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.ts
index e2eb68d328d..a96799400b4 100644
--- a/studio/frontend/src/i18n/locales/fr.ts
+++ b/studio/frontend/src/i18n/locales/fr.ts
@@ -793,6 +793,8 @@ export const fr = {
picker: {
unifiedTightFit: "Juste",
unifiedTightFitHint: "Peut se charger avec un contexte plus court ou être plus lent sur ce Mac.",
+ residentToRun: "pour l'exécution",
+ residentToRunHint: "Mémoire GPU que la vérification de chargement exige pendant l'exécution",
onDevice: "Sur l'appareil",
huggingFace: "Hugging Face",
retry: "Réessayer",
diff --git a/studio/frontend/src/i18n/locales/he.ts b/studio/frontend/src/i18n/locales/he.ts
index c0b54721590..e8e0ce90b8d 100644
--- a/studio/frontend/src/i18n/locales/he.ts
+++ b/studio/frontend/src/i18n/locales/he.ts
@@ -830,6 +830,8 @@ export const he = {
picker: {
unifiedTightFit: "התאמה צפופה",
unifiedTightFitHint: "ייתכן שייטען עם הקשר קצר יותר או ירוץ לאט יותר ב-Mac הזה.",
+ residentToRun: "להרצה",
+ residentToRunHint: "זיכרון GPU שבדיקת הטעינה דורשת בזמן הריצה",
onDevice: "במכשיר",
huggingFace: "Hugging Face",
retry: "נסה שוב",
diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.ts
index be0579568a9..900743301b8 100644
--- a/studio/frontend/src/i18n/locales/hi.ts
+++ b/studio/frontend/src/i18n/locales/hi.ts
@@ -793,6 +793,8 @@ export const hi = {
picker: {
unifiedTightFit: "तंग फ़िट",
unifiedTightFitHint: "इस Mac पर छोटे कॉन्टेक्स्ट के साथ लोड हो सकता है या धीमा चल सकता है।",
+ residentToRun: "चलाने के लिए",
+ residentToRunHint: "चलते समय लोड जांच के लिए आवश्यक GPU मेमोरी",
onDevice: "डिवाइस पर",
huggingFace: "Hugging Face",
retry: "पुनः प्रयास करें",
diff --git a/studio/frontend/src/i18n/locales/id.ts b/studio/frontend/src/i18n/locales/id.ts
index be9dfde4eae..d2ec42350ad 100644
--- a/studio/frontend/src/i18n/locales/id.ts
+++ b/studio/frontend/src/i18n/locales/id.ts
@@ -891,6 +891,9 @@ export const id = {
unifiedTightFit: "Pas-pasan",
unifiedTightFitHint:
"Mungkin dimuat dengan konteks lebih pendek atau berjalan lebih lambat di Mac ini.",
+ residentToRun: "untuk menjalankan",
+ residentToRunHint:
+ "Memori GPU yang dibutuhkan pemeriksaan pemuatan saat berjalan",
onDevice: "Di Perangkat",
huggingFace: "Hugging Face",
retry: "Coba lagi",
diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.ts
index ccd88f03215..e592064e389 100644
--- a/studio/frontend/src/i18n/locales/it.ts
+++ b/studio/frontend/src/i18n/locales/it.ts
@@ -3673,6 +3673,8 @@ export const it = {
picker: {
unifiedTightFit: "Al limite",
unifiedTightFitHint: "Su questo Mac potrebbe caricarsi con un contesto più breve o essere più lento.",
+ residentToRun: "per l'esecuzione",
+ residentToRunHint: "Memoria GPU richiesta dal controllo di caricamento durante l'esecuzione",
onDevice: "Sul dispositivo",
huggingFace: "Hugging Face",
retry: "Riprova",
diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.ts
index 5a8ef699a3d..80ae6dcf5b5 100644
--- a/studio/frontend/src/i18n/locales/ja.ts
+++ b/studio/frontend/src/i18n/locales/ja.ts
@@ -793,6 +793,8 @@ export const ja = {
picker: {
unifiedTightFit: "ぎりぎり",
unifiedTightFitHint: "この Mac では短いコンテキストで読み込まれるか、動作が遅くなる可能性があります。",
+ residentToRun: "実行に必要",
+ residentToRunHint: "実行中に読み込みチェックが必要とする GPU メモリ",
onDevice: "デバイス上",
huggingFace: "Hugging Face",
retry: "再試行",
diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.ts
index 20f073ff579..1f880f1c363 100644
--- a/studio/frontend/src/i18n/locales/ko.ts
+++ b/studio/frontend/src/i18n/locales/ko.ts
@@ -792,6 +792,8 @@ export const ko = {
picker: {
unifiedTightFit: "빠듯함",
unifiedTightFitHint: "이 Mac에서는 더 짧은 컨텍스트로 로드되거나 느리게 실행될 수 있습니다.",
+ residentToRun: "실행에 필요",
+ residentToRunHint: "실행 중 로드 검사가 요구하는 GPU 메모리",
onDevice: "기기",
huggingFace: "Hugging Face",
retry: "다시 시도",
diff --git a/studio/frontend/src/i18n/locales/nl.ts b/studio/frontend/src/i18n/locales/nl.ts
index 7bcd015d9b7..a89beefb18e 100644
--- a/studio/frontend/src/i18n/locales/nl.ts
+++ b/studio/frontend/src/i18n/locales/nl.ts
@@ -902,6 +902,9 @@ export const nl = {
unifiedTightFit: "Krap",
unifiedTightFitHint:
"Wordt op deze Mac mogelijk geladen met een kortere context of werkt langzamer.",
+ residentToRun: "om te draaien",
+ residentToRunHint:
+ "GPU-geheugen dat de laadcontrole tijdens het draaien vereist",
onDevice: "Op apparaat",
huggingFace: "Hugging Face",
retry: "Opnieuw proberen",
diff --git a/studio/frontend/src/i18n/locales/pl.ts b/studio/frontend/src/i18n/locales/pl.ts
index e573f47d649..229d95a620f 100644
--- a/studio/frontend/src/i18n/locales/pl.ts
+++ b/studio/frontend/src/i18n/locales/pl.ts
@@ -899,6 +899,9 @@ export const pl = {
unifiedTightFit: "Ciasne dopasowanie",
unifiedTightFitHint:
"Może wczytać się z krótszym kontekstem lub działać wolniej na tym Macu.",
+ residentToRun: "do uruchomienia",
+ residentToRunHint:
+ "Pamięć GPU wymagana przez kontrolę ładowania podczas działania",
onDevice: "Na urządzeniu",
huggingFace: "Hugging Face",
retry: "Ponów",
diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.ts
index 103df882fa3..0591b6dac52 100644
--- a/studio/frontend/src/i18n/locales/pt-br.ts
+++ b/studio/frontend/src/i18n/locales/pt-br.ts
@@ -793,6 +793,8 @@ export const ptBR = {
picker: {
unifiedTightFit: "Ajuste apertado",
unifiedTightFitHint: "Pode carregar com um contexto menor ou rodar mais devagar neste Mac.",
+ residentToRun: "para rodar",
+ residentToRunHint: "Memória de GPU que a verificação de carregamento exige durante a execução",
onDevice: "No dispositivo",
huggingFace: "Hugging Face",
retry: "Tentar novamente",
diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.ts
index 60db70216b7..16cc54704cb 100644
--- a/studio/frontend/src/i18n/locales/ru.ts
+++ b/studio/frontend/src/i18n/locales/ru.ts
@@ -793,6 +793,8 @@ export const ru = {
picker: {
unifiedTightFit: "Впритык",
unifiedTightFitHint: "На этом Mac может загрузиться с более коротким контекстом или работать медленнее.",
+ residentToRun: "для запуска",
+ residentToRunHint: "Память GPU, которую проверка загрузки требует во время работы",
onDevice: "На устройстве",
huggingFace: "Hugging Face",
retry: "Повторить",
diff --git a/studio/frontend/src/i18n/locales/sv.ts b/studio/frontend/src/i18n/locales/sv.ts
index 768dfc11f43..01183c1a0b2 100644
--- a/studio/frontend/src/i18n/locales/sv.ts
+++ b/studio/frontend/src/i18n/locales/sv.ts
@@ -846,6 +846,8 @@ export const sv = {
picker: {
unifiedTightFit: "Snäv passform",
unifiedTightFitHint: "Kan laddas med kortare kontext eller köras långsammare på den här Macen.",
+ residentToRun: "för att köra",
+ residentToRunHint: "GPU-minne som laddningskontrollen kräver under körning",
onDevice: "På enheten",
huggingFace: "Hugging Face",
retry: "Försök igen",
diff --git a/studio/frontend/src/i18n/locales/th.ts b/studio/frontend/src/i18n/locales/th.ts
index 61ca579b451..cb46dbf5eea 100644
--- a/studio/frontend/src/i18n/locales/th.ts
+++ b/studio/frontend/src/i18n/locales/th.ts
@@ -844,6 +844,8 @@ export const th = {
picker: {
unifiedTightFit: "พอดีแบบเฉียดฉิว",
unifiedTightFitHint: "อาจโหลดด้วยบริบทที่สั้นลงหรือทำงานช้าลงบน Mac เครื่องนี้",
+ residentToRun: "สำหรับการรัน",
+ residentToRunHint: "หน่วยความจำ GPU ที่การตรวจสอบการโหลดต้องใช้ระหว่างทำงาน",
onDevice: "ในอุปกรณ์",
huggingFace: "Hugging Face",
retry: "ลองอีกครั้ง",
diff --git a/studio/frontend/src/i18n/locales/tr.ts b/studio/frontend/src/i18n/locales/tr.ts
index 9e64cb45f6f..a29e2473bb5 100644
--- a/studio/frontend/src/i18n/locales/tr.ts
+++ b/studio/frontend/src/i18n/locales/tr.ts
@@ -887,6 +887,9 @@ export const tr = {
unifiedTightFit: "Sınırda",
unifiedTightFitHint:
"Bu Mac'te daha kısa bir bağlamla yüklenebilir veya daha yavaş çalışabilir.",
+ residentToRun: "çalıştırmak için",
+ residentToRunHint:
+ "Yükleme denetiminin çalışırken gerektirdiği GPU belleği",
onDevice: "Cihazda",
huggingFace: "Hugging Face",
retry: "Yeniden dene",
diff --git a/studio/frontend/src/i18n/locales/uk.ts b/studio/frontend/src/i18n/locales/uk.ts
index c34faae63d0..9c3bae087d1 100644
--- a/studio/frontend/src/i18n/locales/uk.ts
+++ b/studio/frontend/src/i18n/locales/uk.ts
@@ -898,6 +898,9 @@ export const uk = {
unifiedTightFit: "Впритул",
unifiedTightFitHint:
"Може завантажитися з коротшим контекстом або працювати повільніше на цьому Mac.",
+ residentToRun: "для запуску",
+ residentToRunHint:
+ "Пам'ять GPU, яку перевірка завантаження вимагає під час роботи",
onDevice: "На пристрої",
huggingFace: "Hugging Face",
retry: "Повторити",
diff --git a/studio/frontend/src/i18n/locales/vi.ts b/studio/frontend/src/i18n/locales/vi.ts
index f0a8981f298..15ed8ea8af9 100644
--- a/studio/frontend/src/i18n/locales/vi.ts
+++ b/studio/frontend/src/i18n/locales/vi.ts
@@ -893,6 +893,8 @@ export const vi = {
unifiedTightFit: "Sát giới hạn",
unifiedTightFitHint:
"Có thể được nạp với ngữ cảnh ngắn hơn hoặc chạy chậm hơn trên máy Mac này.",
+ residentToRun: "để chạy",
+ residentToRunHint: "Bộ nhớ GPU mà bước kiểm tra tải yêu cầu khi chạy",
onDevice: "Trên thiết bị",
huggingFace: "Hugging Face",
retry: "Thử lại",
diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.ts
index bb1807dac18..39c140e94b5 100644
--- a/studio/frontend/src/i18n/locales/zh-CN.ts
+++ b/studio/frontend/src/i18n/locales/zh-CN.ts
@@ -792,6 +792,8 @@ export const zhCN = {
picker: {
unifiedTightFit: "勉强可用",
unifiedTightFitHint: "在这台 Mac 上可能以更短的上下文加载,或运行更慢。",
+ residentToRun: "运行所需",
+ residentToRunHint: "加载检查要求的运行时 GPU 显存",
onDevice: "本机",
huggingFace: "Hugging Face",
retry: "重试",
diff --git a/studio/frontend/src/i18n/locales/zh-TW.ts b/studio/frontend/src/i18n/locales/zh-TW.ts
index 82891e3e9ae..8a2551ddbcf 100644
--- a/studio/frontend/src/i18n/locales/zh-TW.ts
+++ b/studio/frontend/src/i18n/locales/zh-TW.ts
@@ -841,6 +841,8 @@ export const zhTW = {
unifiedTightFit: "勉強可容納",
unifiedTightFitHint:
"在這台 Mac 上可能會以較短的上下文載入,或執行速度較慢。",
+ residentToRun: "執行所需",
+ residentToRunHint: "載入檢查要求的執行時 GPU 記憶體",
onDevice: "裝置上",
huggingFace: "Hugging Face",
retry: "重試",
diff --git a/studio/frontend/src/lib/gguf-fit.ts b/studio/frontend/src/lib/gguf-fit.ts
index dcdc6df5bfd..398bdd5b626 100644
--- a/studio/frontend/src/lib/gguf-fit.ts
+++ b/studio/frontend/src/lib/gguf-fit.ts
@@ -21,6 +21,8 @@ export interface GgufFitInput {
gpuCount?: number;
/** Apple MLX loader budget (`GpuInfo.unifiedLoadBudgetGb`): past it, `fits` becomes `marginal`. */
unifiedLoadBudgetGb?: number | null;
+ /** `audioCppCardGb`, what audio.cpp estimates are judged on; absent means gpuGb is one card. */
+ audioCppCardGb?: number;
}
/** Shared with the memory bar; the loader's `_CTX_FIT_VRAM_FRACTION`. 0.90 was tried and
@@ -105,6 +107,50 @@ export interface GgufVariantSizes {
download_size_bytes?: number;
/** Lookup tables inside `size_bytes` llama.cpp reads lazily from disk; 0 on older backends. */
lookup_table_bytes?: number;
+ /** audio.cpp only: the GiB its load check requires. It loads whole on one GPU, never offloaded. */
+ estimated_resident_gb?: number | null;
+}
+
+/** The card an audio.cpp load lands on: the largest GPU torch sees, the placement check's inventory
+ * (llama.cpp's can add Vulkan-only cards). 0 for a CPU RAM load, left to the llama.cpp rule. */
+export function audioCppCardGb(
+ gpu: { available: boolean; maxDeviceMemoryGb: number },
+ cpuLoad = false,
+): number {
+ return gpu.available && !cpuLoad ? gpu.maxDeviceMemoryGb : 0;
+}
+
+export function audioCppResidentFit(
+ residentGb: number | null | undefined,
+ gpuGb: number,
+): GgufFitClass | null {
+ if (residentGb == null || !(residentGb > 0) || !(gpuGb > 0)) return null;
+ return residentGb <= gpuGb ? "fits" : "oom";
+}
+
+/** An audio.cpp model row fits a card when any variant does, so its smallest variant decides. */
+export function audioCppRowFit(
+ row: {
+ estimatedResidentGb?: number | null;
+ smallestResidentGb?: number | null;
+ },
+ gpuGb: number,
+): GgufFitClass | null {
+ return audioCppResidentFit(
+ row.smallestResidentGb ?? row.estimatedResidentGb,
+ gpuGb,
+ );
+}
+
+export function classifyVariantFitOnCard(
+ fitOf: (sizeBytes: number) => GgufFitClass,
+ variant: GgufVariantSizes,
+ gpuGb: number,
+): GgufFitClass {
+ return (
+ audioCppResidentFit(variant.estimated_resident_gb, gpuGb) ??
+ classifyGgufFitWithLookupTables(fitOf, variant)
+ );
}
/** The larger of `size_bytes` and `download_size_bytes` (companions like mmproj or a drafter).
@@ -135,8 +181,9 @@ export function classifyGgufVariantFit(
variant: GgufVariantSizes,
input: GgufFitInput,
): GgufFitClass {
- return classifyGgufFitWithLookupTables(
+ return classifyVariantFitOnCard(
(sizeBytes) => classifyGgufFit(sizeBytes, input),
variant,
+ input.audioCppCardGb ?? input.gpuGb ?? 0,
);
}
diff --git a/studio/frontend/tests/audio-cpp-resident-fit.test.ts b/studio/frontend/tests/audio-cpp-resident-fit.test.ts
new file mode 100644
index 00000000000..ba2dc656efd
--- /dev/null
+++ b/studio/frontend/tests/audio-cpp-resident-fit.test.ts
@@ -0,0 +1,220 @@
+// 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 {
+ pickDefaultQuant,
+ recommendedQuantForDevice,
+} from "../src/features/model-picker/components/model-selector/model-catalog.ts";
+import {
+ hfModelFitsDevice,
+ loadScopedGpu,
+} from "../src/features/model-picker/components/model-selector/recommended-fit.ts";
+import { parseMetaTokens } from "../src/features/model-picker/components/model-selector/row-meta.ts";
+import {
+ audioCppCardGb,
+ audioCppRowFit,
+ classifyGgufFit,
+ classifyGgufVariantFit,
+ classifyVariantFitOnCard,
+} from "../src/lib/gguf-fit.ts";
+import { readSrc } from "./helpers/kit.ts";
+
+test("a row shows the load estimate beside the file size, not in its place", () => {
+ const parsed = parseMetaTokens("GGUF · 7.7GB · 20.5 GB to run");
+ assert.equal(parsed.size, "7.7GB");
+ assert.equal(parsed.resident, "20.5 GB");
+ assert.deepEqual(parsed.texts, []);
+});
+
+const GB = 1024 ** 3;
+const yue2 = [
+ {
+ quant: "Q4_0",
+ filename: "yue2-3b-q4_0.gguf",
+ size_bytes: 2933424181,
+ estimated_resident_gb: 7.73,
+ },
+ {
+ quant: "Q8_0",
+ filename: "yue2-3b-q8_0.gguf",
+ size_bytes: 4531978293,
+ estimated_resident_gb: 9.51,
+ },
+ {
+ quant: "BF16",
+ filename: "yue2-3b-bf16.gguf",
+ size_bytes: 7529267253,
+ estimated_resident_gb: 12.86,
+ },
+];
+const aceQ8 = { size_bytes: 6185468096, estimated_resident_gb: 12.17 };
+const card10 = { gpuGb: 10, systemRamGb: 32 };
+
+test("an audio.cpp variant is judged on the load check's estimate, not its file size", () => {
+ assert.notEqual(classifyGgufFit(aceQ8.size_bytes, card10), "oom");
+ assert.equal(classifyGgufVariantFit(aceQ8, card10), "oom");
+ assert.equal(classifyGgufVariantFit(yue2[1], card10), "fits");
+ assert.equal(classifyGgufVariantFit(yue2[2], card10), "oom");
+});
+
+test("without an estimate, or without a known GPU, the llama.cpp rule still decides", () => {
+ const plain = { size_bytes: 4 * GB };
+ const rule = (bytes: number) => classifyGgufFit(bytes, card10);
+ assert.equal(
+ classifyVariantFitOnCard(rule, plain, 10),
+ classifyGgufFit(4 * GB, card10),
+ );
+ assert.equal(
+ classifyVariantFitOnCard(rule, aceQ8, 0),
+ classifyGgufFit(aceQ8.size_bytes, card10),
+ );
+});
+
+test("the fits-on-device filter keeps a row when any of its quants fits the card", () => {
+ const row = {
+ id: "audio-cpp/YuE2-GGUF",
+ isGguf: true,
+ estimatedSizeBytes: yue2[1].size_bytes,
+ estimatedResidentGb: yue2[1].estimated_resident_gb,
+ smallestResidentGb: yue2[0].estimated_resident_gb,
+ };
+ const card = (gpuGb: number) => ({
+ memoryTotalGb: gpuGb,
+ systemRamAvailableGb: 32,
+ });
+ const rule = (gpuGb: number) => (bytes: number) =>
+ classifyGgufFit(bytes, { gpuGb, systemRamGb: 32 });
+ for (const [gpuGb, listed, quant] of [
+ // Nothing fits: RAM must not lift the row onto a card every quant reads as oom.
+ [6, false, undefined],
+ [8, true, "Q4_0"],
+ [10, true, "Q8_0"],
+ ] as const) {
+ assert.equal(hfModelFitsDevice(row, card(gpuGb)), listed, `${gpuGb} GiB`);
+ assert.equal(
+ audioCppRowFit(row, gpuGb),
+ listed ? "fits" : "oom",
+ `${gpuGb} GiB badge`,
+ );
+ const fitting = yue2.filter(
+ (v) => classifyGgufVariantFit(v, { gpuGb, systemRamGb: 32 }) === "fits",
+ );
+ assert.equal(fitting.length > 0, listed, `${gpuGb} GiB quants`);
+ if (quant)
+ assert.equal(
+ recommendedQuantForDevice(yue2, rule(gpuGb), null, gpuGb)?.quant,
+ quant,
+ );
+ }
+ const { smallestResidentGb: _, ...defaultOnly } = row;
+ assert.equal(hfModelFitsDevice(defaultOnly, card(8)), false);
+ const { estimatedResidentGb: __, ...plain } = defaultOnly;
+ assert.equal(hfModelFitsDevice(plain, card(6)), true);
+});
+
+test("the recommended and default quant follow the estimate on a 10 GiB card", () => {
+ const rule = (bytes: number) => classifyGgufFit(bytes, card10);
+ assert.equal(
+ recommendedQuantForDevice(yue2, rule, yue2[2], 10)?.quant,
+ "Q8_0",
+ );
+ assert.equal(recommendedQuantForDevice(yue2, rule, null, 8)?.quant, "Q4_0");
+ assert.equal(pickDefaultQuant(yue2, "BF16", card10)?.quant, "Q8_0");
+});
+
+test("an audio.cpp row is judged on the largest card, where automatic placement loads it", () => {
+ // 10 GiB GPU0 beside 24 GiB GPU1: scoping narrows to GPU0, but the load puts ACE-Step on GPU1.
+ const host = {
+ available: true,
+ memoryTotalGb: 34,
+ maxDeviceMemoryGb: 24,
+ loadDeviceMemoryGb: 10,
+ systemRamAvailableGb: 32,
+ deviceCount: 2,
+ };
+ const aceStep = {
+ id: "audio-cpp/ACE-Step-1.5-GGUF",
+ isGguf: true,
+ estimatedResidentGb: 16.36,
+ smallestResidentGb: aceQ8.estimated_resident_gb,
+ };
+ const scoped = loadScopedGpu(host, true);
+ assert.equal(scoped.memoryTotalGb, 10);
+ const card = audioCppCardGb(host);
+ assert.equal(card, 24);
+ assert.equal(
+ hfModelFitsDevice(aceStep, scoped, { audioCppCardGb: card }),
+ true,
+ );
+ // Two 8 GiB cards: the Hub passes their 16 GiB sum, but no one card holds YuE2 BF16 (12.86 GiB).
+ const twoCards = {
+ gpuGb: 16,
+ gpuCount: 2,
+ audioCppCardGb: 8,
+ systemRamGb: 32,
+ };
+ assert.equal(classifyGgufVariantFit(yue2[2], twoCards), "oom");
+ assert.equal(classifyGgufVariantFit(yue2[0], twoCards), "fits");
+});
+
+test("a CPU RAM load leaves audio.cpp quants to the RAM-aware rule", () => {
+ const host = { available: true, maxDeviceMemoryGb: 6 };
+ const card = audioCppCardGb(host, true);
+ assert.equal(card, 0);
+ const budget = { gpuGb: 6, systemRamGb: 64 };
+ const rule = (bytes: number) => classifyGgufFit(bytes, budget);
+ for (const variant of yue2) {
+ assert.equal(
+ classifyVariantFitOnCard(rule, variant, audioCppCardGb(host)),
+ "oom",
+ );
+ assert.equal(
+ classifyVariantFitOnCard(rule, variant, card),
+ classifyGgufFit(variant.size_bytes, budget),
+ );
+ }
+ const plain = yue2.map(({ estimated_resident_gb: _, ...rest }) => rest);
+ assert.equal(
+ recommendedQuantForDevice(yue2, rule, null, card)?.quant,
+ recommendedQuantForDevice(plain, rule, null)?.quant,
+ );
+ assert.equal(
+ classifyGgufVariantFit(yue2[2], { ...budget, audioCppCardGb: card }),
+ classifyGgufFit(yue2[2].size_bytes, budget),
+ );
+ const row = {
+ id: "audio-cpp/Yue2-3B-GGUF",
+ isGguf: true,
+ estimatedSizeBytes: yue2[1].size_bytes,
+ estimatedResidentGb: yue2[1].estimated_resident_gb,
+ smallestResidentGb: yue2[0].estimated_resident_gb,
+ };
+ const gpu = { memoryTotalGb: 6, systemRamAvailableGb: 64 };
+ assert.equal(hfModelFitsDevice(row, gpu, { audioCppCardGb: 6 }), false);
+ assert.equal(hfModelFitsDevice(row, gpu, { audioCppCardGb: card }), true);
+});
+
+test("the picker judges audio.cpp variants on the card its load lands on", () => {
+ // The quant expander and row badges render only under React, so their wiring is read from source.
+ const pickers = readSrc(
+ "features/model-picker/components/model-selector/pickers.tsx",
+ );
+ assert.match(pickers, /const audioCardGb = audioCppCardGb\(gpu, cpuLoad\);/);
+ assert.match(
+ readSrc("features/hub/hub-page.tsx"),
+ /audioCppCardGb\(gpu, audioDevice === "cpu"\)/,
+ );
+ assert.match(pickers, /const audioCardGb = useContext\(AudioCppCard\);/);
+ assert.match(
+ pickers,
+ /const residentGb = audioCardGb > 0 \? v\.estimated_resident_gb : null;/,
+ );
+ assert.doesNotMatch(pickers, /audioCppRowFit\([^)]*memoryTotalGb\)/);
+ assert.match(
+ readSrc("features/audio/audio-page.tsx"),
+ /cpuLoad=\{audioDevice === "cpu"\}/,
+ );
+});
diff --git a/studio/frontend/tests/hub-row-selection.test.ts b/studio/frontend/tests/hub-row-selection.test.ts
index 78bb8795764..dbbf09105df 100644
--- a/studio/frontend/tests/hub-row-selection.test.ts
+++ b/studio/frontend/tests/hub-row-selection.test.ts
@@ -49,7 +49,7 @@ test("the picker reads one fit per variant, companions included", () => {
assert.notEqual(at, -1, "getVariantFit is missing");
assert.match(
PICKERS.slice(at, at + 400),
- /ggufVariantFitSizeBytes\(variant\)|classifyGgufFitWithLookupTables\(getGgufFit, variant\)/,
+ /ggufVariantFitSizeBytes\(variant\)|classifyGgufFitWithLookupTables\(getGgufFit, variant\)|classifyVariantFitOnCard\(getGgufFit, variant, cardGb\)/,
);
assert.equal(PICKERS.match(/getVariantFit\(v\)/g)?.length, 2);
});