vllm-project/vllm · error · AttributeError

Class {connector_name} not found in {connector_module_path}

Error message

Class {connector_name} not found in {connector_module_path}

What it means

The factory imported the external module given by kv_connector_module_path, but getattr(module, connector_name) raised AttributeError: the module has no attribute with the connector class name from kv_connector. The original AttributeError is re-raised with a clearer message.

Source

Thrown at vllm/distributed/kv_transfer/kv_connector/factory.py:111

        return cls._registry[connector_name]()

    @classmethod
    def get_connector_class(
        cls, kv_transfer_config: "KVTransferConfig"
    ) -> type[KVConnectorBaseType]:
        connector_name = kv_transfer_config.kv_connector
        if connector_name is None:
            raise ValueError("Connector name is not set in KVTransferConfig")
        connector_module_path = kv_transfer_config.kv_connector_module_path
        if connector_module_path is not None and not connector_module_path:
            raise ValueError("kv_connector_module_path cannot be an empty string.")
        if connector_module_path:
            # External module path takes priority over internal registry.
            connector_module = importlib.import_module(connector_module_path)
            try:
                connector_cls = getattr(connector_module, connector_name)
            except AttributeError as e:
                raise AttributeError(
                    f"Class {connector_name} not found in {connector_module_path}"
                ) from e
            connector_cls = cast(type[KVConnectorBaseType], connector_cls)
            if not supports_kw(connector_cls, "kv_cache_config"):
                msg = (
                    f"Connector {connector_cls.__name__} uses deprecated "
                    "2-argument constructor signature. External v1 KV "
                    "connectors must accept kv_cache_config as the third "
                    "constructor argument and pass it to super().__init__()."
                )
                logger.error(msg)
                raise ValueError(msg)
        elif connector_name in cls._registry:
            connector_cls = cls._registry[connector_name]()
        else:
            raise ValueError(f"Unsupported connector type: {connector_name}")
        return connector_cls

View on GitHub (pinned to c794754062)

Solutions

  1. Verify the class exists: python -c "import my_pkg.connectors as m; print(m.MyConnector)"
  2. Fix the name in kv_connector to the exact class name, or fix the module path to the module that defines/re-exports the class
  3. Reinstall/upgrade the external connector package so the expected class is present

Example fix

# before
kv_connector="FlexKVConnectorV1Impl", kv_connector_module_path="flexkv.integration.vllm"

# after
kv_connector="FlexKVConnectorV1Impl", kv_connector_module_path="flexkv.integration.vllm.vllm_v1_adapter"
Defensive patterns

Strategy: validation

Validate before calling

import importlib
mod = importlib.import_module(kv_transfer_config.kv_connector_module_path)
assert hasattr(mod, kv_transfer_config.kv_connector), (
    f"{kv_transfer_config.kv_connector} not in {kv_transfer_config.kv_connector_module_path}"
)

Type guard

def module_exports(module_path: str, cls_name: str) -> bool:
    try:
        return hasattr(importlib.import_module(module_path), cls_name)
    except ImportError:
        return False

Try / catch

try:
    cls = KVConnectorFactory.get_connector_class(cfg)
except AttributeError as e:
    raise SystemExit(f"External connector class missing: {e}") from e

Prevention

When it happens

Trigger: kv_connector_module_path points to a valid Python module, but the class named by kv_connector is absent — wrong class name, class not imported into that module's namespace (__init__.py missing the re-export), or the module installed is a different version.

Common situations: External connector package where the class lives in a submodule but kv_connector_module_path names the package; renaming the connector class without updating configs; stale installed version of the external package.

Related errors


AI-assisted analysis of vllm-project/vllm@c794754062 (2026-08-14). Data as JSON: /api/errors/6fe4f14031cd8cc8. Report an issue: GitHub.