Why TensorRT + Triton?
Why TensorRT?
NVIDIA TensorRT is a software development kit for high-performance deep learning inference. It compiles model weights into optimized engines that run more efficiently on specific GPU hardware through CUDA-level optimizations, custom kernels, and optional quantization. TensorRT requires you to specify optimization parameters upfront - GPU architecture, batch size, precision (FP8, INT8, etc.), and input/output shapes. This specialization allows TensorRT to generate highly optimized inference engines that maximize GPU utilization, reduce latency, and lower inference costs compared to serving raw model weights.Why Triton?
NVIDIA Triton Inference Server streamlines production AI deployment by handling operational concerns that are critical for serving models at scale. It provides automatic request batching, health checks, metrics collection, and standardized HTTP/gRPC APIs out of the box. Triton supports multiple frameworks (TensorRT, PyTorch, TensorFlow, ONNX, etc.), offers built-in Prometheus metrics for observability, and integrates seamlessly with Kubernetes for auto-scaling. It also supports model versioning, A/B testing, and can chain multiple models into pipelines. Here is a diagram of how Triton works. Below is the process of how the two work together in terms of handling requests:- Client sends text via HTTP/gRPC to Triton
- Triton queues the request in the scheduler
- Triton batches incoming requests (waits for more or timeout)
- When batch is ready, Triton calls your Python backend
- TensorRT-LLM generates tokens for the entire batch in parallel on GPU
- Triton returns responses to clients
Basic Setup
Install the Cerebrium CLI:HF_AUTH_TOKEN through the dashboard for authentication during download.
Implementation
All files should be placed in the same project directory.Triton Model Configuration
Createconfig.pbtxt to define Triton’s model interface. See the full configuration reference for all available options.
- Use Python backend (runs our model.py)
- Automatically batch up to 128 requests together for efficient GPU utilization
- Use dynamic batching with a 100 microsecond queue delay to maximize batch sizes
- Accept text input with optional sampling parameters
- Run on a single GPU instance
- Return generated text as output
Python Backend Implementation
Triton’s Python backend requires implementing aTritonPythonModel class with three key methods:
-
initialize(args): Called once when Triton loads the model. This is where you load the tokenizer and initialize TensorRT-LLM with your build configuration. -
execute(requests): Called every time Triton has a batch ready. Triton automatically batches incoming requests (up to your configuredmax_batch_size) and passes them here. This method extracts prompts from each request, runs batch inference with TensorRT-LLM, and returns responses. -
finalize(): Called when the model is being unloaded. Use this to clean up GPU memory and shut down the TensorRT-LLM engine.
model.py implementing Triton’s Python backend interface:
Model Download Script
Createdownload_model.py to download the model:
Container Setup
CreateDockerfile extending Nvidia’s Triton container:
Deployment Configuration
Configure the container and autoscaling environment incerebrium.toml:
replica_concurrency = 128: Each replica can handle up to 128 concurrent requests, matching our Triton batch sizemax_replicas = 5: Scale up to 5 replicas for peak load
Deploy
Download Model to Persistent Storage
Before deploying, download the model to Cerebrium’s persistent storage. This ensures the model is available across all deployments and avoids redundant downloads during container startup. Thecerebrium run command executes a Python script in a temporary container with the same environment and hardware configuration as the deployment. It has access to persistent storage at /persistent-storage, so any files written there are available to deployed containers.
Run the download script:
Deploy the Model
Deploy the model:Test
Send a request to your deployed endpoint:data field of the output tensor.
Performance Analysis
Test Setup
To validate performance improvements, TensorRT + Triton was compared against a vanilla HuggingFace baseline serving the same Llama 3.2 3B Instruct model. Both deployments used identical hardware (NVIDIA A10 GPU) and were tested under the same load conditions. Vanilla Baseline Setup:- Model served directly using HuggingFace Transformers with PyTorch
- Single request processing (no batching)
- Standard FastAPI endpoint
- Same hardware configuration (A10 GPU, 4 CPU cores, 40GB memory)
- TensorRT-LLM with PyTorch backend
- Triton Inference Server with dynamic batching (max batch size: 128)
- Automatic request queuing and batching
- Same hardware configuration (A10 GPU, 4 CPU cores, 40GB memory)
Results
The TensorRT + Triton setup delivers 15x higher throughput with 100% reliability compared to the baseline, while reducing latency by 7-9x across all percentiles. The baseline’s 61.6% success rate and high latency come from processing requests sequentially without batching, leading to GPU underutilization and request timeouts. TensorRT + Triton eliminates these issues by keeping the GPU fully utilized with batched, optimized inference, resulting in 100% success rate and consistent, predictable latency.
These results demonstrate that TensorRT + Triton is not just faster, but also more reliable and cost-effective for production LLM serving at scale.