fix: prevent HNSW node degree decay across merge generations by adding absolute M-based threshold - #16555
fix: prevent HNSW node degree decay across merge generations by adding absolute M-based threshold#16555waterWang wants to merge 1 commit into
Conversation
…g absolute M-based threshold When IncrementalHnswGraphMerger reuses an existing segment's HNSW graph as the base for a merged segment, a surviving node's neighbor list is copied verbatim minus its deleted neighbors. The node is repaired (searched for replacement neighbors) only if it lost more than 15% of its neighbors in that single merge (DISCONNECTED_NODE_FACTOR = 0.85). The threshold is relative to the node's current (potentially already thinned) degree at the start of each merge, not its target or original degree. Therefore, nodes that lose only a small fraction of their neighbors (<15%) stay above the threshold every time, and are never flagged and repaired, so their degree decays silently across merge generations with no re-diversification. This fix adds an absolute M-based threshold as a second condition: if a node's remaining neighbor count is below M * DISCONNECTED_NODE_FACTOR, it is also flagged for repair regardless of the proportional loss. This prevents the silent progressive decay of connectivity across multiple merge generations. Fixes apache#16552
|
I don't think this will entirely fix #16552, and it would slow merges doing unnecessary work every time: First, it uses
|
|
I do appreciate the problem description, but also the description of the problems with this approach. I do think setting a minimum outdegree floor makes sense, and we should consider allowing it to override the diversification. And we definitely need benchmarks in order to settle on anything. |
Fix
This PR fixes a progressive recall degradation issue in
IncrementalHnswGraphMergerwhen merging HNSW graphs across multiple merge generations.Root Cause
In
InitializedHnswGraphBuilder.copyGraphStructure(), a surviving node's neighbor list is copied verbatim minus its deleted neighbors. The node is flagged for repair only if it lost more than 15% of its neighbors in that single merge (DISCONNECTED_NODE_FACTOR = 0.85).The threshold is relative to the node's current (potentially already thinned) degree at the start of each merge, not its target or original degree. Therefore, nodes that lose only a small fraction of their neighbors (<15%) stay above the threshold every time, and are never flagged and repaired, so their degree decays silently across merge generations with no re-diversification.
Fix
This fix adds an absolute
M-basedthreshold as a second condition: if a node's remaining neighbor count is belowM * DISCONNECTED_NODE_FACTOR, it is also flagged for repair regardless of the proportional loss. This prevents the silent progressive decay of connectivity across multiple merge generations.Changes
lucene/core/src/java/org/apache/lucene/util/hnsw/InitializedHnswGraphBuilder.java: Added absolute M-based threshold incopyGraphStructure()alongside the existing proportional threshold.Related
Fixes #16552