8000 Vector sets: store vectors quantized (Q8, BIN) instead of always f32 · Issue #697 · kividbio/kividb · GitHub
[go: up one dir, main page]

Skip to content

Vector sets: store vectors quantized (Q8, BIN) instead of always f32 #697

Closed

Description

@murtazayusuf

VADD accepts NOQUANT, Q8 and BIN but ignores them: every vector is kept as f32 (src/commands/vset.rs, the option loop around line 257), and VINFO reports quant-type f32. Redis 8 stores what is asked for, and Q8 is its default, so a vector set of the same data takes about 4x the memory here.

Plan (Parikalp):

  1. Baseline first with the vector-set benchmark of Benchmark vector sets (VADD/VSIM) against Garnet and Redis 8 #627: memory per vector, recall@10 and VSIM throughput, KiviDB vs Redis 8.10.2, at a few dimensions (e.g. 128/768/1536) and set sizes.
  2. Store Q8 (int8 with a per-vector scale, as Redis does), and BIN where asked, and compare the same three numbers.

Open questions to settle with numbers, not up front:

  • The default when no option is given: f32 as now, or Q8 like Redis. It changes recall and VEMB output for existing users, so it's a maintainer call once the recall cost is measured.
  • Distance kernels on int8: they should be no slower than the f32 ones (scalar vs SIMD).
  • VEMB (dequantized values) and VEMB RAW shapes, VINFO quant-type, and refusing a quantization the set wasn't made with, matching Redis.
  • Persistence and replication: sets saved by 1.2.x (f32) must load unchanged, and DUMP/RESTORE, snapshots, AOF and replica full sync must round-trip each quantization. A downgrade to 1.2.x has to be refused cleanly or keep working, not mis-read the data.
  • Memory accounting: MEMORY USAGE and used_memory should reflect the smaller vectors.

Target: 1.3.0.

Activity

  1. added this to the 1.3.0 milestone on Nov 13, 2026
  2. added
    enhancement
    redis-compat
    memory
    on Nov 13, 2026
  3. Parikalp-Bhardwaj commented on Nov 13, 2026

    @Parikalp-Bhardwaj
    Collaborator

    One thing to keep in mind for the benchmarks is that KiviDB's VSIM currently uses exact brute-force search, while Redis vector sets use HNSW.

    I think we should test quantization separately from the search algorithms. For KiviDB, we can compare FP32, Q8, and BIN using the same datasets, with FP32 results as the ground truth for recall@10.

    For correctness, we should also test zero vectors, negative values, extreme ranges, and vector updates.

    For the distance calculations, I'd benchmark both scalar and SIMD implementations before choosing an approach. The main goal is to reduce memory usage, but we also need to check how much overhead decoding adds. I will start by collecting baseline measurements before changing the storage layout.

  4. murtazayusuf commented on Nov 13, 2026

    @murtazayusuf
    ContributorAuthor

    agreed on all of it: f32 as ground truth for recall@10, quantization measured on its own, and the edge cases (zero vectors, negatives, extreme ranges, updates via VADD on an existing element) as tests. scalar vs SIMD measured before picking one is right too.

    the brute-force VSIM is a separate and probably bigger gap: query time grows with the set, where Redis's HNSW stays roughly flat, so on large sets VSIM throughput will be far behind no matter how vectors are stored. I've opened #710 for it so the two don't get mixed up in the numbers. for this issue, please record VSIM latency at each set size in the baseline anyway, so we know how much of the gap is the search and how much is the vector format.

  5. murtazayusuf commented on Nov 13, 2026

    @murtazayusuf
    ContributorAuthor

    @Parikalp-Bhardwaj the vector-set harness is in master now: benchmarks/vector-sets (#720). It does VADD load plus VSIM at 1/16/100 clients, with ops/s, p50/p99, bytes per vector and recall@10 against exact ground truth, against any host:port. The README has KiviDB vs Redis 8.10.2 at 10k/100k with Q8 and NOQUANT. use it for your baseline and the Q8 comparison so the numbers line up

  6. murtazayusuf commented on Nov 13, 2026

    @murtazayusuf
    ContributorAuthor

    @Parikalp-Bhardwaj heads-up on ordering, decided today: vector sets are moving onto one shared HNSW index with FT (#710, plan there). Vectors will be stored once, inside that index, so Q8/BIN storage should go into the shared index's vector storage rather than into VSetEntry. That makes it step 6 of #710, after the index is generalized (step 1). in the meantime your baseline measurements with benchmarks/vector-sets are still very useful, and the int8/binary distance kernels (scalar vs SIMD, with their accuracy) can be built and measured on their own now, since they'll plug straight into the index. sorry for the reshuffle

  7. murtazayusuf commented on Nov 14, 2026

    @murtazayusuf
    ContributorAuthor

    Done in #730 (thanks @Parikalp-Bhardwaj): VADD stores Q8 and BIN vectors as Redis 8.10 does, with AOF markers and a capability-gated replication path so mixed 1.2/1.3 deployments stay consistent. Follow-ups from the review (RESTORE/MIGRATE of quantized sets in mixed versions, O(1) quantized-set check on PSYNC, SIMD kernels for the int8/bit distances) can get their own issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementmemoryredis-compat

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0