Skip to content

fix(hgraph): expose skip_ratio and skip_strategy search parameters (v0.17 backport)#2370

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

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

Conversation

@LHT129

@LHT129 LHT129 commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Backport of #2367 to v0.17 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.

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:44
@LHT129 LHT129 self-assigned this Jun 29, 2026
@LHT129 LHT129 added kind/bug Bug fixes, defects, or unexpected behavior 修复程序错误、缺陷或异常行为 version/0.17 labels 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 in HGraphSearchParameters, including parsing them from JSON and passing them during a KNN search. However, the reviewer noted that these parameters are missing from other key search paths (SearchWithRequest and RangeSearch), meaning custom configurations would be ignored there. Additionally, a formatting regression in the test file needs to be corrected.

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.cpp
Comment thread src/algorithm/hgraph_parameter_test.cpp
@LHT129 LHT129 changed the title feat(hgraph): expose skip_ratio and skip_strategy search parameters (v0.17 backport) fix(hgraph): expose skip_ratio and skip_strategy search parameters (v0.17 backport) Jun 29, 2026
@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio-0.17 branch 2 times, most recently from f1f6203 to f939d95 Compare June 29, 2026 13:13
@codecov

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

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

@@            Coverage Diff             @@
##             0.17    #2370      +/-   ##
==========================================
- Coverage   91.94%   91.45%   -0.49%     
==========================================
  Files         320      320              
  Lines       17848    17856       +8     
==========================================
- Hits        16410    16331      -79     
- Misses       1438     1525      +87     
Flag Coverage Δ
cpp 91.45% <94.11%> (-0.49%) ⬇️

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

Components Coverage Δ
common 91.75% <ø> (ø)
datacell 93.09% <ø> (ø)
index 90.50% <100.00%> (-0.49%) ⬇️
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 f966069...040a7ff. 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.17 branch 12 times, most recently from 6647f8d to 5883142 Compare July 3, 2026 03:52
@pull-request-size pull-request-size Bot removed the size/L label Jul 3, 2026
@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio-0.17 branch from 5883142 to 62ceae2 Compare July 6, 2026 07:11
@vsag-bot

vsag-bot commented Jul 6, 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.17 branch from 62ceae2 to 780f6e6 Compare July 6, 2026 07:23
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Jul 6, 2026
@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio-0.17 branch 2 times, most recently from 42e0fc4 to aca0ad8 Compare July 7, 2026 06:13
…0.17 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.17 branch from aca0ad8 to 040a7ff Compare July 7, 2026 06:20
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/L version/0.17

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants