Skip to content

vllm.distributed.kv_transfer

Modules:

Functions:

ensure_kv_transfer_initialized(vllm_config, kv_cache_config)

Initialize KV cache transfer parallel group.

Source code in vllm/distributed/kv_transfer/kv_transfer_state.py
def ensure_kv_transfer_initialized(
    vllm_config: "VllmConfig", kv_cache_config: "KVCacheConfig"
) -> None:
    """
    Initialize KV cache transfer parallel group.
    """

    global _KV_CONNECTOR_AGENT

    if vllm_config.kv_transfer_config is None:
        return

    if (
        vllm_config.kv_transfer_config.is_kv_transfer_instance
        and _KV_CONNECTOR_AGENT is None
    ):
        _sync_engine_id_across_tp(vllm_config)

        _KV_CONNECTOR_AGENT = KVConnectorFactory.create_connector(
            config=vllm_config,
            role=KVConnectorRole.WORKER,
            kv_cache_config=kv_cache_config,
        )

is_v1_kv_transfer_group(connector=None)

Check if the KV connector is the v1 connector. If the argument is None, it will check the global KV connector

Parameters:

  • connector

    (KVConnectorBaseType | None, default: None ) –

    The KV connector to check. If None, it will check the global KV connector.

Note

This function will no-longer be needed after the v1 KV connector becomes the default.

Source code in vllm/distributed/kv_transfer/kv_transfer_state.py
def is_v1_kv_transfer_group(connector: KVConnectorBaseType | None = None) -> bool:
    """Check if the KV connector is the v1 connector.
    If the argument is None, it will check the global KV connector

    Args:
        connector: The KV connector to check. If None, it will check the
            global KV connector.

    Note:
        This function will no-longer be needed after the v1 KV connector
        becomes the default.
    """
    if connector is None:
        connector = _KV_CONNECTOR_AGENT

    if connector is None:
        return False

    return isinstance(connector, KVConnectorBase_V1)