TL;DR
Vector databases rely on HNSW graphs for lightning-fast similarity search, but what if you need to "time travel" and query an earlier version of your data—like inspecting an AI agent's past memory? Rewind-HNSW solves this by keeping only the latest graph in place and storing older connections as compact "reverse deltas." It uses 86.9% less memory than keeping separate snapshots while keeping queries on the latest data just as fast as standard HNSW.
What Problem Does This Paper Address?
HNSW (Hierarchical Navigable Small World) indexes are the go-to data structure for in-memory approximate nearest neighbor search. They work by routing queries greedily through a multi-layered proximity graph, where each node maintains an adjacency list of its neighbors.
Increasingly, applications like AI agent memory services or nightly-refreshed product catalogs need to query historical snapshots of an evolving vector collection. The catch? In HNSW, old answers need old edges. When new vectors are inserted or existing ones are replaced, the graph's topology is rewired. Simply filtering out newer vectors isn't enough—you need the exact graph connections that existed at that target version.
Existing solutions force an ugly trade-off:
- Naïve versioning saves a complete, independent HNSW index for every version. Queries are fast, but memory explodes—retaining 20 versions of a 1M-vector dataset means 90.5% of the stored nodes are duplicates.
- Fine-grained versioning (like TANNS) shares vectors in one graph and timestamps every single operation's neighbor list. It saves memory, but forces every query—even on the latest version—to binary-search or assemble lists from history, slowing queries down by ~2×.
Methods
Rewind-HNSW hits the sweet spot by versioning at batch boundaries (since many real-world apps ingest updates in batches) and storing history lazily:
- Fixed-size nodes & in-place latest state: Each vector is stored once in a fixed-size node alongside its latest adjacency list for each level. This preserves standard HNSW's direct memory addressing and hardware prefetching, so queries on the latest version read in place with zero reconstruction overhead.
- Reverse deltas: Instead of copying whole adjacency lists when an update rewires a node, Rewind-HNSW stores a reverse delta in a separate, on-demand packed history buffer. A reverse delta records only the older list's length and the specific
(position, neighbor_ID)pairs needed to rewind the newer list back to the older one. - On-demand rewinding: During a historical query at version $v$, if a visited node's latest list is newer than $v$, the thread copies it into a cache-friendly temporary buffer and applies reverse deltas backward until it reconstructs the exact list for version $v$.
- Deletes & replacements: Deletions simply record a "retirement version" on the node without rewiring the graph (so retired nodes can still route traffic for older versions while being excluded from newer results). Vector replacements insert a new node at the same level and retire the old one.
Datasets
The authors evaluate Rewind-HNSW on four standard 1M-vector datasets—BIGANN, DEEP, GIST, and 200-dimensional GloVe—using squared Euclidean distance, typically split into 20 equal update batches. They also test scalability up to 5M and 10M vectors on BIGANN, and up to 1,000 versions. Queries are tested under both uniform (equal access to all versions) and skewed (Zipfian, ~28% targeting the latest version) workloads. No new benchmarks are introduced.
Key Insights and Ideas
- Most of an adjacency list doesn't change: Across the four datasets, an average reverse delta replaces only 3.49 neighbors in lists averaging 21.2 neighbors, taking just 31.4% of the space of a full list copy.
- Don't penalize the common case: By keeping the latest adjacency list at a fixed offset in the node, Rewind-HNSW avoids breaking CPU prefetching—a subtle hardware detail that accounts for a 30.5% latency drop in their ablation study.
- Coarser versioning wins: Batch-level versioning avoids the intermediate-state bloat of per-operation versioning (TANNS), keeping at most one reverse delta per list per batch.
Key Results
- Memory: Across the four 1M datasets (20 versions), Rewind-HNSW uses 86.9% less memory than naïve versioning on average. On BIGANN, DEEP, and GloVe, it uses 76.0% less memory than latency-optimized TANNS and 44.6% less than memory-optimized TANNS. Even at 1,000 versions on BIGANN, it uses only 1.22 GB (just 17% more than 20 versions).
- Latest-version latency: At recall 0.99, Rewind-HNSW stays within 8.3% of naïve versioning on its worst dataset (GloVe), while latency-optimized and memory-optimized TANNS are 1.95× and 2.48× slower than Rewind-HNSW on average.
- Historical-version latency: Under skewed queries at recall 0.99, Rewind-HNSW nearly matches naïve versioning and beats TANNS by 1.83× (and compressed TANNS by 2.47×). Under uniform queries, it's at most 14.7% slower than naïve versioning.
Limitations and Future Work
- No automatic reclamation: Retired nodes (from deletions or replacements) and historical reverse deltas are never reclaimed in the current implementation. Because deleted nodes remain on search routes, deleting 50% of vectors increases query latency by 18.2%. Periodic compaction—once old versions are no longer needed—is left for future work.
- Positional deltas: Because reverse deltas track changes by list position rather than set membership, heavy reordering of neighbors can occasionally make a delta larger than a full list.
Summary updated