Skip to contents

Exact CPU search scans all reference blocks for each query block. method = "hnsw_sharded" builds one persistent faissR CPU HNSW index per reference shard, searches all query blocks against it, and merges candidates into the file-backed output. It is approximate; its target recall is not measured unless audit_rows is positive. Multiple shard passes can be I/O-heavy. Checkpointed HNSW builds each shard with n.cores threads and saves its native faissR index until that shard is complete. Resume checks the index file hash and a fixed search probe before reusing it. The result records build threads in hnsw_settings and the time to reload an index in index_load_seconds. CUDA method = "exact" on one device builds one persistent faissR GPU Flat index per reference shard and reuses it across all query blocks. Multiple CUDA devices build sharded Flat indexes for each query block. CUDA method = "ivf_sharded" uses a persistent faissR GPU IVF-Flat index within each shard on one device. It remains approximate across shards; request audit_rows to measure sampled full-graph ID recall. Each shard pilot compares up to 256 fixed query rows with a faissR CPU Flat reference and gates distance and minimum row ID recall. It does not guarantee untouched rows. CUDA search never falls back. Metal exact search reads each reference shard once into Metal shared memory and searches it against successive float32 query blocks. It merges global IDs into the same file-backed graph. Metal method = "metal_ivf" reads a float32 file once and builds a transient native IVF index when conservative RAM and Metal budgets fit. It fails rather than switching algorithms if the budget or pilot misses.

Usage

massive_full_knn_graph(
  x,
  k,
  output,
  backend = "cpu",
  n.cores = 1L,
  chunk_rows = NULL,
  reference_chunk_rows = NULL,
  memory_limit = fastembedr_memory_option(),
  checkpoint = FALSE,
  resume = FALSE,
  method = c("exact", "metal_ivf", "hnsw_sharded", "ivf_sharded", "coarse_postings"),
  audit_rows = 0L,
  checkpoint_every = 100L,
  postings = NULL,
  centers = NULL,
  nprobe = NULL,
  query_order = c("original", "posting"),
  ef_search = 0L,
  hnsw_build = NULL,
  devices = NULL,
  target_recall = NULL
)

Arguments

x

A massive_matrix() descriptor.

k

Number of non-self neighbors, at most 65,536.

output

New prefix for graph files.

backend

"cpu", "cuda", or "metal". Metal supports exact shards or capacity-checked IVF and never falls back to CPU.

n.cores

CPU workers for each query block.

chunk_rows

Maximum query rows per block; reduced if needed to respect memory_limit. Posting search defaults to at most 65,536 rows per block to reduce repeated posting scans.

reference_chunk_rows

Maximum reference rows per block. For sharded CPU HNSW or CUDA exact/IVF search, the requested maximum resident index-shard size.

memory_limit

Conservative RAM budget. For CUDA sharded search, estimated VRAM is also capped at 70% of this limit and 65% of free VRAM.

checkpoint

Save completed query blocks, including sharded search. Multi-GPU IVF checkpoints completed GPU query shards only.

resume

Continue a matching checkpoint and partial graph. An interrupted multi-GPU IVF shard restarts from its first query row.

method

"exact", "metal_ivf", "hnsw_sharded", "ivf_sharded", or "coarse_postings". The posting route requires the original file-backed source, postings, and matching centers.

audit_rows

Query rows to compare with streamed exact search (maximum 10,000). Posting search also samples small posting lists and distant-from-center rows; other methods use evenly spaced rows. Multi-GPU IVF excludes each device's first tuning query batch and samples only untouched rows. Defaults to zero. Reported recall covers only sampled rows, not the full graph. Strict ID sample_target_met requires every sampled row to meet the selected tier. distance_equivalent_recall also accepts exact kth-distance ties; the CUDA IVF pilot additionally gates strict IDs.

checkpoint_every

Commit every this many query blocks. A shard boundary is always committed. Defaults to 100.

postings

Physical posting descriptor for "coarse_postings".

centers

Centers used to construct postings.

nprobe

Posting lists examined per row; defaults to at most eight.

query_order

For posting search, "original" retains source-row order; "posting" scans grouped posting rows and externally restores original graph order with bounded memory and additional disk space.

CPU HNSW search effort per shard. Zero starts from the shape-based setting and increases effort until a separate, full-reference pilot meets the selected recall guard. A positive value is checked by that pilot and must be at least k + 1; it cannot exceed the smallest reference shard. Other methods reject it.

hnsw_build

Optional named list with m and ef_construction for an explicitly calibrated CPU HNSW build. NULL uses faissR's shape-based build policy. Other methods and backends reject this setting.

devices

Optional CUDA device indices. Two or more devices require exact or IVF sharded search and a file-backed source. CPU and Metal requests fail explicitly; the graph is never moved to another route.

target_recall

Requested recall tier (0.9, 0.95, or 0.99). Exact CPU, CUDA, and Metal search are unchanged by the tier and remain exact by construction. CPU HNSW and CUDA IVF use the tier in sampled pilots. Other file-backed routes currently require 0.99.

Value

A validated fastEmbedR_massive_graph descriptor.