Fix IVF extend list resize bug#2297
Conversation
|
old_used_size is the old logical size. old real size is checked via extends. |
in ivf-flat extend, resize_list() receives |
|
here is poc after base extend after grow extend BUG: index-visible size is 120 but internal list::size stayed 100 |
|
Ok, sorry for closing this prematurely, this does seem legit. I'm not sure though if this internal get_size() is used where it could cause any problems. I'll look into this in the following days. |
|
Thank you very much! I forgot to mention how i even stumbled upon this - i got very strange Illegal memory access errors (i am using python wrapper for multiple extends + search + torch for calculating the vectors) and believe that this bug is related (IMA was in calc_chunk_indices_kernel) |
|
off-topic, figured out why i got IMA, NVIDIA/raft#3041, different issue. |
|
Everything that gets merged in the main branch before next burndown, gets automatically in the next release - the new release branch is forked from the main when burndown starts. Here's our schedule https://docs.rapids.ai/maintainers/ |
huuanhhuyn
left a comment
There was a problem hiding this comment.
Thank you for your contribution! I'd have 1 doubt.
| auto shared_list_size = old_used_size; | ||
| if (new_used_size <= old_used_size || | ||
| auto shared_list_size = old_logical_size; | ||
| if (new_used_size <= old_logical_size || |
There was a problem hiding this comment.
I guess there are 3 cases:
- new_used_size <= old_logical_size -> no size update, no reallocation
- old_logical_size < new_used_size <= old_used_size -> size update, no reallocation
- new_used_size > old_used_size -> size update, reallocation
If I understand it correctly, your current version will do both size update and reallocation for the 2nd case.
There was a problem hiding this comment.
If I understand it correctly, your current version will do both size update and reallocation for the 2nd case.
Only if orig_list->size.compare_exchange_strong(shared_list_size, new_used_size) returns false
it returns false if orig_list->size was already mutated before this resize_list call ( if the current shared list size is not old_logical_size anymore)
Description
Fixes a bug in IVF-Flat and IVF-SQ
extend()where a list could receive new vectors but keep its old logicallist::size.The issue happens when extending a list that already has enough allocated capacity. Interleaved IVF list storage may be padded, so the old copy extent can be larger than the old logical size.
Example:
Previously,
resize_list()received only the padded value,128, and used it both for copying old storage and for deciding whetherlist::sizeneeded to be updated. It checked120 <= 128, skipped the update, and leftlist::size == 100even though new vectors were inserted up to120.This stale size can break the shared-list / copy-on-write logic in later extends and corrupt search results.
Fix
Pass separate old sizes to
ivf::resize_list():The existing overload is kept for call sites where both sizes are the same.
Tests
Added regression tests for: