Skip to main content

Vector index using Clifford-rotor block-diagonal quantization (PlanarQuant / RotorQuant / IsoQuant)

Project description

rotorvec

Vector index using block-diagonal Clifford-rotor quantization. Three rotation variants, one API: Planar2 (2D Givens), Rotor3 (Cl(3,0) sandwich, default), Iso4 (4D quaternion).

A block-diagonal cousin of turbovec (TurboQuant): same compression and bit-plane layout, but the dense d×d random rotation is replaced by small per-block rotors — O(d) work, ~d parameters, no BLAS dependency.

See the main repo README for the full algorithm description, attribution, and benchmarks.

Install

pip install rotorvec

Wheels are built for Linux (x86_64, aarch64), macOS (x86_64, aarch64), and Windows (x64), abi3-py310 (one binary per platform covers Python 3.10–3.13).

Usage

import numpy as np
from rotorvec import RotorQuantIndex, IdMapIndex

# Default: Cl(3,0) rotors, 4-bit codes
index = RotorQuantIndex(dim=1536, bits=4)

# Or pick a variant explicitly
planar = RotorQuantIndex(dim=1536, bits=4, rotation="planar2")
iso    = RotorQuantIndex(dim=1536, bits=4, rotation="iso4")

vectors = np.random.randn(10_000, 1536).astype(np.float32)
queries = np.random.randn(8, 1536).astype(np.float32)

index.add(vectors)
scores, indices = index.search(queries, k=10)   # (8, 10) float32 / int64

index.write("index.rv")
loaded = RotorQuantIndex.load("index.rv")

Stable external ids:

ids = np.array([1001, 1002, 1003], dtype=np.uint64)
m = IdMapIndex(dim=1536, bits=4, rotation="planar2")
m.add_with_ids(vectors[:3], ids)
scores, returned_ids = m.search(queries, k=3)   # ids are uint64
m.remove(1002)

Accepted rotation values: "planar2", "rotor3" (default), "iso4" (case-insensitive; aliases "givens", "clifford", "quaternion" also work).

Development

git clone https://github.com/smarthi/rotorvec
cd rotorvec/rotorvec-python
uv venv --python 3.10
uv pip install -e .
uv run pytest tests/

License

MIT — see 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

rotorvec-0.2.1.tar.gz (55.7 kB view details)

Uploaded Source

Built Distributions

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

rotorvec-0.2.1-cp310-abi3-win_amd64.whl (260.3 kB view details)

Uploaded CPython 3.10+Windows x86-64

rotorvec-0.2.1-cp310-abi3-manylinux_2_28_x86_64.whl (403.3 kB view details)

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

rotorvec-0.2.1-cp310-abi3-manylinux_2_28_aarch64.whl (403.4 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

rotorvec-0.2.1-cp310-abi3-macosx_11_0_arm64.whl (362.4 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file rotorvec-0.2.1.tar.gz.

File metadata

  • Download URL: rotorvec-0.2.1.tar.gz
  • Upload date:
  • Size: 55.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rotorvec-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b2691fc80c029536ad69830d873d30974cdd994402d59093b104002240ee7311
MD5 fa94186f7376fdfa43e36ba20779de14
BLAKE2b-256 c1fdc6a4ad4dabc40b892851994612c84f25d5381470e2ac6a60ba74bfe1db05

See more details on using hashes here.

Provenance

The following attestation bundles were made for rotorvec-0.2.1.tar.gz:

Publisher: release-pypi.yml on smarthi/rotorvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rotorvec-0.2.1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: rotorvec-0.2.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 260.3 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rotorvec-0.2.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a26783be41df86d659a60a4ed58c73efd01fa522e586486b1287563433795798
MD5 fd9903d8d3417824b292f19d92e7776a
BLAKE2b-256 01f336b5cfe6204c566072b637a2115e0e0ab7c49f18a3900c93c6ade2a86d3a

See more details on using hashes here.

Provenance

The following attestation bundles were made for rotorvec-0.2.1-cp310-abi3-win_amd64.whl:

Publisher: release-pypi.yml on smarthi/rotorvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rotorvec-0.2.1-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rotorvec-0.2.1-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 74bf2d73bbb43d7e6c8e066405c5f32b7730a53b70c13588491f0d019250da85
MD5 5386ceb82e9f1d9b235bfa1c1acfc988
BLAKE2b-256 b9c99c833a61ab5a453f973164cc558986f57784ff82d2e39ac4860bd883e33d

See more details on using hashes here.

Provenance

The following attestation bundles were made for rotorvec-0.2.1-cp310-abi3-manylinux_2_28_x86_64.whl:

Publisher: release-pypi.yml on smarthi/rotorvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rotorvec-0.2.1-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rotorvec-0.2.1-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 21913b6f4265461a5e31a732874eabf27fe44b4303aeb6d85b902c29dc3a73f3
MD5 00b66122f48fec7a1035c8446d42efeb
BLAKE2b-256 dae1c9b469bd6541c9f22ba3754deda70acdb85dc109b1b2436b4d174fe18af1

See more details on using hashes here.

Provenance

The following attestation bundles were made for rotorvec-0.2.1-cp310-abi3-manylinux_2_28_aarch64.whl:

Publisher: release-pypi.yml on smarthi/rotorvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rotorvec-0.2.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rotorvec-0.2.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f8bcb4b3d2c202af72ce8c26e416acefa491f92956d9a78b8941a5a1080975a0
MD5 91be8ea8272efc1b12b5b431b1f5bc88
BLAKE2b-256 20e5f6758f606f792ef2cbe7d1aa889cb9304251e3ae1fcb95eca678d45ceb35

See more details on using hashes here.

Provenance

The following attestation bundles were made for rotorvec-0.2.1-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release-pypi.yml on smarthi/rotorvec

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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