Skip to content

fix(hgraph): expose skip_ratio and skip_strategy search parameters (v0.18 backport)#2369

Open
LHT129 wants to merge 1 commit into
antgroup:0.18from
LHT129:lht/hgraph-skip-ratio-0.18
Open

fix(hgraph): expose skip_ratio and skip_strategy search parameters (v0.18 backport)#2369
LHT129 wants to merge 1 commit into
antgroup:0.18from
LHT129:lht/hgraph-skip-ratio-0.18

Conversation

@LHT129

@LHT129 LHT129 commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Backport of #2367 to v0.18 branch.

Fixes #2368

Breaking Change: skip_ratio semantics inverted

The skip_ratio parameter semantics have been inverted to match the parameter name.

Before: skip_ratio=0.8 meant visit 80% of invalid points.
After: skip_ratio=0.2 means skip 20% of invalid points (visit 80%).

Default values changed: HGraph 0.8 to 0.2, HNSW 0.9 to 0.1.

If using custom skip_ratio values, change to (1 - old_value) to maintain same behavior.

@LHT129 LHT129 requested review from inabao and wxyucs as code owners June 29, 2026 12:43
@LHT129 LHT129 added kind/bug Bug fixes, defects, or unexpected behavior 修复程序错误、缺陷或异常行为 version/0.18 labels Jun 29, 2026
@LHT129 LHT129 self-assigned this Jun 29, 2026
@mergify

mergify Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 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+)

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request adds support for configuring skip_ratio and skip_strategy_type parameters in HGraph search parameters, including parsing them from JSON and propagating them to the search parameters. The feedback suggests: 1) correcting a test case to use the supported RANDOM strategy instead of PROBABILISTIC to avoid compilation failures; 2) propagating these parameters in standard KNN and Range search paths (SearchWithRequest and RangeSearch) so they are not ignored; and 3) adding validation to ensure skip_ratio is within the valid range of [0.0, 1.0].

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/algorithm/hgraph_parameter_test.cpp
Comment thread src/algorithm/hgraph.cpp
Comment thread src/algorithm/hgraph_parameter.cpp
@LHT129 LHT129 changed the title feat(hgraph): expose skip_ratio and skip_strategy search parameters (v0.18 backport) fix(hgraph): expose skip_ratio and skip_strategy search parameters (v0.18 backport) Jun 29, 2026
@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio-0.18 branch 2 times, most recently from 2bac350 to 60f2910 Compare June 29, 2026 13:14
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.

@@            Coverage Diff             @@
##             0.18    #2369      +/-   ##
==========================================
- Coverage   91.45%   91.44%   -0.02%     
==========================================
  Files         330      330              
  Lines       19627    19638      +11     
==========================================
+ Hits        17950    17958       +8     
- Misses       1677     1680       +3     
Flag Coverage Δ
cpp 91.44% <93.33%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
common 85.94% <ø> (ø)
datacell 92.69% <ø> (-0.71%) ⬇️
index 91.85% <100.00%> (+0.08%) ⬆️
simd 100.00% <ø> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d967907...f376f8d. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pull-request-size pull-request-size Bot added size/L and removed size/M labels Jun 30, 2026
@mergify mergify Bot added the module/index label Jun 30, 2026
@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio-0.18 branch 11 times, most recently from 67ef682 to 9b8102d Compare July 3, 2026 03:02
@pull-request-size pull-request-size Bot added size/M and removed size/L labels Jul 3, 2026
@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio-0.18 branch from 9b8102d to 8b98440 Compare July 7, 2026 06:08
@vsag-bot

vsag-bot commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

/label S-waiting-on-review
/waiting-on reviewer
/request-review @jiaweizone
/request-review @wxyucs
/request-review @inabao
/request-review @ShawnShawnYou

@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio-0.18 branch 2 times, most recently from dca040e to e19b677 Compare July 7, 2026 06:20
…0.18 backport)

Expose skip_ratio and skip_strategy as configurable search parameters for
HGraph index. These parameters control the filter skip strategy during
graph traversal, allowing users to tune the trade-off between search
speed and recall when using filters.

Key changes:
- Add skip_ratio and skip_strategy_type fields to HGraphSearchParameters
- Parse these parameters from JSON in FromJson()
- Add validation for skip_ratio range [0.0, 1.0]
- Pass parameters to InnerSearchParam in both KnnSearch and
  SearchWithRequest paths
- Invert skip_ratio semantics to match parameter name meaning:
  skip_ratio now means "what percentage of invalid points to skip"
- Remove special case for valid_ratio==1.0 in get_retain_ratio
- Add unit tests for parameter parsing and validation
- Update test comments with correct formula

skip_ratio semantics (after inversion):
- skip_ratio=0.2 (default): skip 20% of invalid points
- retain_ratio = (1 - valid_ratio) * (1 - skip_ratio)
- visit_ratio = valid_ratio + retain_ratio

The underlying skip mechanism was already supported in BasicSearcher/
ParallelSearcher since v0.17.0, but was never exposed through the
public API for HGraph. This change maintains backward compatibility
by using the same default value (0.2) that was previously hardcoded.

Fixes: antgroup#2368

Signed-off-by: LHT129 <tianlan.lht@antgroup.com>
Assisted-by: opencode:qwen3.7-plus
@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio-0.18 branch from e19b677 to f376f8d Compare July 8, 2026 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Bug fixes, defects, or unexpected behavior 修复程序错误、缺陷或异常行为 module/index size/M version/0.18

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants