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.

2.8 KB
Raw Blame
# SPDX-License-Identifier: AGPL-3.0-only
# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0

"""Speech-architecture verdict, single definition; a leaf, so importing it does not pull in PyYAML."""

from __future__ import annotations

from typing import Optional

# Architectures no Unsloth runtime can decode; all Hub spellings of CSM are listed.
SPEECH_GGUF_ARCHS = frozenset({"llama-csm", "csm", "csm-tts", "mimi"})

# Foreign ASR GGUFs (e.g. mudler/parakeet.cpp). Not audiocpp, not llama.cpp; Studio cannot run them (#16273).
FOREIGN_ASR_GGUF_ARCHS = frozenset({"parakeet"})

# The Mimi vocoder GGUF puts a sentence in general.architecture; match the flag.
_VOCODER_MARKERS = ("--model-vocoder", "cannot be used as llm")


def is_speech_gguf_architecture(architecture: Optional[str]) -> bool:
    """None and empty are not speech, but unknown: every caller fails open on an unknown architecture."""
    if not architecture:
        return False
    normalized = architecture.strip().lower()
    if normalized in SPEECH_GGUF_ARCHS:
        return True
    return any(marker in normalized for marker in _VOCODER_MARKERS)


def is_foreign_asr_gguf_architecture(architecture: Optional[str]) -> bool:
    """Whether ``general.architecture`` names an ASR GGUF no Unsloth runtime can load (e.g. parakeet.cpp)."""
    return bool(architecture) and architecture.strip().lower() in FOREIGN_ASR_GGUF_ARCHS


DIFFUSION_IMAGE_GGUF_ARCHS = frozenset(
    {
        "flux",
        "flux2",
        "qwen_image",
        "qwenimage",
        "qwen_image21",
        "qwenimage21",
        "z_image",
        "zimage",
        "krea2",
        "moss_image",
    }
)
# Archs that alone name the family. Not "flux" / "qwen_image": several DiTs ship under those (#14474).
FAMILY_NAMING_DIFFUSION_GGUF_ARCHS = frozenset({"krea2", "moss_image"})
# Recognised, but no Studio page can run them.
UNSUPPORTED_DIFFUSION_GGUF_ARCHS = frozenset(
    {"sd1", "sd3", "sdxl", "aura", "hidream", "cosmos", "hyvid"}
)
# Shared by several families, so the header alone does not decide if Images can run it.
AMBIGUOUS_DIFFUSION_GGUF_ARCHS = frozenset({"lumina2"})
# Not architectures: placeholders gguf-connector writes for its diffusion GGUFs.
PLACEHOLDER_DIFFUSION_GGUF_ARCHS = frozenset({"pig", "cow"})
VIDEO_GGUF_ARCHS = frozenset({"ltxv", "wan"})


# ``general.architecture`` of every GGUF audio.cpp writes. Only audiocpp_server reads these (speech,
# music, transcription); llama.cpp has no such architecture.
AUDIO_CPP_GGUF_ARCHITECTURE = "audiocpp"


def is_audio_cpp_gguf_architecture(architecture: Optional[str]) -> bool:
    """Whether ``general.architecture`` names a GGUF only audio.cpp runs. Case- and space-insensitive."""
    return bool(architecture) and architecture.strip().lower() == AUDIO_CPP_GGUF_ARCHITECTURE