-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: InferenceSpec support for MMS and testing #4763
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
Conversation
719fe7e
to
aa4a62e
Compare
image_uri: str, | ||
inference_spec: InferenceSpec = None, | ||
) -> str: | ||
"""This is a one-line summary of the function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has been updated, thank you
@@ -109,7 +119,7 @@ def _get_hf_metadata_create_model(self) -> Type[Model]: | |||
""" | |||
|
|||
hf_model_md = get_huggingface_model_metadata( | |||
self.model, self.env_vars.get("HUGGING_FACE_HUB_TOKEN") | |||
self.env_vars.get("HF_MODEL_ID"), self.env_vars.get("HUGGING_FACE_HUB_TOKEN") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if model
is set with an HF model ID but the environment variable doesn't exist? does the environment variable get set based on self.model
before this line is executed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, HF Model ID gets set before the line is executed. This is where it is called:
https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/serve/builder/transformers_builder.py#L248-L261
https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/serve/builder/transformers_builder.py#L263
https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/serve/builder/transformers_builder.py#L83
) | ||
|
||
self.pysdk_model = self._create_transformers_model() | ||
|
||
if self.mode == Mode.LOCAL_CONTAINER: | ||
self._prepare_for_mode() | ||
|
||
logger.info("Model configuration %s", self.pysdk_model) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this logs a lot of info that customers may not necessarily need to see, what's the reason for adding this log line here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great comment, I will remove it.
@@ -881,8 +881,8 @@ def _build_for_model_server(self): # pylint: disable=R0911, R1710 | |||
if self.model_metadata: | |||
mlflow_path = self.model_metadata.get(MLFLOW_MODEL_PATH) | |||
|
|||
if not self.model and not mlflow_path: | |||
raise ValueError("Missing required parameter `model` or 'ml_flow' path") | |||
if not self.model and not mlflow_path and not self.inference_spec: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this here? Since we already have a PR for it? #4769
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes these changes can be removed, since i've moved this to another PR and added UT coverage for it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did the sync, thank you
|
||
class MultiModelServerPrepareTests(TestCase): | ||
def test_start_invoke_destroy_local_multi_model_server(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to re-run this locally to understand where it is failing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it
if isinstance(obj[0], InferenceSpec): | ||
inference_spec, schema_builder = obj | ||
|
||
logger.info("in model_fn") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This log statement can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has been removed
|
||
def predict_fn(input_data, predict_callable): | ||
"""Placeholder docstring""" | ||
logger.info("in predict_fn") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This log statement can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's now removed
|
||
|
||
def predict_fn(input_data, predict_callable): | ||
"""Placeholder docstring""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we update docstring here with what the method does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, thank you
|
||
|
||
def output_fn(predictions, accept_type): | ||
"""Placeholder docstring""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Update doc string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's now updated
self.instance_type, | ||
) | ||
else: | ||
raise ValueError("Cannot detect required model or inference spec") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add more details on how to fix this error. Like what parameter does the customer need to pass to fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it has just been updated. Thank you.
Issue #, if available:
Description of changes:
Added InferenceSpec support for MMS by adding inference.py file and code changes to testing script, and enabled support in local and endpoint mode.
Testing done:
Integr tests run locally
Merge Checklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.General
Tests
unique_name_from_base
to create resource names in integ tests (if appropriate)By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.