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: state the audio memory estimate in placement refusals (#16628)

Debojyoti Banerjee781b72f0e29c
diff --git a/studio/backend/core/inference/audio_cpp_failures.py b/studio/backend/core/inference/audio_cpp_failures.py
index 9c4a7f39b05..a7395444a75 100644
--- a/studio/backend/core/inference/audio_cpp_failures.py
+++ b/studio/backend/core/inference/audio_cpp_failures.py
@@ -74,7 +74,7 @@ _MESSAGES = {
"device to CPU.",
"capacity_cpu": "This input does not fit in memory. Try a shorter input.",
# Unsloth Studio's own refusal before launch.
- "placement": "No single GPU has enough free memory for {name}. Free GPU memory, choose a "
+ "placement": "No single GPU has enough free memory for {name}.{need} Free GPU memory, choose a "
"smaller variant, or set the audio device to CPU.",
}
@@ -139,6 +139,8 @@ _GENERIC_PROFILE = (2.5, 1.5)
# family -> (per_weight, fixed, largest package measured): audio.cpp v0.9.3 CUDA 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),
"chatterbox": (1.0, 3.5, 3.5),
"higgs_audio_tts": (1.0, 2.0, 4.8),
"kokoro_tts": (1.0, 3.5, 0.2),
@@ -167,7 +169,8 @@ def smaller_variants(
free_gb: Optional[float] = None,
limit: int = 3,
) -> list[dict]:
- """Variants smaller than the loaded one, largest first; only those that fit ``free_gb``."""
+ """Variants with a lower estimate than the loaded one, largest first; only those that fit
+ ``free_gb``. Byte size alone is not enough: ACE-Step base is a few bytes under turbo."""
if model is None:
return []
from core.inference.audio_cpp_models import quant_label, resolve
@@ -179,11 +182,15 @@ def smaller_variants(
except Exception: # noqa: BLE001 - an unknown companion counts as nothing
found = None
extra += found.size_bytes if found is not None else 0
+ family = getattr(model, "family", None)
+ current = estimate_resident_gb(model.size_bytes + extra, family)
rows = []
for variant in sorted(model.variants, key = lambda v: v.size_bytes, reverse = True):
- estimate = estimate_resident_gb(variant.size_bytes + extra, getattr(model, "family", None))
- if not 0 < variant.size_bytes < model.size_bytes or (
- free_gb is not None and estimate > free_gb
+ estimate = estimate_resident_gb(variant.size_bytes + extra, family)
+ if (
+ not 0 < variant.size_bytes < model.size_bytes
+ or estimate >= current
+ or (free_gb is not None and estimate > free_gb)
):
continue
label = variant.label or quant_label(variant.main_file)
@@ -221,6 +228,7 @@ def classify_audio_cpp_failure(
model = None,
runtime_status: Optional[int] = None,
free_gb: Optional[float] = None,
+ required_gb: Optional[float] = None,
) -> Optional[AudioCppFailure]:
"""The known failure in ``text`` (a runtime log tail or error), or None."""
raw = str(text or "")
@@ -239,7 +247,17 @@ def classify_audio_cpp_failure(
on_cpu = code == "out_of_memory" and backend == "cpu"
key = "placement" if placement else "capacity" if capacity else code
key = f"{key}_cpu" if on_cpu and key in ("out_of_memory", "capacity") else key
- message = _MESSAGES[key].format(name = getattr(model, "display_name", None) or "This model")
+ need = ""
+ if placement and required_gb is not None:
+ need = f" It needs about {required_gb:.1f} GB of GPU memory while running"
+ need += (
+ f", and the most free on one GPU is {free_gb:.1f} GB."
+ if free_gb is not None
+ else "."
+ )
+ message = _MESSAGES[key].format(
+ name = getattr(model, "display_name", None) or "This model", need = need
+ )
# "device": the run was already on the CPU, so "set the audio device to CPU" can't help.
extras: dict = {"device": "cpu"} if on_cpu else {}
if code == "out_of_memory" and not capacity:
diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py
index ab87d7db58e..8fb831ef64c 100644
--- a/studio/backend/routes/inference.py
+++ b/studio/backend/routes/inference.py
@@ -16322,7 +16322,10 @@ async def _preflight_native_audio_placement(
free_by_gpu = availability.effective_free_gb if availability is not None else {}
free = [gb for index, gb in free_by_gpu.items() if index in candidates]
failure = classify_audio_cpp_failure(
- str(refusal), model = audio_cpp_model, free_gb = max(free, default = None)
+ str(refusal),
+ model = audio_cpp_model,
+ free_gb = max(free, default = None),
+ required_gb = required_gb,
)
attach_failure(refusal, failure)
raise refusal
diff --git a/studio/backend/tests/test_audio_cpp_failure_routes.py b/studio/backend/tests/test_audio_cpp_failure_routes.py
index 1c2ed9abaa1..0f7535ca420 100644
--- a/studio/backend/tests/test_audio_cpp_failure_routes.py
+++ b/studio/backend/tests/test_audio_cpp_failure_routes.py
@@ -140,7 +140,10 @@ def test_placement_refusal_lists_variants_that_fit(monkeypatch):
assert ri.audio_cpp_resident_gb is af.estimate_resident_gb
assert raised.value.status_code == 400 and detail["code"] == "out_of_memory"
assert [row["label"] for row in detail["smaller_variants"]] == ["Q2", "Q1"]
- assert detail["message"].startswith("No single GPU has enough free memory for Model M.")
+ assert detail["message"].startswith(
+ "No single GPU has enough free memory for Model M. It needs about 21.5 GB of GPU memory "
+ "while running, and the most free on one GPU is 7.0 GB."
+ )
@pytest.mark.parametrize(
@@ -155,6 +158,9 @@ def test_placement_refusal_lists_variants_that_fit(monkeypatch):
("voxcpm2", 2.75, 9.5, False),
("qwen3_tts", 2.75, 9.5, True),
("kokoro_tts", 0.18, 3.0, False),
+ # ACE-Step1.5 Q8_0 on a 16 GB card: measured 11.2 GB, the generic formula said 15.9.
+ ("ace_step", 5.76, 15.0, True),
+ ("ace_step", 5.76, 9.2, False),
],
)
def test_placement_uses_the_family_estimate(monkeypatch, family, size_gb, free_gb, fits):
diff --git a/studio/backend/tests/test_audio_cpp_failures.py b/studio/backend/tests/test_audio_cpp_failures.py
index fffaf52fc6f..5aaa2e1b0fa 100644
--- a/studio/backend/tests/test_audio_cpp_failures.py
+++ b/studio/backend/tests/test_audio_cpp_failures.py
@@ -138,6 +138,9 @@ 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
def test_past_the_measured_sizes_the_estimate_never_drops_below_either_profile():
@@ -156,6 +159,50 @@ def test_smaller_variants_estimate_with_the_family(monkeypatch):
assert [row["label"] for row in af.smaller_variants(model, free_gb = 7.3)] == ["Q3", "Q1"]
+def test_a_sibling_package_a_few_bytes_smaller_is_not_offered(monkeypatch):
+ monkeypatch.setattr(af, "offload_options", lambda model: [])
+ # ACE-Step1.5-GGUF on the Hub: base/Q8_0 is 1,152 bytes under turbo/Q8_0 and needs as much.
+ sizes = {
+ "turbo/BF16": 10090406336,
+ "turbo/Q8_0": 6185468096,
+ "base/Q8_0": 6185466944,
+ "base/BF16": 10090405184,
+ }
+ variants = tuple(
+ AudioCppVariant(key, (RepoFile(f"{key}.gguf", size),), f"{key}.gguf", label = key)
+ for key, size in sizes.items()
+ )
+ model = replace(
+ _model(),
+ family = "ace_step",
+ variant = variants[1],
+ variants = variants,
+ default_variant = variants[1].key,
+ )
+ assert af.smaller_variants(model) == []
+ refusal = af.classify_audio_cpp_failure(
+ "No single GPU has enough free memory for this native audio model.", model = model
+ )
+ assert "Smaller variants" not in refusal.message and "smaller_variants" not in refusal.extras
+
+
+def test_placement_refusal_states_the_estimate_and_the_free_memory(monkeypatch):
+ monkeypatch.setattr(af, "offload_options", lambda model: [])
+ text = "No single GPU has enough free memory for this native audio model."
+ model = _model(sizes = (4, 1), current = 0)
+ required = af.estimate_resident_gb(4 * 1024**3)
+ refusal = af.classify_audio_cpp_failure(text, model = model, free_gb = 9.3, required_gb = required)
+ assert refusal.message.startswith(
+ "No single GPU has enough free memory for Model M. It needs about 11.5 GB of GPU memory "
+ "while running, and the most free on one GPU is 9.3 GB. Free GPU memory,"
+ )
+ assert refusal.message.endswith("Smaller variants: Q1 (~4.0 GB).")
+ unknown = af.classify_audio_cpp_failure(text, model = model, required_gb = required)
+ 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")
+
+
def test_oom_lists_smaller_variants_and_offload_options(monkeypatch):
from core.inference import audio_cpp_models as models