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

Various fixes to enable tempo to pack environment for single models #189

Merged
merged 31 commits into from
Sep 8, 2021

Conversation

sakoush
Copy link
Member

@sakoush sakoush commented Sep 2, 2021

This PR adds various fixes that we needed to get an mlflow model(e.g based on pytorch) saved and deployed using Tempo.

The main change is to pack the conda environment if save_env is True even if there is no custom predict function (i.e. BaseModel._user_func is False) defined, which is the case with individual models.

Other changes that are required as well:

  • Pack the runtime mlserver dependency as well, for example in the case of mlfow runtime we need to pack mlserver-mlflow. Models have platform which we use to specify with platform we use. (ModelFramework.MLFlow -> mlserver-mlflow) and that is defined in MLServerRuntimeEnvDeps.

  • MLServer supports a numpy codec for request input when the whole input in the (case of an image) is being sent in one go as in the first input. Setting content_type=np in the inference request will trigger that. check: Add request codec for numpy and strings which returns the first element MLServer#286 .

There is an example to showcase the pytorch model serving as a notebook.

TODO in this PR still:

  • Make sure that the other notebooks are still functional.

@sakoush sakoush changed the title Various fixes to enable temp to pack environment for single models Various fixes to enable tempo to pack environment for single models Sep 2, 2021
@@ -6,6 +6,8 @@
from tempo.serve.metadata import ModelDataArgs, ModelDetails
from tempo.serve.protocol import Protocol

_REQUEST_NUMPY_CONTENT_TYPE = {"content_type": "np"}
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 a MLServer specific parameter. The KFServing V2 could be for any compliant V2 server like Triton. Would need to check if this will be ignored by them?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes I think this is specific to MLServer. Doing a quick search on "content_type" in the triton repo doesnt result in anything that suggests that it is being used. We need to check then that it will be ignored by triton as you suggested.

this bit is a little bit convoluted I admit, so we might want to think how to do it properly.

Choose a reason for hiding this comment

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

The parameters field of the v2 payload should accept any arbitrary field. So unless Triton already uses this field for something else, I think that it should be alright.

@@ -8,7 +10,13 @@
DefaultRemoteFilename = "remote.pickle"
DefaultEnvFilename = "environment.tar.gz"

MLServerEnvDeps = ["mlserver==0.4.0"]
MLServerEnvDeps = ["mlserver==0.4.1.dev1"]
Copy link
Contributor

Choose a reason for hiding this comment

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

What are the changes in MLServer to require the dev1 release?

Copy link
Member Author

Choose a reason for hiding this comment

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

SeldonIO/MLServer#273 and SeldonIO/MLServer#286

These are specific changes required for being able to serve pytorch models (via mlflow) and it needed numpy fixes.

Choose a reason for hiding this comment

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

Now that the parallel inference fix for the outlier example is also in, should we build a 0.4.2 release and use that instead?



def _get_env(conda_env_file_path: str = None, env_name: str = None) -> dict:
def _get_env(conda_env_file_path: str = None, env_name: str = None, platform: ModelFramework = None) -> dict:
Copy link
Contributor

@ukclivecox ukclivecox Sep 3, 2021

Choose a reason for hiding this comment

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

Can you explain the changes in this file?

Copy link
Member Author

Choose a reason for hiding this comment

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

if we pack the conda environment, we need to add mlserver dependencies if not defined in conda.yaml

In the case of mlflow this is the case as the model conda.yaml generated will not have anything related to mlserver as not required for training.

There is logic to add mlserver package in _add_required_deps however we also need the corresponding runtime to be packaged (e.g. mlserver-mlflow in this case) and it is dependant on the type of model used. A reference to the platform is able to let us do that.

There is logic that

@ukclivecox
Copy link
Contributor

Should we add an associated example with MLFlow?

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@ukclivecox ukclivecox merged commit 0a0be3b into SeldonIO:master Sep 8, 2021
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.

3 participants