Skip to content

fix(python): resolve multi-index search core dumps by exposing missing state (#643)#754

Open
Abhinav2656 wants to merge 1 commit into
unum-cloud:mainfrom
Abhinav2656:fix/python-multi-index
Open

fix(python): resolve multi-index search core dumps by exposing missing state (#643)#754
Abhinav2656 wants to merge 1 commit into
unum-cloud:mainfrom
Abhinav2656:fix/python-multi-index

Conversation

@Abhinav2656
Copy link
Copy Markdown

Description

Fixes #643: Mult-Index Search Doesn't Work in Python

Root Cause Analysis

When utilizing the Python bindings for multi-index search, ix.search(query) was failing violently via either a Python ValueError (dimension mismatch) or a C++ std::bad_function_call (core dump).

This occurred because the Indexes wrapper class dropped the state of its underlying Index children upon initialization:

  1. Missing Metadata: The Indexes class lacked the ndim, dtype, and metric properties required by _search_in_compiled.
  2. Dangling Pointers / GC: The Indexes.__init__ method consumed an iterable of Index objects, passed their compiled pointers to C++, and then immediately discarded the Python objects. If instantiated with anonymous objects, Python's garbage collector destroyed the underlying indices, leaving the C++ core with null pointers to metric functions (triggering the std::bad_function_call).

The Fix

  • Bound the iterable of indices to self.indices within the Indexes constructor to ensure the Python objects (and their C++ metric callbacks) survive garbage collection.
  • Implemented @property methods for ndim, dtype, and metric on the Indexes class that dynamically inherit the architectural state from the first underlying index in the collection.

Validation

Added test_multi_index to the Python test suite to strictly verify:

  • Boundary Conditions: Empty Indexes([]) gracefully returns 0 / None / unknown.
  • Recall Verification: Multi-index router successfully locates distinct vectors across different C++ shards.
  • Batch Memory Alignment: Wrapper successfully handles batch matrix queries (np.vstack) across the boundary without dimension mismatch errors.

…earch core dumps

Resolves unum-cloud#643 by exposing ndim, dtype, and metric properties in the multi-index wrapper and retaining references to underlying Index objects to prevent premature garbage collection of metric functions.
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.

Bug: Mult-Index Search Doesn't Work in Python

1 participant