Repository navigation
Conversation
recompute_internal_state copied the data and indices pointers of every list to the device with a separate one-element copy from pageable host memory, i.e. 2 * n_lists small copies. Gather the pointers on the host and upload each array with one copy; the function already synchronizes the stream before returning.
|
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. |
|
/ok to test bbca1f0 |
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
|
/ok to test 4dd07b8 |
irina-resh-nvda
left a comment
There was a problem hiding this comment.
A nice minimal change, looks good to me. Only one comment nitpick from me
|
|
||
| // Actualize the list pointers | ||
| // Actualize the list pointers: gather them on the host and upload each array with a single copy | ||
| // instead of one tiny pageable H2D copy per list. The host buffers outlive the sync_stream below. |
There was a problem hiding this comment.
The readers of this comment won't have the context for the historical "instead of one tiny pageable H2D copy per list".
|
/ok to test bf503b6 |
ivf::detail::recompute_internal_staterefreshes the device arrays that hold each list's data and index pointers. It uploaded them with one 8-byteraft::copyper list and per array, each from a host stack variable: 2 ×n_listspageable host-to-device copies. The function runs on every IVF-Flat, IVF-PQ and IVF-SQ extend, deserialize,extend_list/erase_list, clone and devicerefine.ivf_flat::extendruns it twice, once incloneand once after adding the rows.This PR gathers the pointers into two host vectors and uploads each array with a single
raft::copy.list ? list->data_ptr() : nullptrandlist ? list->indices_ptr() : nullptr, from the sameindex.lists().Microbenchmark
IVF-Flat, float, dim 8, 16 rows per list, all lists non-empty, on an RTX 6000 Ada. The same binary was run against
libcuvs.sobuilt from main (f751cad) with and without this commit, 3 alternated runs each. Each cell is the median over the 3 runs of the per-run median of 21 calls (11 forextend), with the range of the 3 run medians in parentheses.n_listsivf_flat::helpers::recompute_internal_state, beforeivf_flat::extendof 1 row, beforeBefore this change the function cost about 2.9 µs per list, which is linear in
n_lists. A one-rowextendof a 65,536-list index took 386 ms; it now takes 6.4 ms.The C++ test suites barely notice, because their indexes have few lists. On the same GPU, single process, fastest run:
NEIGHBORS_ANN_IVF_FLAT_TEST228.1 → 219.3 s,NEIGHBORS_ANN_IVF_PQ_TEST401.7 → 395.5 s andNEIGHBORS_ANN_IVF_SQ_TEST33.8 → 32.6 s, all close to run-to-run noise. The fullctestsuite passes, including the IVF-Flat, IVF-PQ, IVF-SQ, MG, tiered-index, dynamic-batching and refine tests.Benchmark source