unslothai/unsloth · error · RuntimeError

Unknown audio_type: {audio_type}

Error message

Unknown audio_type: {audio_type}

What it means

generate_audio dispatches on the active model's audio_type ('snac' and siblings); an audio_type that is set but matches no known codec branch falls through to RuntimeError('Unknown audio_type: {audio_type}'). This guards against registry entries claiming audio support with a codec this build cannot generate for.

Source

Thrown at studio/backend/core/inference/inference.py:2135

                    stopping_criteria = stopping_criteria,
                    cancel_event = cancel_event,
                )
            elif audio_type == "dac":
                result = self._generate_dac(
                    model,
                    tokenizer,
                    text,
                    temperature,
                    top_k,
                    top_p,
                    min_p,
                    max_new_tokens,
                    repetition_penalty,
                    stopping_criteria = stopping_criteria,
                    cancel_event = cancel_event,
                )
            else:
                raise RuntimeError(f"Unknown audio_type: {audio_type}")
            if cancel_event is not None and cancel_event.is_set():
                raise RuntimeError("Audio generation cancelled")
            return result

    def _generate_snac(
        self,
        model,
        tokenizer,
        text,
        temperature,
        top_p,
        max_new_tokens,
        repetition_penalty,
        *,
        stopping_criteria = None,
        cancel_event = None,
    ):
        """Generate audio using SNAC codec (Orpheus)."""

View on GitHub (pinned to 203007d190)

Solutions

  1. Check the model's config for the audio_type value and correct it to a supported codec
  2. Update the backend to a build that supports the codec (e.g. via _generate_snac siblings)
  3. Reload the model so its registry entry is rebuilt from its true config
Defensive patterns

Strategy: validation

Validate before calling

KNOWN = {"snac"}  # plus the other codecs this build implements
audio_type = engine.models[engine.active_model_name].get("audio_type")
if audio_type not in KNOWN:
    raise HTTPException(409, f"Unsupported audio_type '{audio_type}' — update backend or fix model config")

Type guard

def supported_audio_type(engine) -> bool:
    return engine.models.get(engine.active_model_name, {}).get("audio_type") in KNOWN_CODECS

Try / catch

try:
    engine.generate_audio(text)
except RuntimeError as e:
    if str(e).startswith("Unknown audio_type:"):
        return JSONResponse(status_code=409, content={"detail": str(e)})
    raise

Prevention

When it happens

Trigger: The active model's registry entry has audio_type set to a value outside the supported set (e.g. a new/experimental codec string or a corrupted config), reaching the else branch after the snac branch.

Common situations: Model config from a newer backend version naming a codec this build doesn't implement; custom/locally-edited model configs; registry pollution from a failed load writing partial entries.

Related errors


AI-assisted analysis of unslothai/unsloth@203007d190 (2026-08-15). Data as JSON: /api/errors/f65b13782cce8522. Report an issue: GitHub.