Model Deployment and Predictions
Deploy machine learning models to a GridGain 9 cluster and run simple, batch, SQL-based, and colocated predictions, including advanced custom translators and compute jobs.
Model Deployment
Preparing the Model
You can use models from the following sources:
Pretrained models from DJL Model Zoo.
Locally trained models.
Pre-trained models in supported formats with correct model names.
DJL Model Zoo
DJL Model Zoo models come in supported formats pre-configured with serving.properties that have the modelName preconfigured. You can download them easily using a program like the one in the quickstart guide.
Other Sources
The system automatically searches for model files named model.* (e.g., model.onnx, model.pt). You can override this default behavior by adding .name("your-model-name") to your job parameters.
Supported Model Formats
PyTorch
.pt
Model file + configuration files.
TensorFlow
.pb
Model file + configuration files.
ONNX
.onnx
Model file + configuration files.
Unsupported Formats
SafeTensors (.safetensors): Not supported by DJL. Must convert to PyTorch format.
Pytorch Pickled (.pth): Not supported by DJL. Must convert to TorchScript (.pt) format.
Pickle files (.pkl): Raw pickle files need proper model wrapper.
Deploying the Model
Models are deployed as deployment units using the CLI or REST:
For more information refer to code deployment documentation.
Automated Deployment
GridGain ML provides utility methods to automate model download and deployment for different scenarios.
Standard Models with Custom Classes
For models with custom input/output types, translators, or marshallers:
This method automatically:
Downloads all required model files from the specified URLs
Creates a temporary directory for the model files
Packages custom classes (translators, marshallers) into a JAR
Deploys both the model and custom classes to the GridGain cluster
DJL Model Zoo Models
For models from the DJL Model Zoo using djl:// protocol:
This method automatically:
Downloads the PyTorch model from DJL model zoo
Compiles custom classes from the source directory
Generates a JAR containing the custom compiled classes
Deploys both the model files and custom classes JAR to the GridGain cluster
TensorFlow Models with Folder Structure
For TensorFlow SavedModel format that requires specific folder structure:
This method automatically:
Downloads all required TensorFlow model files
Creates the proper folder structure (
saved_model.pbin root, variables invariables/subdirectory)Packages custom classes into a JAR
Deploys both the model and custom classes to the GridGain cluster
Model Properties Reference
Core Properties
Some examples of common model properties that could optionally be used in job parameters:
application
DJL application type
groupId
Model zoo group ID
artifactId
Model zoo artifact ID
Translator Arguments
Properties without the option. prefixes are passed to the TranslatorFactory.
For built-in translators you will need to check their source code.
For custom translators, you can pass ANY properties (without the
option.prefix) and they will be available in your TranslatorFactory'snewInstance()method via the arguments' parameter.
Engine Options
Properties that do not match the Core Properties and do not have the option. prefix are passed as engine options.
Examples:
option.mapLocation- (PyTorch) Map to CPU before loading.option.ortDevice- (ONNX) Device selection.option.Tags- (TensorFlow) Model tags.
Running Predictions
Simple Predictions
Execute inference with a single input.
Batch Predictions
Execute inference on multiple inputs in a batch.
SQL-Based Predictions
Execute inference using SQL queries on database tables:
Parameterized Queries
Execute inference using parameterized SQL queries:
Colocated Predictions
Execute inference on data stored locally on specific cluster nodes.
Asynchronous Operations
All prediction methods support asynchronous execution:
Execution Modes
GridGain ML examples can run in different modes depending on your deployment scenario. The examples use a base class (MlBaseExample) that supports two execution modes:
All four examples supports both execution modes, we can select either MODE.EMBEDDED or MODE.CLIENT_ONLY
Available Modes
Embedded Mode (MODE.EMBEDDED)
Runs the ML inference directly within the GridGain server process.
Characteristics:
Single JVM process
No separate client connection needed
Lowest latency for inference operations
Ideal for testing and development
Setup:
Client-Only Mode (MODE.CLIENT_ONLY)
Connects to an existing GridGain cluster as a thin client.
Characteristics:
Requires a running GridGain cluster
Separate client process connects to the cluster
Production-ready deployment pattern
Network overhead for operations
Setup:
Advanced Usage
When to Use Standard vs Custom Approaches
Use Standard Approach When:
Standard input/output types: Working with primitives or built-in DJL types (e.g.,
String,Classifications)Built-in DJL translator functionality: The translator provided by DJL meets your pre/post data processing needs
Simple data flows: No complex pre/post-processing workflows required
This approach is shown in the basic prediction examples above.
Use Custom Compute Jobs When:
Custom input/output types: Implementing user-defined types that require specialized marshalling beyond built-in DJL serialization
Advanced processing logic: Building complex pre/post-processing workflows that extend beyond standard translator capabilities
Non-standard data flows: Creating advanced examples with specialized data handling requirements
Fine-grained execution control: Needing direct control over the model inference pipeline and data transformation steps
Custom compute jobs provide the flexibility to define independent input types, output types, translators, and marshallers when the standard framework cannot accommodate your specific use case.
Download Model
Download a zeroshot classification model files from HuggingFace:
Custom Translator
Create a custom translator and translator factory to pre-process the inputs before prediction and post process the output from the model for consumption.
Step 1: Create a Custom Translator
Step 2: Create a Custom Translator Factory
Step 3: Using Custom Translator
Custom Compute Jobs (Brief Introduction)
When you need full control over the prediction pipeline, including custom marshallers for serialization, you can extend the MlComputeJob class.
Basic Structure
When to Use Custom Compute Jobs
Custom compute jobs are required when:
You have custom input/output types that need specialized serialization
You need to implement custom marshallers for data transfer
You want to use different prediction methods (predict, batchPredict, predictFromSql, predictColocated) with custom types
Adding to Job Parameters
This page is: Copyright © 2026 MariaDB. All rights reserved.
Last updated
Was this helpful?

