---
title: Deploy with Triton on Model Serving
description: Run a GPU Model Serving endpoint behind the NVIDIA Triton Inference Server backend to batch concurrent requests for GPU-bound models.
canonical_url: https://docs.databricks.com/aws/en/machine-learning/model-serving/serve-triton
---

# Deploy with Triton on Model Serving

> [!NOTE]
> **Beta**
>
> This feature is in [Beta](https://docs.databricks.com/aws/en/release-notes/release-types.md). To use it, a workspace admin must turn on **Throughput Optimized Serving Backend for Databricks Model Serving** from the **Previews** page. See [Manage Databricks previews](https://docs.databricks.com/aws/en/admin/workspace-settings/manage-previews.md).

[Custom Model Serving](https://docs.databricks.com/aws/en/machine-learning/model-serving/custom-models.md) can run your GPU endpoint behind the NVIDIA Triton Inference Server backend, which batches concurrent requests before they reach your model. Triton helps most when the GPU is your bottleneck under real-time, high-concurrency traffic.

## When to use Triton

Triton coalesces concurrent requests into batches on the GPU, so it helps most when the GPU is your bottleneck. Good candidates are heavy, batchable GPU workloads under real-time, high-concurrency traffic:

* BERT and other transformer inference
* Embedding models
* Image classification
* Object detection

Triton helps less when the GPU isn't the bottleneck, such as small models or a vision model that decodes and resizes images on the CPU. There, the GPU sits idle waiting on CPU preprocessing, so batching in front of it only adds a hop. Move preprocessing onto the GPU so that such a model benefits.

Batching adds some per-request latency in exchange for higher throughput, and the gain depends on concurrency. If traffic is low, batches stay small and the benefit is limited. Before you release widely, start with one endpoint and measure both throughput and latency under realistic concurrency.

## <a id="requirements" />Requirements

This feature requires that:

* **The preview is turned on for your workspace.** A workspace admin turns on the preview from the **Previews** page. See [Manage Databricks previews](https://docs.databricks.com/aws/en/admin/workspace-settings/manage-previews.md). Nothing below works until this is done.
* **GPU serving:** The served entity must use a [GPU workload type](https://docs.databricks.com/aws/en/machine-learning/model-serving/custom-models.md#compute-type) (`GPU_SMALL`, `GPU_MEDIUM`, `GPU_LARGE`, and so on). Triton is a no-op for CPU endpoints.
* **A batch-eligible model:** The model must be batch-friendly: input counts match output counts (N inputs produce N outputs), and requests have no cross-request dependencies. The model must process a whole batch in one call. In a [`pyfunc`](https://docs.databricks.com/aws/en/machine-learning/model-serving/deploy-custom-python-code.md), pass the whole batch (for example, `model(**batched_inputs)`) instead of looping over inputs. A per-item loop gets no batching benefit.

- **A model on the express deployment path:** Eligible GPU models use [express deployment](https://docs.databricks.com/aws/en/machine-learning/model-serving/express-deployments.md) automatically. A model that isn't eligible for express deployment can't get the Triton backend. Explicit environment preparation with `env_pack="databricks_model_serving"` also remains supported.

## <a id="register-your-model" />Step 1: Register your model for express deployment

Log and register your model. Eligible models use express deployment automatically when you create the GPU endpoint. No `env_pack` parameter is required.

The following example uses explicit environment preparation to package the notebook environment during registration. Run this example from AI Runtime environment version 6, using either the Standard or AI environment, so the packaged environment includes GPU dependencies.

```python
import mlflow

mlflow.set_registry_uri("databricks-uc")

with mlflow.start_run():
    model_info = mlflow.pyfunc.log_model(
        name="model",
        python_model=MyModel(),
        # Include an input example with the model.
        input_example=example,
    )

# Package the notebook environment during registration.
mlflow.register_model(
    model_info.model_uri,
    "<catalog>.<schema>.<model>",
    env_pack="databricks_model_serving",
)
```

In this sample, `MyModel` is your pyfunc model class and `example` is a sample input for the model.

The command finishes without errors. The model version appears in Unity Catalog as `<catalog>.<schema>.<model>`.

## Step 2: Enable throughput optimization and create the endpoint

Select **Throughput optimized** when you create the endpoint. The endpoint then serves the model on Triton, which batches requests with default settings. Turning on the preview alone doesn't attach Triton to an endpoint.

Batching is available only when all of the following are true:

* The served entity uses a GPU workload type, not CPU.
* The model uses a single GPU.
* The served model has no custom entrypoint. A custom LLM has one, so it isn't eligible.
* The model isn't an agent.
* The model was logged from an AI Runtime environment.
* The model is registered in Unity Catalog.
* The model version is eligible for express deployment. See [Step 1](https://docs.databricks.com/aws/en/machine-learning/model-serving/serve-triton.md#register-your-model).
* The preview is turned on for your workspace. See [Requirements](https://docs.databricks.com/aws/en/machine-learning/model-serving/serve-triton.md#requirements).

[Create the endpoint](https://docs.databricks.com/aws/en/machine-learning/model-serving/create-manage-serving-endpoints.md) as a normal GPU endpoint from the Serving UI:

1. On the **Create serving endpoint** form, select an express-deployment eligible model version and a GPU workload type.
2. Select **Throughput optimized**. This checkbox appears only when the preceding conditions are met.
3. Finish configuring the endpoint, then select **Create**.

![Throughput optimized checkbox on the Create serving endpoint form in the Serving UI](https://docs.databricks.com/aws/en/images/machine-learning/throughput-optimized-checkbox.png)

Wait until the endpoint is ready. Step 4 shows how to confirm that Triton is active.

To change the setting later, edit the endpoint and select or clear **Throughput optimized**. The change takes effect on the next deploy, which rolls Triton in or out. It doesn't apply to a deployment that's already running.

## Step 3: Query the endpoint

Send a small batch to confirm that the endpoint serves. Match the input shape that your model expects. Set the `DATABRICKS_TOKEN` environment variable to your Databricks API token, and replace `<workspace-host>` with your workspace URL.

Replace `my-detector` with the name of your endpoint. To query the endpoint, run the following:

```python
import os

import numpy as np
import requests

host = "https://<workspace-host>"
endpoint = "my-detector"
DATABRICKS_TOKEN = os.environ["DATABRICKS_TOKEN"]

batch = np.zeros((2, 3, 224, 224), dtype=np.float32)  # example input shape

resp = requests.post(
    f"{host}/serving-endpoints/{endpoint}/invocations",
    headers={
        "Authorization": f"Bearer {DATABRICKS_TOKEN}",
        "Content-Type": "application/json",
    },
    json={"inputs": batch.tolist()},
)
resp.raise_for_status()
predictions = np.array(resp.json()["predictions"])
```

The command finishes without errors, and `predictions` holds the model output as a NumPy array.

Triton endpoints also accept [protobuf requests](https://docs.databricks.com/aws/en/machine-learning/model-serving/score-custom-model-endpoints.md#protobuf-tensor-input), which avoid parsing large numeric tensors from JSON. To decode images on the GPU, send the encoded image files in a `BYTES` tensor, which holds variable-length values, such as the contents of a file. See [Send files in protobuf requests](https://docs.databricks.com/aws/en/machine-learning/model-serving/score-custom-model-endpoints.md#protobuf-files).

## <a id="confirm-triton" />Step 4: Confirm Triton is active

A `READY` status alone doesn't prove that the Triton backend attached. Confirm with one of the following:

* **Service logs:** On the endpoint's **Logs** tab, check the service logs for Triton startup lines (the Triton Inference Server banner and model-loading messages). Their presence means the backend attached. The [logs API](https://docs.databricks.com/aws/en/machine-learning/model-serving/manage-serving-endpoints.md#get-model-server-logs) returns the same lines. A sample log follows:

```text
[ts/g7zw9] I0911 22:42:18.894428 1 cuda_memory_manager.cc:107] "CUDA memory pool is created on device 0 with size 67108864"
[ts/g7zw9] I0911 22:42:18.916439 1 model_lifecycle.cc:473] "loading: model:1"
[ts/g7zw9] I0911 22:42:23.775240 1 python_be.cc:2289] "TRITONBACKEND_ModelInstanceInitialize: model_0_0 (GPU device 0)"
[ts/g7zw9] I0911 22:43:22.356197 1 model_lifecycle.cc:849] "successfully loaded 'model'"
[ts/g7zw9] I0911 22:43:22.357208 1 server.cc:681]
[ts/g7zw9] +-------+---------+--------+
[ts/g7zw9] | Model | Version | Status |
[ts/g7zw9] +-------+---------+--------+
[ts/g7zw9] | model | 1       | READY  |
[ts/g7zw9] +-------+---------+--------+
[ts/g7zw9] I0911 22:43:22.387088 1 grpc_server.cc:2562] "Started GRPCInferenceService at 127.0.0.1:8001"
[ts/g7zw9] I0911 22:43:22.387651 1 http_server.cc:4809] "Started HTTPService at 127.0.0.1:8002"
[ts/g7zw9] I0911 22:43:22.430569 1 http_server.cc:358] "Started Metrics Service at 0.0.0.0:8003"
```

* **Contact your Databricks account team** to confirm that the backend attached for your endpoint. If it did not, they can tell you why. Common causes are covered in [Troubleshooting](https://docs.databricks.com/aws/en/machine-learning/model-serving/serve-triton.md#troubleshooting).

Then benchmark under realistic concurrency. Any throughput gain from Triton shows up under load, and batching adds some per-request latency, so measure both before rolling out.

## (Optional) Tune batching

Databricks sets the batching defaults for each deployment. To change them for your endpoint, contact your Databricks account team.

## <a id="troubleshooting" />Troubleshooting

| Issue                                                                                           | Cause and fix                                                                                                                                                                                                                                                                                                                       |
| ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `READY`, but no performance change and no Triton in the logs                                    | Throughput optimization isn't enabled, or the preview is off. Confirm the preview is on and that **Throughput optimized** is enabled (Step 2), then redeploy.                                                                                                                                                                       |
| Create or update fails with an error that includes `is only supported with express deployments` | A throughput-optimized endpoint needs express deployment and doesn't fall back to a container build. If the message says to re-register the model, register it again from AI Runtime with `env_pack="databricks_model_serving"`, then create or update the endpoint. Otherwise, fix the reason the message gives.                   |
| The deployment fails with the event `Model artifact preparation failed`                         | Express deployment couldn't prepare the model, and a throughput-optimized endpoint doesn't fall back to a container build. If the error says to re-register the model, register it again from AI Runtime with `env_pack="databricks_model_serving"`, then create or update the endpoint. Otherwise, fix the reason the error gives. |
| No throughput gain versus a non-Triton endpoint                                                 | The model isn't GPU-bound (GPU idle, or CPU-bound preprocessing). This is expected. For vision models, move image decode and resize onto the GPU.                                                                                                                                                                                   |
| Triton crashes on large inputs                                                                  | `/dev/shm` is too small. Ask your Databricks account team to raise the `/dev/shm` size (8 GiB or more for vision). The default is 2 GiB for each replica.                                                                                                                                                                           |
| Endpoint over-provisions to max concurrency during steady-state traffic                         | Autoscaling is currently aggressive and can provision to max concurrency early. Contact your Databricks account team to tune autoscaling more conservatively.                                                                                                                                                                       |

Reach out to your Databricks account team for feedback or questions.

## Additional resources

| Resource                                                                                                                                       | Description                                               |
| ---------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| [Express deployments for model serving endpoints](https://docs.databricks.com/aws/en/machine-learning/model-serving/express-deployments.md)    | Check the requirements and steps for express deployments. |
| [Query serving endpoints for custom models](https://docs.databricks.com/aws/en/machine-learning/model-serving/score-custom-model-endpoints.md) | Send requests to an endpoint from Python, REST, or SQL.   |
