Skip to content
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

Update training validation to be handled per algo type #2462

Merged
merged 6 commits into from
Feb 27, 2025

Conversation

anntians
Copy link
Contributor

Description

This PR is a follow up to another PR #2378. In the other PR we added more detailed error messages to validate training parameters, and this PR builds on those changes by updating the validation to be handled per algo type.

Related Issues

Resolves #2268

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

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.

@anntians
Copy link
Contributor Author

This PR is a follow up to another PR #2378. Can I get help with adding the skip-changelog and backport main label to this PR please. Thanks!

@@ -182,4 +182,30 @@ protected void validateCompressionConflicts(CompressionLevel originalCompression
throw validationException;
}
}

protected void validateMDivisibleByVectorDimension(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we generalize this? M is specific to PQ so shouldnt go in abstract class.

.getParameters()
.get(METHOD_ENCODER_PARAMETER);

if (knnMethodContext.getMethodComponentContext().getParameters().containsKey(METHOD_PARAMETER_NLIST)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to move specifics into the HNSW and IVF method classes?


TrainingConfigValidationOutput.TrainingConfigValidationOutputBuilder builder = TrainingConfigValidationOutput.builder();

// validate ENCODER_PARAMETER_PQ_M is divisible by vector dimension
Copy link
Member

@jmazanec15 jmazanec15 Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flat encoder doesnt have M parameter. Only PQ does. So you can just noop on this


TrainingConfigValidationOutput.TrainingConfigValidationOutputBuilder builder = TrainingConfigValidationOutput.builder();

// validate ENCODER_PARAMETER_PQ_M is divisible by vector dimension
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PQ_M is only valid for PQ encoders. You can noop on this.

.getParameters()
.get(METHOD_ENCODER_PARAMETER);

if (knnMethodContext.getMethodComponentContext().getParameters().containsKey(METHOD_PARAMETER_NLIST)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we delegate this to the encoder?

.getParameters()
.get(METHOD_ENCODER_PARAMETER);

if (knnMethodContext.getMethodComponentContext().getParameters().containsKey(METHOD_PARAMETER_NLIST)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

@@ -61,4 +63,10 @@ public CompressionLevel calculateCompressionLevel(
// TODO: Hard code for now
return CompressionLevel.x2;
}

@Override
public TrainingConfigValidationOutput validateEncoderConfig(TrainingConfigValidationInput trainingConfigValidationInput) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


TrainingConfigValidationOutput.TrainingConfigValidationOutputBuilder builder = TrainingConfigValidationOutput.builder();

// validate ENCODER_PARAMETER_PQ_M is divisible by vector dimension
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We dont need this for QFrameEncoder - this should just noop

@anntians anntians requested a review from Vikasht34 as a code owner February 5, 2025 21:26
@anntians anntians force-pushed the errorMessages branch 2 times, most recently from 1e26bd2 to 2cc1523 Compare February 10, 2025 17:46
@jmazanec15
Copy link
Member

@anntians can you rebase to main? Also is this PR ready to be reviewed? I think overall it looks pretty good

@@ -182,4 +182,5 @@ protected void validateCompressionConflicts(CompressionLevel originalCompression
throw validationException;
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove this line


if (validationOutput.getValid() != null && !validationOutput.getValid()) {
ValidationException validationException = new ValidationException();
validationException.addValidationError("Training request ENCODER_PARAMETER_PQ_M is not divisible by vector dimensions");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we fix this?

@anntians anntians force-pushed the errorMessages branch 2 times, most recently from 170af13 to 00e597a Compare February 25, 2025 22:24
@anntians anntians force-pushed the errorMessages branch 2 times, most recently from ff2c1a5 to c823ce1 Compare February 26, 2025 17:03
@anntians anntians changed the base branch from 2.x to main February 26, 2025 17:04
@anntians anntians force-pushed the errorMessages branch 2 times, most recently from f267557 to 5941b02 Compare February 26, 2025 17:11
AnnTian Shao added 6 commits February 26, 2025 10:21
Signed-off-by: AnnTian Shao <anntians@amazon.com>
Signed-off-by: AnnTian Shao <anntians@amazon.com>
Signed-off-by: AnnTian Shao <anntians@amazon.com>
Signed-off-by: AnnTian Shao <anntians@amazon.com>
Signed-off-by: AnnTian Shao <anntians@amazon.com>
Signed-off-by: AnnTian Shao <anntians@amazon.com>
@jed326 jed326 added the v3.0.0 label Feb 27, 2025
@naveentatikonda naveentatikonda merged commit 0d06b23 into opensearch-project:main Feb 27, 2025
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error messaging/validation for faiss training
4 participants