-
Notifications
You must be signed in to change notification settings - Fork 21
[MOD-10185] add SVS fp16 tests #740
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
add validateSVSIndexAttributesInfo to compare info to params add populate_float16_vec
fix cosine batch iterators tests and all fp16 tests
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #740 +/- ##
==========================================
+ Coverage 96.82% 97.02% +0.19%
==========================================
Files 122 122
Lines 7496 7521 +25
==========================================
+ Hits 7258 7297 +39
+ Misses 238 224 -14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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 introduces comprehensive FP16 testing for the SVS algorithm, adding a new test suite that validates SVS functionality with float16 vectors across single-index, multi-index, and tiered index configurations. The tests are adapted from the existing SVS test suite with proper FP32→FP16 conversion handling.
Key Changes
- Adds 47 specialized FP16 tests across three test classes covering core SVS functionality, multi-index scenarios, and tiered indexing
- Implements proper FP16 vector data retrieval in SVS index for testing purposes
- Enhances test infrastructure with FP16 vector generation utilities and improved debugging capabilities
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
tests/unit/test_svs_fp16.cpp | New comprehensive FP16 test suite for SVS algorithm (mentioned in CMakeLists.txt) |
tests/utils/tests_utils.h | Adds FP16 vector generation utility function |
tests/unit/unit_test_utils.h | Declares SVS parameter validation function |
tests/unit/unit_test_utils.cpp | Implements SVS parameter validation and enhances test debugging |
tests/unit/test_index_test_utils.cpp | Adds tests for new query result print operators |
tests/unit/CMakeLists.txt | Includes new FP16 test file in build |
src/VecSim/query_result_definitions.h | Adds debug print operators for query results |
src/VecSim/algorithms/svs/svs.h | Implements vector data retrieval by label for testing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM, It seems like we have a good coverage here without going deeply into the test code itself. Few general questions:
- Should we cover the tests listed under "New FP16-specific tests" for Float32 as well?
- Any particular reason why "KNNSearch" is the only one that we have only for single and for multi as well?
- Regarding the excluded tests - what does it mean in general that tests "couldn't be reliably implemented with FP16 precision"? relaxing the accuracy expectation did not work in that case? And in particular, why not covering timeouts and why do "infinity values not achievable with FP16"? As for the rest of the excluded tests, I understand the reason for the exclusion.
Overview
This PR introduces a comprehensive test suite for FP16 data types in the SVS algorithm.
The new test file
test_svs_fp16.cpp
is adapted from the existingtest_svs.cpp
to specifically validate SVS functionality withfloat16
vectors across single-index, multi-index, and tiered index configuration.Key Changes
New Test File:
tests/unit/test_svs_fp16.cpp
Test Class Structure
The file introduces three specialized test classes:
FP16SVSTest
: Core SVS functionality tests for single-index scenariosFP16SVSMultiTest
: Multi-index SVS tests (inherits fromFP16SVSTest
)FP16SVSTieredIndexTest
: Tiered index SVS tests (inherits fromFP16SVSTest
)Type Definitions: runs
float16
with quantization modes:VecSimSvsQuant_NONE
VecSimSvsQuant_8
VecSimSvsQuant_8x8_LeanVec
Custom Vector Generation: Added
GenerateVector()
andGenerateAndAddVector()
methods specifically forfloat16
with proper FP32→FP16 conversionData Conversion: All vector operations use
vecsim_types::FP32_to_FP16()
andvecsim_types::FP16_to_FP32()
for proper type conversionTest Coverage
Total Test Count: 47 tests (28 core + 10 multi-index + 9 tiered index)
Core SVS Tests (
FP16SVSTest
- 31 tests)All essential SVS functionality tests adapted for FP16, including both adapted tests from the original suite and new FP16-specific tests:
Adapted from original test suite (26 tests):
svs_vector_add_test
,svs_vector_update_test
svs_bulk_vectors_add_delete_test
svs_indexing_same_vector
,svs_reindexing_same_vector
,svs_reindexing_same_vector_different_id
svs_batch_iterator
,svs_batch_iterator_non_unique_scores
,svs_batch_iterator_reset
,svs_batch_iterator_corner_cases
,batchIteratorSwapIndices
resizeIndex
,svs_empty_index
,test_delete_vector
svs_vector_search_test_ip
,svs_vector_search_test_l2
,svs_vector_search_test_cosine
rangeQuery
,rangeQueryCosine
test_svs_info
,test_basic_svs_info_iterator
,test_dynamic_svs_info_iterator
testSizeEstimation
sanity_reinsert_1280
svs_get_distance
scalar_quantization_query
New FP16-specific tests (2 tests):
quant_modes
: Comprehensive quantization mode validationtest_override_all
: Vector override functionality testingMulti-Index Tests (
FP16SVSMultiTest
- 10 tests)Specialized tests for multi-index scenarios where multiple vectors can share the same label:
vector_add_multiple_test
: Adding multiple vectors with same labelvector_search_test
: Search functionality in multi-index contextsearch_more_than_there_is
: Edge case handling for search limitsfind_better_score
: Score optimization in multi-vector scenariosfind_better_score_after_pop
: Score optimization after vector removalreindexing_same_vector_different_id
: Reindexing with different IDstest_svs_info
: Multi-index debug information validationtest_basic_svs_info_iterator
: Multi-index debug iterator testingrangeQuery
: Range queries in multi-index contextsvs_batch_iterator_basic
: Batch iteration for multi-indexTiered Index Tests (
FP16SVSTieredIndexTest
- 9 tests)Tests for tiered index architecture with background indexing:
CreateIndexInstanceSingle
/CreateIndexInstanceMulti
: Index creation validationRangeTestSingle
/RangeTestMulti
: Range query testing for both configurationsKNNSearch
: K-nearest neighbor search in tiered contextdeleteVector
/deleteVectorMulti
: Vector deletion in tiered indexesBatchIteratorSingle
/BatchIteratorMulti
: Batch iteration for tiered indexesTests Excluded (18 tests)
Tests from the original
test_svs.cpp
that were intentionally not included, either because they are not relevant to For couldn't be reliably implemented with FP16 precision:testTimeoutReturn_topK
,testTimeoutReturn_range
,testTimeoutReturn_batch_iterator
test_svs_parameter_combinations_and_defaults
,test_svs_parameter_consistency_across_metrics
resolve_ws_search_runtime_params
,resolve_bc_search_runtime_params
,resolve_use_search_history_runtime_params
,resolve_epsilon_runtime_params
svs_test_inf_score
(infinity values not achievable with FP16)debugInfoIteratorFieldOrder
,svs_vector_search_by_id_test
testInitialSizeEstimation
(covered bytestSizeEstimation
),joinSearchParams
(type not relevant),FitMemoryTest
(no-op),logging_runtime_params
,preferAdHocOptimization
(essentially no-op test),svs_search_empty_index
(duplicate ofsvs_empty_index
),Additional Infrastructure Changes
SVS Index Implementation Enhancements
Enhanced Vector Data Access (
src/VecSim/algorithms/svs/svs.h
)getStoredVectorDataByLabel()
: Added comprehensive implementation for retrieving stored vector data by label (only supported for non-compressed indices, both single and multi-index configurations)Query Result Debugging (
src/VecSim/query_result_definitions.h
)operator<<
forVecSimQueryResult
andVecSimQueryReply
to enable better test debugging#ifdef BUILD_TESTS
to keep production code cleanvalidateTopKSearchTest()
function now prints all results of the assertion fails:ASSERT_TRUE(allUniqueResults(res)) << *res;
)Test Infrastructure Improvements
Enhanced Test Utilities (
tests/unit/unit_test_utils.cpp
&.h
)validateSVSIndexAttributesInfo()
function to validate SVS index parameters againstsvsInfoStruct
valuesExtended Test Data Generation (
tests/utils/tests_utils.h
)populate_float16_vec()
function for generating random FP16 test vectors