sgl-project/sglang · error · ValueError

Unsupported model type: {model_type}

Error message

Unsupported model type: {model_type}

What it means

In the ComfyUI SGLDiffusion generator, get_comfyui_model inspects the raw state dict with ComfyUI's model_detection to determine image_model type, then requires that type to be a key in pipeline_class_dict (the set of pipelines SGLDiffusion supports). Unknown or undetectable model architectures raise ValueError.

Source

Thrown at python/sglang/multimodal_gen/apps/ComfyUI_SGLDiffusion/core/generator.py:146

        if model_options is None:
            model_options = {}
        dtype = model_options.get("dtype", None)
        # Allow loading unets from checkpoint files
        sd = load_torch_file(model_path)
        diffusion_model_prefix = model_detection.unet_prefix_from_state_dict(sd)
        temp_sd = state_dict_prefix_replace(
            sd, {diffusion_model_prefix: ""}, filter_keys=True
        )
        if len(temp_sd) > 0:
            sd = temp_sd

        parameters = calculate_parameters(sd)
        load_device = model_management.get_torch_device()

        model_detect_config = model_detection.detect_unet_config(sd, "")
        model_type = model_detect_config.get("image_model", None)
        if model_type is None or model_type not in self.pipeline_class_dict:
            raise ValueError(f"Unsupported model type: {model_type}")
        model_config = model_detection.model_config_from_unet(sd, "")

        if model_config is not None:
            new_sd = sd
        else:
            new_sd = model_detection.convert_diffusers_mmdit(sd, "")
            if new_sd is not None:  # diffusers mmdit
                model_config = model_detection.model_config_from_unet(new_sd, "")
                if model_config is None:
                    return None
            else:  # diffusers unet
                model_config = model_detection.model_config_from_diffusers_unet(sd)
                if model_config is None:
                    return None

                diffusers_keys = unet_to_diffusers(model_config.unet_config)
                new_sd = {}
                for k in diffusers_keys:

View on GitHub (pinned to 0132848349)

Solutions

  1. Check the supported model types by printing self.pipeline_class_dict and use a checkpoint of a supported architecture
  2. Re-save/convert the checkpoint in standard ComfyUI format so model_detection can identify it
  3. Update sglang/ComfyUI-SGLDiffusion to a version that adds your architecture to pipeline_class_dict

Example fix

# before
sd = safetensors.load_file("new_arch.safetensors")
generator.load_model("new_arch.safetensors")  # raises

# after
# convert to a supported architecture or update pipeline_class_dict
print(generator.pipeline_class_dict)  # pick a supported model type
generator.load_model("supported_flux_dev.safetensors")
Defensive patterns

Strategy: try-catch

Validate before calling

supported = set(generator.pipeline_class_dict.keys())
# detect type the same way before loading
from comfy import model_detection
sd = safetensors.load_file(path)
t = model_detection.detect_unet_config(sd, "").get("image_model")
if t not in supported:
    raise SystemExit(f"{path} is {t}; supported: {supported}")

Try / catch

try:
    generator.load_model(path)
except ValueError as e:
    if "Unsupported model type" in str(e):
        # fall back to a known-good checkpoint or report to user
        raise SystemExit(f"Unsupported: {e}")
    raise

Prevention

When it happens

Trigger: Loading a checkpoint whose detect_unet_config returns an image_model value not present in self.pipeline_class_dict (e.g. an architecture ComfyUI knows but this backend doesn't map), or returns None because the checkpoint format is unrecognized.

Common situations: Dropping a new/exotic diffusion checkpoint (e.g. Flux variants, unconverted Diffusers uploads) into ComfyUI and trying to run it through the SGLang diffusion backend; using a checkpoint saved in a format detect_unet_config can't parse.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/60319f9c7839e7f3. Report an issue: GitHub.