Repository navigation
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
Some initial benchmarks using the datasets from issue #2955. Setup: NVIDIA H100 80GB HBM3, AMD EPYC 7413 (24 cores) In all setups, CAGRA graph bridging pass 1 was sufficient (afterwards only 1 WCC remained). cohere-v4-1024-angular-q8.hdf5
cohere-v4-1024-angular-q200.hdf5
|
9b6cc78 to
8698fe7
Compare
| } | ||
|
|
||
| if constexpr (can_bridge) { | ||
| if (bridge) { |
There was a problem hiding this comment.
Can we use if (bridge && num_components > 1) here, too?
The host path (IVF-PQ/NN-Descent, build_cagra_host_graph_from_knn_params) only calls bridge_components if bridge && num_components > 1. Here, the iterative CAGRA build calls bridge_components independent of num_components. We could also skip bridge_components in the iterative CAGRA build when WCC = 1.
In search_and_optimize, the return value of graph::optimize is discarded (which is num_components already). We could pass it out of search_and_optimize and use it in the iterative build for the check, to be consistent with the IVF-PQ/NN-Descent path.
| constexpr bool can_bridge = std::is_same_v<IdxT, uint32_t> && | ||
| !cuvs::neighbors::is_device_vpq_f16_dataset_view_v<DatasetViewT>; |
There was a problem hiding this comment.
| constexpr bool can_bridge = std::is_same_v<IdxT, uint32_t> && | |
| !cuvs::neighbors::is_device_vpq_f16_dataset_view_v<DatasetViewT>; | |
| constexpr bool is_vpq = cuvs::neighbors::is_device_vpq_f16_dataset_view_v<DatasetViewT>; | |
| constexpr bool can_bridge = std::is_same_v<IdxT, uint32_t> && !is_vpq; |
Bridging isn't supported for VPQ yet, so a VPQ build with guarantee_connectivity = false can still end up disconnected. I'd add a warning when the final graph has WCC > 1 (see further down).
| dev_dataset.extent(1), | ||
| dev_graph.view()); | ||
| } | ||
| } |
There was a problem hiding this comment.
| } | |
| } else if constexpr (is_vpq) { | |
| if (helpers::bridge_enabled() && !params.guarantee_connectivity && num_components > 1) { | |
| RAFT_LOG_WARN( | |
| "CAGRA graph bridging is not supported for VPQ datasets, so the graph keeps its %lu weakly " | |
| "connected components. Set guarantee_connectivity = true to connect it with the MST.", | |
| num_components); | |
| } | |
| } |
In case you decide to remove the MST path, please remove !params.guarantee_connectivity from the condition and the warning comment.
| cagra::detail::graph::optimize_device_graph(handle, | ||
| merged_graph.view(), | ||
| optimized_graph.view(), | ||
| params.guarantee_connectivity && !bridge); |
There was a problem hiding this comment.
| params.guarantee_connectivity && !bridge); | |
| params.guarantee_connectivity && !bridge); | |
| merged_graph = raft::make_device_matrix<uint32_t, int64_t>(handle, 0, 0); |
This frees the merged kNN graph earlier, since it is not used afterwards. Otherwise it would stay allocated until the function returns, so it would still use GPU memory during bridge_components, which allocates its own temporary buffers.
| @@ -962,6 +966,16 @@ auto iterative_build_graph(raft::resources const& res, | |||
| curr_graph_size = next_graph_size; | |||
| } | |||
There was a problem hiding this comment.
| } | |
| } | |
| dev_knn_graph = | |
| raft::make_device_mdarray<IdxT, int64_t>(res, large_mr, raft::make_extents<int64_t>(0, 0)); |
This frees the kNN graph buffer after the last iteration. Only the search iterations use it. Without this line, it stays allocated during bridge_components.
|
Maybe another thing to mention: I know it's not decided yet how to handle
|
| const uint64_t i = threadIdx.x + static_cast<uint64_t>(blockDim.x) * blockIdx.x; | ||
| if (i >= n) { return; } | ||
| const uint32_t root = labels[i]; | ||
| const uint32_t rate = max(ratio, raft::ceildiv(sizes[root], cap)); |
There was a problem hiding this comment.
I was thinking about this line: it caps the number of nodes per component used for bridging at approx. 128. It does not grow with the component size. Is 128 big enough for common problems and is this scalable?
E.g., if the disconnected components are much larger than 128 nodes, there may be few or no bridges near the component boundaries, which can make the graph less navigable.
Before this change, a disconnected CAGRA graph was either left alone or, with guarantee_connectivity, patched by an MST step whose links ignore where the vectors are. (see #2955)
Now, whenever the check in optimize() finds more than one weakly connected component, the build calls bridge_components() with the dataset. It adds two-way links between nearest neighbours across components, gives in-edges to nodes that have none, and finishes with an exact fallback that guarantees one weak component.
CC @tfeher