{"record":{"id":"d7f8f21c2d613329","repo":"sgl-project/sglang","slug":"pipeline-cls-must-inherit-from-composedpipelinebas","errorCode":null,"errorMessage":"pipeline_cls must inherit from ComposedPipelineBase","messagePattern":"pipeline_cls must inherit from ComposedPipelineBase","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/registry.py","lineNumber":389,"sourceCode":"    if model_detectors:\n        for detector in model_detectors:\n            _MODEL_NAME_DETECTORS.append((model_id, detector))\n    return model_id\n\n\ndef register_pipeline(\n    pipeline_cls: Type[ComposedPipelineBase],\n    *,\n    sampling_param_cls: Any,\n    pipeline_config_cls: Type[PipelineConfig],\n    hf_model_paths: Optional[List[str]] = None,\n    model_detectors: Optional[List[Callable[[str], bool]]] = None,\n    overwrite: bool = False,\n) -> None:\n    \"\"\"Register an out-of-tree native diffusion pipeline and its configs.\"\"\"\n    _discover_and_register_pipelines()\n    if not issubclass(pipeline_cls, ComposedPipelineBase):\n        raise TypeError(\"pipeline_cls must inherit from ComposedPipelineBase\")\n    if not issubclass(pipeline_config_cls, PipelineConfig):\n        raise TypeError(\"pipeline_config_cls must inherit from PipelineConfig\")\n\n    pipeline_name = pipeline_cls.pipeline_name\n    existing_pipeline = _PIPELINE_REGISTRY.get(pipeline_name)\n    if existing_pipeline is not None and not overwrite:\n        raise ValueError(\n            f\"Pipeline '{pipeline_name}' is already registered; pass overwrite=True to replace it\"\n        )\n    for model_path in hf_model_paths or []:\n        if model_path in _MODEL_HF_PATH_TO_NAME and not overwrite:\n            raise ValueError(f\"Model path '{model_path}' is already registered\")\n        registered_pipeline = KNOWN_NON_DIFFUSERS_DIFFUSION_MODEL_PATTERNS.get(\n            model_path.lower()\n        )\n        if registered_pipeline is not None and not overwrite:\n            raise ValueError(\n                f\"Model path '{model_path}' is already registered for pipeline \"","sourceCodeStart":371,"sourceCodeEnd":407,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/registry.py#L371-L407","documentation":"registry.register_pipeline validates out-of-tree diffusion pipeline registrations. The first check requires pipeline_cls to be a subclass of ComposedPipelineBase; anything else (including plain diffusers Pipeline classes) raises TypeError.","triggerScenarios":"Calling register_pipeline(MyPipeline, MyConfig, ...) where MyPipeline does not inherit from ComposedPipelineBase (e.g. subclasses diffusers.DiffusionPipeline or object).","commonSituations":"Porting an existing diffusers pipeline into sglang's multimodal_gen registry; forgetting to rebase the custom pipeline class on ComposedPipelineBase; passing the class in the wrong argument position.","solutions":["Make your pipeline class inherit from ComposedPipelineBase (from sglang.multimodal_gen) and implement its required interface","Confirm you are passing pipeline_cls first and pipeline_config_cls second","Ensure the import path brings in the sglang base class, not a diffusers one"],"exampleFix":"# before\nclass MyPipeline(DiffusionPipeline): ...\nregistry.register_pipeline(MyPipeline, MyConfig)\n# after\nfrom sglang.multimodal_gen.registry import register_pipeline\nfrom sglang.multimodal_gen.pipelines import ComposedPipelineBase\nclass MyPipeline(ComposedPipelineBase): ...\nregister_pipeline(MyPipeline, MyConfig)","handlingStrategy":"type-guard","validationCode":"from sglang.multimodal_gen.registry import register_pipeline\nfrom sglang.multimodal_gen.pipelines import ComposedPipelineBase\nassert issubclass(MyPipeline, ComposedPipelineBase), \"pipeline must subclass ComposedPipelineBase\"","typeGuard":"def is_composed_pipeline(cls) -> bool:\n    from sglang.multimodal_gen.pipelines import ComposedPipelineBase\n    return isinstance(cls, type) and issubclass(cls, ComposedPipelineBase)","tryCatchPattern":"try:\n    register_pipeline(MyPipeline, MyConfig)\nexcept TypeError as e:\n    if \"ComposedPipelineBase\" in str(e):\n        raise RuntimeError(f\"{MyPipeline} must inherit ComposedPipelineBase\") from e\n    raise","preventionTips":["Base custom pipelines on ComposedPipelineBase from the start","Run issubclass checks in unit tests for registered pipelines","Use keyword arguments when calling register_pipeline"],"tags":["type-error","registry","pipeline","validation","subclass"],"backgroundTag":"invalid-registry-entry","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}