fishaudio/fish-speech · critical · ValueError

Unknown model type: {config.model_type}

Error message

Unknown model type: {config.model_type}

What it means

After parsing config, from_pretrained maps model_type to a Transformer class (NaiveTransformer or DualARTransformer) and raises if the type is unknown. This catches configs whose model_type parsed in step 1 but has no concrete model class (e.g. fish_qwen3_omni on a build lacking that model).

Source

Thrown at fish_speech/models/text2semantic/llama.py:518

        try:
            tokenizer = FishTokenizer.from_pretrained(path)
            config.semantic_begin_id = tokenizer.semantic_begin_id
            config.semantic_end_id = tokenizer.semantic_end_id
            logger.info(
                f"Injected Semantic IDs into Config: {config.semantic_begin_id}-{config.semantic_end_id}"
            )
        except Exception as e:
            logger.warning(
                f"Failed to load tokenizer for config injection: {e}. Semantic IDs might be 0."
            )

        match config.model_type:
            case "naive":
                model_cls = NaiveTransformer
            case "dual_ar":
                model_cls = DualARTransformer
            case _:
                raise ValueError(f"Unknown model type: {config.model_type}")

        logger.info(f"Loading model from {path}, config: {config}")
        # Initialize model without passing tokenizer explicitly to __init__
        model = model_cls(config)
        # Attach tokenizer to model instance for inference convenience (optional, but good for user scripts)
        model.tokenizer = tokenizer

        if load_weights is False:
            logger.info("Randomly initialized model")
        else:
            if "int8" in str(Path(path)):
                logger.info("Using int8 weight-only quantization!")
                from tools.llama.quantize import WeightOnlyInt8QuantHandler

                simple_quantizer = WeightOnlyInt8QuantHandler(model)
                model = simple_quantizer.convert_for_runtime()

            if "int4" in str(Path(path)):

View on GitHub (pinned to befe400174)

Solutions

  1. Upgrade fish-speech/checkout to the version matching the checkpoint
  2. Verify model_type in the model config matches a class registered in llama.py
  3. Re-download the model from an official release compatible with your version
Defensive patterns

Strategy: try-catch

Validate before calling

assert config.model_type in {"naive", "dual_ar"}, "model class unavailable for this model_type"

Try / catch

try:
    BaseTransformer.from_pretrained(path)
except ValueError as e:
    if "Unknown model type" in str(e):
        # checkpoint architecture not in this build
        ...

Prevention

When it happens

Trigger: Calling BaseTransformer.from_pretrained on a checkpoint whose model_type is not 'naive' or 'dual_ar' in this build of the codebase.

Common situations: Loading new-architecture checkpoints with an older checkout; partially upgraded installs where config parsing and model classes are out of sync.

Related errors


AI-assisted analysis of fishaudio/fish-speech@befe400174 (2026-08-27). Data as JSON: /api/errors/cb3dde4d6e6d39bc. Report an issue: GitHub.