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

Refactor deployment docs and tutorials #10726

Merged
merged 12 commits into from Dec 21, 2023
Merged

Refactor deployment docs and tutorials #10726

merged 12 commits into from Dec 21, 2023

Conversation

B-Step62
Copy link
Collaborator

@B-Step62 B-Step62 commented Dec 20, 2023

🛠 DevTools 🛠

Open in GitHub Codespaces

Install mlflow from this PR

pip install git+https://github.com/mlflow/mlflow.git@refs/pull/10726/merge

Checkout with GitHub CLI

gh pr checkout 10726

Related Issues/PRs

#xxx

What changes are proposed in this pull request?

Follow-up on #10675. Refactoring the existing Kubernetes deployment guide to include concrete and runnable steps.

How is this PR tested?

  • Existing unit/integration tests
  • New unit/integration tests
  • Manual tests

Does this PR require documentation update?

  • No. You can skip the rest of this section.
  • Yes. I've updated:
    • Examples
    • API references
    • Instructions

Release Notes

Is this a user-facing change?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release notes for MLflow users.

What component(s), interfaces, languages, and integrations does this PR affect?

Components

  • area/artifacts: Artifact stores and artifact logging
  • area/build: Build and test infrastructure for MLflow
  • area/deployments: MLflow Deployments client APIs, server, and third-party Deployments integrations
  • area/docs: MLflow documentation pages
  • area/examples: Example code
  • area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry
  • area/models: MLmodel format, model serialization/deserialization, flavors
  • area/recipes: Recipes, Recipe APIs, Recipe configs, Recipe Templates
  • area/projects: MLproject format, project running backends
  • area/scoring: MLflow Model server, model deployment tools, Spark UDFs
  • area/server-infra: MLflow Tracking server backend
  • area/tracking: Tracking Service, tracking client APIs, autologging

Interface

  • area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev server
  • area/docker: Docker use across MLflow's components, such as MLflow Projects and MLflow Models
  • area/sqlalchemy: Use of SQLAlchemy in the Tracking Service or Model Registry
  • area/windows: Windows support

Language

  • language/r: R APIs and clients
  • language/java: Java APIs and clients
  • language/new: Proposals for new client languages

Integrations

  • integrations/azure: Azure and Azure ML integrations
  • integrations/sagemaker: SageMaker integrations
  • integrations/databricks: Databricks integrations

How should the PR be classified in the release notes? Choose one:

  • rn/none - No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" section
  • rn/breaking-change - The PR will be mentioned in the "Breaking Changes" section
  • rn/feature - A new user-facing feature worth mentioning in the release notes
  • rn/bug-fix - A user-facing bug fix worth mentioning in the release notes
  • rn/documentation - A user-facing documentation change worth mentioning in the release notes

Copy link

github-actions bot commented Dec 20, 2023

Documentation preview for 32c1d40 will be available here when this CircleCI job completes successfully.

More info

@github-actions github-actions bot added area/docs Documentation issues rn/none List under Small Changes in Changelogs. labels Dec 20, 2023
@@ -124,24 +124,19 @@ MLflow offers support for a variety of deployment targets. For detailed informat
</a>
</div>
<div class="simple-card">
<a href="deploy-model-to-ray-serve.html">
<a href="../plugins.html#deployment-plugins">
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ray serve plugin is not actively maintained. We will probably replace this with deployment guide for LLMs, but for the time being just link to community plugins.

Please open the experient named "wine-quality" on the left, then click the run named "default-params" in the table.
For this case, you should see parameters including ``alpha`` and ``l1_ratio`` and metrics like ``training_score`` and ``mean_absolute_error_X_test``.

Step 4: Running Hyperparameter Tuning
Copy link
Member

Choose a reason for hiding this comment

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

Is this step necessary?

Copy link
Collaborator Author

@B-Step62 B-Step62 Dec 20, 2023

Choose a reason for hiding this comment

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

I initially had the same thought for the original tutorial, but ended up not removing this and positioned this page as an end-to-end tutorial. The main reason is that pure deployment steps are pretty much covered by the partner's docs, so the main audience I expect here is ppl who already know about k8s but not much about MLflow. Hence I thought it's not a bad idea to stretch a bit to demonstrate MLflow capability in realistic scenario - single training run doesn't look nice in the UI indeed. For ppl who already have knowledge about MLflow, I added an info box to tell skip to Step 6:)

Copy link
Member

Choose a reason for hiding this comment

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

I think that giving the UI some runs is a good idea :)

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good, let's keep this step

=================================
Using MLServer as the Inference Server
--------------------------------------
By default, MLflow deployment uses `Flask <https://flask.palletsprojects.com/en/1.1.x/>`_, a widely used WSGI web application framework for Python,
Copy link
Member

Choose a reason for hiding this comment

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

It might be nice to provide either a link or a brief description of what WSGI is (it can help to inform why we're saying this about Flask :) ) since the reading audience might not be familiar with the differences between a standard Web Server Gateway Interface and something else (like ASGI or the built-in optimizations for inference serving that MLServer from Seldon has).
What do you think about some brief education for readers on these topics so that they know why we're talking about and supporting MLServer on k8s?

Copy link
Collaborator Author

@B-Step62 B-Step62 Dec 21, 2023

Choose a reason for hiding this comment

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

The comparison is briefly described here in local deployment guide: https://output.circle-artifacts.com/output/job/0576e156-79b5-48d6-a81d-8ceafb03de8b/artifacts/0/docs/build/html/deployment/deploy-model-locally.html#serving-frameworks

But I didn't add low-level details on why, I will write a bit more specific details there and put link to it here.

Copy link
Member

Choose a reason for hiding this comment

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

Perfect! :D


MLflow provides an easy-to-use interface for deploying modeles as a Flask-based inference server. You can deploy the same inference
server to a Kubernetes cluster by containerizing it using the ``mlflow models build-docker`` command. However, this approach may not be scalable
and could be unsuitable for production use cases. Flask is not designed for high performance, and manually managing multiple instances of
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 say why Flask isn't ideally suited for ML inference (it's blocking) and how async gateways are far more optimized due to the potentially long-running nature of inference (depending on the model architecture, size, and optimization of the underlying library) and issues with scalability with a synchronous blocking web gateway?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure! Will add brief explanation on why.


warnings.filterwarnings("ignore")

alphas = [0.2, 0.5, 1.0]
Copy link
Member

Choose a reason for hiding this comment

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

Grid Search is terrible. Can we do a Random Search instead?
A fun paper to read on the topic: https://www.jmlr.org/papers/volume13/bergstra12a/bergstra12a.pdf

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah no reason not doing it:)


.. code-block:: python

from itertools import product
Copy link
Member

@harupy harupy Dec 21, 2023

Choose a reason for hiding this comment

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

Can we https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.GridSearchCV.html instead? Autologging automatically creates child runs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure (will use RandomizedSearchCV as per above comment)


Step 4: Running Hyperparameter Tuning
-------------------------------------

Copy link
Member

Choose a reason for hiding this comment

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

We might want to add a ref to https://www.mlflow.org/docs/latest/traditional-ml/hyperparameter-tuning-with-child-runs/notebooks/hyperparameter-tuning-with-child-runs.html
For people who want to see a more in-depth guide on hyperparameter tuning

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great idea, will add!


mlflow models serve -m runs:/<run_id_for_your_best_run>/model -p 1234 --enable-mlserver

This command starts a local server listening on port 1234. You can send a request to the server using ``curl`` command:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
This command starts a local server listening on port 1234. You can send a request to the server using ``curl`` command:
This command starts a local server listening on port 1234. You can send a request to the server using a ``curl`` command:

For this tutorial, we'll push the image to `Docker Hub <https://hub.docker.com/>`_, but you can use any other Docker registry,
such as `Amazon ECR <https://aws.amazon.com/ecr/>`_ or private registry.

If you don't have a Docker Hub account yet, create one at https://hub.docker.com/signup.
Copy link
Member

Choose a reason for hiding this comment

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

link

By default, MLflow stores the model in the local file system, so you need to configure MLflow to store the model in remote storage.
Please refer to `Artifact Store <../../../tracking.html#artifact-stores>`_ for setup instructions.

After configuring the artifact store, repeat the model training steps.
Copy link
Member

Choose a reason for hiding this comment

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

or load the best model from the model uri and re-log it from its in-memory object?

Copy link
Member

@BenWilson2 BenWilson2 left a comment

Choose a reason for hiding this comment

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

Fantastic work here @B-Step62 !! This is a HUGE improvement with a ton of great detail and a very easy to read step by step guide to something that is quite complex for most users.
After addressing the remaining comments, let's get this merged so we can push it out with the next site push (probably early next week when I get time :) )

Copy link
Member

@harupy harupy left a comment

Choose a reason for hiding this comment

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

LGTM!

B-Step62 and others added 11 commits December 21, 2023 18:21
…ks guides (mlflow#10675)

Signed-off-by: B-Step62 <yuki.watanabe@databricks.com>
Signed-off-by: Yuki Watanabe <31463517+B-Step62@users.noreply.github.com>
Co-authored-by: Ben Wilson <39283302+BenWilson2@users.noreply.github.com>
Co-authored-by: Serena Ruan <82044803+serena-ruan@users.noreply.github.com>
Signed-off-by: B-Step62 <yuki.watanabe@databricks.com>
Signed-off-by: B-Step62 <yuki.watanabe@databricks.com>
Signed-off-by: B-Step62 <yuki.watanabe@databricks.com>
Signed-off-by: B-Step62 <yuki.watanabe@databricks.com>
Co-authored-by: Harutaka Kawamura <hkawamura0130@gmail.com>
Signed-off-by: Yuki Watanabe <31463517+B-Step62@users.noreply.github.com>
Signed-off-by: B-Step62 <yuki.watanabe@databricks.com>
Signed-off-by: B-Step62 <yuki.watanabe@databricks.com>
Signed-off-by: B-Step62 <yuki.watanabe@databricks.com>
Co-authored-by: Ben Wilson <39283302+BenWilson2@users.noreply.github.com>
Signed-off-by: Yuki Watanabe <31463517+B-Step62@users.noreply.github.com>
Signed-off-by: B-Step62 <yuki.watanabe@databricks.com>
@B-Step62 B-Step62 changed the base branch from deployment-doc-revamp to master December 21, 2023 09:22
@B-Step62 B-Step62 changed the title Add deployment guide for Kubernetes Refactor deployment docs and tutorials Dec 21, 2023
@github-actions github-actions bot added rn/documentation Mention under Documentation Changes in Changelogs. and removed rn/none List under Small Changes in Changelogs. labels Dec 21, 2023
Signed-off-by: B-Step62 <yuki.watanabe@databricks.com>
@B-Step62 B-Step62 merged commit cf1cf51 into mlflow:master Dec 21, 2023
36 checks passed
@B-Step62 B-Step62 deleted the k8s branch December 21, 2023 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docs Documentation issues rn/documentation Mention under Documentation Changes in Changelogs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants