Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: let YuE2 finish a song instead of cutting it at the asked length (#13346)
Daniel Han85ac36d3c182
diff --git a/studio/backend/core/inference/audio_cpp_models.py b/studio/backend/core/inference/audio_cpp_models.pyindex 7aff439edb7..b985e2dcb9b 100644--- a/studio/backend/core/inference/audio_cpp_models.py+++ b/studio/backend/core/inference/audio_cpp_models.py@@ -194,6 +194,8 @@ class MusicSpec:# The runtime's default seed is fixed, so repeat runs would be identical.fixed_seed: bool = Truertf: float = 4.0+ # Token budget as a multiple of the asked length, for a model that ends the song itself.+ overrun: float = 1.0def mode(self, mode_id: Optional[str]) -> Optional[MusicMode]:return next((m for m in self.modes if m.id == mode_id), None)@@ -263,6 +265,8 @@ MUSIC_SPECS: dict[str, MusicSpec] = {# Empty lyrics still sing; only this tag stays wordless.instrumental_lyrics = "[Instrumental]",rtf = 6.0,+ # 1.0x cut long lyrics mid-song (#13337); 240 s x 1.5 = the runtime's 9000-token default.+ overrun = 1.5,),}diff --git a/studio/backend/core/inference/audio_cpp_music.py b/studio/backend/core/inference/audio_cpp_music.pyindex 2e19537e6d7..1c851627df9 100644--- a/studio/backend/core/inference/audio_cpp_music.py+++ b/studio/backend/core/inference/audio_cpp_music.py@@ -52,7 +52,7 @@ def seconds_text(value: float) -> str:def timeout_seconds(family: Optional[str], seconds: float, variations: int, cpu: bool) -> float:music = MUSIC_SPECS.get(str(family or ""))- rtf = music.rtf if music is not None else 4.0+ rtf = music.rtf * music.overrun if music is not None else 4.0work = rtf * max(0.0, float(seconds)) * max(1, int(variations)) * (_CPU_FACTOR if cpu else 1.0)return max(_TIMEOUT_FLOOR, min(_TIMEOUT_CEILING, _TIMEOUT_FLOOR + work))@@ -192,9 +192,10 @@ def song_request(request["text"] = lyricsrequest_options["style"] = descriptionrequest_options["lyrics"] = lyrics- # Length is the semantic token budget (25 fps); the default 200-frame floor outlasts short asks.+ # Length caps the semantic tokens (25 fps); the default 200-frame floor outlasts short asks.frames = int(round(seconds * 25))- request_options["semantic_max_tokens"] = frames+ overrun = MUSIC_SPECS["yue2"].overrun+ request_options["semantic_max_tokens"] = int(round(seconds * overrun * 25))request_options["semantic_min_tokens"] = min(200, frames)return _finish(model, request, request_options, seed)if instrumental and music is not None and music.instrumental_lyrics is not None:diff --git a/studio/backend/tests/test_audio_cpp_models.py b/studio/backend/tests/test_audio_cpp_models.pyindex 2c03e79ecff..71355f62ed7 100644--- a/studio/backend/tests/test_audio_cpp_models.py+++ b/studio/backend/tests/test_audio_cpp_models.py@@ -1438,7 +1438,7 @@ def test_yue2_takes_the_description_as_its_required_style():assert request["options"] == {"style": "rock, male vocal","lyrics": "[chorus] oh",- "semantic_max_tokens": 2048,+ "semantic_max_tokens": 3072,"semantic_min_tokens": 200,}with pytest.raises(RuntimeError, match = "style"):@@ -2108,11 +2108,13 @@ def test_yue2_length_follows_the_requested_duration():b, srv = _backend_with(_speech_model("yue2"), MUSIC_REPLY)b.generate_audio_response("[chorus] oh", instructions = "rock", max_new_tokens = 125)options = srv.calls[0][1]["request"]["options"]- # 5 s at 25 frames per second, with the 200-frame default lowered to fit.- assert options["semantic_max_tokens"] == 125 and options["semantic_min_tokens"] == 125+ # 5 s at 25 frames per second, with the 200-frame default lowered to fit; the cap is 1.5x.+ assert options["semantic_max_tokens"] == 188 and options["semantic_min_tokens"] == 125b.generate_audio_response("[chorus] oh", instructions = "rock", max_new_tokens = 1500)options = srv.calls[1][1]["request"]["options"]- assert options["semantic_max_tokens"] == 1500 and options["semantic_min_tokens"] == 200+ assert options["semantic_max_tokens"] == 2250 and options["semantic_min_tokens"] == 200+ b.generate_audio_response("[chorus] oh", instructions = "rock", max_new_tokens = 6000)+ assert srv.calls[2][1]["request"]["options"]["semantic_max_tokens"] == 9000def test_music_requests_missing_a_required_field_are_a_400_message():diff --git a/studio/backend/tests/test_audio_cpp_music_requests.py b/studio/backend/tests/test_audio_cpp_music_requests.pyindex 7dfd5e3ab21..ea9fd8a1efb 100644--- a/studio/backend/tests/test_audio_cpp_music_requests.py+++ b/studio/backend/tests/test_audio_cpp_music_requests.py@@ -375,7 +375,7 @@ def test_yue2_instrumental_sends_the_instrumental_tag_not_its_style():assert request["text"] == "[Instrumental]"assert request["options"]["lyrics"] == "[Instrumental]"assert request["options"]["style"] == "ambient piano"- assert request["options"]["semantic_max_tokens"] == 500+ assert request["options"]["semantic_max_tokens"] == 750def test_minimax_gguf_keeps_its_body_through_the_studio():@@ -497,6 +497,7 @@ def test_the_wait_grows_with_the_audio_asked_for_and_is_capped():assert t(10) < t(60) < t(60, 3) < t(60, 3, cpu = True)assert t(0) == 300.0 and t(240, 4, cpu = True) == 4 * 3600.0assert cm.timeout_seconds("stable_audio", 10, 1, False) == 310.0+ assert t(60) == 300.0 + 6.0 * 1.5 * 60b = _backend(_model("yue2"))_run(b, text = "rock", lyrics = "x", duration_s = 60)assert b._server.calls[0][2]["timeout"] == t(60)