Skip to main content
Version: v1.0.0

MLOps model support

In H2O MLOps, the following model formats are supported:

note

Before a model can be deployed, it must first be registered in the H2O MLOps Model Registry.

H2O Driverless AI MOJO pipeline / Python scoring pipeline

You can import H2O Driverless AI MOJO / scoring pipeline .zip files directly through the H2O DAI interface or by dragging and dropping the file.

Alternatively, you can create an H2O MLOps deployment directly from the completed experiment page in H2O Driverless AI.

For more information, see Deploy Driverless AI models.

The following H2O Driverless AI versions are compatible with H2O MLOps v1.0.0:

  • 1.10.7
  • 1.10.7.1
  • 1.10.7.2
  • 1.10.7.3
  • 1.10.7.4
  • 1.10.7.5
  • 1.11.0
  • 1.11.1.1
  • 2.0.0
  • 2.1.0
  • 2.2.0

H2O-3 open-source MOJO

You can upload an H2O-3 open-source MOJO .zip file by dragging and dropping it into the interface to deploy it in H2O MLOps.

H2O Hydrogen Torch MLflow artifact

After building a model in H2O Hydrogen Torch, you can deploy it to H2O MLOps. To learn more, see Deploy a model to H2O MLOps through the H2O Hydrogen Torch UI.

You can also download an H2O MLOps scoring pipeline for a model built in H2O Hydrogen Torch and use it to score new data through the H2O MLOps REST API. To learn more, see H2O MLOps pipeline.

Third-party model frameworks through MLflow

Third-party model frameworks include scikit-learn, PyTorch, XGBoost, LightGBM, and TensorFlow. You can import models by dragging and dropping an MLflow-packaged file.

To learn more about adding third-party models to H2O MLOps, see MLflow model support.

The following examples demonstrate how to wrap third-party model frameworks such as PyTorch, scikit-learn, and custom Python models using MLflow. You can then upload the resulting MLflow .zip file directly to H2O MLOps.

Example walkthrough

# Train PyTorch model
X_train, y_train = sklearn.datasets.load_wine(return_X_y=True, as_frame=True)
X_tensor = torch.from_numpy(X_train.to_numpy())
y_tensor = torch.from_numpy(y_train.to_numpy())
dataset = torch.utils.data.dataset.TensorDataset(X_tensor, y_tensor)

torch_model = torch.nn.Linear(13, 1)
loss_fn = torch.nn.MSELoss(reduction="sum")

learning_rate = 1e-6
for batch in dataset:
torch_model.zero_grad()

X, y = batch
y_prediction = torch_model(X.float())
loss = loss_fn(y_prediction, y.float())
loss.backward()

with torch.no_grad():
for param in torch_model.parameters():
param -= learning_rate * param.grad

# Infering and setting model signature
# Model signature is mandatory for models that are going to be loadable by the server.
# Only ColSpec inputs and output are supported.
model_signature = signature.infer_signature(X_train)
model_signature.outputs = mlflow.types.Schema(
[mlflow.types.ColSpec(name="quality", type=mlflow.types.DataType.float)]
)

# Save as MLflow and zip the artifact.
model_tmp = tempfile.TemporaryDirectory()
try:
model_dir_path = os.path.join(model_tmp.name, "wine_model")
mlflow.pytorch.save_model(
torch_model, model_dir_path, signature=model_signature
)
zip_path = shutil.make_archive(
os.path.join(model_tmp.name, "artifact"), "zip", model_dir_path
)
final_zip_path = os.path.abspath("wine_model_artifact.zip")
shutil.copy(zip_path, final_zip_path)
finally:
model_tmp.cleanup()

Feedback