Skip to content

vllm.v1.kv_offload.tiering.factory

Factory for creating secondary tier implementations.

create_secondary_tier

create_secondary_tier(
    tier_config: dict,
    primary_kv_view: memoryview,
    vllm_config: VllmConfig,
) -> SecondaryTierManager

Create a secondary tier from configuration.

Parameters:

Name Type Description Default
tier_config dict

Dictionary with tier configuration containing: - type (required): Type of secondary tier (e.g., "example") - Additional tier-specific parameters are passed directly to the tier constructor

required
primary_kv_view memoryview

Memoryview of the primary tier's CPU KV cache.

required
vllm_config VllmConfig

Global vLLM configuration.

required

Returns:

Type Description
SecondaryTierManager

SecondaryTierManager instance

Raises:

Type Description
ValueError

If tier type is unknown or configuration is invalid

Source code in vllm/v1/kv_offload/tiering/factory.py
def create_secondary_tier(
    tier_config: dict,
    primary_kv_view: memoryview,
    vllm_config: "VllmConfig",
) -> SecondaryTierManager:
    """
    Create a secondary tier from configuration.

    Args:
        tier_config: Dictionary with tier configuration containing:
            - type (required): Type of secondary tier (e.g., "example")
            - Additional tier-specific parameters are passed directly
              to the tier constructor
        primary_kv_view: Memoryview of the primary tier's CPU KV cache.
        vllm_config: Global vLLM configuration.

    Returns:
        SecondaryTierManager instance

    Raises:
        ValueError: If tier type is unknown or configuration is invalid
    """
    config = tier_config.copy()

    tier_type = config.pop("type", None)
    if not tier_type:
        raise ValueError("Secondary tier configuration must include 'type'")

    cls = _TIER_REGISTRY.get(tier_type)
    if cls is None:
        raise ValueError(
            f"Unknown secondary tier type: {tier_type!r}. "
            f"Supported types: {list(_TIER_REGISTRY)}"
        )
    return cls(vllm_config=vllm_config, primary_kv_view=primary_kv_view, **config)