feat(agent): optional int8 vector index, re-scored against exact embeddings
`MemoryConfig::quantized_index` stores the HNSW index's own copy of the embeddings as i8 rather than f32. At 100k x 384 that takes the index from 266 to 123 MiB and the whole reopened store from 399 to 256 MiB — 2.72x to 1.74x the raw vectors, the largest remaining item in the footprint. Quantised distances are approximate and `ef` cannot compensate, because the loss is in the distances rather than in the graph: recall@10 tops out at 0.967 against f32's 0.9995 and does not move between ef=128 and ef=256. The store already holds the exact embeddings, though, so when the index is quantised the query path re-scores the candidate pool against them before fusion. That restores recall (0.9940 vs 0.9945 at ef=64) and costs about 13% of QPS. Off by default: it trades query speed for memory and which side is worth more depends on the deployment. The flag is persisted in `/meta`, so a reopened store does not silently revert to four times the index memory, and the sidecar graph is rehydrated into the configured storage. Also on the CLI as `create --quantized-index`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
@@ -563,7 +563,9 @@ fn bench_footprint(n: usize) {
|
||||
.collect();
|
||||
let after_entries = heap_bytes();
|
||||
|
||||
let mut mem = HDF5Memory::create(MemoryConfig::new(path, "bench", DIM)).unwrap();
|
||||
let mut config = MemoryConfig::new(path, "bench", DIM);
|
||||
config.quantized_index = INT8.load(std::sync::atomic::Ordering::Relaxed);
|
||||
let mut mem = HDF5Memory::create(config).unwrap();
|
||||
mem.save_batch(entries).unwrap();
|
||||
let after_store = heap_bytes();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user