Commit ea98506
authored
CAGRA: decouple source idx type from graph idx type and add a mapping between them (#1251)
Add a mapping from internal graph index type to the source (user) index type for CAGRA index.
This PR contains a minimal set of changes required to decouple the graph index type from the public API index type:
- Add the mapping - a device vector of `n_rows` elements storing the original indices (which are provided by the user)
- Add corresponding setters/getters and update the serialization code
- Modify all search kernels accordingly: (1) using the map before coercing the output to `OutputIdxT` and (2) using the map every time the filter operator is used (so that the filtering happens on "user-space" indices rather than on internal indices).
In the detail namespace, I add a new template parameter `SourceIdxT` , which doesn't currently multiply the template instantiations. `SourceIdxT` is bound directly to IdxT in `index<T, IdxT>`, whereas the `IndexT` in the detail namespace becomes hard-coded to `graph_idx_t`, which is `uint32_t`.
***What's not here***
This PR does not modify the order of the graph or the dataset during construction. Hence to test this feature now, a user needs to reorder both the dataset and the graph manually using the `update_xxx` methods of the CAGRA index.
***IVF-XX Feature parity***
With the addition of the index mapping, it will be possible to add the indices argument to the `extend` function similar to the other algorithms.
***Multi-vector index***
(related issue #1191)
This PR can be seen as a prerequisite for <single_id - multiple_vectors> mapping: since the ids in the source_indicies vector are not necessarily unique. To actually allow multi-vector usage in a meaningful way, we also need to:
- De-duplicate the indices in the search results
- Extend the public API - how do add new vectors and indices alongside them, and where/how to keep the dataset.
Authors:
- Artem M. Chirkin (https://github.com/achirkin)
- Corey J. Nolet (https://github.com/cjnolet)
- Ben Frederickson (https://github.com/benfred)
Approvers:
- Divye Gala (https://github.com/divyegala)
- Ben Frederickson (https://github.com/benfred)
URL: #12511 parent 2415c82 commit ea98506
15 files changed
Lines changed: 1174 additions & 885 deletions
File tree
- cpp
- include/cuvs/neighbors
- src/neighbors/detail/cagra
- tests/neighbors
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
| 294 | + | |
294 | 295 | | |
295 | 296 | | |
296 | 297 | | |
| |||
334 | 335 | | |
335 | 336 | | |
336 | 337 | | |
337 | | - | |
| 338 | + | |
338 | 339 | | |
339 | 340 | | |
340 | 341 | | |
341 | 342 | | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
342 | 353 | | |
343 | 354 | | |
344 | 355 | | |
| |||
361 | 372 | | |
362 | 373 | | |
363 | 374 | | |
364 | | - | |
| 375 | + | |
365 | 376 | | |
366 | 377 | | |
367 | 378 | | |
| |||
405 | 416 | | |
406 | 417 | | |
407 | 418 | | |
408 | | - | |
| 419 | + | |
409 | 420 | | |
410 | 421 | | |
411 | 422 | | |
| |||
424 | 435 | | |
425 | 436 | | |
426 | 437 | | |
427 | | - | |
428 | | - | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
429 | 442 | | |
430 | 443 | | |
431 | | - | |
| 444 | + | |
432 | 445 | | |
433 | 446 | | |
434 | 447 | | |
| |||
536 | 549 | | |
537 | 550 | | |
538 | 551 | | |
539 | | - | |
540 | | - | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
541 | 555 | | |
542 | 556 | | |
543 | 557 | | |
| |||
547 | 561 | | |
548 | 562 | | |
549 | 563 | | |
550 | | - | |
551 | | - | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
552 | 567 | | |
553 | 568 | | |
554 | 569 | | |
555 | 570 | | |
556 | 571 | | |
557 | | - | |
558 | | - | |
559 | | - | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
560 | 577 | | |
561 | 578 | | |
562 | 579 | | |
| |||
565 | 582 | | |
566 | 583 | | |
567 | 584 | | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
568 | 624 | | |
569 | 625 | | |
570 | | - | |
571 | | - | |
| 626 | + | |
| 627 | + | |
572 | 628 | | |
| 629 | + | |
| 630 | + | |
573 | 631 | | |
574 | 632 | | |
575 | 633 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
62 | 65 | | |
| 66 | + | |
| 67 | + | |
63 | 68 | | |
64 | 69 | | |
65 | 70 | | |
| |||
80 | 85 | | |
81 | 86 | | |
82 | 87 | | |
83 | | - | |
84 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
85 | 91 | | |
86 | 92 | | |
87 | 93 | | |
| |||
104 | 110 | | |
105 | 111 | | |
106 | 112 | | |
| 113 | + | |
107 | 114 | | |
108 | 115 | | |
109 | 116 | | |
| |||
147 | 154 | | |
148 | 155 | | |
149 | 156 | | |
150 | | - | |
| 157 | + | |
| 158 | + | |
151 | 159 | | |
152 | 160 | | |
153 | 161 | | |
| 162 | + | |
154 | 163 | | |
155 | 164 | | |
156 | 165 | | |
| |||
159 | 168 | | |
160 | 169 | | |
161 | 170 | | |
162 | | - | |
| 171 | + | |
163 | 172 | | |
164 | | - | |
165 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
166 | 183 | | |
167 | 184 | | |
168 | 185 | | |
169 | 186 | | |
170 | 187 | | |
171 | 188 | | |
172 | | - | |
| 189 | + | |
173 | 190 | | |
174 | | - | |
175 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
176 | 201 | | |
177 | 202 | | |
178 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
74 | 76 | | |
75 | | - | |
| 77 | + | |
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| 84 | + | |
| 85 | + | |
82 | 86 | | |
83 | 87 | | |
84 | 88 | | |
| |||
284 | 288 | | |
285 | 289 | | |
286 | 290 | | |
287 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
288 | 294 | | |
289 | 295 | | |
290 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
291 | 306 | | |
292 | 307 | | |
293 | 308 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
40 | | - | |
| 41 | + | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
| |||
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
55 | | - | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
62 | | - | |
| 63 | + | |
| 64 | + | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
66 | | - | |
| 68 | + | |
| 69 | + | |
67 | 70 | | |
68 | 71 | | |
69 | 72 | | |
70 | | - | |
| 73 | + | |
| 74 | + | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
| |||
0 commit comments