feat: add SQ8 vector quantization, lazy loading, and two-phase rerank to HNSW

- SQ8 scalar quantization (8-bit) for 4x vector storage reduction
- Lazy vector loading: evict float32 vectors after graph construction,
  load on-demand from storage via UnifiedCache
- Two-phase search: over-retrieve with SQ8 approximate distances,
  rerank top candidates with exact float32 distances
- Configuration surface: hnsw.quantization and hnsw.vectorStorage in BrainyConfig
- All features disabled by default (zero behavior change for existing users)
- 27 new tests covering quantization accuracy, lazy loading, reranking
- Remove GitHub Actions CI (build locally, cortex CI handles native builds)
This commit is contained in:
David Snelling 2026-01-31 12:41:53 -08:00
parent e384afcdac
commit 0f3a88429d
9 changed files with 1138 additions and 222 deletions

View file

@ -728,6 +728,16 @@ export interface BrainyConfig {
// Cloud storage (GCS/S3/R2/Azure) should use 'deferred' for 30-50× faster adds
hnswPersistMode?: 'immediate' | 'deferred'
// HNSW optimization options (v7.11.0)
hnsw?: {
quantization?: {
enabled?: boolean // default: false — current behavior exactly
bits?: 8 | 4 // default: 8 (SQ8). SQ4 requires brainy-cortex native.
rerankMultiplier?: number // default: 3 — over-retrieve 3x, rerank with float32
}
vectorStorage?: 'memory' | 'lazy' // default: 'memory' — 'lazy' evicts vectors after insert
}
// Memory management options
maxQueryLimit?: number // Override auto-detected query result limit (max: 100000)
reservedQueryMemory?: number // Memory reserved for queries in bytes (e.g., 1073741824 = 1GB)