Skip to content

feat: Support for ModelBuilder In_Process Mode (1/2) #4784

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

Merged
merged 27 commits into from
Aug 9, 2024

Conversation

bryannahm1
Copy link
Contributor

Issue #, if available:

Description of changes:
Adding new mode of deployment named in_process_mode. Added in_process script to mode, made edits to transformers and model builder in order to support.

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

  • I have read the CONTRIBUTING doc
  • I certify that the changes I am introducing will be backward compatible, and I have discussed concerns about this, if any, with the Python SDK team
  • I used the commit message format described in CONTRIBUTING
  • I have passed the region in to all S3 and STS clients that I've initialized as part of this change.
  • I have updated any necessary documentation, including READMEs and API docs (if appropriate)

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added unit and/or integration tests as appropriate to ensure backward compatibility of the changes
  • I have checked that my tests are not configured for a specific region or account (if appropriate)
  • I have used 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.

Comment on lines 918 to 919
"IN_PROCESS mode is not supported yet for model server. It is "
"supported for MMS/Transformers server in beta release."
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: IN_PROCESS mode is only supported for MMS/Transformers server in beta release.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is better wording, I will change it thank you!

@@ -161,7 +164,7 @@ def _get_hf_metadata_create_model(self) -> Type[Model]:
vpc_config=self.vpc_config,
)

if not self.image_uri and self.mode == Mode.LOCAL_CONTAINER:
if self.mode == Mode.LOCAL_CONTAINER or self.mode == Mode.IN_PROCESS:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

LOCAL_MODES = [Mode.LOCAL_CONTAINER, Mode.IN_PROCESS]
if self.mode in LOCAL_MODES:
      ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion, I've made the edit, thank you

@@ -274,7 +293,7 @@ def _build_transformers_env(self):

self.pysdk_model = self._create_transformers_model()

if self.mode == Mode.LOCAL_CONTAINER:
if self.mode == Mode.LOCAL_CONTAINER or self.mode == Mode.IN_PROCESS:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:

if self.mode in LOCAL_MODES:
      ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the change

_PING_HEALTH_CHECK_INTERVAL_SEC = 5

_PING_HEALTH_CHECK_FAIL_MSG = (
"Container did not pass the ping health check. "
Copy link
Contributor

Choose a reason for hiding this comment

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

Does IN_PROCESS mode uses Container?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it does not, I will be sure to change this, good catch.

@samruds samruds self-requested a review July 16, 2024 04:06
):
"""Placeholder docstring"""

# self._pull_image(image=image)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can remove this this comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

def _multi_model_server_deep_ping(self, predictor: PredictorBase):
"""Placeholder docstring"""
response = None
logger.debug("AM I HERE? PING PING")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove this line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed it, thank you

)

def _invoke_multi_model_server_serving(self, request: object, content_type: str, accept: str):
"""Placeholder docstring"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Update doc strings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The docstrings are updated, good catch.

@@ -67,10 +67,18 @@
class TestModelBuilder(unittest.TestCase):
@patch("sagemaker.serve.builder.model_builder._ServeSettings")
def test_validation_in_progress_mode_not_supported(self, mock_serveSettings):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add a test a where it is supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I will add it. Good suggestion.


return (True, response)

def _multi_model_server_deep_ping(self, predictor: PredictorBase):
Copy link
Contributor

Choose a reason for hiding this comment

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

is this complete?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have stubbed it.

else:
env_vars = env

self.container = client.containers.run(
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we spinning up a docker container or using fast api for serving?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The container will be stubbed, this is only 1/2 of the full implementation of InProcess mode. My next PR will include the FastAPI.

Copy link
Collaborator

@samruds samruds left a comment

Choose a reason for hiding this comment

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

LGTM, please ensure existing servers dont break. Please run notebook against this change to ensure backward compatibility...

@makungaj1
Copy link
Contributor

Can we have this merge in a feature branch and merge to master until all complete and fully tested? cc @samruds

@bryannahm1 bryannahm1 marked this pull request as ready for review July 18, 2024 18:48
@bryannahm1 bryannahm1 requested a review from a team as a code owner July 18, 2024 18:48
@bryannahm1 bryannahm1 requested a review from nargokul July 18, 2024 18:48
@samruds
Copy link
Collaborator

samruds commented Jul 18, 2024

Can we have this merge in a feature branch and merge to master until all complete and fully tested? cc @samruds

Proposed split to enable to merge to mainline.

1/2 -> introduce in process mode , it should hit no-op stubs and return an empty response. Other servers should not be impacted.

2/2 - we introduce the fast API logic into the stubs. At this point the response should be a valid inference response. Other servers should not be impacted.

@sage-maker sage-maker merged commit a870e19 into aws:master Aug 9, 2024
14 checks passed
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