Repository navigation
Add GPU graph building for bbq_hnsw - #163642
Conversation
Build the HNSW graph for bbq_hnsw fields on GPU, while keeping the on-disk format identical to ES93HnswBinaryQuantizedVectorsFormat. The new ES97GpuHnswBBQVectorsFormat reuses the ES93 format name, so segments written on GPU nodes are read and merged by the CPU format on nodes without a GPU. 1-bit codes with per-vector corrections can't be used as a CAGRA dataset, so the graph is built from the raw float32 vectors, both on flush and on merge (from the merged raw vector slice). Also export the es93 codec package unqualified (qualified exports don't work for library modules) and add m(), efConstruction() and onDiskRescore() accessors to BBQHnswIndexOptions. KnnIndexTester now accepts quantize_bits=1 for gpu_hnsw, using ES97GpuHnswBBQVectorsFormat. Relates elastic#161567
|
Hi @mayya-sharipova, I've created a changelog YAML for you. |
🔍 Preview links for changed docs |
✅ Elastic Docs Style Checker (Vale)No issues found on modified lines! The Vale linter checks documentation changes against the Elastic Docs style guide. To use Vale locally or report issues, refer to Elastic style guide for Vale. |
ℹ️ Important: Docs version tagging👋 Thanks for updating the docs! Elastic docs cover multiple versions and deployment types on the same page. Need help with
The automated docs review also checks for tagging issues on your PR, where enabled. |
Benchmarks: GPU graph building for float32 vs int8 vs bbqRan with GPU: NVIDIA GeForce RTX 4060, 8 GB memory Settings: m=16, ef_construction=200, 8 indexing threads, force-merged (1 segment); search on CPU with k=10, num_candidates=1000, 1 search thread, 1000 queries.
quora-E5-small: 522,931 docs, 384 dims, dot_product
gist-1M: 1,000,000 docs, 960 dims, euclidean
wiki-cohere: 934,024 docs, 768 dims, cosine
hotpotqa-arctic: 5,233,329 docs, 768 dims, dot_product
Observations
|
Benchmarks: dbpedia-openai (3072 dims)Same setup as above: No force merge for this dataset: at 3072 dims, large merges (~390K+ vectors) fail on this 8 GB GPU with dbpedia-openai: 999,000 docs, 3072 dims, cosine
Observations
|
Benchmarks: bbq GPU-built vs CPU-built indicesSame setup as above:
Both write the same on-disk format. All runs: bbq (1 bit), m=16, ef_construction=200, 8 indexing threads; search on CPU with k=10, num_candidates=1000, 1 search thread, 1000 queries; without rescoring and with 3x oversampling + rescoring. dbpedia was run without force merge (see the previous comment). Build timeBuild time = index time + force merge time.
quora-E5-small: 522,931 docs, 384 dims, dot_product
gist-1M: 1,000,000 docs, 960 dims, euclidean
wiki-cohere: 934,024 docs, 768 dims, cosine
hotpotqa-arctic: 5,233,329 docs, 768 dims, dot_product
dbpedia-openai: 999,000 docs, 3072 dims, cosine (no force merge)
Observations
|
Mark GPU bbq_hnsw support as GA in 9.7 in the node settings docs, simplify the raw float comments in the GPU writer, and remove redundant comments from the es93 module export and the GPU tests.
|
Pinging @elastic/es-search-relevance (Team:Search Relevance) |
| * `false` - GPU will not be used for vector indexing. | ||
|
|
||
| GPU indexing is supported for `hnsw` and `int8_hnsw` index types with `float` element type only. | ||
| GPU indexing is supported for `hnsw`, `int8_hnsw` and {applies_to}`stack: ga 9.7` `bbq_hnsw` index types with `float` element type only. |
There was a problem hiding this comment.
Does this whole section sit under 9.3 preview? (from above - {applies_to} stack: preview 9.3 )
There was a problem hiding this comment.
@ChrisHegarty should we remove preview from 9.3? and just say ?
stack: 9.3
There was a problem hiding this comment.
is it still in preview? if it moved to ga we should have the preview and ga info in the same segment. if it was ga in 9.3 it can be updated to ga 9.3
stack: preview 9.3, ga 9.4
There was a problem hiding this comment.
@shainaraskas Thanks, it should be GA in 9.4, fixed in 58f53b2
|
This is great @mayya-sharipova. I left a few questions/comments. Question on merge failures (since I don't remember): the dbpedia 3072-dim benchmark shows merges failing with limiting_resource_adaptor: Exceeded memory limit. mergeOneField wraps that in an IOException and has no CPU fallback, unlike flush, which uses tryAcquire. What happens to the shard when that merge fails in a real node? Does it fail the engine or just skip the merge? |
…ings.md Co-authored-by: shainaraskas <58563081+shainaraskas@users.noreply.github.com>
With on_disk_merge, the bbq flat format wrote the merged raw vectors with direct I/O. The GPU writer reads them straight back (mmapped) to build the graph, so that read was cold and refilled the page cache. Decline direct I/O merge writes for GPU bbq_hnsw, as plain HNSW does, while keeping direct I/O for searches (on_disk_rescore) and for merge reads of the source segments. Add a DirectIOCapableFlatVectorsFormatTests case for the buffered bbq flat format, and explain in the GPU writer why the merge still takes the mmap fast path with the on_disk options.
Pass on_disk_rescore and on_disk_merge to the GPU bbq_hnsw format, which was always built with both disabled, so checkVec can exercise direct I/O on search and merge for gpu_hnsw with 1 bit quantization.
Benchmarks: GPU bbq with the CPU graph threshold for tiny segmentsRe-ran the GPU builds from the previous comment after 3dce311, which makes Same setup:
Build timeBuild time = index time + force merge time.
Index and force merge time
Observations
|
|
@ChrisHegarty Thanks for the review. Great feedback. I've tried to address it.
It fails the engine, not just the merge: the IOException from mergeOneField reaches ThreadPoolMergeScheduler.doMerge, which calls handleMergeException, and InternalEngine.mergeException then calls failEngine("merge failed", ...). I reproduced this with Note that this time the OOM came from CUDA itself, not from our Log output and stack traceI've created a item to address this before as a part of releasing bbq_hnsw. |
ldematte
left a comment
There was a problem hiding this comment.
It turned out to be more work than I thought, but I can see it's mostly wiring. I like the improvements to the existing codecs too!
LGTM
|
GPu tests keep failing even after I tried multiple times with : six checkPart1–6 / gpu-tests jobs were canceled after 5 failed attempts to get an agent: InsufficientInstanceCapacity ... g6.8xlarge ... (us-west-2c). I have to remove |
Resolve conflicts between the direct I/O rework on lucene_snapshot (#161210, #161495, #163409), which moved the direct I/O decision from the vector formats into FsDirectoryFactory, and main's GPU bbq_hnsw graph building (#163642) and confined temp-file arenas (#164482). ES97GpuHnswBBQVectorsFormat drops its useDirectIO/onDiskMerge arguments like the other formats and uses the plain ES93BinaryQuantizedVectorsFormat. Main's withBufferedMergeWrites, which kept GPU merge writes of the raw vectors in the page cache with on_disk_merge, has no counterpart here yet; a TODO marks it to revisit.
Addresses #161567 (Stage 1):
Builds the HNSW graph for
bbq_hnswfields on GPU:vectors are binary quantized on CPU
CAGRA graph is built on GPU from the raw float32 vectors (both on flush and merge)
on-disk format is identical to
ES93HnswBinaryQuantizedVectorsFormatCost: the GPU receives and holds 32-bit floats instead of 1-bit codes, which is about 32× more dat
Stage 2 of the issue: cuVS BbqQuantizer / CagraIndex.Builder#withBbqDataset (Add support for BBQ compressed datasets in NN-Descent and CAGRA NVIDIA/cuvs#2654) would let the GPU work on the bit codes directly and remove this limitation.