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

enable prebuilt model #729

Merged
merged 3 commits into from
Feb 17, 2023
Merged

enable prebuilt model #729

merged 3 commits into from
Feb 17, 2023

Conversation

ylwu-amzn
Copy link
Collaborator

@ylwu-amzn ylwu-amzn commented Feb 16, 2023

Description

As we have published prebuilt models to OpeSearch repo, we can enable uploading prebuilt model function now.

Example:

POST /_plugins/_ml/models/_upload
{
  "name": "huggingface/sentence-transformers/paraphrase-MiniLM-L3-v2",
  "version": "1.0.1",
  "model_format": "TORCH_SCRIPT"
}

Issues Resolved

#745

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --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.

Signed-off-by: Yaliang Wu <ylwu@amazon.com>
@ylwu-amzn ylwu-amzn requested a review from a team February 16, 2023 18:34
Copy link
Collaborator

@dhrubo-os dhrubo-os left a comment

Choose a reason for hiding this comment

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

Don't we need to add any test for this?

// }
// }
if (url != null) {
if (modelFormat == null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need to check modelFormat two times?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, I will remove this.

return String.format("https://ci.opensearch.org/ci/dbc/models/ml-models/%s/%s/config.json", modelName, version, Locale.ROOT);
public String getPrebuiltModelConfigPath(String modelName, String version, MLModelFormat modelFormat) {
String format = modelFormat.name().toLowerCase(Locale.ROOT);
return String.format("%s/%s/%s/%s/config.json", MODEL_REPO, modelName, version, format, Locale.ROOT);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we check if the file is actually there? May be raise an exception if the model config path is not valid?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The download function will throw exception if file doesn't exist.

// /huggingface/sentence-transformers/msmarco-distilbert-base-tas-b/1.0.0/onnx/config.json
String format = modelFormat.name().toLowerCase(Locale.ROOT);
String modelZipFileName = modelName.substring(index).replace("/", "_") + "-" + version + "-" + format;
return String.format("%s/%s/%s/%s/%s.zip", MODEL_REPO, modelName, version, format, modelZipFileName, Locale.ROOT);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here, may be we can check if the file is actually there? if not raise an exception saying invalid file path?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The download function will throw exception if file doesn't exist.

Zhangxunmt
Zhangxunmt previously approved these changes Feb 16, 2023
@dhrubo-os
Copy link
Collaborator

I had another comment about testing. Don't we need any corresponding testing for this code?

@ylwu-amzn
Copy link
Collaborator Author

I had another comment about testing. Don't we need any corresponding testing for this code?

This PR is to enable pre-built model feature.
The code was developed in this PR #655 , as we have no model published on model repo, we disabled in PR #682 before 2.5 release.
You can find testing code in PR #655. As the Github CI instance is not so powerful, we don't add IT for prebuilt model now. We have called out this issue to infra on 2.5 retro. Create an issue to track this

@codecov-commenter
Copy link

Codecov Report

Merging #729 (444228f) into 2.x (ffb8a4e) will increase coverage by 0.10%.
The diff coverage is 0.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@             Coverage Diff              @@
##                2.x     #729      +/-   ##
============================================
+ Coverage     84.95%   85.05%   +0.10%     
- Complexity     1076     1078       +2     
============================================
  Files           100      100              
  Lines          3922     3922              
  Branches        370      370              
============================================
+ Hits           3332     3336       +4     
+ Misses          433      430       -3     
+ Partials        157      156       -1     
Flag Coverage Δ
ml-commons 85.05% <0.00%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...n/java/org/opensearch/ml/model/MLModelManager.java 78.60% <0.00%> (ø)
.../cluster/MLCommonsClusterManagerEventListener.java 79.41% <0.00%> (+11.76%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Signed-off-by: Yaliang Wu <ylwu@amazon.com>
dhrubo-os
dhrubo-os previously approved these changes Feb 17, 2023
Signed-off-by: Yaliang Wu <ylwu@amazon.com>
@ylwu-amzn ylwu-amzn merged commit dc7a0b7 into opensearch-project:2.x Feb 17, 2023
ylwu-amzn added a commit to ylwu-amzn/ml-commons that referenced this pull request Mar 3, 2023
* enable prebuilt model

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* address comments

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* add unit test for prebuilt model url

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

---------

Signed-off-by: Yaliang Wu <ylwu@amazon.com>
ylwu-amzn added a commit to ylwu-amzn/ml-commons that referenced this pull request Mar 4, 2023
* enable prebuilt model

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* address comments

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* add unit test for prebuilt model url

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

---------

Signed-off-by: Yaliang Wu <ylwu@amazon.com>
ylwu-amzn added a commit that referenced this pull request Mar 4, 2023
* enable prebuilt model

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* address comments

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

* add unit test for prebuilt model url

Signed-off-by: Yaliang Wu <ylwu@amazon.com>

---------

Signed-off-by: Yaliang Wu <ylwu@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants