Skip to content

Fix argmin/argmax based on the distance type#2016

Open
achirkin wants to merge 5 commits into
mainfrom
fix-calc-truth-for-inner-product-1
Open

Fix argmin/argmax based on the distance type#2016
achirkin wants to merge 5 commits into
mainfrom
fix-calc-truth-for-inner-product-1

Conversation

@achirkin
Copy link
Copy Markdown
Contributor

Fix the distance type not taken into account when generating ground truth on GPU.

@achirkin achirkin requested a review from a team as a code owner April 13, 2026 13:33
@achirkin achirkin added bug Something isn't working non-breaking Introduces a non-breaking change labels Apr 13, 2026
Copy link
Copy Markdown
Contributor

@tfeher tfeher left a comment

Choose a reason for hiding this comment

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

LGTM.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 51abaa07-a75d-4e42-97fd-60f8c333b0ef

📥 Commits

Reviewing files that changed from the base of the PR and between 5f7d5a6 and 102a03a.

📒 Files selected for processing (1)
  • python/cuvs_bench/cuvs_bench/generate_groundtruth/__main__.py

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Corrected the ranking order for the inner_product metric when selecting top-k neighbors in groundtruth generation, ensuring accurate benchmark results.

Walkthrough

The change updates the top-k neighbor selection logic in the calc_truth function to correctly handle the "inner_product" metric. When merging results from batched distance computations, the code now negates distances for "inner_product" before sorting, ensuring the highest inner products are selected as top-k neighbors rather than the lowest.

Changes

Inner Product Metric Handling in Top-K Selection

Layer / File(s) Summary
Top-K Selection with Metric-Aware Sort Keys
python/cuvs_bench/cuvs_bench/generate_groundtruth/__main__.py
Top-k neighbor selection after batch concatenation now computes sort keys that negate distances when metric == "inner_product", ensuring correct ordering before argsort and final index reordering.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly addresses the main change: fixing argmin/argmax logic based on distance type, which aligns with the code modification that handles inner_product metric differently.
Description check ✅ Passed The description is directly related to the changeset, explaining that the fix addresses the distance type not being taken into account when generating ground truth on GPU.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-calc-truth-for-inner-product-1

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

bug Something isn't working non-breaking Introduces a non-breaking change

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

3 participants