Skip to main content

Python bindings for memcache_hybrid implemented with pybind11

Project description


High-performance distributed key-value cache

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


🔄Latest News

  • [2025/12] MemCache已作为vllm-ascend backend使能大模型推理加速,详情查看vllm-ascend开源社区,使用示例

  • [2025/11] MemCache项目于2025年11月开源,开源社区地址为:https://gitcode.com/Ascend/memcache

🔜 Roadmap

MemCache roadmap和版本分支策略详见: Roadmap

🎉概述

MemCache是针对LLM推理、GR推理场景设计的高性能分布式KVCache存储引擎,其主要特性包括:

  • 基于对象操作的API:支持批量和非批量的put/get/exist/remove操作,支持多层结构的KV Block读写接口。
  • 支持多副本:单个对象支持多副本放置到不同的LocalService,默认是单副本,支持put接口指定副本数量。
  • 高带宽低时延:使用 MemFabric 作为多级内存和异构网络传输的底座,在Ascend硬件上,基于device_rdma(A2)、device_sdma(A3)、host_rdma(A2/A3) 等路径提供OneCopy跨机跨介质数据直接访问能力,满足高带宽,低时延的读写性能述求。在鲲鹏硬件上,支持host_urma(K5)。支持host_shm实现同节点共享内存通信。
  • 支持扩缩容:支持LocalService动态加入和移除
  • HA能力:在K8S集群中,MetaService支持多活能力,支持元数据恢复,提供尽力而为的HA能力。
architecture

🧩核心组件

MemCache包含LocalService和MetaService两大核心组件:

  • MetaService

    • 负责管理整个集群中内存池空间的分配和管理,处理LocalService的加入与退出。
    • MetaService作为独立进程运行,提供两种启动方式:python API启动;二进制启动,详见 安装部署
    • MetaService支持两种部署形态: 1、单点模式:MetaService由单个进程组成,部署方式简单,但存在单点故障的问题。如果MetaService进程崩溃或无法访问,系统将无法继续提供服务,直至重新恢复为止。 2、HA模式:该模式基于K8S的的ClusterIP Service和Lease资源构建,部署较为复杂,该模式会部署多个MetaService进程实例,实现多活高可用。部署详见 MetaService HA
  • LocalService:负责承担如下功能:

    • 客户端:作为客户端,以whl/so形式作为共享库被应用进程加载调用API
    • 内存提供者:负责提供一段连续的内存区域作为内存池空间的一部分,其内存可以被其他LocalService实例基于地址直接访问。

🔥性能表现

MemCache核心能力是提供大容量内存池和高性能的H2D、D2H、D2RH、RH2D数据访问能力,由于MemCache以 MemFabric 作为池化底座,所以支持RH2D、D2RH等OneCopy跨机跨介质数据直接访问能力,下图为RH2D对比其他中转路径的对比示意图。

RH2D

基于OneCopy跨机跨介质数据直接访问的能力,MemCache在A2/A3做了相关性能测试如下: 模拟构造DeepSeek-R1模型KV大小的block,单个block size为:61x128K + 61x16K = 8784KB ≈ 8.57MB,共122个离散地址。

  • 使用2个昇腾A2节点(每节点8张卡)组成双机内存池进行读写测试性能如下:
A2 perf
  • 使用2个昇腾A3节点(每节点8张卡16Die)组成双机内存池进行读写测试性能如下:
A3 perf

🔍目录结构

├── LICENSE                                 # LICENSE
├── .clang-format                           # 格式化配置
├── .gitmodules                             # git配置
├── .gitignore                              # git忽视配置文件
├── CMakeLists.txt                          # 项目的CMakeList
├── doc                                     # 文档目录
├── example                                 # 样例
│  ├── cpp                                  # c++样例
│  └── python                               # python样例
├── script                                  # 构建脚本
│  ├── build_and_pack_run.sh                # 编译+打包脚本
│  ├── build.sh                             # 编译脚本
│  ├── run_ut.sh                            # 编译+运行ut脚本
├── test                                    # test目录
│  ├── python                               # python测试用例
│  ├── k8s_deploy                           # k8s ha样例脚本
│  └── ut                                   # 单元测试用例
├── src                                     # 源码
│  ├── memcache                             # MemCache 源码
├── config                                  # 配置目录
│  ├── mmc-local.conf                       # 本地服务配置文件模板
│  ├── mmc-meta.conf                        # meta服务配置文件模板
├── README.md

🚀快速入门

请访问以下文档获取简易教程。

  • 编译部署:介绍组件编译和安装教程。
  • 配置文件:涉及MetaService、LocalService公共配置
  • 样例执行:介绍如何端到端执行样例代码,包括C++和Python样例。
  • [最佳实践]:推出中...

📑学习教程

  • c++接口:C++接口介绍以及C++接口对应的API列表
  • python接口:python接口介绍以及python接口对应的API列表

📦软件硬件配套说明

  • MemCache软件依赖 MemFabric,相关配套与MemFabric相同

📌FAQ

常见问题请参考:FAQ

📝相关信息

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

memcache_hybrid-1.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

memcache_hybrid-1.1.2-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

memcache_hybrid-1.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

memcache_hybrid-1.1.2-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

memcache_hybrid-1.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

memcache_hybrid-1.1.2-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

memcache_hybrid-1.1.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

memcache_hybrid-1.1.2-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (3.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

File details

Details for the file memcache_hybrid-1.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for memcache_hybrid-1.1.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0e27ebcc0308e7f28956ecc3703f1eb8c63fdb228a3bbee68babf5603048e48e
MD5 17d1b0b6c9962071d7ba7d23aed7666c
BLAKE2b-256 dfca90868a276268d46ce8ff41ebb2b2bacc77852fc1bc0485fdc60bb868e509

See more details on using hashes here.

File details

Details for the file memcache_hybrid-1.1.2-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for memcache_hybrid-1.1.2-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4a55db4268b74d1d66e58e07dc9d286c14b799723311c201007cead18874307d
MD5 538ac18f83b6d0f6192039743612b6e1
BLAKE2b-256 3338921b4d2295bcdd5a4d8a33c95848d7c4645db4a175d0cae6a721c10e9b51

See more details on using hashes here.

File details

Details for the file memcache_hybrid-1.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for memcache_hybrid-1.1.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e5d0a3159c8a8a85650219a16f5ef1fd35486b60f3d13a047d1617ea0fb20481
MD5 b63662baefdf7a53b2cbc1bfe7d88c04
BLAKE2b-256 83ea75e8e66a512dc18949e0b69aa594edfb1a84d8192424bc3e8713487d619d

See more details on using hashes here.

File details

Details for the file memcache_hybrid-1.1.2-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for memcache_hybrid-1.1.2-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 facf921948c57a51a2d101bb4ed65b1f37c385dbca4c09adf82d19033905b1f4
MD5 95a1291876494435fc88ea8af1a2534a
BLAKE2b-256 4bdadb5b2ae387ebc1a6951c051f2769110df8e98f567e5ab1220e42d8937c5f

See more details on using hashes here.

File details

Details for the file memcache_hybrid-1.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for memcache_hybrid-1.1.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 954c0e548ad2d0a4b89dcba55fa2f9a1f89d9f59cfd5c9fa703baed398a2955e
MD5 ec1514d9436ac2b9a0cace27b0c0eec7
BLAKE2b-256 140cb65c7db154f634150b2aa72d9920d365a3d214bfa069d8dfae3935afc97c

See more details on using hashes here.

File details

Details for the file memcache_hybrid-1.1.2-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for memcache_hybrid-1.1.2-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9453cd000e82274e46a59a5a1c63a5f76985ee08cf8d74dda9870f0fd7d2e84e
MD5 ad3b7df94cb2dcff0c2c7a5b908cf8bf
BLAKE2b-256 6e7687253ab2360f899b59d549fa35c82089003a84797ccb50202977c229cd43

See more details on using hashes here.

File details

Details for the file memcache_hybrid-1.1.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for memcache_hybrid-1.1.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1c068729e623a17fc6fe5ccd5b72d84b4d9343f0af249fe46fe7263bea8b52bd
MD5 006d7dff9834fec5b66197c868f99289
BLAKE2b-256 0fc2e8140ce8f969ed57b02d3b214c5c262a3a5fc82286c09f739ea2d4908aa9

See more details on using hashes here.

File details

Details for the file memcache_hybrid-1.1.2-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for memcache_hybrid-1.1.2-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e81dddd0aff9d4928e74bda2bb9bc66012cb85292935d0bbe10232cc0a2bcf6f
MD5 87c145a8a341873843a9136b99024ab3
BLAKE2b-256 262733d26281ea2e233837b6de8c3621ff5f2c7d426773b19d16ff5909743948

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