Skip to content

Unset params in CAGRA w/ build_algo = IVF-PQ not using heuristics #152

Description

@ManasSingh12345

Problem

CAGRA can tune IVF-PQ parameters (n_lists, pq_dim, n_probes, etc.) from dataset size and dimension — see ivf_pq_params and the Java copy in getCuVSIvfPqParams().

If a user sets only a few knobs (e.g. n_lists and pq_bits in a sweep), they expect the rest to be filled by those heuristics. That works with Strategy.HEURISTIC (≥ 5M vectors). It does not work with Strategy.CUSTOM, which is what you get when explicitly configuring IVF_PQ — unset fields fall back to fixed Builder defaults like n_lists=1024 and kmeans_trainset_fraction=0.5, regardless of dataset size.

Native code already does the right thing — heuristic baseline, then overlay only supplied fields (cagra.cpp) — but Java passes every field, clobbering the baseline. Only pq_dim=0 gets a partial escape hatch via calculate_pq_dim.

Expected

explicit value  >  dataset heuristic  >  static default

Per parameter. Match native behavior: baseline from ivf_pq_params(dataset), overlay only what the caller set.

Example

10M × 1536d — user sets only n_lists=5000, pq_bits=4:

Param Should be Today
kmeans_n_iters 10 20
kmeans_trainset_fraction ~0.1 0.5
n_probes ~8 20
search dtypes fp16 fp32

(pq_dim accidentally works via 0calculate_pq_dim; other fields don't.)

Fix

  1. Track explicitly set IVF-PQ keys.
  2. Baseline = getCuVSIvfPqParams(N, D); overlay explicit keys only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions