How much faster is GPU embedding? Testing offline ingestion and online queries on DGX Spark

A Zilliz author compares CPU FP32, GPU FP32 and GPU BF16 on one DGX Spark using BGE text and CLIP image embeddings. GPUs improve offline batch throughput and online throughput under equal P95 latency budgets. BF16 quality findings apply only to the tested models and datasets.
Editor's introduction:
This is the second article in our VectorDB hardware-selection series.
The previous article focused on retrieval performance after vectors had been ingested, comparing CPU and GPU vector search on NVIDIA DGX Spark. See: Are GPUs always faster than CPUs for vector search? Testing on DGX Spark (opens in a new tab)
In real RAG, knowledge-base, and image-search applications, retrieval is not the beginning of the pipeline. Before that, documents and images to be ingested, as well as users' real-time queries, must first be converted into vectors by embedding models.
This raises new questions:
- For offline ingestion, we care about total processing time for the entire dataset. When dealing with thousands or more documents and images, is GPU batch embedding much faster than CPU embedding?
- For online queries, the service must meet both latency and throughput requirements. Can a GPU handle more embedding requests while satisfying those latency constraints?
To investigate, I used the same DGX Spark machine for text and image embedding tasks, comparing embedding generation speed under three configurations: CPU FP32, GPU FP32, and GPU BF16.
Beyond computing speed, we tested how batch size and online dynamic batching affect performance, and checked BF16 precision's impact on retrieval and classification quality.
The experiment details follow.
01
Experimental design: how to compare CPU and GPU embedding performance fairly
To make the comparison useful, we selected two representative embedding tasks: text and images.
The embedding models were selected as follows:
Text embedding: BGE-base-en-v1.5
The offline test used titles and abstracts of 5,183 papers from SciFact. The online test selected short-text inputs from the dataset's 300 test queries. The model outputs 768-dimensional vectors, with text truncated to a maximum of 512 tokens.
Image embedding: CLIP ViT-B/32
The offline test used 3,925 JPEG images from Imagenette's validation set, while the online test used a single compressed JPEG as input. The model outputs 512-dimensional vectors. Images came from Imagenette 160px v2; during load testing, JPEGs were decoded and preprocessed to the model's 224×224 input size.
Three precision configurations were compared:
- CPU FP32: single-precision floating-point execution on the CPU, serving as the CPU performance baseline.
- GPU FP32: single-precision floating-point execution on the GPU, comparing CPU and GPU at the same precision.
- GPU BF16: 16-bit brain floating-point execution on the GPU, testing performance gains from reduced precision.
To reduce interference from other factors, each configuration ran only one resident model instance. Inference used the same fixed set of 10 CPU cores. Timing began only after model warmup. TF32 was disabled for GPU FP32, and all three configurations ultimately returned normalized FP32 vectors.
BF16 was tested separately because its 16-bit brain floating-point format has a lower bit width than 32-bit FP32, enabling higher computing efficiency on GPUs with the corresponding support. However, reduced precision can cause numerical differences in vectors, so its impact on final retrieval quality must also be checked.
Testing was divided into two parts:
- Offline testing: the caller explicitly constructs batches, comparing single-item computation time and total time to process the full dataset.
- Online testing: each request contains one input, with per-request processing and server-side dynamic batching tested separately.

With this test setup, let us first examine offline-ingestion performance.
02
Offline ingestion tests: how much can a GPU shorten embedding time?
The main goal in offline ingestion is to reduce total embedding time for the full dataset. We begin with single-item computation, then move to batch processing.
2.1 Single-item embedding: GPUs already show a substantial lead
We sampled 300 items from each of the text and image collections, ran five consecutive rounds per configuration, and used serial execution: the next item was processed only after the previous one returned. Latency was measured using P50 (median time) and P95 (95th-percentile time, reflecting tail latency). Results follow:
Single-item embedding latency (P50 / P95, in ms)

For the BGE text model, median CPU FP32 latency per item was about 67ms, falling to just over 10ms with GPU FP32 and further to about 3.5ms with GPU BF16.
For the CLIP image model, median CPU FP32 latency was about 16ms, versus 6.7ms for GPU FP32 and 3.1ms for GPU BF16.
This shows a significant GPU speed advantage even for serial single-item processing.
However, single-item performance does not fully represent actual offline-ingestion efficiency. Building a collection generally uses batch processing, sending multiple items to the model together, which allows GPU parallel computing capacity to be used more fully.
2.2 Batch processing: how batch size affects full-dataset embedding efficiency
Batch size is the number of items processed in one model inference call. Batch size 1 processes items individually; batch size 32 processes 32 items in parallel.
In theory, batching fully exploits GPU parallelism, but larger batches are not always better. Too small a batch underutilizes computing resources, while too large a batch is constrained by GPU memory, input length, preprocessing performance, and other factors. We therefore tested batch sizes of 1, 8, 32, and 64. Each configuration processed the complete dataset in the same order, with three runs per batch size. The fastest batch was selected by median full-dataset time, then independently validated in three more runs. Final timing included the incomplete last batch.
Embedding time for the complete dataset

Note: Image-test timing starts with compressed JPEG data in memory and covers decoding, preprocessing, model inference, data transfers, and vector normalization. It ends when all vectors are readable in CPU memory. Full-dataset tests used four resident preprocessing workers and one model instance. Disk I/O, model loading, vector ingestion into the database, and index construction are excluded.
For text embedding, processing all 5,183 documents took 370.76 seconds on CPU FP32 and 51.33 seconds on GPU FP32, a 7.22× speedup. GPU BF16 reduced this further to 15.68 seconds, a 23.64× speedup over CPU.
For image embedding, processing all 3,925 images took 36.62 seconds on CPU FP32, 5.35 seconds on GPU FP32, and 1.96 seconds on GPU BF16, giving speedups of 6.85× and 18.65×, respectively. GPU BF16 processed about 2,000 images per second.
2.3 Larger batch sizes are not always better
The optimal batch size clearly varies by model and computing configuration.
For example, with CLIP on GPU BF16, increasing the batch from 8 to 32 reduced full-dataset time from 2.57 to 1.99 seconds. Increasing it further to 64 instead raised the time slightly to 2.02 seconds.
For BGE on GPU BF16, batches of 8 and 64 took 15.81 and 15.82 seconds, essentially the same. For BGE on CPU FP32, processing items individually was actually the fastest mode in this test.
Batch size therefore needs empirical tuning for the model, input lengths, hardware environment, and implementation. There is no universally optimal value.
03
Online query tests: how GPUs handle high concurrency
The key difference between online embedding and offline ingestion is how requests arrive. Offline callers can deliberately organize batches; online user requests arrive individually and independently. Later requests often enter the queue while the current one is still being processed. Thus, each request contains one input, but more than one request can be in flight.
Sometimes high QPS comes at the cost of long queues, making it practically worthless for real-time queries. What we need is the highest stable throughput that meets latency constraints.
Online performance therefore cannot be evaluated solely by one embedding computation's duration. Two key metrics matter together:
- P95 latency: the time within which 95% of requests complete, representing the service's latency.
- QPS: the number of requests successfully processed per second, representing the service's throughput.
We set two latency budgets:
- P95 50ms: 95% of requests must complete within 50ms.
- P95 100ms: 95% of requests must complete within 100ms.
Timing starts when the client sends a request and ends when it receives the complete vector, covering queuing, input preprocessing, model inference, and result transmission. Client and server communicate through TCP loopback on the same machine, each using its own separate set of 10 CPU cores.
Note: These latency budgets apply only to the embedding service, not the entire RAG pipeline. Real applications also need time for network transmission, vector retrieval, large-model generation, and other stages.
3.1 Fixed-concurrency tests: determining the service's operating range
Before the formal throughput tests, we first determined the service's operating range using fixed-concurrency tests.
Fixed concurrency means controlling the number of requests being processed simultaneously, adding a new request whenever one completes. We progressively increased in-flight requests, ran each setting for 60 seconds, and repeated it three times, observing throughput and latency trends. For the CPU, text and images met the 50ms latency budget at fixed concurrency of 3 and 2, respectively. Relaxing the budget to 100ms increased the highest tested passing concurrency to 8 and 6.
3.2 Sustained request tests: comparing throughput at equal latency limits
Based on the fixed-concurrency results, we next simulated real, independent request arrivals.
The client sent requests at randomized intervals, with arrival times independent of whether the previous request had returned. Each sending-rate setting ran for five minutes and was repeated three times with different random seeds.
Results were retained only when all the following conditions held:
- P95 latency met the applicable budget in all three runs.
- Both the failure rate and timeout rate were no greater than 0.1% in any individual run.
- The server's processing rate matched the client's sending rate.
- The queue did not accumulate a persistent backlog.
Finally, across per-request processing and dynamic batching, we selected the highest stable throughput achievable by each configuration and took the median of the three runs. Because each request contains one input, QPS here equals vectors generated per second.
The highest passing QPS under P95 budgets of 50ms and 100ms is shown below.

Under the 50ms latency budget, GPU FP32 text throughput was about 16.92 times CPU throughput, and image throughput about 13.21 times. GPU BF16's advantage was larger: text throughput was about 51.31 times CPU throughput and image throughput about 23.83 times.
These results show GPU advantages not only in offline batching but also in the number of real-time online queries handled under the same latency constraints, substantially exceeding CPU capacity.
Note that the substantial increase in GPU online throughput comes not just from its computing capacity but also from server-side request scheduling.
3.3 Online dynamic batching: unleashing GPU parallelism
GPUs excel at batch computation, but online clients submit requests individually. If the server immediately infers each request separately, GPU parallelism is underused and utilization remains low. Dynamic batching is a common solution.
The idea is that the server does not infer immediately when a request arrives. It temporarily queues the request, collects others in a very short window, and combines them into a batch for inference. Once inference finishes, the results are returned to their respective clients.
For BGE text embedding on GPU BF16 with a 50ms latency budget, stable per-request throughput was 316.62 QPS. Enabling dynamic batching with a maximum wait of 3ms and maximum batch size of 16 increased throughput to 2,467.15 QPS.
Dynamic batching raised throughput to 7.8 times the original level. Even the worst P95 across the three runs was only 36.94ms, meeting the 50ms constraint. This is one of the main reasons GPU online throughput improved so substantially.
Dynamic batching does not work in every situation. Waiting to assemble batches consumes part of the latency budget. If arrivals are too sparse, waiting overhead may outweigh the gains from batch computation.
04
Does BF16's speedup reduce vector retrieval quality?
Performance is an important optimization dimension, but accurate vector retrieval is a core business requirement. If faster embedding sacrifices retrieval accuracy, the optimization loses practical value. We therefore compared the vectors generated by the three configurations on text retrieval and image classification tasks.
4.1 Text retrieval: BF16's impact on recall
Text retrieval was tested using SciFact's 300 test queries.
Each configuration generated query and document vectors at its corresponding precision. All searches then used exact FP32 inner products on the CPU, eliminating interference from approximate-index parameters and isolating embedding precision's effect on retrieval quality.
We used two metrics:
- Recall@10: the proportion of a query's labeled relevant documents appearing in the top 10 results, measuring recall.
- nDCG@10: considers both retrieval of relevant documents and their ranked positions, measuring ranking quality.

All three configurations achieved identical Recall@10. BF16's nDCG@10 did not decrease and was slightly higher than the other two. In this SciFact text-retrieval test, therefore, BF16 caused no loss of recall quality.
4.2 Image classification: BF16's impact on image-text matching
Image classification was tested on Imagenette's 3,925 validation images.
We fixed the 10 class-text vectors generated on CPU FP32 and generated image vectors under each of the three configurations. We calculated each image's similarity to the class vectors and predicted the class with the highest similarity, evaluating performance with Top-1 accuracy.

Classification accuracy was essentially identical across the three configurations; BF16 correctly classified only one more image than the other two.
Taken together, the two tests show that BF16 vectors differ numerically from FP32 vectors, but no degradation in downstream metrics was observed for the models, datasets, and tasks in this experiment.
(This does not mean BF16 preserves quality for every model and business dataset. For applications requiring high retrieval accuracy, we recommend controlled comparisons using your own data and real retrieval tasks.)
05
Conclusions: choosing hardware for embedding
The tests support three conclusions:
- For offline batch ingestion, GPUs can substantially reduce embedding time. In these tests, full-dataset processing was about 7 times as fast on GPU FP32 as on CPU, and about 18–24 times as fast on GPU BF16.
- For real-time online queries, GPUs can handle higher request volumes. Under the same P95 latency constraint, GPU BF16's text and image service throughput was substantially higher than CPU throughput.
- BF16 precision did not reduce vector quality in these tests. Neither SciFact text retrieval nor Imagenette image classification metrics declined.
For practical deployment:
For high-concurrency online embedding services, we recommend GPUs with dynamic batching. Compared with individual inference, batching combines multiple users' requests for parallel computation, substantially improving GPU utilization. Tune maximum batch size and batching wait time to actual traffic density and latency budgets, balancing throughput against latency.
For low-concurrency, low-traffic online services, a CPU may already meet latency and throughput requirements. GPU deployment need not be mandatory. First test CPU capacity against real request volumes, then assess whether a hardware upgrade is necessary.
For applications requiring high retrieval quality, first establish an FP32 quality baseline, then compare BF16 as an optimization. Validation should focus not just on numerical vector differences but on final Recall@K, ranking quality, and recall on real queries.
About the author

Li Chenglong
Developer Advocate at Zilliz
Article from "Zilliz," by "Li Chenglong".
Related topics
After reading
Join the AINRK community
Read how to join the community and connect with people working in AI.




