Skip to content
HMS-labPublic

About

Fork of https://gitcode.com/Ascend/memcache

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation


High-performance distributed key-value cache

Docs PyPI PyPI - Python Version PyPI - Downloads GitCode commit activity license


🔄 Latest News

  • [2026/06] MemCache enables PrefixCache acceleration for inference. See the deployment examples for the latest examples.

  • [2025/12] MemCache is available as a vllm-ascend backend to accelerate LLM inference. See the vllm-ascend open-source community and the usage example.

  • [2025/11] MemCache was open-sourced in November 2025. The community repository is https://gitcode.com/Ascend/memcache.

🔜 Roadmap and Release Strategy

See the MemCache roadmap: Roadmap. See the MemCache branch release strategy.

🎉 Overview

MemCache is a high-performance distributed KVCache storage engine designed for LLM and GR inference. Its main features include:

  • Object-based APIs: Supports individual and batch put, get, exist, and remove operations, plus read and write APIs for multilayer KV blocks.
  • Tiered cache pools: Uses HBM, DRAM, and SSD as cache tiers and moves hot and cold data between tiers through prefetching and eviction.
  • High bandwidth and low latency: Uses MemFabric as the foundation for tiered memory and heterogeneous network transfers. On Ascend hardware, device_rdma (A2), device_sdma (A3), host_rdma (A2/A3), and device_urma (A5) provide direct OneCopy data access across hosts and memory tiers. Kunpeng hardware supports host_urma (K5). The host_shm protocol provides shared-memory communication within a node.
  • Dynamic scaling: LocalService instances can join or leave at runtime.
  • High availability: On Kubernetes, MetaService supports multiple active instances and metadata recovery for best-effort high availability.
architecture

🧩 Core Components

MemCache consists of two core components: LocalService and MetaService.

  • MetaService

    • Allocates and manages memory-pool capacity throughout the cluster and handles LocalService membership changes.
    • MetaService runs as a standalone process. Start it through the Python API or launch the binary.
    • Supports two deployment modes: 1. Standalone mode: A single MetaService process is easy to deploy, but creates a single point of failure. If the process crashes or becomes unreachable, the system cannot provide service until it recovers. 2. HA mode: Uses Kubernetes ClusterIP Services and Lease resources. This more complex deployment runs multiple MetaService instances for active-active high availability. See how to deploy a MemCache HA cluster.
  • LocalService: Provides the following functions:

    • Client: Applications load LocalService as a shared library distributed as a wheel or shared object and invoke its API.
    • Memory provider: Provides a contiguous memory region for the memory pool. Other LocalService instances can access it directly by address.

📁 Project Structure

MemCache's core code follows a modular design, with the main implementation under src/memcache/csrc.

src/memcache/csrc/                        # C++ core implementation
  ├── meta_service/                       # MetaService: cluster metadata, allocation, and eviction
  │    ├── mmc_meta_service.cpp           # Main MetaService logic
  │    ├── mmc_meta_manager.cpp           # Metadata manager (global key-to-blob map)
  │    ├── mmc_blob_allocator.cpp         # Memory-pool allocator
  │    ├── mmc_meta_container_lru.cpp     # LRU metadata container (temperature tracking and eviction)
  │    └── mmc_meta_net_server.cpp        # RPC network server
  ├── client/                             # Local client loaded by inference processes as a wheel/shared library
  │    ├── mmc_client_default.cpp         # Core client implementation (batch put/get/copy)
  │    └── mmc_meta_net_client.cpp        # RPC network client
  ├── local_service/                      # LocalService: memory provider
  │    ├── mmc_local_service_default.cpp  # Main LocalService implementation
  │    └── mmc_bm_proxy.cpp               # MemFabric BM semantic proxy
  └── under_api/                          # Foundation integration layer (MemFabric / UBSIO)
       ├── mf_smem/                       # MemFabric shared-library integration (HBM / DRAM tiers)
       │    └── smem_bm_api.cpp           # Batch memory-copy API
       └── ubs_io/                        # UBSIO shared-library integration (SSD tier)
            ├── mmc_ubs_io_proxy.cpp      # UBSIO proxy wrapper
            └── dl_ubsio_api.cpp          # Dynamic loading of UBSIO

🔥 Performance

MemCache provides a high-capacity memory pool and high-performance H2D, D2H, D2RH, and RH2D transfers. Built on MemFabric, it uses OneCopy for direct transfers across hosts and memory tiers, including RH2D and D2RH. The diagram compares RH2D with paths that use an intermediate copy.

RH2D

Based on OneCopy direct access across machines and media, the following performance tests were run on A2/A3. The benchmark simulates a DeepSeek-R1 KV block. A block spans 122 discrete addresses and contains 61 × 128 KB + 61 × 16 KB = 8,784 KB (about 8.57 MB).

  • Read/write performance using a two-node memory pool with two Ascend A2 nodes (8 cards per node):
A2 perf
  • Read/write performance using a two-node memory pool with two Ascend A3 nodes (8 cards and 16 dies per node):
A3 perf

🚀 Quick Start

See the following guides to get started:

📑 Tutorials

📦 Software and Hardware Compatibility

📌 FAQ

See the FAQ for common questions.

📝 Related Information

Note

This open-source project is not a Huawei product and provides limited support.

About

Fork of https://gitcode.com/Ascend/memcache

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages