Repository navigation
Python: Initialize key mapping for a custom FAISS index - #14569
Open
A Aswanth Raj (aswanth-07) wants to merge 1 commit into
Open
A Aswanth Raj (aswanth-07) wants to merge 1 commit into
A Aswanth Raj (aswanth-07) wants to merge 1 commit into
Conversation
A Aswanth Raj (aswanth-07)
deployed
to
github-app-auth
October 8, 2026 06:49 — with
GitHub Actions
Active
A Aswanth Raj (aswanth-07)
deployed
to
github-app-auth
October 8, 2026 06:49 — with
GitHub Actions
Active
A Aswanth Raj (aswanth-07)
marked this pull request as ready for review
October 8, 2026 06:50
A Aswanth Raj (aswanth-07)
deployed
to
github-app-auth
October 8, 2026 06:51 — with
GitHub Actions
Active
Copilot started reviewing on behalf of
A Aswanth Raj (aswanth-07)
October 8, 2026 06:51
View session
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused fix is consistent with existing index initialization paths and has comprehensive regression coverage.
0 open findings
What changed in this PR
Initializes FAISS key mappings for supplied single indexes, preventing first-upsert failures.
Changes:
- Adds missing key-map initialization while preserving existing mappings.
- Adds regression coverage for flat and HNSW custom indexes across both setup paths.
| File | Description |
|---|---|
python/semantic_kernel/connectors/faiss.py |
Initializes the vector field’s key map. |
python/tests/unit/connectors/memory/test_faiss.py |
Tests insertion, search, repeated setup, and recreation. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
I found that
FaissCollection.ensure_collection_exists(index=...)accepts a trained custom index, but the firstupsert()raisesVectorStoreOperationExceptioncaused byKeyError('vector'). This prevents record insertion through the documented single-index setup path, including custom HNSW indexes.The single-index branch returns before initializing the vector field's key map. Both the automatic and
indexes={...}branches already initialize that map. The existing custom-index test covers collection creation without inserting a record.Description
I added the missing
setdefaultbefore the early return. It initializes a new mapping and preserves an existing mapping when collection setup runs again. The supplied index object, training validation, native search behavior, default setup and dictionary setup remain unchanged. The change adds no file operations or persisted-format changes.The new test uses real flat L2, flat inner-product and HNSW indexes across both custom-index entry points. It checks insertion, retrieval, ordered search, repeated setup after insertion, and collection deletion/recreation.
Validation on Windows, Python 3.11.9 and faiss-cpu 1.13.2:
main, the three single-index regression cases fail with the missing-map error; the three dictionary-route controls pass.pytest tests/unit/connectors/memory/test_faiss.py: 21 passed.pytest tests/unit/connectors/memory/test_in_memory.py: 43 passed on base and patch.git diff --checkpassed.I did not run the complete Python suite, GPU FAISS or non-Python builds locally. The FAISS unit module emits existing SWIG deprecation warnings.
Contribution Checklist
The local validation above covers the affected connector and its inherited in-memory behavior. The full-build and complete-suite assertions remain unchecked.
AI assistance disclosure: AI-assisted development tools were used during investigation and implementation. The reported tests were run against the final diff.