Truston
A high-performance Rust client library for NVIDIA Triton Inference Server.
Truston provides a type-safe, ergonomic interface for communicating with Triton Inference Server via its REST API, supporting multiple data types, seamless NDArray integration, and async operations.
Features
- 🚀 Type-safe inference - Strongly-typed input/output handling with compile-time guarantees
- 🎯 Multiple data types - Support for all Triton data types (INT8-64, UINT8-64, FP32/64, BOOL, STRING, BF16)
- 🔢 NDArray integration - Direct conversion between
ndarray::ArrayDand Triton tensors - ⚡ Async/await - Built on
tokiofor efficient concurrent operations - 🛡️ Error handling - Comprehensive error types with context
- 📊 Production-ready - Includes logging, tracing, and comprehensive tests
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
= { = "1.47", = ["full"] }
= "0.16"
Quick Start
use TritonRestClient;
use InferInput;
use ArrayD;
async
Usage Examples
Creating Inputs from NDArray
use InferInput;
use array;
// From a 2D array
let arr = array!.into_dyn;
let input = from_ndarray;
Creating Inputs from Raw Vectors
use ;
// For float32 data
let data = F32;
let input = new;
// For int64 data
let data = I64;
let input = new;
Multi-Input Models
use TritonRestClient;
use InferInput;
use ArrayD;
async
Handling Outputs
// Convert to vector
if let Some = output.data.as_f32_vec
// Convert to ndarray
if let Some = output.data.to_ndarray_f32
// Handle different types
match &output.data
Error Handling
use TrustonError;
match client.infer.await
Supported Data Types
| Rust Type | Triton Type | DataType Variant |
|---|---|---|
bool |
BOOL | DataType::Bool |
u8 |
UINT8 | DataType::U8 |
u16 |
UINT16 | DataType::U16 |
u64 |
UINT64 | DataType::U64 |
i8 |
INT8 | DataType::I8 |
i16 |
INT16 | DataType::I16 |
i32 |
INT32 | DataType::I32 |
i64 |
INT64 | DataType::I64 |
f32 |
FP32 | DataType::F32 |
f64 |
FP64 | DataType::F64 |
String |
STRING | DataType::String |
u16 (raw) |
BF16 | DataType::Bf16 |
Requirements
- Rust 1.70 or later
- Triton Inference Server (any version supporting v2 REST API)
Running Tests
Some tests require a running Triton server:
# Run all tests except integration tests
# Run integration tests (requires Triton server at localhost:50000)
Examples
Check the examples/ directory for more usage examples:
# Check server connection
# Run inference test
# NDArray examples
Documentation
For detailed API documentation, run:
Or visit docs.rs/truston.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
Licensed:
- MIT license (LICENSE-MIT)
Acknowledgments
- NVIDIA Triton Inference Server
- Built with reqwest, tokio, and ndarray