{"record":{"id":"967854df63f67fa2","repo":"sgl-project/sglang","slug":"subclass-self-class-name-must-define-su","errorCode":null,"errorMessage":"Subclass {self.__class__.__name__} must define _supported_attention_backends","messagePattern":"Subclass (.+?) must define _supported_attention_backends","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/models/dits/base.py","lineNumber":77,"sourceCode":"            \"param_names_mapping\",\n            \"_compile_conditions\",\n        ]\n        super().__init_subclass__()\n        for attr in required_class_attrs:\n            if not hasattr(cls, attr):\n                raise AttributeError(\n                    f\"Subclasses of BaseDiT must define '{attr}' class variable\"\n                )\n\n    def __init__(self, config: DiTConfig, hf_config: dict[str, Any], **kwargs) -> None:\n        super().__init__()\n        # `config.arch_config` contains static model metadata. Runtime\n        # capabilities remain class attributes on the model implementation.\n        self.config: DiTArchConfig = config.arch_config\n        self.prefix = config.prefix\n        self.hf_config = hf_config\n        if not self.supported_attention_backends:\n            raise ValueError(\n                f\"Subclass {self.__class__.__name__} must define _supported_attention_backends\"\n            )\n\n    @abstractmethod\n    def forward(\n        self,\n        hidden_states: torch.Tensor,\n        encoder_hidden_states: torch.Tensor | list[torch.Tensor],\n        timestep: torch.LongTensor,\n        encoder_hidden_states_image: torch.Tensor | list[torch.Tensor] | None = None,\n        guidance=None,\n        **kwargs,\n    ) -> torch.Tensor:\n        pass\n\n    def __post_init__(self) -> None:\n        required_attrs = [\"hidden_size\", \"num_attention_heads\", \"num_channels_latents\"]\n        for attr in required_attrs:","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/models/dits/base.py#L59-L95","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Define _supported_attention_backends on the subclass with the supported backend names, e.g. _supported_attention_backends = [\"flashinfer\", \"fa3\"]","Verify the attribute name spelling matches exactly what the supported_attention_backends property reads","Ensure the value is a non-empty list/tuple"],"exampleFix":"// before\nclass MyDiT(BaseDiT):\n    ...\n// after\nclass MyDiT(BaseDiT):\n    _supported_attention_backends = [\"flashinfer\"]\n    ...","handlingStrategy":"validation","validationCode":"def has_attention_backends(cls) -> bool:\n    return bool(getattr(cls, \"_supported_attention_backends\", None))","typeGuard":"def is_constructible_dit(cls) -> bool:\n    return (isinstance(cls, type) and issubclass(cls, BaseDiT)\n            and bool(cls.supported_attention_backends))","tryCatchPattern":null,"preventionTips":["Set _supported_attention_backends in the same commit that adds the subclass","Assert in model unit tests that supported_attention_backends is non-empty"],"tags":["sglang","dit","attention-backend","init-validation"],"backgroundTag":"missing-required-attribute","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}