Repository navigation
Replace LLMPrefixCache stub with HNSW-based similarity search - #239
Merged
Merged
Conversation
Co-authored-by: makr-code <[email protected]>
Co-authored-by: makr-code <[email protected]>
Co-authored-by: makr-code <[email protected]>
Co-authored-by: makr-code <[email protected]>
Co-authored-by: makr-code <[email protected]>
Copilot
AI
changed the title
[WIP] Implement real LLM prefix cache with HNSW integration
Replace LLMPrefixCache stub with HNSW-based similarity search
Jan 5, 2026
Owner
|
@copilot preview |
Contributor
Author
Implementation PreviewSuccessfully replaced the stub LLMPrefixCache with production-ready HNSW integration. Here's what was implemented: Core Changes1. HNSW Integration (
2. Testing (
3. Documentation (
Key Improvements
Files Changed (424 insertions, 21 deletions)
All existing APIs unchanged. Fully backward compatible. Ready for merge. |
makr-code
marked this pull request as ready for review
January 5, 2026 15:53
6 tasks
Merged
7 of 25 tasks
7 tasks done
Copilot AI
added a commit
that referenced
this pull request
May 5, 2026
…oid, self-consistency) Agent-Logs-Url: https://github.com/makr-code/ThemisDB/sessions/17b97ffe-2d15-4d81-bfe5-cb887b80a165 Co-authored-by: makr-code <[email protected]>
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.
The LLM Prefix Cache used a stub implementation with O(N) linear search over embeddings. This prevented the claimed 10-20x first-token speedup from KV-cache reuse in production workloads.
Changes
Core Integration (
src/llm/llm_prefix_cache.cpp)EmbeddingCachewith HNSW index for O(log N) similarity searchBefore:
After:
Configuration
enable_kv_caching = true/tmp/themis_llm_prefix_cacheTesting (
tests/test_llm_prefix_cache.cpp)HNSWIntegrationTestvalidating similarity matching across multiple prefixesDocumentation (
docs/en/llm/KV_CACHE_REUSE_IMPLEMENTATION.md)Performance Impact
Backward Compatibility
Fully compatible. No API changes, automatic fallback, all existing tests pass.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.