{"record":{"id":"ebb2dbf1075d551d","repo":"elastic/elasticsearch","slug":"attempt-to-retrieve-score-correction-for-different","errorCode":null,"errorMessage":"attempt to retrieve score correction for different ord {} than the quantization was done for: {}","messagePattern":"attempt to retrieve score correction for different ord (.+?) than the quantization was done for: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"libs/gpu-codec/src/main/java/org/elasticsearch/gpu/codec/MergedQuantizedVectorValues.java","lineNumber":238,"sourceCode":"        private final FloatVectorValues values;\n        private final ScalarQuantizer quantizer;\n        private final byte[] quantizedVector;\n        private int lastOrd = -1;\n        private float offsetValue = 0f;\n\n        private final VectorSimilarityFunction vectorSimilarityFunction;\n\n        QuantizedFloatVectorValues(FloatVectorValues values, VectorSimilarityFunction vectorSimilarityFunction, ScalarQuantizer quantizer) {\n            this.values = values;\n            this.quantizer = quantizer;\n            this.quantizedVector = new byte[values.dimension()];\n            this.vectorSimilarityFunction = vectorSimilarityFunction;\n        }\n\n        @Override\n        public float getScoreCorrectionConstant(int ord) {\n            if (ord != lastOrd) {\n                throw new IllegalStateException(\n                    \"attempt to retrieve score correction for different ord \" + ord + \" than the quantization was done for: \" + lastOrd\n                );\n            }\n            return offsetValue;\n        }\n\n        @Override\n        public int dimension() {\n            return values.dimension();\n        }\n\n        @Override\n        public int size() {\n            return values.size();\n        }\n\n        @Override\n        public byte[] vectorValue(int ord) throws IOException {","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/libs/gpu-codec/src/main/java/org/elasticsearch/gpu/codec/MergedQuantizedVectorValues.java#L220-L256","documentation":"Thrown by QuantizedFloatVectorValues.getScoreCorrectionConstant() when called with an ordinal different from the one used in the most recent vectorValue() call. This class lazily quantizes vectors: vectorValue(ord) sets lastOrd = ord and computes the offset/score correction, then getScoreCorrectionConstant(ord) must be called with the same ord. Calling getScoreCorrectionConstant with a different ord means the caller is out of sync with the quantization state.","triggerScenarios":"Calling getScoreCorrectionConstant(ord) before calling vectorValue(ord), or calling them with mismatched ordinals. This class is used during merging of quantized vectors where the scoring path expects the score correction constant to match the vector that was just quantized. The error indicates a protocol violation in the caller: vectorValue must be called first, then getScoreCorrectionConstant with the same ord.","commonSituations":"Bug in the merge/scoring code that calls getScoreCorrectionConstant before or without calling vectorValue for the same ordinal; concurrent access to the same QuantizedFloatVectorValues instance from multiple threads (not thread-safe); caller using a stale ord value after the iterator advanced.","solutions":["Always call vectorValue(ord) before getScoreCorrectionConstant(ord) with the same ord.","Do not share a QuantizedFloatVectorValues instance across threads — create a new instance per thread.","Check that the ord passed to getScoreCorrectionConstant matches the ord from the last vectorValue call.","If this occurs during segment merge, verify that the merge code follows the correct quantize-then-score protocol."],"exampleFix":"// before — calling score correction before vectorValue\nbyte[] quantized = values.vectorValue(5);\nfloat correction = values.getScoreCorrectionConstant(6); // wrong ord\n\n// after — same ord for both calls\nbyte[] quantized = values.vectorValue(5);\nfloat correction = values.getScoreCorrectionConstant(5); // matches","handlingStrategy":"validation","validationCode":"// Always call vectorValue before getScoreCorrectionConstant with the same ord\nbyte[] quantized = values.vectorValue(ord);\n// use quantized for scoring...\nfloat correction = values.getScoreCorrectionConstant(ord); // must match the ord above","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always call vectorValue(ord) before getScoreCorrectionConstant(ord) with the same ord.","Never share a QuantizedFloatVectorValues instance across threads.","Do not call getScoreCorrectionConstant after advancing the iterator without calling vectorValue first."],"tags":["gpu-codec","vector-search","quantization","validation","protocol-violation"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}