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.0.tar.gz (49.4 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.0-cp310-abi3-win_amd64.whl (260.0 kB view details)

Uploaded CPython 3.10+Windows x86-64

rotorvec-0.2.0-cp310-abi3-manylinux_2_28_x86_64.whl (403.0 kB view details)

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

rotorvec-0.2.0-cp310-abi3-manylinux_2_28_aarch64.whl (395.9 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

rotorvec-0.2.0-cp310-abi3-macosx_11_0_arm64.whl (353.8 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: rotorvec-0.2.0.tar.gz
  • Upload date:
  • Size: 49.4 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.0.tar.gz
Algorithm Hash digest
SHA256 abafee9ee63837f4212ac445cdc6d5076b1561b9ace5d3f5cc716c4b372cebf3
MD5 3b3aa9346ce6186a083512e8bf3f9c15
BLAKE2b-256 40e020a88e337f73582992feb06ff09bd7cf0696288252a0e9dbe8dc3d267f8b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: rotorvec-0.2.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 260.0 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.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 497bcdb023b1b55680b6ec7472db8b357cee3619be27e15185e6a977496d6e3b
MD5 0f1b352f79b9047e6d9ed2eb3a57c7e8
BLAKE2b-256 64a40e55f6d76c071a19cd45fc1016ae36ce416dec94c7e2d26f3ccdb916054a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rotorvec-0.2.0-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 db2737891dbdf96c86605858da7fab5306e59087873b9959f36b486f734f4432
MD5 2206a23e24fc77f3f2e96633051977fa
BLAKE2b-256 934ee2982b983a033f4162b42d0a42002c61d6ddeacdb99c356cfd089d2808da

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rotorvec-0.2.0-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 29e657ca18580047d6d14e244527fb475fd422d7a2847f4f2ed1a256305068be
MD5 4cdc91298ca269e52db1a50af0ab2f82
BLAKE2b-256 ce3a1b791da3cf79c6914841c54854b8dfa229b6f459afc89194c22dad256f62

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for rotorvec-0.2.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7dd720e25d5352ae215d097ee1ee5b2ee671ebcc335d1f1fcd4c1810bf69e20e
MD5 2a59088ce5272a399916d84e738bba70
BLAKE2b-256 d00cd59b9416cb9c8430494e58cce32adbf2a26a71eceb73b512aabfc715d23f

See more details on using hashes here.

Provenance

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