Skip to content

feat: run distribution-aware filtered fixtures as benchmark cases - #905

Open
yejonz wants to merge 8 commits into
zilliztech:mainfrom
yejonz:filtered-cases-v02
Open

yejonz wants to merge 8 commits into
zilliztech:mainfrom
yejonz:filtered-cases-v02

Conversation

@yejonz

@yejonz yejonz commented Nov 13, 2026 •

Copy link
Copy Markdown

Fixes #882.

Builds on #903 (V01). Until that merges, this branch also contains its commits; the V02 changes are 14d6b38 and f18af25 (the merges bring in the #903 review fix and main).

What changed

#903 generates filtered fixtures, but VectorDBBench could not run them. A fixture's label values and ground-truth files don't follow the label_{p}p naming, there was no int-range filter, the reader rejects ground truth narrower than K (which a fixture has whenever fewer rows match), recall was scored out of K even when fewer than K neighbors exist, and a client that doesn't support a filter type failed the whole run.

Following the review, this runs through the existing PerformanceCustomDataset case instead of a new one. The custom case takes an optional filter_config with an explicit filter and its ground-truth file, and --fixture-dir/--fixture-case fill that in, along with the dataset settings, from the fixture's manifest:

vectordbbench milvushnsw --uri http://localhost:19530 \
    --case-type PerformanceCustomDataset --fixture-dir ./fixture --fixture-case 00_label_equal_0.01
  • filter_config is a label_equal value or an int_range (low <= field < high_exclusive), plus gt_name and matching_rows. Any custom dataset can pass it directly; the manifest is only a convenience input. Without it, PerformanceCustomDataset behaves as before, and setting it together with use_filter is rejected.
  • Label filters use the given value and ground-truth file (ExplicitLabelFilter), so every client that supports label filters runs them unchanged.
  • Int ranges use a new FilterOp.NumRange (IntRangeFilter). Milvus supports it with an INT64 int_attr field and an STL_SORT index, the same index its id field gets for NumGE; the insert runner passes the column as int_data. Range cases get their own load reuse key, so they never reuse a collection loaded without that field.
  • A client that doesn't support an explicit filter's type skips that case with a warning instead of failing the run. Other cases keep the existing FilterNotSupportedError.
  • Recall and NDCG are scored out of min(K, rows the filter matches), and the reader requires ground truth that wide, so running with a K larger than the ground truth's is rejected instead of scored as perfect.
  • For fixture cases, each result records the case, its expression, target and actual selectivity, matching rows and the fixture's metadata distributions in additional_parameters["filter_metadata"]. The saved custom_case holds the absolute dataset path and the filter, so saved results load without the manifest.

Example

Against Milvus 2.6.27 (standalone in Docker), FLAT index, on a 5,000 x 32 fixture with 100 queries:

$ vectordbbench milvusflat --uri http://127.0.0.1:19530 --case-type PerformanceCustomDataset \
    --fixture-dir ./fixture --fixture-case 03_int_range_0.01 --num-concurrency 1,2 --concurrency-duration 5
...
search entire test_data: cost=0.2376s, queries=100, avg_recall=1.0, avg_ndcg=1.0, avg_latency=0.0024, p99=0.0038, p95=0.0028, p50=0.0019, recall_at={}
Performance case got result: Metric(... qps=1223.6572, ... recall=1.0 ...)

The case is int_attr >= 4 and int_attr < 113, which matches 51 rows, so each query has 51 true neighbors. Before this change the same exact answers would score 0.51. The saved result includes:

"filter_config": {"type": "int_range", "field": "int_attr", "low": 4, "high_exclusive": 113,
  "gt_name": "neighbors_03_int_range_0.01", "matching_rows": 51}
"filter_metadata": {"case_id": "03_int_range_0.01", "expr": "int_attr >= 4 and int_attr < 113",
  "target_selectivity": 0.01, "actual_selectivity": 0.0102, "matching_rows": 51, ...}
"ground_truth": {"file": "neighbors_03_int_range_0.01.parquet", "query_count": 100, "width": 51}

Verification

  • tests/test_filtered_fixture_case.py, 15 tests: label and range cases built from a manifest; an explicit filter on a custom dataset without a manifest; invalid filter configs and filter_config with use_filter rejected; unknown case ids and format versions rejected; the CLI options; short ground truth loads for explicit filters but is still rejected for an ordinary label filter; K above the ground truth's K rejected; recall and NDCG scored out of the available neighbors; insert batches carrying int_attr; the Milvus range expression; the assembler skipping unsupported explicit filters while still failing ordinary cases; label and range cases getting different load reuse keys; a saved result loading after the fixture is deleted.
  • make lint passes.
  • The existing test files that cover the changed modules (28 files, including test_custom_dataset_filter.py, test_milvus.py, test_case_runner_reuse.py and test_concurrent_runner.py) give the same results as on main. The download tests in test_dataset.py and test_data_source.py fail or time out offline on both.
  • From the CLI: vectordbbench test with each case skips it with a warning, e.g. Skipping Filtered fixture 03_int_range_0.01 - filtered_synthetic on test: NumRange filters (int_attr >= 4 and int_attr < 113) are not supported by this client; --fixture-dir without --fixture-case is a usage error; PerformanceCustomDataset without a fixture still requires the --custom-dataset-* options.
  • Against Milvus 2.6.27 in Docker, with all stages including concurrent search: the label case (labels == "label_20", 50 matching rows) and the range case above both had recall 1.0 and about 1,200 QPS at concurrency 2. One run with both cases dropped and reloaded the collection for the range case, and both had recall 1.0.

Not tested here

  • Label filters on clients other than Milvus (they use the existing label path, unchanged).
  • NumRange on other clients; they skip range cases until they add it.
  • Explicit filters from the web UI; this adds them to the case config and CLI only.
  • Approximate indexes (HNSW etc.) and larger fixtures; only FLAT was run, to check exact recall.
  • recall_at is empty when fewer rows match than the smallest cutoff, since the existing code skips cutoffs above the number of true neighbors.
  • Windows.

… truth

Adds vectordb_bench/backend/filtered_dataset, a generator for filtered-search
fixtures (Stanford catalog V01). A spec sets vector shape, metric, seed, label
and int metadata distributions (uniform or Zipf), how strongly the metadata
follows vector position, and target selectivities for label-equality and
int-range filters. It writes the custom-dataset layout (train, test,
scalar_labels, one neighbors file per case) plus a manifest with each case's
actual selectivity, matching rows, short or empty ground truth, boundary ties
and how often unfiltered neighbors already pass the filter. Ground truth is an
exact float64 top-k ranked by (distance, id). A verify command re-checks a
fixture against an independent exact reference.

issue: zilliztech#881
Signed-off-by: yejonz <yejonz@gmail.com>
Cap num_train * dim (50M elements, about 1.3 GB peak and below Arrow's int32
list offsets) and the int domain width. Say that only the base files load
through CustomDataset today and per-case ground truth needs V02. Qualify the
reproducibility claim and record numpy/pyarrow versions in the manifest.
Accept an empty --config with --seed, and reword --overwrite.

Signed-off-by: yejonz <yejonz@gmail.com>
…ately

Signed-off-by: yejonz <yejonz@gmail.com>
Adds FilteredFixtureCase, which runs one case of a fixture generated by
vectordb_bench.backend.filtered_dataset (V01):

    vectordbbench milvushnsw ... --case-type FilteredFixtureCase \
        --fixture-dir ./fixture --fixture-case 00_label_equal_0.01

Label cases become a label-equality filter with the manifest's value, so
every client with label support runs them unchanged. Int-range cases use
a new NumRange filter type; Milvus supports it with an INT64 column and
an STL_SORT index, like its id field for NumGE. A client that cannot run
a case's filter type skips that case with a warning instead of failing
the run; other cases keep the existing error.

Recall and NDCG are scored over min(K, rows the filter matches), and the
reader requires ground truth that wide, so a fixture generated with a
smaller K is rejected rather than scored as perfect. Range cases get
their own load reuse key. Each result records the case, expression,
target and actual selectivity and the fixture's distributions in
additional_parameters, and stores the manifest entries it needs so it
loads after the fixture moves.

issue: zilliztech#882
Signed-off-by: yejonz <yejonz@gmail.com>
@yejonz

yejonz commented Nov 13, 2026

Copy link
Copy Markdown
Author

/assign @XuanYang-cn

@jamesgao-jpg jamesgao-jpg left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this integration! The generated filtered datasets look useful, and the changes for integer-range filters and short ground truth address real capability gaps.

Could we extend the existing PerformanceCustomDataset case instead of introducing a separate public FilteredFixtureCase? The new case already constructs the same CustomDataset and dataset manager, so the main difference seems to be how the filter, ground-truth file, and dataset metadata are configured.

A possible approach would be to let the custom case accept an explicit filter and associated ground-truth file, with the generated manifest acting as a convenience input that populates those settings. That could support both these synthetic fixtures and other user-provided filtered datasets through the same case.

The range-filter support, handling of fewer than k matching rows, and result metadata would still be needed; this suggestion is about reusing the existing public case and configuration path. Is there a reason the separate case is preferable?

…endence baseline

Count an int range from the first row tied at its lower bound, so a run of
ties at the start no longer pushes the upper bound past the closest match.
In verify, report neighbor ids outside 0..N-1 before indexing (NumPy reads
-1 as the last row) and check each ground-truth file's query ids against the
test file. Compute the expected queries with no unfiltered match by sampling
without replacement from the observed matching rows (hypergeometric) instead
of (1 - selectivity) ** k.

Signed-off-by: yejonz <yejonz@gmail.com>
@yejonz

yejonz commented Dec 2, 2026

Copy link
Copy Markdown
Author

Thanks, that makes sense, no strong reason for a separate case. I'll fold it into PerformanceCustomDataset: the custom case takes an optional filter (label value or int range) with its ground-truth file, and --fixture-dir/--fixture-case just fill those in from the manifest. The int-range filter, short ground-truth handling and result metadata stay as they are. I'll also rebase onto main for the conflicts.

Signed-off-by: yejonz <yejonz@gmail.com>

# Conflicts:
#	vectordb_bench/backend/task_runner.py
Per review, drop the separate FilteredFixtureCase. PerformanceCustomDataset
now takes an optional filter_config (a label_equal value or an int_range,
with its own ground-truth file and matching row count), and
--fixture-dir/--fixture-case fill in the dataset settings and that filter
from the fixture's manifest. Any custom dataset can pass filter_config
directly. The custom_case holds everything the case needs, so saved results
load without the manifest. Results record the fixture's metadata under
additional_parameters["filter_metadata"]; unsupported explicit filters are
still skipped with a warning.

Signed-off-by: yejonz <yejonz@gmail.com>
@yejonz

yejonz commented Dec 2, 2026

Copy link
Copy Markdown
Author

Done in f18af25. PerformanceCustomDataset now takes an optional filter_config (a label value or int range with its ground-truth file), and --fixture-dir/--fixture-case just fill it in from the manifest, so other custom datasets can use the same filter. I also merged main to resolve the conflicts. I've updated the description.

@sre-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: yejonz
To complete the pull request process, please assign jamesgao-jpg after the PR has been reviewed.
You can assign the PR to them by writing /assign @jamesgao-jpg in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]: [Stanford V02] Integrate distribution-aware filter cases into VectorDBBench

3 participants