Skip to main content

AIBrix KV Cache offloading framework for cross-engine KV reuse

Project description

AIBrix KV Cache Offloading Framework for Cross-Engine KV Reuse

AIBrix KV cache offloading framework provides several common functionalities for cross-engine KV reuse use cases:

Tensor Parallelism Aware Management: When inference engine (e.g., vLLM) uses tensor parallelism, each participating engine instance fetches KV tensors independently from the cache backend. In case of cache misses, before proceeding with prefill computation, participants must align the potentially different number of KV tensors fetched from the external KV cache service to ensure a consistent view .

Embedded Cache w/ CPU Memory: To meet performance requirements, it's common to have a small CPU memory-based cache embedded in the engine to avoid frequently accessing remote cache backends.

Selective KV Cache Offloading: Enables fine-grained control over offloading strategies and thus is crucial in optimizing performance across diverse deployment environments:

  1. Many cloud providers and companies deploy lower-end GPU instances without high-speed interconnects like RDMA, suited for tasks related to 7B/8B models running on 24/32GiB GPU cards. In these setups, GPUs within the same instance (typically 8-16 GPUs) share a single VPC NIC, leading to significant network bandwidth contention. Selective KV cache offloading (e.g., only offloading KV tensors identified by the employed eviction policy as hot rather than offloading all KV tensors) helps mitigate this issue by reducing unnecessary data transfers and conserving limited network bandwidth.
  2. Even in high-performance environments with RDMA-equipped GPUs, selective KV cache offloading can enhance efficiency by limiting the PCIe bandwidth consumed by remote data movement. While RDMA enables low-latency, high-bandwidth communication, remote data access still incurs higher latency than local memory access. By leveraging selective KV offloading, the framework reduces the frequency of remote data transfers, preserving PCIe bandwidth and ensuring that local memory access remains the preferred data pathway. To achieve selective KV cache offloading, we introduce an eviction policy layer that can be extended and customized with advanced offloading strategies to determine which KV tensors should be offloaded. Within this layer, multiple callbacks are available to support different offloading modes, including offloading all KV tensors, only hot KV tensors, or only cold KV tensors, with the definition of "hot" and "cold" being determined by the specific eviction policy in use. In this initial PR, the framework will provide built-in support for LRU, FIFO, and S3FIFO eviction policies.

Quick Start

Installation

AIBrix KV cache offloading framework can be installed by pip.

pip install aibrix-kvcache

Contributing

We welcome contributions from the community! Check out our contributing guidelines to see how you can make a difference.

Build from source

# This may take several minutes
pip install -e .

Lint, Format and Type Check

Before contribute your code, please run the following commands to ensure that your code passes the tests and linting checks.

# install dependencies
poetry install --no-root --with dev

# linting, formatting and type checking
bash ./scripts/format.sh

License

AI Runtime is licensed under the APACHE License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aibrix_kvcache-0.1.0.post1.tar.gz (53.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aibrix_kvcache-0.1.0.post1-py3-none-any.whl (89.8 kB view details)

Uploaded Python 3

File details

Details for the file aibrix_kvcache-0.1.0.post1.tar.gz.

File metadata

  • Download URL: aibrix_kvcache-0.1.0.post1.tar.gz
  • Upload date:
  • Size: 53.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.12 Linux/6.11.0-1012-azure

File hashes

Hashes for aibrix_kvcache-0.1.0.post1.tar.gz
Algorithm Hash digest
SHA256 862687f797ef427d280b7c8b08f85e1ec434451643c942c75af936cb5a5a2ccc
MD5 bc8e8c945a19775c4c09f854cd34d28c
BLAKE2b-256 d5a38abf38227e9f40947ad37f1baa71f999616f7387f286ab31b93230d03d44

See more details on using hashes here.

File details

Details for the file aibrix_kvcache-0.1.0.post1-py3-none-any.whl.

File metadata

  • Download URL: aibrix_kvcache-0.1.0.post1-py3-none-any.whl
  • Upload date:
  • Size: 89.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.11.12 Linux/6.11.0-1012-azure

File hashes

Hashes for aibrix_kvcache-0.1.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 902976ea5ec84bede0b34fe12d894b5593f467ab9c01ff1958e410bf50e38fb5
MD5 a15da23f5927a947e97fb2b255b1b3b0
BLAKE2b-256 557ba2a8b38fa428f1257a9bb44d88d3dc7880e8401701ef61ebda8040fc8237

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page