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.1.1.tar.gz (35.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.1.1-cp310-abi3-win_amd64.whl (259.5 kB view details)

Uploaded CPython 3.10+Windows x86-64

rotorvec-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl (402.5 kB view details)

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

rotorvec-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl (395.5 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

rotorvec-0.1.1-cp310-abi3-macosx_11_0_arm64.whl (353.4 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: rotorvec-0.1.1.tar.gz
  • Upload date:
  • Size: 35.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.1.1.tar.gz
Algorithm Hash digest
SHA256 2367254ce8c24bcab8779fabca33ad87e1729d502c379c0851d4005a446ccac0
MD5 a678f34dc868078688f269d70b8d0927
BLAKE2b-256 74b61c8d60f4375b99731f27f000b5d176a38c6989a317f2f0d7cafd02281200

See more details on using hashes here.

Provenance

The following attestation bundles were made for rotorvec-0.1.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.1.1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: rotorvec-0.1.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 259.5 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.1.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c262ca0cef8a2354a9fc1c464ed21da1d421231411089faef0dd3cfb72d13dd8
MD5 deb3a3161b874be5f5805ac0e267affa
BLAKE2b-256 362ce56081e7c8b0a6fff0b201018a332d45f1a6113675c1ffd23b98ea56b7e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for rotorvec-0.1.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.1.1-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rotorvec-0.1.1-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2b54b510e481736fe0e7544a8fd1f62f7a8a55cf525995fe479e3c8172331b77
MD5 3a1e2fe80a37e7f76f7f31aa97338ad6
BLAKE2b-256 14a840d0b59e97c5c6f2c4e7abb946ced0951cef814cc620daa8f8d62cd291d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for rotorvec-0.1.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.1.1-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rotorvec-0.1.1-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 129d2b5f09bd3ec583193e7dc8e69a502fc91a0728b3d16ee65bfb8c1d8852a2
MD5 d51ac41a4266de35a5e66f04edc37462
BLAKE2b-256 9be6a3341f97f259248a79e306a29e6c705e88152443f2b87ad4f131d6336bfc

See more details on using hashes here.

Provenance

The following attestation bundles were made for rotorvec-0.1.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.1.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rotorvec-0.1.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b6e5d16ad6015216ad256b59acbcf3f680dfae0dfac49664d429447df4228a90
MD5 e2ab542c434feb9b46bd59b9ff0c2094
BLAKE2b-256 fed51749b9db0b9abb8d4f41818349a1c409f06c119afb942bffe25631a3acac

See more details on using hashes here.

Provenance

The following attestation bundles were made for rotorvec-0.1.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