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 with optional Walsh-Hadamard cross-block mixing. Four rotation variants, one API:

  • "planar2" — 2D Givens, O(d), cheapest
  • "rotor3" — Cl(3,0) sandwich, O(d), default
  • "iso4" — quaternion left-iso, O(d)
  • "walshrotor3" ✨ — signed FWHT then Cl(3,0) sandwich, O(d log d). Closes the recall gap on data with strong cross-coordinate correlations (image features, SIFT). Requires dim ∈ {128, 256, 512, 1024, 2048, 4096}.

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. Beats turbovec on SIFT-1M recall (0.496 vs 0.487) at 1.8× faster build time when "walshrotor3" is used.

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")

# Power-of-two dim → use walshrotor3 for the strongest recall
walsh  = RotorQuantIndex(dim=1024, bits=4, rotation="walshrotor3")

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", "walshrotor3" (case-insensitive; aliases "givens", "clifford", "quaternion", "walsh", "walsh-rotor3", "rotor3+walsh" 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.4.tar.gz (58.8 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.4-cp310-abi3-win_amd64.whl (264.1 kB view details)

Uploaded CPython 3.10+Windows x86-64

rotorvec-0.2.4-cp310-abi3-manylinux_2_28_x86_64.whl (407.4 kB view details)

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

rotorvec-0.2.4-cp310-abi3-manylinux_2_28_aarch64.whl (408.3 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

rotorvec-0.2.4-cp310-abi3-macosx_11_0_arm64.whl (368.7 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: rotorvec-0.2.4.tar.gz
  • Upload date:
  • Size: 58.8 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.4.tar.gz
Algorithm Hash digest
SHA256 473780473b3bd88f5882a6fa7b96f54363e0cc3763a3ba358681eb5bb1c4a928
MD5 b8b62ca092c1febbf08dc4c42504b415
BLAKE2b-256 46bb6294e81f119b2725ac14da312237c6eea7a9b5f6dd7410d312c7d01fc011

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: rotorvec-0.2.4-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 264.1 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.4-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 cfabf71fb5e8a551a819ba4e29dba457ee1dad3019b0954194b50691c05cabfc
MD5 b0319fc4a01147851f0a0807891403ed
BLAKE2b-256 ea7edad97abf0e113590f556722b08e8cf289969c150cc63b08829c8af40ae8b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rotorvec-0.2.4-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c2c5bf7f891ced6887156f8c1fd3685ce6cbc62ad29cbb1a65a055ff96aff29f
MD5 8baa8b9a4d3bfe412de8ebb83ec5a18e
BLAKE2b-256 2f3383eb011ed5521795ff49a081941304350cbd3374e87423c39b94b376258d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rotorvec-0.2.4-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 5191957d494fda2a6b12f5bb5a3e1400061cff868dc093c5609f42cac83e43dd
MD5 1e5613956515b6dea5c5f37246afd5be
BLAKE2b-256 b5d89d63bd1f065376df69457ac5db01545c28e1b7de323286cc6470e83c7a2a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rotorvec-0.2.4-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 90446af9af3c57c6abf1ac2be2e5f77670f3565fcaa28f898a2946a3c80ea6ad
MD5 27c7f478cf231887ec5e627b2483a986
BLAKE2b-256 ab3b15bf3485eff2634c07883efddba8b5e741c59bd241684da1e9d86c46df75

See more details on using hashes here.

Provenance

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