AI reviews

Are GPUs Always Faster at Vector Search? A DGX Spark Test

By 李成龙0 viewsSource: Zilliz
Are GPUs Always Faster at Vector Search? A DGX Spark Test

Zilliz tests four indexes on DGX Spark using one million 768-dimensional vectors. At about 99.3% recall, single-query CPU HNSW latency was 6.6 ms versus GPU CAGRA's 7.9 ms; GPU brute force led throughput at batch size 256. Results depend on the stated configuration.

Editorial check (2026-11-25): This is the author's test under a particular DGX Spark setup, index configuration and resource limits. Throughput is measured in query vectors per second, while latency for a 256-vector request means the completion time of the entire batch. The CPU container's available CPU time is equivalent to 12 cores at full utilization. The results do not represent all CPUs, GPUs or end-to-end RAG scenarios. Official Milvus GPU_BRUTE_FORCE documentation | (opens in a new tab)Official Milvus GPU_CAGRA documentation | (opens in a new tab)NVIDIA DGX Spark User Guide (opens in a new tab)

These days, whether you are building agents, RAG or semantic search, GPUs are almost unavoidable across the AI application pipeline: at the front, a GPU runs an embedding model to turn text into vectors; after retrieval in the middle, the results are fed to a large model for GPU inference at the back.

With both ends running on GPUs, people naturally assume that vector search in the middle should use one too. Over time, this becomes an instinctive judgment: GPUs are faster than CPUs at everything, and indexing must be no exception.

But is that actually true?

Recently, on the DGX Spark platform, we compared CPU and GPU brute-force and graph indexes using one million 768-dimensional vectors, under both single-query and batch-query modes. The findings were as follows:

  • Single-query approximate search, at about 99.3% recall: CPU HNSW had lower latency, averaging 6.6 ms per request, versus GPU CAGRA's 7.9 ms.
  • Single-query exact search, at 100% recall: GPU brute-force search took less time per request than CPU FLAT, at 57.5 ms and 102.5 ms, respectively.
  • Batches of 256 queries: GPU brute force had the highest throughput, processing 4,495 query vectors per second with exact results—the highest throughput among the four indexes tested. If the application permits approximate results, GPU CAGRA achieved 1,748 query vectors per second under the same conditions.

Below are my experimental process, our analysis of the reasons behind the performance differences, and our recommended approach to choosing an index.

01

Why a GPU Index Is Not Necessarily Faster

There was an interesting contrast in this test. With one query at a time, the CPU was faster for graph indexes, but the GPU was faster for exhaustive search. Hardware peak performance alone cannot explain this difference; how the index's computational pattern matches the hardware architecture also matters.

1.1 Indexes Differ Dramatically in How They Parallelize

The goal of vector search is to find the TopK most similar vectors in a database. But different indexes execute in entirely different ways, with major differences in how much parallelism they allow and how they call on CPU and GPU resources.

In FLAT brute-force search, a query vector is compared against every vector in the database to calculate distances, and the results are then returned by similarity. Total computation is proportional to the amount of data, but each distance calculation is independent, making this a naturally highly parallel task.

Article illustration

Figure 1. How Flat selects TopK from all vectors in the database

IVF indexes first cluster all database vectors into multiple groups by similarity. At query time, they search only the few clusters closest to the query vector, then calculate distances by brute force within those clusters. Those distance calculations can still be highly parallel, but the total computation is much smaller than FLAT's, so there is less overall room for parallelism.

Graph indexes, including HNSW and CAGRA, search iteratively along the edges connecting the index graph. Each round first calculates distances for a batch of candidate vectors, then uses the results to select the nodes to visit in the next round. The entire process depends heavily on the previous step's output, with a large sequential component. Only the distance calculations within a round can run in parallel, leaving far less overall parallelism than brute-force search.

To summarize: moving from FLAT to IVF to graph indexes progressively reduces total computation, but also progressively reduces the task's natural parallelism.

1.2 Differences Between CPU and GPU Computation

CPUs and GPUs are designed for very different goals. CPUs have fewer cores at high clock speeds and strong branch prediction, making them good at sequential tasks with complex logic and frequent jumps. In search, CPUs execute operations such as iterative traversal and candidate filtering in graph indexes with lower latency.

GPUs, by contrast, have a many-core parallel architecture. Thousands or even tens of thousands of compute units are suited to executing batches of uniform, independent calculations. In search, the huge number of independent distance calculations in brute-force retrieval is just what can fully occupy a GPU's compute capacity.

Article illustration

Figure 2. How CPUs and GPUs perform the same set of vector comparisons

Accordingly, GPUs have an advantage only when the index's computational pattern can make full use of their parallelism.

1.3 Single Queries Versus Batch Queries

Article illustration

Figure 3. Parallel computation in single-query and batch-query modes

NQ denotes the number of query vectors in one request.

The conclusions above concern one query at a time. In an offline setting, if you already have a batch of query vectors, you can submit them together to retrieve TopK for each. That changes the picture.

The key to batch querying is that the queries within a batch are independent, so their entire search processes can execute in parallel. This adds parallelism across queries on top of the parallelism within a single query, greatly increasing the total amount of computation available.

At that point, CPUs have a limited number of cores, and single queries already occupy substantial compute, so batching yields limited throughput gains. GPUs have plenty of cores, and single queries typically cannot use all their capacity. Batch queries fill the remaining resources, so the throughput improvement is markedly greater than on CPUs.

Batch querying has clear boundaries, though. For online real-time requests, waiting to accumulate a batch before searching adds to the user's wait. In real applications, we therefore have to weigh throughput against latency according to business needs.

02

Experimental Validation

Of course, the discussion above is theoretical reasoning. Next, we designed a comparative experiment on DGX Spark (GB10) to examine two questions.

First, at equivalent recall, how large are the performance differences between CPU and GPU indexes under different search algorithms?

Second, how do the extra parallelism from batching and its performance benefits differ for CPUs and GPUs?

To investigate this, we carefully controlled the variables:

Article illustration

  • Independent variables (test variables): index type, with four types; and query vectors per batch, NQ, with two settings: 1 and 256.
  • Controlled variables (fixed conditions): dataset size and dimensionality, distance metric, TopK, concurrency, hardware resource limits—CPU and GPU share 128 GB of physical memory, with the GPU memory-pool limit configured in Milvus—and software versions were all held constant. All indexes were tested at both NQ=1 and NQ=256, with concurrency fixed at 4. Index parameters were kept unchanged to exclude the effect of parameter tuning on the results.
  • Observed metrics: recall, query throughput (QPS) and average request time.

The test environment and configuration were as follows:

Article illustration

Test rules and metric definitions:

  • Each test group was warmed up first to eliminate cold-start effects. Each measured test lasted at least 60 seconds and completed no fewer than 30 successful requests. Three rounds were run and averaged.
  • Recall: using CPU FLAT's exact results as the reference, measure Top100 hit rate over 1,000 queries and take the average.
  • Throughput (QPS): the total number of query vectors processed per second. A fully returned batch of 256 counts as 256 queries.
  • Request latency: the time from the same-machine client issuing a request to receiving the complete results. At NQ=256, this is the total time for the entire batch.

2.2 Test Results

2.2.1 Throughput of Exhaustive Search

Across 1,000 query vectors, both CPU FLAT and GPU brute force retrieved all the exact Top100 results, achieving 100% recall.

Article illustration

Figure 4. Query throughput of CPU FLAT and GPU brute force. Error-bar endpoints show the minimum and maximum across the three rounds.

The GPU already had a clear performance advantage for single queries, and the gap widened further when batch size increased to 256. At NQ=256, CPU FLAT's CPU utilization reached the container's 12-core limit and hit a compute bottleneck, while the GPU could still handle the additional computational load from batching.

2.2.2 Throughput of Graph Indexes

CPU HNSW achieved 99.255% recall at both batch sizes, while GPU CAGRA achieved approximately 99.28% at both. Their retrieved-result proportions were close, allowing their query throughput to be compared.

Article illustration

Figure 5. Query throughput of CPU HNSW and GPU CAGRA. Error-bar endpoints show the minimum and maximum across the three rounds.

CPU HNSW was faster for single queries, whereas GPU CAGRA was faster at 256 queries per batch.

Also at a batch size of 256, GPU brute force processed about 4,495 query vectors per second, above GPU CAGRA's 1,748. Brute-force search has a highly regular computational pattern: once a batch of database vectors has been read, multiple queries in the same batch can reuse it, giving extremely high compute utilization. CAGRA, meanwhile, randomly reads neighboring nodes and filters candidate sets in every iteration, greatly increasing memory-access overhead and branching logic. At the one-million-vector scale in this test, those additional overheads offset the gains from "reducing distance calculations."

2.2.3 Average Request Time

Online scenarios focus more on single-request latency, while batch scenarios focus on whole-batch completion time. The specific figures are below:

Table 3. Average request time (milliseconds)

Article illustration

Note that the time at NQ=256 is the total time for the whole batch request. If an online application accumulates requests into batches, the user's actual wait must also include the time spent forming the batch. Search time alone is not sufficient.

03

Recommendations for Choosing an Index

3.1 Analysis of the Experimental Results

When batch size increased from 1 to 256, GPU query throughput improved more in both comparisons, consistent with the earlier hypothesis. Single-query performance depends on the index. Even with only one query vector, exhaustive search performs one million vector comparisons, so the GPU already benefits from parallel computation. With a graph index, CPU HNSW was faster for single queries.

On this DGX Spark, the CPU time available to the Milvus container was equivalent to 12 fully utilized cores. With 256 query vectors submitted per batch, GPU brute-force throughput was about 68.1 times that of CPU FLAT.

3.2 Application Scenarios and Index Selection

For three of the most common application scenarios, test candidates in the following priority order and then validate them against your own data.

  1. Online single-query search allowing approximate results. Typical scenarios include knowledge-base Q&A, semantic search and online content recommendations. These are latency-sensitive but tolerate some loss of precision. Start by testing CPU HNSW. At the million-vector scale, it has lower single-query latency and does not occupy GPU resources, leaving GPU compute for embedding models or large-model inference. Evaluate the benefits of GPU CAGRA only when CPU resources become a bottleneck.
  2. Online single-query search requiring exact results. Typical scenarios include exact deduplication, high-precision matching in small databases and applications with zero tolerance for missed retrievals. Start with GPU brute force and use CPU FLAT as the baseline. Exact-search computation grows linearly with data volume, making the GPU's parallel advantage more apparent as datasets grow.
  3. Offline large-batch querying. Typical scenarios include nightly batch retrieval, exhaustive similarity calculations and batch feature processing. The query vectors are already available, so throughput takes priority over single-query latency. Start with GPU brute force. In this test, it delivered 100% exact results and the highest throughput of the four index types. If approximate results are acceptable, also test GPU CAGRA to compare the trade-off between precision and throughput.

3.3 Memory and GPU Memory Requirements

First, calculate the size of the vectors themselves. One million 768-dimensional Float32 vectors, at four bytes per dimension, occupy about 3.07 GB in raw form. You also need headroom for the index structure, temporary query workspace and the service itself. Do not size the machine solely by the raw vectors.

On DGX Spark, the CPU and GPU allocate space from the same physical memory. With a graphics card that has dedicated GPU memory, calculate the available GPU memory separately.

If the GPU will also run an embedding model or large model, test the model and retrieval together. They share compute and memory resources. If you already have a GPU, it is worth trying, but what ultimately matters is whether the entire application's response improves. This experiment did not cover models and retrieval running simultaneously.

3.4 Validation in Your Application

Once you have selected candidate indexes and confirmed there is enough memory, validate them using your application's own data and requests.

  • Recall. Use the application's query vectors, TopK and filtering conditions to check whether returned results meet requirements.
  • Request time and query throughput. For individual queries, focus on how long requests wait at peak load and whether they succeed. For batch jobs, also examine whole-batch completion time and the number of query vectors processed per second. If the application needs to accumulate a batch, include that wait too.
  • If both CPU and GPU meet the application's requirements, compare the total cost of the two approaches at actual usage volumes.

Conclusion

This test covered only two GPU index types, GPU_BRUTE_FORCE and GPU_CAGRA. Its main purpose was to challenge the instinctive assumption that "GPUs are faster across the entire pipeline" and provide a basic framework for choosing an index.

Milvus also has GPU index types such as GPU_IVF_FLAT and GPU_IVF_PQ, each suited to different data scales and precision requirements. Real applications also vary enormously in data volume, vector dimensionality, concurrency and recall requirements, so no single conclusion fits every scenario. The most dependable approach is always to test with your own application data.

Over the past seven years, we have accumulated extensive experience deploying Milvus in the community. If you are unsure which index suits a particular scenario, or have test data you would like to discuss, we welcome the conversation.

About the Author

Article illustration

Chenglong Li

Developer Advocate at Zilliz

This article is from Zilliz, by Chenglong Li.

Related topics

After reading

Join the AINRK community

Read how to join the community and connect with people working in AI.

Community information (opens in a new tab)