sgl-project/sglang · error · ValueError

Model config does not contain a _class_name attribute. Only

Error message

Model config does not contain a _class_name attribute. Only diffusers format is supported.

What it means

The adapter loader reads the component's config.json and pops '_class_name' to determine which diffusers class to instantiate. If the key is absent (or None), it raises this ValueError because only diffusers-format component configs, which always carry _class_name, are supported.

Source

Thrown at python/sglang/multimodal_gen/runtime/loader/component_loaders/adapter_loader.py:53

        "connectors": LTX2ConnectorConfig,
        "duration_head": LTX2DurationHeadConfig,
    }

    def load_customized(
        self,
        component_model_path: str,
        server_args: ServerArgs,
        component_name: str = "connectors",
        *args,
    ):
        config = self.load_component_config(component_model_path, component_name)
        component_weights_path = self.resolve_component_weights_path(
            component_model_path, server_args, component_name
        )

        cls_name = config.pop("_class_name", None)
        if cls_name is None:
            raise ValueError(
                "Model config does not contain a _class_name attribute. "
                "Only diffusers format is supported."
            )

        config.pop("_diffusers_version", None)
        config.pop("_name_or_path", None)

        server_args.model_paths[component_name] = component_model_path

        model_cls, _ = ModelRegistry.resolve_model_cls(cls_name)

        # Not a fixed name: connectors follow DiT offload, while the duration
        # head stays resident unless selected explicitly.
        target_device = self.target_device(
            server_args.should_start_component_on_cpu(component_name)
        )
        default_dtype = resolve_precision(
            server_args, component_name, precision_attr="dit_precision"

View on GitHub (pinned to 0132848349)

Solutions

  1. Re-export the adapter with diffusers save_pretrained so config.json contains _class_name
  2. Point the component path at the correct diffusers-format adapter directory
  3. If the config is valid but hand-edited, add "_class_name": "<AdapterClass>" to config.json

Example fix

// before: config.json has no _class_name
// after: config.json
{ "_class_name": "MotionAdapter", "...": "..." }
Defensive patterns

Strategy: validation

Validate before calling

import json

cfg = json.load(open(f"{adapter_path}/config.json"))
assert "_class_name" in cfg, "adapter is not in diffusers format (missing _class_name)"

Try / catch

try:
    loader.load_customized(path, server_args, name)
except ValueError as e:
    if "_class_name" in str(e):
        raise SystemExit(f"{path} is not a diffusers-format adapter") from e
    raise

Prevention

When it happens

Trigger: Calling load_customized on an adapter component directory whose config.json has no '_class_name' key — e.g. a plain transformers-style config, a hand-written config, or a config where the key was renamed.

Common situations: Pointing --adapter-path (or the component model path) at a transformers checkpoint instead of a diffusers one; exporting an adapter without diffusers save_pretrained; config file edited/renamed keys.

Related errors


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