For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
GitHubCUDA-X
    • Home
    • Installation
  • Getting Started
    • Introduction
    • Integrations
    • Use-cases
  • User Guide
    • API Guide
    • Benchmarking Guide
    • Field Guide
    • References
  • Developer Guide
    • Coding Guidelines
    • Contributing
  • API Reference
    • C API Documentation
    • Cpp API Documentation
    • Python API Documentation
      • Cluster Kmeans
      • Common
      • Distance
      • Neighbors Multi GPU Cagra
      • Neighbors Multi GPU IVF Flat
      • Neighbors Multi GPU IVF PQ
      • Neighbors All Neighbors
      • Neighbors Brute Force
      • Neighbors Cagra
      • Neighbors Filters
      • Neighbors HNSW
      • Neighbors IVF Flat
      • Neighbors IVF PQ
      • Neighbors IVF SQ
      • Neighbors NN Descent
      • Neighbors
      • Neighbors Tiered Index
      • Neighbors Vamana
      • Preprocessing Quantize Binary
      • Preprocessing PCA
      • Preprocessing Quantize PQ
      • Preprocessing Quantize Scalar
    • Java API Documentation
    • Rust API Documentation
    • Go API Documentation
NVIDIANVIDIA
Developer-friendly docs for your API
Privacy Policy | Your Privacy Choices | Terms of Service | Accessibility | Corporate Policies | Product Security | Contact

Copyright © 2026, NVIDIA Corporation.

LogoLogocuVS
GitHubCUDA-X
On this page
  • no_filter
  • from_bitmap
  • from_bitset
  • Prefilter
API ReferencePython API Documentation

Filters

||View as Markdown|
Previous

Neighbors Cagra

Next

Neighbors HNSW

Python module: cuvs.neighbors.filters

no_filter

1def no_filter()

Create a default pre-filter which filters nothing.

from_bitmap

1def from_bitmap(bitmap)

Create a pre-filter from an array with type of uint32.

Parameters

NameTypeDescription
bitmapnumpy.ndarrayAn array with type of uint32 where each bit in the array corresponds to if a sample and query pair is greenlit (not filtered) or filtered. The array is row-major, meaning the bits are ordered by rows first. Each bit in a uint32 element represents a different sample-query pair.

- Bit value of 1: The sample-query pair is greenlit (allowed).
- Bit value of 0: The sample-query pair is filtered.

Returns

NameTypeDescription
filtercuvs.neighbors.filters.PrefilterAn instance of Prefilter that can be used to filter neighbors based on the given bitmap.
resourcescuvs.common.Resources, optional

Examples

1>>> import cupy as cp
2>>> import numpy as np
3>>> from cuvs.neighbors import filters
4>>>
5>>> n_samples = 50000
6>>> n_queries = 1000
7>>>
8>>> n_bitmap = np.ceil(n_samples * n_queries / 32).astype(int)
9>>> bitmap = cp.random.randint(1, 100, size=(n_bitmap,), dtype=cp.uint32)
10>>> prefilter = filters.from_bitmap(bitmap)

from_bitset

1def from_bitset(bitset)

Create a pre-filter from an array with type of uint32.

Parameters

NameTypeDescription
bitsetnumpy.ndarrayAn array with type of uint32 where each bit in the array corresponds to if a sample is greenlit (not filtered) or filtered. Each bit in a uint32 element represents a different sample of the dataset.

- Bit value of 1: The sample is greenlit (allowed).
- Bit value of 0: The sample pair is filtered.

Returns

NameTypeDescription
filtercuvs.neighbors.filters.PrefilterAn instance of Prefilter that can be used to filter neighbors based on the given bitset.
resourcescuvs.common.Resources, optional

Examples

1>>> import cupy as cp
2>>> import numpy as np
3>>> from cuvs.neighbors import filters
4>>>
5>>> n_samples = 50000
6>>> n_queries = 1000
7>>>
8>>> n_bitset = np.ceil(n_samples / 32).astype(int)
9>>> bitset = cp.random.randint(1, 100, size=(n_bitset,), dtype=cp.uint32)
10>>> prefilter = filters.from_bitset(bitset)

Prefilter

1cdef class Prefilter

Constructor

1def __init__(self, cuvsFilter prefilter, parent=None)