Skip to main content

EngramDB 的 Python 分发包

Disk-first storage engine for Engram / PLE n-gram memory tables (Rust).

分发名 engramdb-python(PyPI 相似名规避);import 名仍为 engramdb。

当前 v0.2.x 同时包含两条 Python 接入路径:

  1. PyO3 原生扩展(优先):crates/engramdb-pyo3,构建后以 python/engramdb/_engramdb.so 提供 Store / View / PageReader / Linux IoUringPageReader。
  2. ctypes C-ABI 回退:crates/engramdb-python,无 PyO3 构建产物时也能用。

python/engramdb/__init__.py 会自动优先加载 PyO3,失败则回退 ctypes。

快速使用

# 方式 1:maturin 构建 wheel(推荐,直接产生可安装的 native wheel)
cd python
CARGO_HOME=/tmp/cargo-home RUSTFLAGS="-C link-arg=-undefined -C link-arg=dynamic_lookup" \
  maturin build --release --interpreter python3

# 方式 2:开发期内直接构建并复制到包目录
CARGO_HOME=/tmp/cargo-home RUSTFLAGS="-C link-arg=-undefined -C link-arg=dynamic_lookup" \
  cargo build -p engramdb-pyo3 --release
cp target/release/lib_engramdb.dylib python/engramdb/_engramdb.so

# 在 engram-peft 等项目中用 uv 添加本地开发依赖
cd ~/code/engram-peft
uv add --editable ../EngramDB/python

# 发布到 PyPI 后可直接:
# uv add engramdb-python
import engramdb

# 打开 Store-I:目录内为 shard_000.bin 等定长行文件
store = engramdb.Store("path/to/rows", shards=1, rows_per_shard=100, width=256)
row_bytes = store.fetch([0, 1, 2])   # bytes, 每条 256B
store.close()

# 打开 Store-P 视图
view = engramdb.View("path/to/view.bin")
rec = view.read_record(0)            # 一条 e_t 记录

# SGLang 兼容:从多个 fd/offset 读页(Unix 有 PageReader,Linux 另有 IoUringPageReader)
reader = engramdb.PageReader(page_size=4096)
pages = reader.read_pages([fd0, fd1], [offset0, offset1])

引擎适配层

  • engramdb.sglang.SGLangPageReader:与 SGLang IoUringReader.read_pages(fds, offsets) 同形的适配器,Linux 优先用 IoUringPageReader。
  • engramdb.vllm_plugin.DiskPleEmbedding / patch_named_embedding:用 EngramDB 替代模型中 PLE 表的 nn.Embedding,内部走 PleDiskGather 去重+批量读+展开。

engram-peft 集成

安装 engramdb-python 后,可以直接使用内置的磁盘版 MultiHeadEmbedding:

import engramdb
from engramdb.integrations import install_disk_multi_head_embedding

store = engramdb.Store("path/to/embedding-store", shards=1, rows_per_shard=100, width=256)
install_disk_multi_head_embedding(store)

# 之后再调用 engram-peft 的 get_engram_model(...) 即可让 Engram 层从磁盘读取 embedding

定位(一句话)

让"确定性哈希的 n-gram 记忆表"(Qwen PLE、DeepSeek Engram 等)像数据库一样落盘、建索引、预取、服务化——单机 CPU+NVMe 低延迟推理 / 高吞吐训练预处理。

详细文档见上游仓库 docs/(design.md / specifications / roadmap)以及 examples/interop_engram_peft.py。

Metadata

Release files for engramdb-python 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for engramdb-python 0.2.4
File Size Uploaded
engramdb_python-0.2.4.tar.gz 37.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for engramdb-python 0.2.4
File
engramdb_python-0.2.4-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
engramdb_python-0.2.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
engramdb_python-0.2.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
engramdb_python-0.2.4-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
engramdb_python-0.2.4-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 1.5 MB

Release files / engramdb_python-0.2.4.tar.gz

Download URL engramdb_python-0.2.4.tar.gz
Size 37.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0fa72ad36d03926dae9d0c9a086235946787f4ad0eaffd0993a1b9f9d6e38926
BLAKE2b-256 checksum
How to use checksums
6922e80037bc629f0b78a707943ae3ea489edadb8330601176b1ec15d503157c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Release files / engramdb_python-0.2.4-cp310-abi3-win_amd64.whl

Download URL engramdb_python-0.2.4-cp310-abi3-win_amd64.whl
Size 208.2 kB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
f9f1e54fc97212e3de4b47a67355f11b36a78a5abf3750a879e252f214bbee71
BLAKE2b-256 checksum
How to use checksums
014c4f99a5888c6a27de2b10c369fc473733a15e63e0af4b4c7ea55a1d11d168
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Release files / engramdb_python-0.2.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL engramdb_python-0.2.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 334.2 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
ff11b7f60b19bb94cef6271a59998d088244184180c0965fde4565ef35fd3d58
BLAKE2b-256 checksum
How to use checksums
7b2a7a55edd9dde6c4e0b365b90f5cb663db11d062cd47e78d8d8118fbb195d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Release files / engramdb_python-0.2.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL engramdb_python-0.2.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 318.1 kB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
ed1db9da1e1ba0ba79d5b8984bd5683cbcaf33d8eb2cc5a53515ae9536bdba8c
BLAKE2b-256 checksum
How to use checksums
5e7cbae680f651b60cecc304049f7fbb3d6b4f9305c754e1336069ff161d902b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Release files / engramdb_python-0.2.4-cp310-abi3-macosx_11_0_arm64.whl

Download URL engramdb_python-0.2.4-cp310-abi3-macosx_11_0_arm64.whl
Size 313.6 kB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9fe5508486f580dce489fcd96056648146e2a401abb3be85f60e6cae32695392
BLAKE2b-256 checksum
How to use checksums
9c33f90240f811c1e5ec4fd1db9700d8b9960f75b9091592a4f03d83216401c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Release files / engramdb_python-0.2.4-cp310-abi3-macosx_10_12_x86_64.whl

Download URL engramdb_python-0.2.4-cp310-abi3-macosx_10_12_x86_64.whl
Size 322.8 kB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
b290ab06afa0a731469cb6c1de2f33a499670687c81ec2537a1e4264bc564176
BLAKE2b-256 checksum
How to use checksums
401222d0f65e95bbbce287b9a4e5686fb93acca38e01d82c6dfa5d6d703ee679
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.0

6 release files

0.2.10

6 release files

0.2.9

6 release files

0.2.8

6 release files

0.2.6

6 release files

0.2.5

6 release files

This release

0.2.4 This release

6 release files

0.2.3

6 release files

0.2.2

6 release files

0.2.1

6 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page