leann-backend-flashlib
GPU-accelerated FlashLib IVFFlat
backend for LEANN.
FlashLib is a GPU library of classical ML operators built on Triton / CuteDSL.
Its IVFFlat index runs approximate nearest-neighbor search entirely on CUDA
tensors and, at a fixed (nlist, nprobe), probes the same candidate set as a
reference IVF-Flat (FAISS / cuVS).
Requirements
- A CUDA GPU (required at search time; index building only needs numpy).
pip install flashlibandtorch.
Install
# from a LEANN checkout
uv sync --extra flashlib
# or
pip install leann-backend-flashlib
Usage
from leann import LeannBuilder, LeannSearcher
builder = LeannBuilder(backend_name="flashlib") # nlist=1024, distance_metric="mips"
builder.add_text("LEANN recomputes embeddings to save storage.")
builder.build_index("demo.leann")
searcher = LeannSearcher("demo.leann")
print(searcher.search("How does LEANN save storage?", top_k=3))
Or from the CLI / example apps:
python -m apps.document_rag --query "What are the main techniques LEANN explores?" \
--backend-name flashlib
How it works
FlashLib's IVFFlat has no on-disk format, so this backend persists the raw
float32 vectors (<index>.flashlib.npy) plus an id map (<index>.flashlib_id_map.json)
and rebuilds the GPU index at searcher start-up via IVFFlat(...).fit(db).
FlashLib's only distance metric is squared L2. For mips / cosine the vectors
are L2-normalized at build and query time, on which squared-L2 ranking is
equivalent to inner-product / cosine ranking.
Parameters
| kwarg | default | meaning |
|---|---|---|
nlist |
1024 |
number of IVF partitions (clamped to corpus size) |
distance_metric |
"mips" |
mips, cosine, or l2 |
nprobe (search) |
derived from complexity |
partitions probed per query (recall knob) |
Metadata
Release files for leann-backend-flashlib 0.3.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| leann_backend_flashlib-0.3.9-py3-none-any.whl | Python 3 | none | any | Details for leann_backend_flashlib-0.3.9-py3-none-any.whl |
Release files / leann_backend_flashlib-0.3.9-py3-none-any.whl
| Download URL | leann_backend_flashlib-0.3.9-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d6f410a47a2bae630ff191a0a8ea9dee899903e7d10609e3711c228fb905ac0
|
|
BLAKE2b-256 checksum How to use checksums |
e89e28b5df7cd46466c88bb3d0552d19f86da733bedb1076b89dfaef6923f3f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for leann-backend-flashlib 0.3.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.