Skip to content

Parallel bkt build#443

Merged
MaggieQi merged 2 commits into
microsoft:parallel-bkt-buildfrom
MaggieQi:parallel-bkt-build
Mar 18, 2026
Merged

Parallel bkt build#443
MaggieQi merged 2 commits into
microsoft:parallel-bkt-buildfrom
MaggieQi:parallel-bkt-build

Conversation

@MaggieQi

Copy link
Copy Markdown
Member

No description provided.

xufyan and others added 2 commits March 10, 2026 23:02
Add BuildTreesParallel() method to BKTree that parallelizes tree construction
using a level-order (BFS) approach instead of the existing depth-first recursive
method. At each level of the tree, all sibling nodes are processed in parallel
using OpenMP, with each thread running independent k-means clustering. The tree
structure is then assembled sequentially to maintain correctness.

This is controlled by a new ParallelBKTBuild parameter (default: false) that
can be enabled in both BKT index and SPANN select-head configurations.

Benchmark on SIFT 50M (128-dim, L2) with 32 threads on Azure L32s_v2:
- Select Head (BKT build): 16.6 hours -> 1.2 hours (13.6x speedup)
- Build Head graph (RefineGraph): unchanged (~10 hours, memory-bound)
- Total end-to-end build: ~30 hours -> ~15 hours
- Recall@1: 91% -> 94% (slight improvement)
- Query latency: comparable (P50 ~40ms)
@MaggieQi MaggieQi merged commit 498006e into microsoft:parallel-bkt-build Mar 18, 2026
2 checks passed
zqxjjj pushed a commit that referenced this pull request Apr 2, 2026
* Add parallel BKT tree build support via level-order BFS with OpenMP

Add BuildTreesParallel() method to BKTree that parallelizes tree construction
using a level-order (BFS) approach instead of the existing depth-first recursive
method. At each level of the tree, all sibling nodes are processed in parallel
using OpenMP, with each thread running independent k-means clustering. The tree
structure is then assembled sequentially to maintain correctness.

This is controlled by a new ParallelBKTBuild parameter (default: false) that
can be enabled in both BKT index and SPANN select-head configurations.

Benchmark on SIFT 50M (128-dim, L2) with 32 threads on Azure L32s_v2:
- Select Head (BKT build): 16.6 hours -> 1.2 hours (13.6x speedup)
- Build Head graph (RefineGraph): unchanged (~10 hours, memory-bound)
- Total end-to-end build: ~30 hours -> ~15 hours
- Recall@1: 91% -> 94% (slight improvement)
- Query latency: comparable (P50 ~40ms)

* change omp to std:::thread

---------

Co-authored-by: xufyan <nickyoung.fdu@gmail.com>
Co-authored-by: Qi Chen <cheqi@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants