pylance-cuvs provides cuVS-backed IVF_PQ training and artifact building for
Lance datasets.
It covers one narrow part of the indexing pipeline:
- Train an IVF_PQ model with cuVS.
- Build a partition-local artifact from a Lance dataset.
- Pass the training output and artifact back to Lance for finalization.
It does not create or register a Lance index on your behalf.
- Linux
- Python 3.12+
- CUDA 12 runtime available on the machine
- cuVS runtime
libcuvs-cu12==26.2.0 - A matching backend package:
pylance-cuvs-cu12 - A Lance build that includes the vector-build APIs used by this project
Install the loader, the matching backend package, and the cuVS runtime into the same Python environment:
pylance-cuvspylance-cuvs-cu12libcuvs-cu12==26.2.0
If you are working from this repository, the shortest local setup is:
just sync-dev
just backend-developThe loader chooses the backend from the installed cuVS runtime package. You can override detection when needed:
export LANCE_CUVS_BACKEND=cu12Legacy overrides such as cuvs-26-02 are still accepted for compatibility.
from pathlib import Path
import lance
import lance_cuvs
import pyarrow as pa
def vector_array(rows: int, dim: int) -> pa.FixedSizeListArray:
values = pa.array(
[row + axis / 100.0 for row in range(rows) for axis in range(dim)],
type=pa.float32(),
)
return pa.FixedSizeListArray.from_arrays(values, dim)
dataset_uri = Path("/tmp/example.lance")
artifact_uri = Path("/tmp/example-artifact")
table = pa.table({"vector": vector_array(rows=4096, dim=16)})
lance.write_dataset(table, dataset_uri)
training = lance_cuvs.train_ivf_pq(
dataset_uri,
"vector",
metric_type="L2",
num_partitions=8,
num_sub_vectors=4,
sample_rate=4,
max_iters=20,
)
artifact = lance_cuvs.build_ivf_pq_artifact(
dataset_uri,
"vector",
training=training,
artifact_uri=artifact_uri,
)
print(type(training.ivf_centroids()))
print(type(training.pq_codebook()))
print(artifact.artifact_uri)
print(artifact.files)Trains an IVF_PQ model with cuVS and returns IvfPqTrainingOutput.
Key fields and methods:
num_partitionsnum_sub_vectorsnum_bitsmetric_typeivf_centroids()->pyarrow.FixedSizeListArraypq_codebook()->pyarrow.FixedSizeListArray
Builds a partition-local artifact from a Lance dataset and a previously trained
model, then returns IvfPqArtifactOutput.
Key fields:
artifact_urifiles
artifact_uri must resolve to the local filesystem.
Use pylance-cuvs when you want cuVS to do the expensive GPU-side training and
encoding work, but you still want Lance to own index finalization.
Do not expect this package to:
- finalize an index
- register an index in a dataset
- provide a generic Lance wrapper beyond IVF_PQ training and artifact build
List available tasks with:
justRun commands inside the shared development container with:
just container-shellUse --platform linux/amd64 only when you explicitly want to match the
GitHub-hosted runner architecture:
tools/run_in_container.sh --platform linux/amd64 -- bashRun the CI-equivalent CPU build locally with:
just container-python-buildRun the Rust-only build locally with:
just container-rust-buildBuild all release artifacts locally with:
just container-python-releaseCreate the root development environment with:
just sync-devRun loader-only tests with:
just loader-testBuild the root wheel with:
just python-buildBuild the backend wheel with:
just backend-wheelBuild the cu12 backend in-place with:
just backend-developBuild the release distributions with:
just python-releaseRun the Python smoke on a GPU-capable machine with:
just container-gpu-smokepython/lance_cuvs- root loader package
backends/cuvs_26_02- cuVS
26.02source tree for the CUDA 12 backend package
- cuVS
backends/cuvs_26_02/src/backend.rs- Lance-facing orchestration
backends/cuvs_26_02/src/cuda.rs- CUDA / cuVS wrappers and tensor helpers
backends/cuvs_26_02/src/python.rs- PyO3 bindings
Apache License 2.0. See LICENSE.