Skip to content

Support code-first vector storage (drop raw floats / ingest pre-quantized codes) for LSM_VECTOR #3162

Closed

Description

@tae898

Problem

  • LSM_VECTOR hard-codes ARRAY_OF_FLOATS input (getKeyTypes()), so we must ingest float32 vectors even when using INT8/BINARY/PQ.
  • Quantization shrinks only the index files (lsmvecidx, .vecpq, etc.); the float bucket (~5.6 GB for 1M @1024 dimension) is always persisted/mmap’d, so disk and RSS stay high across all quantization modes.

What’s missing

  • A way to build indexes directly from quantized codes (int8, binary, PQ) without requiring a float property.
  • A built-in option to drop or rewrite the raw float property after index build to reclaim disk/RSS.

Prior art

  • Milvus/Qdrant/Weaviate/Pinecone: compression modes with store_raw_vector-style toggles to drop originals.
  • Redis/VecSim: accepts BLOB (pre-encoded) vectors directly.
  • Faiss IVF_PQ: supports adding precomputed codes; raw vectors optional.

Requested features (phased)

  1. Post-build drop/convert: after index build, allow null/drop of the float property or rewrite it to a compact code representation, then compact.
  2. Codes-first ingestion: allow ARRAY_OF_BYTES/BINARY as key type for LSM_VECTOR; skip re-quantization and load provided codes (and PQ codebooks) directly.
  3. PQ storage toggle: for PQ, permit storing only PQ codes/codebooks as the primary persisted form (no float bucket).

Why it matters (disk + memory)

  • Removing the float bucket cuts disk by 4–16× and lowers RSS by eliminating the large mmap’d region that currently dominates memory. Today RSS is ~flat across NONE/INT8/BINARY/PQ because the float bucket is always present.
  • At tens/hundreds of millions of vectors, bucket cost overwhelms the quantized index savings.

Bench context

  • MSMARCO-1M @1024 dimension: bucket ~5.6 GB across modes; INT8 index ~999 MB; PQ index ~11 MB + .vecpq ~247 MB; BINARY index ~140 MB. Total DB size and peak RSS stay high because floats are always stored/mapped.

API thoughts

  • New index option: store_raw_vectors=false (default true for compatibility).
  • New builder path: quantization_input=BYTES plus metadata describing encoding (INT8, BINARY, or PQ with M/K/centroids).
  • Safe fallback: if raw floats are absent but codes exist, allow search and rebuild without needing floats.

Activity

  1. tae898 commented on Jan 16, 2026

    @tae898
    ContributorAuthor

    Here’s a concrete plan for ArcadeDB Java changes to support codes-first/dropping floats, with suggested implementation touchpoints:

    • Allow non-float key types when a “codes input” mode is set

      • Update getKeyTypes() in LSMVectorIndex.java to return Type.ARRAY_OF_FLOATS by default, but accept Type.BINARY/Type.ARRAY_OF_BYTES when a new metadata flag (e.g., metadata.quantizationInput=BYTES) is set and quantizationType is INT8/BINARY/PRODUCT.
      • Plumb this flag through metadata and builders: add quantizationInput (enum: FLOATS, BYTES) to LSMVectorIndexMetadata.java with JSON serialization/deserialization, plus setters in TypeLSMVectorIndexBuilder.java and BucketLSMVectorIndexBuilder.java.
      • In put()/bulk load paths, branch on quantizationInput. If BYTES:
        • Skip float parsing; treat the property as raw codes and store directly in the index’s code storage (for INT8/BINARY) or populate PQ code arrays and codebooks (for PRODUCT) without re-training.
        • Validate length matches expected encoded size (e.g., dim bytes for INT8; dim/8 for BINARY; M * code_size for PQ).
        • If PQ: require codebooks to be provided (e.g., another metadata blob or a side property). Alternatively, disallow BYTES for PQ until codebook ingestion is defined.
    • Add a “drop raw floats after build” option (simpler, short-term win)

      • Add storeRawVectors=true|false to metadata (default true). After buildGraphWithChunking finishes, if false, run a post-build pass to null out the vector property for the indexed type and force a compact, so the bucket no longer mmap’s 5.6 GB of floats.
      • Expose this flag in builders and schema JSON. Guard with a warning: dropping floats means rebuilds can’t re-encode unless codes are present.
    • PQ-specific storage toggle

      • For quantizationType=PRODUCT, write PQ codes into .vecpq as today, but if storeRawVectors=false, avoid writing floats to the bucket (or rewrite them to PQ codes in a BINARY property). That requires the index to serve reads from the PQ store and never expect raw floats.
    • Metadata plumbing

      • LSMVectorIndexMetadata: add fields quantizationInput, storeRawVectors, (optionally) pqCodebook location if ingesting precomputed PQ.
      • Ensure toJSON()/fromJSON() in LSMVectorIndex include the new fields; adjust setMetadata() to honor them.
    • Validation

      • In builders: reject quantizationInput=BYTES unless quantizationType != NONE.
      • In index open: if storeRawVectors=false and no codes present, mark index INVALID with a clear error.
    • Docs/API

      • Document new flags in Python/Java schema APIs: create index with quantizationInput="BYTES" or storeRawVectors=false.
      • Update Python binding to pass these metadata fields through.
  2. tae898 commented on Jan 16, 2026

    @tae898
    ContributorAuthor

    @lvca
    I think this can solve the problem that no matter what quantization we use, the memory consumption is the same.

    See #3140 (comment)

  3. tae898 commented on Jan 16, 2026

    @tae898
    ContributorAuthor

    @lvca

    Can you assign this to me? I wanna try to solve it myself.

  4. lvca commented on Jan 16, 2026

    @lvca
    Member

    All yours ;-)

  5. tae898 commented on Jan 16, 2026

    @tae898
    ContributorAuthor
    • Goal: allow LSM vector indexes to store quantized codes in the bucket (and optionally drop raw float32) so disk/RSS shrink when quantization is enabled.
    • Config: add an opt-in flag (e.g., storeRawVectors=false or storeQuantizedVectors=true); default stays current (floats kept) for safety.
    • Ingest path:
      • INT8/BINARY: write quantized bytes into the bucket instead of floats.
      • PQ: write PQ codes to the bucket; keep codebooks alongside (as today in .vecpq).
      • Optionally allow dual storage (floats + codes) if the flag is left true.
    • Query path: operate on codes; decode to floats only where needed (e.g., re-ranking, graph ops).
    • Metadata/versioning: bump index metadata to record bucket payload type (floats vs codes); refuse/auto-upgrade incompatible files.
    • Migration/compat: mixed deployments reject incompatible indexes unless rebuilt; provide a clear error and rebuild guidance.
    • Testing: build/query/backup/restore across modes (NONE/INT8/BINARY/PQ) with flag on/off; cover mmap sizing/RSS regression; ensure recall parity when decoding is involved.
    • Docs: document trade-offs (can’t recover exact floats if dropped; smaller disk/RSS; recommended modes).
  6. tae898 commented on Jan 17, 2026

    @tae898
    ContributorAuthor

    Decided not to proceed with the “drop raw floats when quantized” work. Keeping both raw vectors and codes in the bucket didn’t pan out, and the build/test path for quantized storage got too fragile (engine test-jar deps, graph vs. inline payloads, etc.). I’m pausing this effort; no code change needed. If we revisit later, we should design a clean storage path for quantized payloads (or a dedicated PQ file) and add end-to-end tests before toggling storeRawVectors off.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions