Skip to content

Commit 2c35686

Browse files
authored
RED-176382 Fix FT.CREATE failure with LeanVec parameters on non-Intel architectures (#7344)
* move isLVQSupported() to info remove isLVQSupportedfrom VecSim_IsLeanVecCompressionType expose isLVQSupported add , 'LeanVec4x8' to test_vecsim_svs:test_svs_vamana_info * add reduce
1 parent beae5f3 commit 2c35686

4 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/info/info_command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ void fillReplyWithIndexInfo(RedisSearchCtx* sctx, RedisModule_Reply *reply, bool
200200
REPLY_KVSTR("compression", VecSimSvsCompression_ToString(svs_params.quantBits));
201201
if (svs_params.quantBits != VecSimSvsQuant_NONE) {
202202
REPLY_KVINT("training_threshold", algo_params.tieredParams.specificParams.tieredSVSParams.trainingTriggerThreshold);
203-
if (VecSim_IsLeanVecCompressionType(svs_params.quantBits)) {
203+
if (isLVQSupported() && VecSim_IsLeanVecCompressionType(svs_params.quantBits)) {
204204
REPLY_KVINT("reduced_dim", svs_params.leanvec_dim);
205205
}
206206
}

src/vector_index.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#define CPUID_AVAILABLE 1
2222
#endif
2323

24-
static bool isLVQSupported() {
24+
bool isLVQSupported() {
2525

2626
#if defined(CPUID_AVAILABLE) && BUILD_INTEL_SVS_OPT
2727
// Check if the machine is Intel based on the CPU vendor.
@@ -298,7 +298,7 @@ const char *VecSimAlgorithm_ToString(VecSimAlgo algo) {
298298
}
299299

300300
bool VecSim_IsLeanVecCompressionType(VecSimSvsQuantBits quantBits) {
301-
return isLVQSupported() && (quantBits == VecSimSvsQuant_4x8_LeanVec || quantBits == VecSimSvsQuant_8x8_LeanVec);
301+
return quantBits == VecSimSvsQuant_4x8_LeanVec || quantBits == VecSimSvsQuant_8x8_LeanVec;
302302
}
303303

304304
const char *VecSimSvsCompression_ToString(VecSimSvsQuantBits quantBits) {

src/vector_index.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ const char *VecSimAlgorithm_ToString(VecSimAlgo algo);
165165
const char *VecSimSvsCompression_ToString(VecSimSvsQuantBits quantBits);
166166
const char *VecSimSearchHistory_ToString(VecSimOptionMode option);
167167
bool VecSim_IsLeanVecCompressionType(VecSimSvsQuantBits quantBits);
168+
bool isLVQSupported();
168169

169170
VecSimMetric getVecSimMetricFromVectorField(const FieldSpec *vectorField);
170171

tests/pytests/test_vecsim_svs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,14 @@ def test_svs_vamana_info():
156156
data_type = random.choice(VECSIM_SVS_DATA_TYPES)
157157

158158
# Create SVS VAMANA index with all compression flavors (except for global SQ8).
159-
compression_types = SVS_COMPRESSION_TYPES if is_intel_opt_enabled() and EXTENDED_PYTESTS else ['NO_COMPRESSION', 'LVQ8']
159+
compression_types = SVS_COMPRESSION_TYPES if is_intel_opt_enabled() and EXTENDED_PYTESTS else ['NO_COMPRESSION', 'LVQ8', 'LeanVec4x8']
160160
for compression_type in compression_types:
161161
cmd_params = ['TYPE', data_type,
162162
'DIM', dim, 'DISTANCE_METRIC', 'L2']
163163
if compression_type != 'NO_COMPRESSION':
164164
cmd_params.extend(['COMPRESSION', compression_type])
165+
if compression_type == 'LeanVec4x8':
166+
cmd_params.extend(['REDUCE', dim // 2])
165167
env.expect('FT.CREATE', 'idx', 'SCHEMA', 'v', 'VECTOR', 'SVS-VAMANA', len(cmd_params), *cmd_params).ok()
166168

167169
# Validate that ft.info returns the default params for SVS VAMANA, along with compression

0 commit comments

Comments
 (0)