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.0.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.0-cp310-abi3-win_amd64.whl (259.5 kB view details)

Uploaded CPython 3.10+Windows x86-64

rotorvec-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl (402.4 kB view details)

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

rotorvec-0.1.0-cp310-abi3-manylinux_2_28_aarch64.whl (395.4 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

rotorvec-0.1.0-cp310-abi3-macosx_11_0_arm64.whl (353.3 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: rotorvec-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 1da88ca1461933dff9e037839daf7e3a2bcd597bf8973acb71cc0b5b76ab2882
MD5 e5ca5d3dfa851795db9abca1a1af8026
BLAKE2b-256 e5c1a7e1159e73d4c0279f504a8729001f351c7d35ff12cf8e4f3cfe6b1c1c7d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: rotorvec-0.1.0-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.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f9d0959e4f24727d289e35a0afe6d5658a7e60e70faf941e8ac957695015f03a
MD5 5bd87451dc3f6117b053796a6999aa82
BLAKE2b-256 3d8c52d001126e6237a20ef7ee3c705c70ef73c2d409f2863970a01802f97031

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rotorvec-0.1.0-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 da54256f4fda59757f48d89cd305908528d94d5838c0ed7932b94912f3dc59ce
MD5 de5172ddb10db9410c6e91d5986142bf
BLAKE2b-256 d4d1a7224dd392c101f0e134afc7a6a0605fd091886f9844ed9abad19e7b7780

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rotorvec-0.1.0-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ce0c1a962476cde763a8136e81f9bb05aa2cd5ad5e088ae318f4ee7210e1c86a
MD5 0e101d2d73d54cbe0bc53b131d574b83
BLAKE2b-256 963344246cb8673616bde940a854e7e09fb17390de0bcd93da4d42dc32a6b73c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rotorvec-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 731ab25321963d183d0d98ac131a531622ad339d86e12b1ff3d16e2cc62d988f
MD5 6e7cd34b5a897ff175357780ecc145ca
BLAKE2b-256 2653717b0cd094c671b313a3ce3f14d617abf5f34c60175582ff8784cc26cf8c

See more details on using hashes here.

Provenance

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