Skip to main content
Version: v0.64.0

Scoring runtimes

Overview

The selection of available runtimes is determined by the artifact type that you specify. The following list provides information on the available options when selecting an artifact type and runtime.

note

Selecting an incorrect runtime causes the deployment to fail.

Artifact typeVersionRuntime optionNotes
Driverless AI MOJO pipelineDAI 1.9.3 and laterDAI MOJO Scorer (Shapley none)
Driverless AI MOJO pipelineDAI 1.10.0 and laterDAI MOJO Scorer (Shapley original only)Requires 2x the memory as the Shapley none option.
Driverless AI MOJO pipelineDAI 1.9.3 and laterDAI MOJO Scorer (Shapley transformed only)Requires 2x the memory as the Shapley none option.
Driverless AI MOJO pipelineDAI 1.10.0 and laterDAI MOJO Scorer (Shapley all)Requires 3x the memory as the Shapley none option.
Driverless AI MOJO pipelineDAI 1.10.0 and laterDAI MOJO Scorer (C++ Runtime)Experiment needs to be linked through project. Original Shapley requires DAI 1.10.3 and later. Transformed Shapley requires DAI 1.10.2 and later.
Driverless AI Python scoring pipelineDAI 1.9.3Python Pipeline Scorer [DAI 1.9.3]No longer supported.
Driverless AI Python scoring pipelineDAI 1.10.0 and laterPython Pipeline Scorer [DAI 1.10.0] and Python Pipeline Scorer [DAI 1.10.4.3]Python pipeline scorer’s version must correspond to the DAI version used to build the model (for example, a model built with DAI 1.10.4.2 must use Python Pipeline Scorer [DAI 1.10.4.2]).
H2O-3 MOJOAll versionsH2O-3 MOJO Scorer
MLflow / .pkl fileMLflow Model Scorer [Python 3.8] and MLflow Model Scorer [Python 3.9]MLflow Model Scorer’s version must correspond to the Python version used to build the model.
MLflow[PY-3.8] MLflow Dynamic Model Scorer, [PY-3.9] MLflow Dynamic Model Scorer, and [PY-3.10] MLflow Dynamic Model ScorerFor information on how to use the dynamic runtime, see MLflow Dynamic Runtime.
note

The C++ MOJO2 runtime (DAI MOJO Scorer (C++ Runtime)) accepts a wider range of algorithms DAI may use that the Java runtime does not support, including BERT, GrowNet, and TensorFlow models. If you want to use one of these models, it must be linked from DAI and not be manually uploaded.

MLflow Dynamic Runtime

The MLflow Dynamic Runtime lets you deploy MLflow models with diverse dependencies in H2O MLOps. The following steps describe how to deploy a dynamic MLflow runtime deployment in H2O MLOps.

Note: For an example of how to train a dynamic runtime, see Train a dynamic runtime.

  1. Save your model using the mlflow.pyfunc.save_model function call. Use the pip_requirements parameter to specify the Python package dependencies required by the model.
mlflow.pyfunc.save_model(
path=...,
python_model=...,
artifacts=...,
signature=...,
pip_requirements=..., # <- Use this parameter to override libs for dynamic runtime
)
  1. After saving the model, create a zip archive of the saved model directory. Ensure that a requirements file (requirements.txt) that lists all dependencies is included in the zip archive. The following is an example of the expected structure for the zip file from a TensorFlow model:
tf-model-py310
├── MLmodel
├── artifacts
│   └── tf.h5
├── conda.yaml
├── python_env.yaml
├── python_model.pkl
└── requirements.txt
  1. Depending on whether you are using Python 3.8 or Python 3.9, select from one of the following options:
  • [PY-3.8] MLflow Dynamic Model Scorer
  • [PY-3.9] MLflow Dynamic Model Scorer
note

The MLflow Dynamic Runtime has a fixed MLflow dependency, which is MLflow 1.26.1. This means that the MLflow Dynamic Runtime is not guaranteed to work with a different version of MLflow model.

Example: Train a dynamic runtime model

The following example demonstrates how to train a dynamic runtime with TensorFlow:

# Import libraries
import mlflow
import pandas as pd
import shutil
import tensorflow as tf
from sklearn import datasets

# Load and prepare data
diabetes = datasets.load_diabetes()
X = diabetes.data[:, 2:3] # Use only one feature for simplicity
y = diabetes.target

# Build and train TensorFlow model
tf_model = tf.keras.models.Sequential([
tf.keras.layers.Dense(1, input_dim=1)
])
tf_model.compile(optimizer='adam', loss='mean_squared_error')
tf_model.fit(X, y, epochs=10)

tf_model_path = "tf.h5"

tf_model.save(tf_model_path, save_format="h5")


# Enable the TensorFlow model to be used in the Pyfunc format
class PythonTFmodel(mlflow.pyfunc.PythonModel):
def load_context(self, context):
import tensorflow as tf
self.model = tf.keras.models.load_model(context.artifacts["model"])

def predict(self, context, model_input):
tf_out = self.model.predict(model_input)
return pd.DataFrame(tf_out, columns=["db_progress"])


# Generate signature from your model definition
model = PythonTFmodel()
context = mlflow.pyfunc.PythonModelContext(model_config=dict(), artifacts={"model": tf_model_path})
model.load_context(context)
x = pd.DataFrame(X, columns=["dense_input"])
y = model.predict(context, x)
signature = mlflow.models.signature.infer_signature(x, y)

...

# Specify a file path where the model will be saved
mlflow_model_path = "./tf-model-py310"

# Save model using MLflow
mlflow.pyfunc.save_model(
path=mlflow_model_path,
python_model=PythonTFmodel(),
signature=signature,
artifacts={"model": tf_model_path},
pip_requirements=["tensorflow"]
)

# Package model as a zip archive
shutil.make_archive(
mlflow_model_path, "zip", mlflow_model_path
)

The following is the structure of the zip file that is generated in the preceding example:

tf-model-py310
├── MLmodel
├── artifacts
│   └── tf.h5
├── conda.yaml
├── python_env.yaml
├── python_model.pkl
└── requirements.txt

Feedback