Skip to content

vllm.v1.kv_offload.config

Normalized configuration consumed by native offloading backends.

Classes:

  • OffloadAccessMode –

    Direction(s) in which an offloading connector may transfer data.

OffloadAccessMode

Bases: Enum

Direction(s) in which an offloading connector may transfer data.

Configured through the optional access_mode key of a connector's config: read serves loads but never accepts stores, write accepts stores but never serves loads, and readwrite (the default) does both.

Methods:

  • from_config –

    Parse a configured access_mode value, defaulting to readwrite.

Attributes:

  • can_read (bool) –

    Whether the connector may serve loads (read from the tier).

  • can_write (bool) –

    Whether the connector may accept stores (write to the tier).

Source code in vllm/v1/kv_offload/config.py
class OffloadAccessMode(Enum):
    """Direction(s) in which an offloading connector may transfer data.

    Configured through the optional `access_mode` key of a connector's
    config: `read` serves loads but never accepts stores, `write` accepts
    stores but never serves loads, and `readwrite` (the default) does both.
    """

    READ = "read"
    WRITE = "write"
    READWRITE = "readwrite"

    @classmethod
    def from_config(cls, value: str | OffloadAccessMode | None) -> OffloadAccessMode:
        """Parse a configured `access_mode` value, defaulting to `readwrite`."""
        if value is None:
            return cls.READWRITE
        if isinstance(value, cls):
            return value
        if not isinstance(value, str):
            raise ValueError(
                f"access_mode must be a string, got {type(value).__name__}: {value!r}"
            )
        try:
            return cls(value.strip().lower())
        except ValueError:
            valid = ", ".join(repr(access_mode.value) for access_mode in cls)
            raise ValueError(
                f"Invalid access_mode {value!r}; expected one of {valid}"
            ) from None

    @property
    def can_read(self) -> bool:
        """Whether the connector may serve loads (read from the tier)."""
        return self is not OffloadAccessMode.WRITE

    @property
    def can_write(self) -> bool:
        """Whether the connector may accept stores (write to the tier)."""
        return self is not OffloadAccessMode.READ

can_read property

Whether the connector may serve loads (read from the tier).

can_write property

Whether the connector may accept stores (write to the tier).

from_config(value) classmethod

Parse a configured access_mode value, defaulting to readwrite.

Source code in vllm/v1/kv_offload/config.py
@classmethod
def from_config(cls, value: str | OffloadAccessMode | None) -> OffloadAccessMode:
    """Parse a configured `access_mode` value, defaulting to `readwrite`."""
    if value is None:
        return cls.READWRITE
    if isinstance(value, cls):
        return value
    if not isinstance(value, str):
        raise ValueError(
            f"access_mode must be a string, got {type(value).__name__}: {value!r}"
        )
    try:
        return cls(value.strip().lower())
    except ValueError:
        valid = ", ".join(repr(access_mode.value) for access_mode in cls)
        raise ValueError(
            f"Invalid access_mode {value!r}; expected one of {valid}"
        ) from None