Skip to content

vllm.v1.kv_offload.cpu.policies.factory

Classes:

CachePolicyFactory

Registry for CachePolicy implementations, resolved by name.

Mirrors OffloadingSpecFactory (vllm/v1/kv_offload/factory.py): built-in policies are pre-registered below. External policies can either register_cache_policy() a friendly short name up front, or skip registration entirely and pass a module path at lookup time (out-of-tree, no vLLM fork/patch required) -- see get_cache_policy_cls.

Methods:

get_cache_policy_cls(name, module_path=None) classmethod

Get a cache policy class by name.

Parameters:

  • name

    (str) –

    Name of the cache policy. Checked against the registry first; if it's not registered and module_path is given, name is imported from there instead -- an out-of-tree policy needs no register_cache_policy() call at all, just this module path passed through config (mirrors OffloadingSpecFactory.get_spec_cls's spec_module_path fallback).

  • module_path

    (str | None, default: None ) –

    Python import path to load name from when it is not a registered policy.

Returns:

Raises ValueError if the cache policy is neither registered nor resolvable via module_path.

register_cache_policy(name, module_path, class_name) classmethod

Register a cache policy with a lazy-loading module and class name.