Skip to content

Fix IVF extend list resize bug#2297

Open
qwertyforce wants to merge 2 commits into
NVIDIA:mainfrom
qwertyforce:fix_ivf_resize
Open

Fix IVF extend list resize bug#2297
qwertyforce wants to merge 2 commits into
NVIDIA:mainfrom
qwertyforce:fix_ivf_resize

Conversation

@qwertyforce

Copy link
Copy Markdown

Description

Fixes a bug in IVF-Flat and IVF-SQ extend() where a list could receive new vectors but keep its old logical list::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:

old logical size: 100
old padded copy size: 128
new logical size: 120

Previously, resize_list() received only the padded value, 128, and used it both for copying old storage and for deciding whether list::size needed to be updated. It checked 120 <= 128, skipped the update, and left list::size == 100 even though new vectors were inserted up to 120.

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():

old_logical_size: used for the list::size update/CAS decision
old_used_size:    used for copying old storage, may be padded

The existing overload is kept for call sites where both sizes are the same.

Tests

Added regression tests for:

IVF-Flat repeated extend from a shared base index with enough existing capacity
IVF-SQ in-place extend with enough existing capacity

@copy-pr-bot

copy-pr-bot Bot commented Jul 4, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant