Skip to content

[feat](eval_performance): support filtered HGraph workloads in AutoTune - #2736

Open
jac0626 wants to merge 1 commit into
antgroup:mainfrom
jac0626:codex/autotune-hgraph-filter
Open

[feat](eval_performance): support filtered HGraph workloads in AutoTune#2736
jac0626 wants to merge 1 commit into
antgroup:mainfrom
jac0626:codex/autotune-hgraph-filter

Conversation

@jac0626

@jac0626 jac0626 commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Change Type

  • Bug fix
  • New feature
  • Improvement/Refactor
  • Documentation
  • CI/Build/Infra

Linked Issue

What Changed

  • Add per-query FilterPtr and invalid BitsetPtr workload inputs to typed HGraph TuneSearch and TuneIndex requests.
  • Route filtered workloads through the shared evaluation core while preserving HGraph's native bitset search path.
  • Validate filter shape, mutual exclusion, supported index scope, and unsupported extra-info filtering.
  • Add separate FilterPtr and BitsetPtr examples, focused regression tests, and English/Chinese user documentation.

Test Evidence

  • make fmt
  • make lint
  • make test
  • make cov, run tests, and collect coverage
  • Other (describe below)

Test details:

clang-format-15 --dry-run --Werror <all changed C++ files>
cmake --build build --target autotune_test eval_dataset_test \
  327_feature_autotune_existing_index \
  330_feature_autotune_existing_index_bitset -j$(nproc)

./build/tools/autotune/autotune_test \
  "AutoTune evaluates per-query filters and bitsets for HGraph"
  All tests passed (29 assertions in 1 test case)

./build/tools/eval/eval_dataset_test \
  "EvalDataset builds a query-only view for id recall"
  All tests passed (21 assertions in 1 test case)

./build/tools/eval/eval_dataset_test \
  "EvaluateSearch validates inputs and propagates search errors"
  All tests passed (23 assertions in 1 test case)

./build/examples/cpp/327_feature_autotune_existing_index
  recall_at_k: 1.0; first neighbor id: 1000

./build/examples/cpp/330_feature_autotune_existing_index_bitset
  recall_at_k: 1.0; first neighbor id: 1000

Compatibility Impact

  • API/ABI compatibility: Additive fields in the build-tree AutoTune API under tools/; no installed VSAG SDK API is changed.
  • Behavior changes: Typed HGraph tuning requests may now evaluate per-query filters. Filtered requests for other index types fail validation explicitly.

Performance and Concurrency Impact

  • Performance impact: The unfiltered evaluation path is unchanged. Filtered trials use the existing native HGraph filter/bitset search overloads.
  • Concurrency/thread-safety impact: The same per-query filters or bitsets may be read by concurrent search workers and therefore must remain immutable and thread-safe during tuning.

Documentation Impact

  • No docs update needed
  • Updated docs:
    • README.md
    • DEVELOPMENT.md
    • CONTRIBUTING.md
    • Other: docs/docs/{en,zh}/src/resources/autotune.md

Risk and Rollback

  • Risk level: medium
  • Rollback plan: Revert commit 92dfeaa4; unfiltered AutoTune behavior is otherwise unchanged.

Checklist

  • I have linked the relevant issue (required for kind/bug and kind/feature; see "Linked Issue" above)
  • I have added/updated tests for new behavior or bug fixes
  • I have considered API compatibility impact
  • I have updated docs if behavior/workflow changed
  • My commit messages follow project conventions (Conventional Commits, optional [skip ci] prefix)

Signed-off-by: jc543239 <jc543239@antgroup.com>
Assisted-by: Codex:gpt-5
Copilot AI lite review requested due to automatic review settings August 21, 2026 03:10
@vsag-bot

vsag-bot commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

/label status/waiting-for-review
/waiting-on reviewer
/request-review @jiaweizone
/request-review @wxyucs
/request-review @inabao

@pull-request-size pull-request-size Bot added the size/XL 500-999 changed lines label Aug 21, 2026
@jac0626 jac0626 added kind/feature Brand-new functionality or capabilities 引入全新的功能、新特性或新能力 version/1.0 1. LazyHGraph & SIMQ 2. Unified search API 3. Streaming serialization 1. 新索引 2. 统一检索接口 3. 流式序列化 labels Aug 21, 2026
@mergify

mergify Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 3 merge protections satisfied — ready to merge.

Show 3 satisfied protections

🟢 Require kind label

  • label~=^kind/

🟢 Require version label

  • label~=^version/

🟢 Require linked issue for feature/bug PRs

  • body~=(?im)(?:^|[\s\-\*])(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s*:?\s+(?:#\d+|[\w.\-]+/[\w.\-]+#\d+|https?://github\.com/[\w.\-]+/[\w.\-]+/issues/\d+)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the eval_performance AutoTune typed API to support filtered HGraph workloads by accepting per-query FilterPtr or exclusion BitsetPtr inputs, routing them through the shared evaluation pipeline while keeping HGraph’s native filtered-search overloads, and documenting the new capability.

Changes:

  • Extend typed AutoTune workload/request plumbing to carry per-query FilterPtr / BitsetPtr into EvalDataset, validation, and evaluation.
  • Update search evaluation to apply per-query filters/bitsets, and restrict filtered workloads to HGraph (including rejecting use_extra_info_filter=true).
  • Add regression tests, new bitset example, and English/Chinese documentation updates.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tools/eval/eval_dataset.h Adds per-query filter/bitset storage + accessors and filtered-query accounting.
tools/eval/eval_dataset.cpp Validates filter/bitset inputs and wires them into dataset construction.
tools/eval/eval_dataset_test.cpp Adds coverage for per-query filters/bitsets and input validation.
tools/eval/case/search_eval_case.cpp Applies per-query filter/bitset during KNN evaluation via HGraph overloads.
tools/autotune/autotune.h Extends Workload with query_filters and query_invalid_bitsets.
tools/autotune/autotune.cpp Propagates filtered workload data into eval datasets; enforces HGraph-only for filtered cases; reports filtered count.
tools/autotune/autotune_internal.h Tracks filtered-workload presence in request context.
tools/autotune/autotune_candidate.cpp Rejects extra-info filtering when tuning filtered workloads.
tools/autotune/autotune_test.cpp Adds end-to-end tuning tests for per-query filters/bitsets and validation failures.
examples/cpp/CMakeLists.txt Registers a new bitset-based AutoTune example target.
examples/cpp/327_feature_autotune_existing_index.cpp Extends existing example to demonstrate per-query FilterPtr tuning and usage.
examples/cpp/330_feature_autotune_existing_index_bitset.cpp New example demonstrating per-query exclusion bitsets in AutoTune + final search.
docs/docs/zh/src/resources/autotune.md Documents filtered typed HGraph workloads and links both examples (FilterPtr + bitset).
docs/docs/en/src/resources/autotune.md Documents filtered typed HGraph workloads and links both examples (FilterPtr + bitset).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tools/eval/eval_dataset.h
Comment thread tools/autotune/autotune_internal.h
@jac0626

jac0626 commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

/retest

@jac0626
jac0626 marked this pull request as ready for review August 21, 2026 06:36
@mergify mergify Bot added area/docs Website and repository documentation 网站与仓库文档 area/examples C++, Python, and TypeScript examples C++、Python 与 TypeScript 示例 area/tools Command-line, evaluation, and developer tools 命令行、评测与开发工具 labels Sep 3, 2026
REQUIRE(bitset_result["recall_avg"].get<double>() == 1.0);
config.enable_recall = false;
config.enable_qps = true;

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.

[suggestion] The bitset recall test verifies recall_avg == 1.0 correctly, but after setting config.enable_recall = false; config.enable_qps = true; on this line, no corresponding EvaluateSearch call is made for the bitset_dataset. The test immediately falls through to the ef_search=0 error-path test using the original dataset (filter-based). This means the bitset path is never exercised under a QPS-only configuration.

If the intent was to also verify the bitset workload works correctly under QPS measurement, add a call like:

const auto bitset_qps = vsag::eval::EvaluateSearch(index, bitset_dataset, config);
REQUIRE(bitset_qps.contains("qps"));

Otherwise, remove the config.enable_qps = true; line to avoid leaving dead state that suggests an incomplete test.

"filtered workloads currently support only ID filters; "
"hgraph.use_extra_info_filter must be false");

auto index_request = fixture.Request(index_workspace.Get());

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.

[note] The index_request is constructed via fixture.Request(index_workspace.Get()) which initializes workload with the unfiltered ground_truth and a hardcoded top_k=3. The test then immediately overwrites ground_truth with filtered_ground_truth and query_invalid_bitsets. This works because TOP_K (3) coincidentally matches the Request() default, but the dependency on the unfiltered ground truth being set first and then overwritten is fragile.

Consider adding a dedicated factory method (e.g. RequestFiltered) or constructing the IndexRequest directly with the filtered workload fields to make the intent explicit and avoid relying on the unfiltered defaults.


bool
CheckValid(int64_t id) const override {
checks_.fetch_add(1, std::memory_order_relaxed);

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.

[note] CheckValid performs a linear scan (std::find) over valid_ids_ on every invocation. For the test fixture this is fine since valid_ids_ is small (size = TOP_K = 3), but if this filter class is ever copied into production code or used with larger allow-lists, the O(n) per-ID check would become a hot-path bottleneck. Consider adding a comment noting this is test-only, or using an unordered_set for the allow-list lookup to make the intent clearer.

@LHT129 LHT129 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 this PR. The implementation is clean and well-structured — the filter/bitset validation, mutual exclusion checks, and index-type gating are all correctly placed. The test coverage is thorough with both positive and negative paths.

I left 3 inline comments:

  1. [suggestion] tools/eval/eval_dataset_test.cpp:556 — The bitset QPS test appears incomplete; config.enable_qps = true is set but never exercised for the bitset dataset.

  2. [note] tools/autotune/autotune_test.cpp:1023 — The filtered index_request construction reuses fixture.Request() which sets unfiltered defaults that are immediately overwritten. Consider a dedicated factory to make the intent clearer.

  3. [note] tools/autotune/autotune_test.cpp:320CountingAllowListFilter::CheckValid uses std::find (O(n)). Fine for the test fixture but worth a comment noting it is test-only.

Overall the PR is in good shape. The core logic (validation, routing, candidate gating) is correct and the documentation updates are thorough.

@vsag-bot vsag-bot removed the version/1.0 1. LazyHGraph & SIMQ 2. Unified search API 3. Streaming serialization 1. 新索引 2. 统一检索接口 3. 流式序列化 label Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Website and repository documentation 网站与仓库文档 area/examples C++, Python, and TypeScript examples C++、Python 与 TypeScript 示例 area/tools Command-line, evaluation, and developer tools 命令行、评测与开发工具 kind/feature Brand-new functionality or capabilities 引入全新的功能、新特性或新能力 size/XL 500-999 changed lines version/1.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat](eval_performance): support filtered HGraph workloads in AutoTune

5 participants