sgl-project/sglang · error · TypeError

pipeline_cls must inherit from ComposedPipelineBase

Error message

pipeline_cls must inherit from ComposedPipelineBase

What it means

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.

Source

Thrown at python/sglang/multimodal_gen/registry.py:389

    if model_detectors:
        for detector in model_detectors:
            _MODEL_NAME_DETECTORS.append((model_id, detector))
    return model_id


def register_pipeline(
    pipeline_cls: Type[ComposedPipelineBase],
    *,
    sampling_param_cls: Any,
    pipeline_config_cls: Type[PipelineConfig],
    hf_model_paths: Optional[List[str]] = None,
    model_detectors: Optional[List[Callable[[str], bool]]] = None,
    overwrite: bool = False,
) -> None:
    """Register an out-of-tree native diffusion pipeline and its configs."""
    _discover_and_register_pipelines()
    if not issubclass(pipeline_cls, ComposedPipelineBase):
        raise TypeError("pipeline_cls must inherit from ComposedPipelineBase")
    if not issubclass(pipeline_config_cls, PipelineConfig):
        raise TypeError("pipeline_config_cls must inherit from PipelineConfig")

    pipeline_name = pipeline_cls.pipeline_name
    existing_pipeline = _PIPELINE_REGISTRY.get(pipeline_name)
    if existing_pipeline is not None and not overwrite:
        raise ValueError(
            f"Pipeline '{pipeline_name}' is already registered; pass overwrite=True to replace it"
        )
    for model_path in hf_model_paths or []:
        if model_path in _MODEL_HF_PATH_TO_NAME and not overwrite:
            raise ValueError(f"Model path '{model_path}' is already registered")
        registered_pipeline = KNOWN_NON_DIFFUSERS_DIFFUSION_MODEL_PATTERNS.get(
            model_path.lower()
        )
        if registered_pipeline is not None and not overwrite:
            raise ValueError(
                f"Model path '{model_path}' is already registered for pipeline "

View on GitHub (pinned to 0132848349)

Solutions

  1. Make your pipeline class inherit from ComposedPipelineBase (from sglang.multimodal_gen) and implement its required interface
  2. Confirm you are passing pipeline_cls first and pipeline_config_cls second
  3. Ensure the import path brings in the sglang base class, not a diffusers one

Example fix

# before
class MyPipeline(DiffusionPipeline): ...
registry.register_pipeline(MyPipeline, MyConfig)
# after
from sglang.multimodal_gen.registry import register_pipeline
from sglang.multimodal_gen.pipelines import ComposedPipelineBase
class MyPipeline(ComposedPipelineBase): ...
register_pipeline(MyPipeline, MyConfig)
Defensive patterns

Strategy: type-guard

Validate before calling

from sglang.multimodal_gen.registry import register_pipeline
from sglang.multimodal_gen.pipelines import ComposedPipelineBase
assert issubclass(MyPipeline, ComposedPipelineBase), "pipeline must subclass ComposedPipelineBase"

Type guard

def is_composed_pipeline(cls) -> bool:
    from sglang.multimodal_gen.pipelines import ComposedPipelineBase
    return isinstance(cls, type) and issubclass(cls, ComposedPipelineBase)

Try / catch

try:
    register_pipeline(MyPipeline, MyConfig)
except TypeError as e:
    if "ComposedPipelineBase" in str(e):
        raise RuntimeError(f"{MyPipeline} must inherit ComposedPipelineBase") from e
    raise

Prevention

When it happens

Trigger: Calling register_pipeline(MyPipeline, MyConfig, ...) where MyPipeline does not inherit from ComposedPipelineBase (e.g. subclasses diffusers.DiffusionPipeline or object).

Common situations: 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.

Related errors


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