Skip to content

fix: use base scalar Similarity types in RVV SQ4U fallback path#1588

Merged
sre-ci-robot merged 1 commit into
zilliztech:mainfrom
CLiqing:fix/rvv-sq4u-fallback-use-base-similarity
Apr 20, 2026
Merged

fix: use base scalar Similarity types in RVV SQ4U fallback path#1588
sre-ci-robot merged 1 commit into
zilliztech:mainfrom
CLiqing:fix/rvv-sq4u-fallback-use-base-similarity

Conversation

@CLiqing
Copy link
Copy Markdown
Contributor

@CLiqing CLiqing commented Apr 16, 2026

Follow-up fix for #1586. The previous fix added simdwidth to the RVV Similarity tag types, but the QT_4bit_uniform fallback path in select_distance_computer_rvv still passed SimilarityL2_rvv<0> / SimilarityIP_rvv<0> directly to the base select_distance_computer, causing compilation failure on riscv64.

Fix:

  1. Map RVV tag types to their base scalar equivalents before calling select_distance_computer:
    • SimilarityL2_rvv<0> (metric_type == METRIC_L2) → SimilarityL2<1>
    • SimilarityIP_rvv<0> (metric_type == METRIC_INNER_PRODUCT) → SimilarityIP<1>
  2. Revert the incomplete fix from fix: add missing simdwidth to RVV Similarity classes for SQ4U fallback #1586 (remove simdwidth from RVV tag types), since the RVV code path never reads Similarity::simdwidth — keeping tag types minimal and consistent with their pure-tag design.

issue: #1587

Compilation errors before this fix (on riscv64 with v2.6.11 + #1586)

ScalarQuantizerCodec.h:659:20: error: no matching function for call to 'SimilarityIP_rvv<0>::SimilarityIP_rvv(std::nullptr_t)'
ScalarQuantizerCodec.h:660:13: error: 'struct SimilarityIP_rvv<0>' has no member named 'begin'
ScalarQuantizerCodec.h:664:17: error: 'struct SimilarityIP_rvv<0>' has no member named 'add_component_2'
ScalarQuantizerCodec.h:666:20: error: 'struct SimilarityIP_rvv<0>' has no member named 'result'
ScalarQuantizerCodec.h:648:20: error: no matching function for call to 'SimilarityL2_rvv<0>::SimilarityL2_rvv(const float*&)'
ScalarQuantizerCodec.h:649:13: error: 'struct SimilarityL2_rvv<0>' has no member named 'begin'
...

@mergify mergify Bot added the needs-dco label Apr 16, 2026
@CLiqing CLiqing force-pushed the fix/rvv-sq4u-fallback-use-base-similarity branch from 11ca213 to 3f92744 Compare April 16, 2026 10:17
@mergify mergify Bot added dco-passed and removed needs-dco labels Apr 16, 2026
@CLiqing CLiqing force-pushed the fix/rvv-sq4u-fallback-use-base-similarity branch from 3f92744 to f82c707 Compare April 16, 2026 10:27
@mergify mergify Bot added needs-dco and removed dco-passed labels Apr 16, 2026
@CLiqing CLiqing force-pushed the fix/rvv-sq4u-fallback-use-base-similarity branch from f82c707 to cb9190c Compare April 16, 2026 12:55
@mergify mergify Bot added dco-passed and removed needs-dco labels Apr 16, 2026
The previous fix (zilliztech#1586) added `simdwidth` to `SimilarityL2_rvv<0>`
and `SimilarityIP_rvv<0>`, but `select_distance_computer_rvv` still
passed RVV tag types directly to the base `select_distance_computer`.
Because that function instantiates `DCTemplate<..., Sim, 1>` for every
switch branch, and the SIMDWIDTH=1 specialization requires a full
scalar Similarity interface (constructor, begin, add_component,
add_component_2, result), the riscv64 build still fails with errors
like "no member named 'begin'" / "no matching constructor".

Fix: map `SimilarityL2_rvv<0>` → `SimilarityL2<1>` and
`SimilarityIP_rvv<0>` → `SimilarityIP<1>` before calling
`select_distance_computer`, so the base function instantiates
templates with types that satisfy the full interface contract.

This also reverts the incomplete fix from zilliztech#1586 (adding `simdwidth`
to RVV tag types), since the RVV code path never reads `simdwidth`
from its Similarity types — keeping the tag types minimal and
consistent with their pure-tag design.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: CLiqing <2208529306@qq.com>
@CLiqing CLiqing force-pushed the fix/rvv-sq4u-fallback-use-base-similarity branch from cb9190c to 44882a1 Compare April 17, 2026 03:14
@alexanderguzhva
Copy link
Copy Markdown
Collaborator

/rerun-e2e

Copy link
Copy Markdown
Collaborator

@foxspy foxspy left a comment

Choose a reason for hiding this comment

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

/lgtm

@sre-ci-robot
Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CLiqing, foxspy

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

The pull request process is described 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

@mergify mergify Bot added the ci-passed label Apr 20, 2026
@sre-ci-robot sre-ci-robot merged commit 3a04fe2 into zilliztech:main Apr 20, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants