sgl-project/sglang · error · ValueError

Subclass {self.__class__.__name__} must define _supported_at

Error message

Subclass {self.__class__.__name__} must define _supported_attention_backends

What it means

At __init__ time BaseDiT checks that the concrete subclass has populated supported_attention_backends (backed by the _supported_attention_backends class attribute). If the property returns an empty/falsy value, the model has no valid attention backend and the runtime refuses to construct it.

Source

Thrown at python/sglang/multimodal_gen/runtime/models/dits/base.py:77

            "param_names_mapping",
            "_compile_conditions",
        ]
        super().__init_subclass__()
        for attr in required_class_attrs:
            if not hasattr(cls, attr):
                raise AttributeError(
                    f"Subclasses of BaseDiT must define '{attr}' class variable"
                )

    def __init__(self, config: DiTConfig, hf_config: dict[str, Any], **kwargs) -> None:
        super().__init__()
        # `config.arch_config` contains static model metadata. Runtime
        # capabilities remain class attributes on the model implementation.
        self.config: DiTArchConfig = config.arch_config
        self.prefix = config.prefix
        self.hf_config = hf_config
        if not self.supported_attention_backends:
            raise ValueError(
                f"Subclass {self.__class__.__name__} must define _supported_attention_backends"
            )

    @abstractmethod
    def forward(
        self,
        hidden_states: torch.Tensor,
        encoder_hidden_states: torch.Tensor | list[torch.Tensor],
        timestep: torch.LongTensor,
        encoder_hidden_states_image: torch.Tensor | list[torch.Tensor] | None = None,
        guidance=None,
        **kwargs,
    ) -> torch.Tensor:
        pass

    def __post_init__(self) -> None:
        required_attrs = ["hidden_size", "num_attention_heads", "num_channels_latents"]
        for attr in required_attrs:

View on GitHub (pinned to 0132848349)

Solutions

  1. Define _supported_attention_backends on the subclass with the supported backend names, e.g. _supported_attention_backends = ["flashinfer", "fa3"]
  2. Verify the attribute name spelling matches exactly what the supported_attention_backends property reads
  3. Ensure the value is a non-empty list/tuple

Example fix

// before
class MyDiT(BaseDiT):
    ...
// after
class MyDiT(BaseDiT):
    _supported_attention_backends = ["flashinfer"]
    ...
Defensive patterns

Strategy: validation

Validate before calling

def has_attention_backends(cls) -> bool:
    return bool(getattr(cls, "_supported_attention_backends", None))

Type guard

def is_constructible_dit(cls) -> bool:
    return (isinstance(cls, type) and issubclass(cls, BaseDiT)
            and bool(cls.supported_attention_backends))

Prevention

When it happens

Trigger: Instantiating a BaseDiT subclass whose _supported_attention_backends is unset or set to an empty list, e.g. MyDiT(config, hf_config) where the class never declared _supported_attention_backends.

Common situations: Writing a new DiT model and defining required class attrs but forgetting the attention-backend declaration; or setting it to [] while the intended backend name was typo'd into a different variable.

Related errors


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