sgl-project/sglang · error · ValueError

Model path '{model_path}' is already registered

Error message

Model path '{model_path}' is already registered

What it means

The hf_model_paths loop in register_pipeline also rejects duplicates: if any provided HuggingFace model path is already present in _MODEL_HF_PATH_TO_NAME and overwrite is False, registration raises ValueError before adding the mapping.

Source

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

    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 "
                f"'{registered_pipeline}'"
            )

    _PIPELINE_REGISTRY[pipeline_name] = pipeline_cls
    _PIPELINE_CONFIG_REGISTRY[pipeline_name] = (
        pipeline_config_cls,
        sampling_param_cls,
    )
    config_id = register_configs(
        sampling_param_cls=sampling_param_cls,
        pipeline_config_cls=pipeline_config_cls,
        hf_model_paths=hf_model_paths,

View on GitHub (pinned to 0132848349)

Solutions

  1. Pass overwrite=True to replace the existing mapping for those model paths
  2. Choose a different/distinct hf_model_path string for your pipeline
  3. Check the existing mapping first and skip registration if the path is already bound to your pipeline

Example fix

# before
register_pipeline(MyPipeline, MyConfig, hf_model_paths=["org/model-v1"])
# after
register_pipeline(MyPipeline, MyConfig, hf_model_paths=["org/model-v1"], overwrite=True)
Defensive patterns

Strategy: validation

Validate before calling

from sglang.multimodal_gen import registry
paths = ["org/model-v1"]
unknown = [p for p in paths if p in getattr(registry, "_MODEL_HF_PATH_TO_NAME", {})]
if unknown:
    register_pipeline(MyPipeline, MyConfig, hf_model_paths=paths, overwrite=True)
else:
    register_pipeline(MyPipeline, MyConfig, hf_model_paths=paths)

Try / catch

try:
    register_pipeline(MyPipeline, MyConfig, hf_model_paths=paths)
except ValueError as e:
    if "already registered" in str(e):
        register_pipeline(MyPipeline, MyConfig, hf_model_paths=paths, overwrite=True)
    else:
        raise

Prevention

When it happens

Trigger: Calling register_pipeline(..., hf_model_paths=["org/model-name"]) where "org/model-name" (or a colliding path) is already present in _MODEL_HF_PATH_TO_NAME — from a built-in registration or a previous call — while overwrite is False.

Common situations: Registering a pipeline for a model path that sglang already knows (built-in registry entry); re-running registration in notebooks/tests; case-insensitive collisions via KNOWN_NON_DIFFUSERS_DIFFUSION_MODEL_PATTERNS.

Related errors


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