arXiv:2610.27306cs.DBOct 2026

Manuscript Offprint

arXiv:2610.27306

SweepANN: A GPU-Accelerated Large-K Approximate Vector Search for Drug Discovery

Zhenyu Zhang, Qi Lin, Nan Zhang, Zhichao Cao

Zhenyu Zhang 1^{1} Qi Lin 1^{1} Nan Zhang 2^{2} Zhichao Cao 1^{1}

1^{1}Arizona State University, Tempe, AZ, USA 2^{2}Independent Researcher

zzhan641@asu.edu qlin36@asu.edu nanzhang1213@gmail.com Zhichao.Cao@asu.edu

Abstract. DrugCLIP places small molecules and protein pockets in one embedding space, turning genome-wide drug discovery into large-K retrieval by vector proximity. A campaign fixes over 20K pockets in advance for one library of over 500M molecules. Each pocket keeps K=500KK = 500K candidates, 0.1% of the collection, versus 100 in ANN benchmarks. Missed hits never get tested, so mean recall must reach 99% relative to exact search. Large answers make IVF probe every list holding a result and graph search track KK or more candidates, so costs grow with KK. On our CPUs and GPUs, neither index family reaches the target without losing most of its edge over scanning.

SweepANN partitions compressed vectors across GPUs and scans each resident partition. One matrix multiplication scores each block for a whole query batch, so each block is read a single time per batch. Several plans perform the K-dependent selection and merging of each query's K answers, each returning an exact top-K under compressed scoring. SweepANN fixes batch size for block reuse and runs the fastest measured plan whose state fits beside the library for the requested K. The window plan retains each query's best K from sampled blocks as its seed. GPUs exchange each seed's minimum score once, and only rows above this cutoff enter fixed-capacity buffers. Overflow triggers exact recomputation, and CUDA Graphs replay the scan on every GPU.

Four NVIDIA RTX PRO 6000 Blackwell GPUs answer all 26,562 pockets with a resident time of about 61 seconds, excluding library loading, and 99.6% mean recall relative to exact FP32 search. Our library follows DrugCLIP's published construction. DrugCLIP reports roughly 24 hours with eight A100 GPUs in its own campaign over its own library. On 500M rows, the window plan runs 1.41× faster than SweepANN's grouped plan, a single selection within the same memory. Across 25M–500M rows and K of 10K–500K, all GPU IVF configurations meeting the recall target take 8.2–24× SweepANN's resident time. Every tested CAGRA configuration misses the target on 25M rows at K≥100KK \geq 100K. The plans serve two public vector datasets and two more embedding models. On DEEP1B's 1B vectors across eight GPUs, the baseline is SweepANN's exact full-score scan of uncompressed FP32 rows. At K=100KK = 100K, the window plan cuts resident time by 5.4× and per-GPU peak memory by 6.0×, losing 1.0 point of mean recall. At K=500KK = 500K, the factors are 3.2× and 5.3× for a 0.7-point loss.

1 Introduction

Vector search is becoming a central operation in drug discovery. A key step searches libraries of billions of molecules for candidates likely to bind a disease-relevant protein. Docking predicts how each molecule fits into the protein's binding site, and evaluating every molecule this way is computationally expensive [18, 28]. Fast learning-based screening therefore ranks the candidates first and selects a smaller pool for downstream evaluation. For example, DrugCLIP maps protein pockets and candidate molecules into a shared embedding space and retrieves promising molecules for each pocket through vector similarity search [15] (Figure 1). Its genome-wide screening campaign searched more than 500M molecular vectors for each of more than 20K pockets [23]. This exhaustive search took about 24 hours on eight A100 GPUs [23, 46]. Target pockets and research priorities change, and every repeated campaign pays this cost again.

Screening also expects more from vector search than approximate nearest-neighbor (ANN) search commonly delivers. Where ANN search usually returns the top K=10K = 10 or 100 most similar vectors per query, screening keeps a broad candidate pool for later docking, rescoring, and clustering. A molecule left out of the pool is never tested, so our workload keeps K=500KK = 500K molecules per pocket, 0.1% of the library, at 99% mean recall or better. The same library serves many campaigns (Section 2.2), and libraries keep growing. ZINC-22 reported over 37B purchasable compounds, over 4.5B of them in ready-to-dock 3D [49]. At a fixed fraction of the library, the answers grow with it.

ANN indexes are the established answer to fast vector search, and for most workloads they are the right one. A graph index such as HNSW or CAGRA, or an inverted-file (IVF) index, visits a small part of the library per query. It answers in milliseconds and is reused across queries [24, 29, 35]. Our measurements confirm these advantages where answers are small. At K=100K = 100, an IVF index reaches 99% recall 16×16\times faster than probing every list (Section 3). The question of this paper is what happens when the answer itself becomes extremely large (i.e., large-K).

Large answers shrink the part of the library that an index can skip. A graph search must hold at least K candidates, and an IVF search must probe enough lists to contain them. At K=100KK = 100K on 10M rows, IVF-Flat at 99% recall is only 3.7×3.7\times faster than probing every list. With

Figure

Figure 1. Vector retrieval in virtual screening. Learned encoders map protein pockets and small molecules into one 768-dimensional embedding space [15, 23], and the molecule vectors are computed once and reused. SweepANN keeps the top K molecules of each pocket query as a candidate pool, which later stages such as docking and rescoring narrow for experimental follow-up. Drawings are schematic.

product quantization, the IVF index misses the target even with every list probed. On 25M rows, no tested CAGRA configuration reaches 99% recall at K=100KK = 100K. Even worse, construction and storage recur with every re-encoded library. The 50M-row HNSW index alone takes two hours to build and 156 GiB to store, and it covers only 10% of our library.

These measurements point to a different design, a GPU scan that scores every row at any K, as DrugCLIP's own campaign did. A scan has full coverage, needs no index, and reads the library in a regular pattern: a batch of queries shares each read of the library through one matrix multiplication. Compressed to INT8, our 500M rows take 387 GB and stay resident within the 408 GB of four GPUs. Scoring the compressed rows is then the only approximation. What grows with the answer is the cost of maintaining it. Consider a scan that merges each block's top K into a running answer. Its batch time more than doubles from K=1KK = 1K to K=500KK = 500K, although it reads and scores the same rows (Section 3.4).

We present SweepANN, a GPU system for large-K approximate vector search with high recall for drug discovery. SweepANN scans the library instead of building an index. It keeps one compressed row partition of the library, a shard, resident in each GPU's memory. Each GPU scores the same batch of pocket queries against every block of its shard with one matrix multiplication per block. SweepANN then merges each pocket's candidates across GPUs into its global top-K answer (Figure 5). At large K, the scan stays fast only if those candidates are cheap to keep in the memory left beside the library. SweepANN has four plans for keeping them (Figure 7). The index measurements of Sections 3 and 5.8 favor a scan at large K. All four plans are SweepANN's designs for that scan, so comparing them isolates the cost of keeping the answers. The baselines are ANN indexes, large-K result collectors, and DrugCLIP's released script.

The plans differ in how often they select and in how much state they keep beside the library. The full-score plan stores every score and selects once, so it is feasible only when the batch's whole score matrix fits. SweepANN's per-tile plan selects after every block, which is slow at large K. Its grouped plan selects once per group of blocks, but its score buffer grows with the group. The window plan instead scores a sample of blocks first and retains each query's top K in that sample as a seed. The seed's lowest score then becomes a cutoff that passes only the later rows that can still enter the answer. All plans return the same top-K of the compressed scores, so they differ only in time and memory. SweepANN first fixes the batch size, which sets how many queries share each block read. It then rules out the plans whose state does not fit beside the library and runs the one measured fastest at the requested K.

Recent large-K systems take other routes. They make an index cheaper at collecting and reranking many candidates [57] or run large-K retrieval inside an OLAP engine [55]. SweepANN instead scores every row and uses the memory left beside the library to select as rarely as that memory allows.

Three ideas make the window plan fit beside the library and run fast. 1) Fused scoring, which also serves the full-score plan, reconstructs compressed values inside the scoring kernel and multiplies them with the pocket batch. It stores no expanded copy of the block, so the resident library leaves room for the per-query candidates (Section 4.2). 2) Selection per window selects once per group of blocks, called a window, instead of after every block. Between selections, it keeps only the rows above the cutoff in a fixed-capacity buffer, and the cutoff is exchanged once across GPUs (Sections 4.3–4.6). 3) Replay captures each GPU's operations in two CUDA Graph segments, one before and one after the cutoff exchange. It replays them for successive query batches, which reduces the CPU work of submitting the scan (Section 4.8).

SweepANN meets the screening target at campaign scale. On four RTX PRO 6000 GPUs, it answers every pocket in about one minute of resident time at 99.63% mean recall against exact FP32 search. Resident time starts from the loaded library and ends with the answers left in GPU memory, global merging included. Four GH200 GPUs complete the same campaign in similar time (Section 5.2). From K=10KK = 10K, SweepANN beats the GPU index baselines at the same 99% target. On 25M to 500M rows, the GPU IVF configurations that reach the target take 8.2–24× SweepANN's resident time. CAGRA, the fastest tested method at K=1KK = 1K on 25M rows, is slower than SweepANN at K=10KK = 10K (Section 5.8). Among SweepANN's own plans at 500M rows, the window plan fits a batch of 64 queries. It delivers 2.51× the throughput of the full-score plan at that plan's best batch size, B=16B = 16. At equal batch, it is 1.10× faster (Section 5.4).

The same plans serve two other embedding models (Section 5.10) and two public vector-search collections (Section 6). On DEEP1B, 1B image descriptors on eight GPUs, the window plan reaches 99.0% and 99.3% mean recall at K=100KK = 100K and 500K. It takes 48 and 96 ms of resident time per batch of 64 queries. That is 5.4 and 3.2 times faster than the full-score plan on the uncompressed FP32 rows, an exact scan. The window plan also needs 6.0 and 5.3 times less peak memory per GPU. On 100M Cohere text embeddings of 1,024 dimensions, the window and full-score plans both exceed 99.5% mean recall at K=100KK = 100K and 500K. With 12.5M rows per GPU, the full-score plan is the faster one, and the plan rule picks it on the calibration queries.

The paper makes three contributions. First, an analysis of large-K batched scans, in which maintaining the answers is the cost that grows with K. It leads to a plan rule that decides by the memory beside the library first and by measured cost second. Second, the window plan. It retains each query's top K rows in a sample as a seed, and the lowest seed score is a cutoff that passes later rows into fixed-capacity buffers. A survivor law sizes these buffers for rows in random order. Our library is shuffled by file, not by row, so it uses an empirical margin instead. A batch that overflows is recomputed exactly, and each GPU replays its scan with fused scoring as CUDA Graphs. At 500M rows on four GPUs, the window plan is 1.41×1.41 \times faster than SweepANN's widest grouped plan in the same memory. Third, an evaluation that shows where indexes miss the recall target or lose their speed advantage at large K, and which plan is fastest in each tested setting. It includes complete 500M-row campaigns on two GPU architectures.

References (39)