Fix mode/comp params so parameter overrides work#2083
Fix mode/comp params so parameter overrides work#2083jmazanec15 merged 2 commits intoopensearch-project:mainfrom
Conversation
497ba8f to
3347eb0
Compare
|
|
||
| this.knnEngine = knnMethodContext.knnEngine; | ||
| this.spaceType = knnMethodContext.spaceType; | ||
| this.isEngineConfigured = true; |
There was a problem hiding this comment.
How do we know if engine configured or not? The engine in passed knnMethodContext might not have been configured.
There was a problem hiding this comment.
It will only be not configured if it is built from parsing. Otherwise, it will be configured.
There was a problem hiding this comment.
+1 its creating ambiguity, why is this needed? why can't we rely on nulls?
There was a problem hiding this comment.
Issue is with respect to BWC. Currently, in the parse method, we default to nmslib. So, we cannot swap this to null or else it might break BWC. For SpaceType, which is similarly defined, @heemin32 added an "SpaceType.UNDEFINED" option. I decided to not do this and just set whether it was explicitly configured on parse in order to check if we need to update.
There was a problem hiding this comment.
probably add a comment why its introduced and cannot be null
| if (entry.getValue() instanceof MethodComponentContext) { | ||
| parameters.put(entry.getKey(), new MethodComponentContext((MethodComponentContext) entry.getValue())); | ||
| } else { | ||
| parameters.put(entry.getKey(), entry.getValue()); |
There was a problem hiding this comment.
Curious what other types will be there. Is it okay not to copy them?
There was a problem hiding this comment.
They'll be one of the following: https://github.com/opensearch-project/k-NN/blob/main/src/main/java/org/opensearch/knn/index/engine/Parameter.java. So it will be okay
PR adds capability to override parameters when specifying mode and compression. In order to do this, I add functionality for creating a deep copy of KNNMethodContext and MethodComponentContext so that we wouldnt overwrite user provided config. Then, re-arranged some of the parameter resolution logic. Signed-off-by: John Mazanec <jmazane@amazon.com>
3347eb0 to
1eebcf6
Compare
|
|
||
| if (isModeConfigured && builder.vectorDataType.getValue() != VectorDataType.FLOAT) { | ||
| private void validateModeAndCompressionForDataType(KNNVectorFieldMapper.Builder builder) { | ||
| boolean isModeOrCompressionConfigured = builder.mode.isConfigured() || builder.compressionLevel.isConfigured(); |
There was a problem hiding this comment.
Why fail for mode = in_memory and/or compression = 1x for float?
There was a problem hiding this comment.
not for float - for non float we dont support setting it. I guess I can change this to support in_memory/1x for binary and byte to be no-op. Is this what you meant?
There was a problem hiding this comment.
so if vector data type is float, mode is in-memory and compression is 1x, doesn't that mean it should the current code path without any quantization? what am I missing?
There was a problem hiding this comment.
Oh nvm I think I missed the ! in the condition below
|
|
||
| if (this.hasDocValues) { | ||
| this.vectorFieldType = buildDocValuesFieldType(knnMethodContext.getKnnEngine()); | ||
| this.vectorFieldType = buildDocValuesFieldType(resolvedKnnMethodContext.getKnnEngine()); |
There was a problem hiding this comment.
There is some ambiguity when to use resolved and when to use original. I am not sure if there is a way to resolve that, there is a comment around it, I think its best to add guidelines in that comment
There was a problem hiding this comment.
Sure, Ill add a comment
| * KNNLibrary is an interface that helps the plugin communicate with k-NN libraries | ||
| */ | ||
| public interface KNNLibrary { | ||
| public interface KNNLibrary extends MethodResolver { |
There was a problem hiding this comment.
Do we really need to implement this? Would prefer punting it for now and rethink for later because no other methods are through interfaces in this interface
There was a problem hiding this comment.
Not sure what you mean. Typically, the requests are routed to the correct library via the knn engine. So, by implementing on the engine and library, we can efficiently route it.
There was a problem hiding this comment.
Its odd when KNNLibrary doesn't follow the pattern for other functions which are stand alone but can be broken down into interfaces
|
|
||
| this.knnEngine = knnMethodContext.knnEngine; | ||
| this.spaceType = knnMethodContext.spaceType; | ||
| this.isEngineConfigured = true; |
There was a problem hiding this comment.
+1 its creating ambiguity, why is this needed? why can't we rely on nulls?
src/main/java/org/opensearch/knn/index/engine/MethodComponentContext.java
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/index/engine/faiss/FaissHNSWPQEncoder.java
Show resolved
Hide resolved
src/main/java/org/opensearch/knn/index/engine/faiss/FaissIVFPQEncoder.java
Show resolved
Hide resolved
51dce61 to
3973235
Compare
3973235 to
95b7cda
Compare
Signed-off-by: John Mazanec <jmazane@amazon.com>
95b7cda to
bc8cae5
Compare
PR adds capability to override parameters when specifying mode and compression. In order to do this, I add functionality for creating a deep copy of KNNMethodContext and MethodComponentContext so that we wouldnt overwrite user provided config. Then, re-arranged some of the parameter resolution logic. Signed-off-by: John Mazanec <jmazane@amazon.com> (cherry picked from commit 270ac6a)
PR adds capability to override parameters when specifying mode and compression. In order to do this, I add functionality for creating a deep copy of KNNMethodContext and MethodComponentContext so that we wouldnt overwrite user provided config. Then, re-arranged some of the parameter resolution logic. Signed-off-by: John Mazanec <jmazane@amazon.com> (cherry picked from commit 270ac6a)
…2083) PR adds capability to override parameters when specifying mode and compression. In order to do this, I add functionality for creating a deep copy of KNNMethodContext and MethodComponentContext so that we wouldnt overwrite user provided config. Then, re-arranged some of the parameter resolution logic. Signed-off-by: John Mazanec <jmazane@amazon.com>
Description
In #1949, the intention was to allow users to override params when specifying the mode/compression. If this cannot be done, then it will make it wont be possible to tune indexing characteristics when mode is set, and is thus a broken experience. PR fixes this so that users can override params when using mode/compression params.
The main classes are:
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.