Repository navigation
Conversation
… (Redis 8.12)
RediSearch MOD-14958 adds `COMPRESSION SQ8` and `TRAINING_THRESHOLD` to
HNSW vector fields: 8-bit scalar quantization of the stored vectors for
FLOAT32/FLOAT16 with L2, IP or cosine, with an optional mean learned from
the first N vectors (server default 10240, maximum 102400, 0 = no
training) while they stay searchable in the flat tier.
HnswVectorField gains CompressionAlgorithm and TrainingThreshold, emitted
after the graph parameters when set, and AddHnswVectorField gains the
matching optional parameters (appended, so positional callers are
unaffected at the source level). VectorCompressionAlgorithm gains SQ8;
the token mapping is now shared with the SVS-VAMANA field.
No client-side validation of type/metric/threshold combinations: the
server owns those rules and reports them clearly ("COMPRESSION is only
supported for FLOAT32 and FLOAT16 vector types", "TRAINING_THRESHOLD is
irrelevant when compression was not requested"), and the tests pin that
the errors surface as RedisServerException. FT.INFO's new `compression`
and `training_threshold` attribute keys flow through the existing
untyped Attributes dictionaries.
Tests are gated to 8.12.0 and were run against the 8.12-m02-int image,
standalone and cluster, RESP2 and RESP3.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Client support for RediSearch MOD-14958 (RediSearch/RediSearch#11330, merged 2026-09-22; VectorSimilarity MOD-14956/7/8/60):
COMPRESSION SQ8andTRAINING_THRESHOLDon HNSW vector fields.What the server does
COMPRESSION SQ8: 8-bit scalar quantization of stored vectors. HNSW only;FLOAT32/FLOAT16withL2/IP/COSINEonly.TRAINING_THRESHOLD n: vectors stay in the flat tier untilnhave arrived, then a mean is learned and they migrate into the compressed graph; searchable throughout. Default 10240, max 102400, explicit 0 = no training. Only valid withCOMPRESSION.FT.INFOattributes gaincompressionandtraining_threshold(absent on uncompressed fields). Disk/Flex indexes reject both. Schema encoding v28.What this PR adds
HnswVectorField.CompressionAlgorithmand.TrainingThreshold, emitted after the graph parameters when set.AddHnswVectorField(..., compressionAlgorithm:, trainingThreshold:)as optional parameters appended aftermissingIndex, so existing positional callers compile unchanged. (Binary-breaking for compiled callers of the old signature, as any optional-parameter addition is; flagged for review.)VectorCompressionAlgorithm.SQ8. The enum stays shared across algorithms; theCOMPRESSIONtoken mapping is now one helper used by both HNSW and SVS-VAMANA.RedisServerException:COMPRESSION is only supported for FLOAT32 and FLOAT16 vector typesTRAINING_THRESHOLD is irrelevant when compression was not requestedFT.INFO: nothing to do;InfoResult.Attributesis untyped per field and the new keys flow through.tests/dockers/.env.v8.12pinned toredislabs/client-libs-test:8.12-m02-int. Same change as 8.12 CMS: support CELL_SIZE, fix CMS.INFO field parsing, cover negative INCRBY #562; whichever merges second is a no-op there.Tests
TestIndexingCreation_Hnsw_Sq8: argument rendering, with and without threshold.TestCreate_Hnsw_Sq8(8.12+, standalone + cluster): create,FT.INFOround trip including the server default of 10240 and the absence of both keys on an uncompressed field, KNN below the training threshold.TestCreate_Hnsw_Sq8_ServerRejectsInvalidCombinations(8.12+): the two server errors above, plus an SVS-only compression value on HNSW.Run locally against
redislabs/client-libs-test:8.12-m02-int(reportsredis_version:255.255.255), standalone and cluster, RESP2 and RESP3: 75/75 in the Search creation set. Library builds with 0 warnings on all TFMs. With the matrix change, the 8.12-gated tests now run in CI too.Not done, deliberately
GlobalSQ8for SVS-VAMANA (its scalar option); separate token, separate ticket if wanted.FT.INFOsurface for the new keys.