メインコンテンツまでスキップ

カスタム モデルサービング エンドポイントの作成

備考

プレビュー

Mosaic AI Model Serving は パブリック プレビュー 段階にあり、 us-east1us-central1でサポートされています。

この記事では、 モデルサービングを使用してDatabricksカスタムモデル を提供するモデルサービングエンドポイントを作成する方法について説明します 。

モデルサービングには、サービングエンドポイントの作成に関する次のオプションがあります。

  • サービングUI
  • REST API
  • MLflow デプロイ SDK

生成AI モデルを提供するエンドポイントの作成については、「 エンドポイントを提供する基盤モデルの作成」を参照してください。

必要条件

  • ワークスペースは 、サポートされているリージョンにある必要があります。
  • カスタムライブラリまたはプライベートミラーサーバーのライブラリをモデルで使用する場合は、モデルエンドポイントを作成する前に、 モデルサービングでカスタム Python ライブラリを使用する を参照してください。
  • MLflow デプロイ SDK を使用してエンドポイントを作成するには、MLflow デプロイ クライアントをインストールする必要があります。 インストールするには、次のコマンドを実行します。
Python
import mlflow.deployments

client = mlflow.deployments.get_deploy_client("databricks")

アクセス制御

エンドポイント管理のためのモデルサービングエンドポイントのアクセスコントロールオプションを理解するには、「 モデルサービングエンドポイントのアクセス許可を管理する」を参照してください。

また、モデルサービングの認証情報を保存するために環境変数を追加することもできます。 モデルサービングエンドポイントからリソースへのアクセスを設定するを参照してください。

エンドポイントを作成する

You can create an endpoint for model serving with the Serving UI.

  1. Click Serving in the sidebar to display the Serving UI.

  2. Click Create serving endpoint.

    Model serving pane in Databricks UI

For models registered in Unity Catalog:

  1. In the Name field provide a name for your endpoint.

  2. In the Served entities section, click into the Entity field to open the Select served entity form.

    1. Select the type of model you want to serve. The form dynamically updates based on your selection.
    2. Select which model and model version you want to serve.
    3. Select the percentage of traffic to route to your served model.
    4. Select what size CPU or GPU compute to use. Only the GPU_MEDIUM compute is supported for GPU.
    5. Under Compute Scale-out, select the size of the compute scale out that corresponds with the number of requests this served model can process at the same time. This number should be roughly equal to QPS x model run time. Available sizes are Small for 0-4 requests, Medium 8-16 requests, and Large for 16-64 requests.
    6. Specify if the endpoint should scale to zero when not in use.
  3. Click Create. The Serving endpoints page appears with Serving endpoint state shown as Not Ready.

    Create a model serving endpoint

また、次のこともできます。

GPU ワークロードの種類

GPU デプロイメントは、次のパッケージバージョンと互換性があります。

  • PyTorch 1.13.0 - 2.0.1
  • TensorFlow 2.5.0 - 2.13.0
  • MLflow 2.4.0 以降

GPU を使用してモデルをデプロイするには、エンドポイントの作成時にエンドポイント設定に workload_type フィールドを含めるか、API を使用してエンドポイント設定の更新として含めます。 Serving UI を使用して GPU ワークロードのエンドポイントを設定するには、 コンピュート Type ドロップダウンから目的の GPU タイプを選択します。

Bash
{
"served_entities": [{
"entity_name": "catalog.schema.ads1",
"entity_version": "2",
"workload_type": "GPU_MEDIUM",
"workload_size": "Small",
"scale_to_zero_enabled": false,
}]
}

次の表は、サポートされている使用可能な GPU ワークロードの種類をまとめたものです。

GPU ワークロードの種類

GPU インスタンス

GPUメモリ

GPU_MEDIUM

L4

カスタムモデルのエンドポイントを変更する

カスタムモデルエンドポイントを有効にした後、必要に応じてコンピュート設定を更新できます。 この構成は、モデルに追加のリソースが必要な場合に特に役立ちます。 ワークロードのサイズとコンピュートの設定は、モデルを提供するためにどのリソースが割り当てられるかにおいて重要な役割を果たします。

新しい設定の準備が整うまで、古い設定は予測トラフィックを提供し続けます。 更新が進行中の間は、別の更新を行うことはできません。 ただし、進行中の更新は Serving UI からキャンセルできます。

After you enable a model endpoint, select Edit endpoint to modify the compute configuration of your endpoint.

You can do the following:

  • Choose from a few workload sizes, and autoscaling is automatically configured within the workload size.
  • Specify if your endpoint should scale down to zero when not in use.
  • Modify the percent of traffic to route to your served model.

You can cancel an in progress configuration update by selecting Cancel update on the top right of the endpoint’s details page. This functionality is only available in the Serving UI.

モデルエンドポイントのスコアリング

モデルをスコアリングするには、モデルサービング エンドポイントに要求を送信します。

追加のリソース

ノートブックの例

次のノートブックには、モデルサービングエンドポイントを使用して起動して実行するために使用できる、さまざまな登録済みモデル Databricks が含まれています。 その他の例については、「 チュートリアル: カスタム モデルのデプロイとクエリ」を参照してください。

モデルの例は、「 ノートブックのインポート」の指示に従ってワークスペースにインポートできます。 いずれかの例からモデルを選択して作成したら、 Unity Catalogで登録するモデルサービングの UI ワークフロー手順に従います。

モデルサービングノートブックのscikit-learnモデルをトレーニングして登録する

Open notebook in new tab

モデルサービングノートブック用のHuggingFaceモデルをトレーニングして登録する

Open notebook in new tab