Skip to content

QVAC-20631 TurboVec: fabric vector index (CPU)#185

Draft
dev-nid wants to merge 15 commits into
tetherto:temp-9518from
dev-nid:turbovec-cpu
Draft

QVAC-20631 TurboVec: fabric vector index (CPU)#185
dev-nid wants to merge 15 commits into
tetherto:temp-9518from
dev-nid:turbovec-cpu

Conversation

@dev-nid

@dev-nid dev-nid commented Jul 15, 2026

Copy link
Copy Markdown

TurboVec: fabric vector index (CPU)

Adds a standalone ggml-vector-index C API and a production-ready CPU implementation for fabric's embedding lookup / retrieval layer. This branch is the CPU-only counterpart of turbovec (which adds Metal on top of the same base).

Summary

Introduces a new ggml_vec_index_* C API (ggml/include/ggml-vector-index.h) and its implementation (ggml/src/ggml-vector-index.cpp), plus full unit, fault, and benchmark coverage.

  • Storage: f32, symmetric q8, and packed q4 (one f32 scale per vector).
  • Search: scalar top-k, filtered top-k, prepared filters, and IVF-flat ANN.
  • SIMD kernels: NEON for q8/q4, runtime-dispatched AVX2 for q8, scalar fallback everywhere.
  • Persistence: crash-safe .tvim v1 snapshots with checksums, delta replay, and compaction on write. Fixed little-endian on disk. Supports mmap loading.
  • Mutation: atomic add with duplicate-id rejection, tombstone-based remove, and in-memory compaction (invalidates prepared filters / IVF state).
  • Concurrency: read-only APIs on the same handle can run concurrently; adds/removes/compaction/persist/IVF-build are serialized with each other and with readers.
  • Error handling: hardened OOM and interrupted-write paths (partial batch rollback, failed-snapshot preservation, temp-file cleanup).

Test plan

  • test-vector-index — API correctness across f32 / q8 / q4, persistence round-trips, migration, corruption, filtered / prepared-filtered search, IVF-flat.
  • test-vector-index-faults — OOM and interrupted-write recovery paths.
  • bench-vector-index — flat search, filtered search, IVF, mmap load, and delete-heavy compaction.
  • Verify AVX2 dispatch on x86 and NEON on ARM; scalar fallback path.
  • Confirm no regressions vs. turbovec base commit (c947e5ca2).

Notes

  • This branch intentionally excludes the two Metal commits present on turbovec (5d59a1b Metal top-k, a94f463 Metal support files) so it can ship as a CPU-only rollout.
  • On-disk format is .tvim v1, fixed little-endian.

Related PR

embed: tetherto/qvac#3292

dev-nid added 7 commits July 10, 2026 16:43
Add a standalone ggml vector index API and flat f32 TurboVec POC implementation for fabric embedding lookup.

Includes .tvim v1 persistence, duplicate-safe atomic adds, scalar top-k search, and focused test coverage.
Adds the fabric vector index API with f32/q8 storage, NEON-accelerated q8 search, crash-safe checksummed .tvim persistence, and regression coverage for corruption and migration paths.

Assisted-by: GPT-5.5
Adds isolated fault-injection coverage for vector index OOM and interrupted-write paths, including partial batch rollback, failed snapshot preservation, and temp-file cleanup.

Assisted-by: GPT-5.5
Adds runtime-dispatched AVX2 acceleration for q8 vector index search on x86 while preserving scalar fallback and the existing ARM NEON path.

Assisted-by: GPT-5.5
Adds quantized q8/q4 storage, crash-safe persistence with checksums, filtered and prepared-filtered search, delta logs with compaction, IVF-flat ANN search, SIMD q8/q4 kernels, and thread-safe concurrent reads.

Assisted-by: GPT-5.5
Adds q8/q4 storage and search, filtered search, IVF-flat ANN, incremental persistence, mmap loading, tombstone deletes, and in-memory compaction.

Covers crash-safe snapshots, checksums, delta replay/compaction, SIMD kernels, fault tests, and vector index benchmarks.

Assisted-by: GPT-5.5
Adds mmap load timing, delete-heavy compaction metrics, multi-distribution q4/q8 quality checks, and benchmark-only q4 calibration experiments.

Assisted-by: GPT-5.5
@dev-nid
dev-nid requested a review from a team as a code owner July 15, 2026 20:11
@dev-nid
dev-nid marked this pull request as draft July 15, 2026 20:11
@dev-nid dev-nid changed the title Turbovec cpu QVAC-20631 TurboVec: fabric vector index (CPU) Jul 15, 2026
dev-nid added 8 commits July 16, 2026 15:16
Move the vector index implementation out of ggml-base into its own exported target, and tighten API invariants around prepared filters, reserved sentinel IDs, and delta-log compaction recovery.
Fix delta-log consistency issues around committed mutation failures, shared log serialization, deterministic quantized replay, and unsafe compaction paths. Also tighten prepared filter validation and CMake package/linkage behavior.
Return success when logged mutations or snapshot replacements have already committed despite late durability checks, and cache validated delta tails to avoid rescanning the full log on repeated appends.
Tighten mmap snapshot safety, delta durability/error handling, IVF probing, length limits, and package exports while expanding vector-index tests and benchmark coverage for edge cases, quantized persistence, and filtered q4 paths.
Keep logged mutation completion checks under the delta log lock, and clarify vector-index API docs around SIMD dispatch, scoring, IVF probes, and mmap endian requirements.
Clarify delta-log writer, replay, and exact-search contracts in the public vector-index API. Add AVX2 acceleration for q4 dot-product search and report the q4 kernel in the vector-index benchmark.
Fix Turbovec delta-log correctness issues by removing stale tail assumptions, adding v2 state tokens, serializing load-with-delta against compaction, making replayed removes strict, and reporting partial compaction explicitly. Also split AVX2 kernels for runtime dispatch, add pkg-config metadata, improve Windows directory durability, and expand regression/fault coverage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant