2026-11-26 15:49 UTC

Rust SDK adds custom-backend development options for NVIDIA Triton

state: seedheat: lowuncertainty: mediumrelevance: mediuminference-infrastructure rust nvidia-tritonrdcm

What is this?

Triton-ng is an MIT-licensed Rust SDK by GitHub user rdcm for building custom backends that load as shared libraries inside NVIDIA Triton Inference Server. Its repository describes a safe Rust backend API, raw FFI bindings and macros, plus an async gRPC client. The 0.4.0 examples cover model composition, streaming, batching, tracing, metrics and memory buffers, and the project targets Triton 25.09/backend API 1.19. The project was promoted in a Show HN post dated Nov. 18, 2026; the linked repository is the primary evidence. No independent adoption or performance validation is supplied.

Why it matters

This is a developer tool, not a new model or an NVIDIA release. It could make it easier to build typed, asynchronous Rust components within Triton deployments, including streaming and model-to-model orchestration. The repository reports faster results than python_backend on several small BLS benchmarks, but these are project-reported measurements in a specific test setup, not evidence of general production gains.

Current assessment

New: rdcm's Triton-ng offers a Rust SDK for custom Triton backends and an async gRPC client. Repository documentation describes shared-library backends and examples for BLS model composition, streaming responses, custom batching, tracing, sequence state, and RAM/pinned/GPU buffers. It targets Triton 25.09/backend API 1.19 and says compatibility is checked at startup. The project reports 2.27×–5.58× throughput versus python_backend across five small BLS workloads at concurrency 64 on one CPU test system; these are author-reported measurements, and the documentation cautions that heavy inference reduces the backend's share of total runtime. The likely significance is lower-friction Rust integration and potentially lower overhead for orchestration-heavy Triton workloads, rather than a change to model capability or serving infrastructure itself. Evidence is a repository and Show HN post; independent validation, adoption, maturity in production, and feature gaps beyond the documentation's own comparison remain uncertain.

Measured heat

now 0 pts/hpeak 1 pts/hcomments 0/hpeers p10momentum: steady2 platformsage 216h
points/hour across evidence · reading as of 2026-11-27 02:23:58.509736+11:00 · deterministic, not a model opinion

How the heat travelled

11-17 16:25 (minted)⭐ origin echo-reconstructedThe GitHub repository README describes it as “A Rust SDK for writing custom backends for NVIDIA Triton Inference Server,” and provides code
rdcm (GitHub account; HN submitter is rdcm) on github (echo) · attributed from hn.story.50532862 · published time unknown
—
11-17 15:39first on hacker news · published · lag ?Show HN: Triton-ng – Write Nvidia Triton inference back ends in Rust
rdcm
—
11-17 15:39amplified on hacker news 👑hn.story.50532862
rdcm
peak 1 · 0 comments · 103% of case engagement
11-17 16:21our radar first saw it · lag ?discovery anchor: hn.story.50532862—
pace: p13 vs 2096 stories at the 168h mark (now 216h old) — behind adobe-max-ai-agents-creative-tools-mcp (0.5x)

Evidence (2) — ⭐ canonical anchor

sourceobjectauthorscorecomments
🟧 hnShow HN: Triton-ng – Write Nvidia Triton inference back ends in Rust
Retrieved article excerpt

Open article · Retrieved 2026-11-17T16:23:02.657222+00:00

# About

[crates.io](https://crates.io/crates/triton-ng)
[docs.rs](https://docs.rs/triton-ng)

A Rust SDK for writing custom backends for NVIDIA Triton Inference Server.
Backends run as shared libraries inside Triton. The project also includes an async gRPC client
for calling a running Triton server.

Targets **Triton 25.09 / backend API 1.19** and **Rust 1.99**. The API checks compatibility at
backend startup. The examples below describe the **0.4.0 API**. See
[CHANGELOG](https://github.com/rdcm/triton-ng/blob/main/CHANGELOG.md) for release boundaries.

| Crate | Description |
| --- | --- |
| [triton-ng](https://crates.io/crates/triton-ng) | Safe backend API |
| [triton-ng-client](https://crates.io/crates/triton-ng-client) | Async gRPC client |
| [triton-ng-sys](https://crates.io/crates/triton-ng-sys) | Raw FFI bindings |
| [triton-ng-macros](https://crates.io/crates/triton-ng-macros) | Backend and batching entry points |

## Getting started

```
[lib]
crate-type = ["cdylib"]

[dependencies]
triton-ng = "0.4.0"
```

Implement one hook to call another model and return its output. This complete backend is also
[examples/minimal-backend](https://github.com/rdcm/triton-ng/tree/main/examples/minimal-backend),
the minimal backend example (the separate batching-strategy example is introduced below):

```
use triton_ng::{Context, CustomBackend, DataType, Error, InferenceRequest, Request, Response};

struct MyBackend;

#[triton_ng::backend]
impl CustomBackend for MyBackend {
    async fn model_instance_execute(ctx: Context, requests: Vec<Request>) -> Result<(), Error> {
        for request in requests {
            let data = request.get_input("INPUT")?.as_bytes()?;

            let mut inference = InferenceRequest::new(ctx.server(), "minimal_backend_target", -1)?;
            inference.add_input_with_data("INPUT0", DataType::Fp32, &[1, 10], data)?;
            inference.add_requested_output("OUTPUT0")?;
            let result = match ctx.server().infer_async(inference).await {
                Ok(result) => result,
                Err(e) => {
                    request.respond_error_with_code(e.code(), &e.to_string())?;
                    continue;
                }
            };

            let mut response = Response::new(request)?;
            response
                .create_output("OUTPUT", DataType::Fp32, &[1, 10])?
                .write_fp32_vec(&result.output("OUTPUT0")?.as_fp32_vec()?)?;
            response.send()?;
        }
        Ok(())
    }
}
```

### gRPC client

Call the custom backend from your application using the gRPC client:

```
use triton_ng_client::{InferInput, InferOptions, TritonClient, TritonClientConfig};

type ClientError = Box<dyn std::error::Error + Send + Sync>;

async fn call_example() -> Result<(), ClientError> {
    let client = TritonClient::new(TritonClientConfig::new("http://localhost:8001")).await?;
    let result = client.infer(
        "minimal_backend", None,
        [InferInput::fp32("INPUT", vec![1, 10], vec![1.0; 10])],
        ["OUTPUT"], InferOptions::default(),
    ).await?;
    for output in result.outputs {
        println!("{}: {:?}", output.name, output.data);
    }
    Ok(())
}
```

The examples below are independent functions or hooks; import their SDK types from
`triton_ng`. Combine state fields when using several examples in one backend.
`make build` compile-checks the Rust snippets in this README and every guide.

## Compose models with BLS

Forward an input to another model without copying it:

```
async fn forward_input(ctx: &Context, request: &Request) -> Result<InferenceResult, Error> {
    let shared = request.get_input("INPUT")?.share()?;
    let mut call = InferenceRequest::new(ctx.server(), "minimal_backend_target", -1)?;
    call.add_input_with_buffer("INPUT0", DataType::Fp32, &[1, 10], shared)?;
    call.add_requested_output("OUTPUT0")?;
    Ok(ctx.server().infer_async(call).await?)
}
```

To replace an input prepared by another helper and request only the embedding:

```
fn replace_audio(call: &mut InferenceRequest, samples: i64, audio: Vec<u8>) -> Result<(), Error> {
    call.remove_input("AUDIO")?;
    call.add_input_with_data("AUDIO", DataType::Fp32, &[1, samples], audio)?;
    call.remove_all_requested_outputs()?;
    call.add_requested_output("EMBEDDING")?;
    Ok(())
}
```

[Request editing and buffer lifetimes](https://github.com/rdcm/triton-ng/blob/main/docs/request_metadata_and_tracing.md#editing-a-bls-request-before-submission).

## Streaming

Return tokens as they become available. Configure the model with
`model_transaction_policy { decoupled: true }`:

```
fn send_tokens(request: Request) -> Result<(), Error> {
    let mut sender = request.into_sender()?;
    for token in [10, 20, 30] {
        let mut response = sender.response()?;
        response.create_output("TOKEN", DataType::Int32, &[1])?.write_i32_vec(&[token])?;
        response.send()?;
    }
    sender.finish()?;
    Ok(())
}
```

Call a streaming model from another backend with `Server::infer_stream`, or from an
application with `TritonClient::infer_stream`. See [streaming and cancellation](https://github.com/rdcm/triton-ng/blob/main/docs/streaming.md)
for complete examples.

## Metrics and response statistics

Count completed requests on Triton's Prometheus endpoint. Create the counter once in
model initialization and call `count_request` from execute:

```
fn model_initialize(model: &Model) -> Result<(), Error> {
    let name = model.name()?;
    let counter = CounterFamily::new("minimal_requests_total", "Requests handled")?
        .counter(&[("model", name.as_str())])?;
    model.set_state(counter)?;
    Ok(())
}

fn count_request(ctx: &Context) -> Result<(), Error> {
    ctx.state::<Counter>()?.increment(1.0)?;
    Ok(())
}
```

Request and batch statistics are automatic. Enable per-response statistics when needed:

```
fn answer_with_statistics(request: Request) -> Result<(), Error> {
    let mut response = Response::new(request)?;
    response.create_output("OUTPUT", DataType::Fp32, &[1, 10])?.write_fp32_vec(&[0.0; 10])?;
    response.enable_statistics();
    response.send()?;
    Ok(())
}
```

[Metric types, error responses, and statistics](https://github.com/rdcm/triton-ng/blob/main/docs/metrics.md).

## Tracing and metadata

Add a trace activity and connect a BLS call to its client request:

```
async fn traced_call(ctx: &Context, request: &Request) -> Result<InferenceResult, Error> {
    request.trace()?.report_activity("decode")?;
    let mut call = InferenceRequest::new(ctx.server(), "minimal_backend_target", -1)?;
    call.set_parent_trace(request)?;
    if let Some(id) = request.id()? { call.set_id(&id)?; }
    call.set_parameter("language", "en")?;
    call.add_input_with_data("INPUT0", DataType::Fp32, &[1, 10], request.get_input("INPUT")?.as_bytes()?)?;
    Ok(ctx.server().infer_async(call).await?)
}
```

[Request IDs, sequence flags, priority, timeouts, and tracing](https://github.com/rdcm/triton-ng/blob/main/docs/request_metadata_and_tracing.md).

## Memory buffers

Choose memory for each output, then take the buffers back for reuse. This example takes a
prepared request for a model with three FP32 outputs of shape `[1, 10]`:

```
async fn reuse_outputs(
    ctx: &Context,
    mut call: InferenceRequest,
    device_id: i32,
) -> Result<(RamBuffer, PinnedRamBuffer, GpuBuffer), Error> {
    call.add_requested_output_into("CPU_OUTPUT", ctx.memory().ram(40)?)?;
    call.add_requested_output_into("PINNED_OUTPUT", ctx.memory().pinned(40)?)?;
    call.add_requested_output_into("GPU_OUTPUT", ctx.memory().gpu(device_id, 40)?)?;
    let mut result = ctx.server().infer_async(call).await?;
    Ok((
        result.take_ram("CPU_OUTPUT")?,
        result.take_pinned("PINNED_OUTPUT")?,
        result.take_gpu("GPU_OUTPUT")?,
    ))
}
```

Use any one of these buffer types, or combine them as above. Pinned and GPU allocations require
Triton's corresponding memory pools. A `GpuBuffer` can become the next BLS call's input without
a host copy; CPU access to its data requires your own CUDA code.

Report memory held by your model so clients can inspect it in model statistics:

```
fn model_initialize(model: &Model) -> Result<(), Error> {
    let allocation = model.memory_manager()?.pinned(4096)?;
    model.set_state(allocation)?;
    model.report_memory_usage(&[BufferAttributes::new(MemoryType::CpuPinned, 4096)?])?;
    Ok(())
}
```

For per-instance allocations use `ModelInstance::report_memory_usage`.
[Memory ownership, GPU chaining, and caching](https://github.com/rdcm/triton-ng/blob/main/docs/memory_buffers.md).

## Configure backend and instances

Keep a setting shared by every model of your backend:

```
fn initialize(backend: &Backend) -> Result<(), Error> {
    let language = backend.config()?.parameter_or("language", String::from("en"))?;
    backend.set_state(language)?;
    backend.set_execution_policy(ExecutionPolicy::Blocking)?;
    let (_, directory) = backend.artifacts()?;
    println!("Backend files: {}", directory.display());
    Ok(())
}

fn language(ctx: &Context) -> Result<&str, Error> {
    Ok(ctx.backend_state::<String>()?.as_str())
}
```

Inspect an instance and save its host policy for later input reads:

```
fn model_instance_initialize(instance: &ModelInstance) -> Result<(), Error> {
    println!("{} passive={} profiles={:?} secondary={:?}",
        instance.name()?, instance.is_passive()?, instance.profile_names()?, instance.secondary_devices()?);
    instance.set_state(instance.host_policy()?)?;
    Ok(())
}
```

[Backend configuration, execution policies, and instance settings](https://github.com/rdcm/triton-ng/blob/main/docs/model_management_and_configuration.md).

### Host-policy input data

Read the input storage selected for this instance:

```
fn read_policy(ctx: &Context, request: &Request) -> Result<Vec<u8>, Error> {
    let policy = ctx.instance_state::<HostPolicy>()?;
    request.get_input("INPUT")?.as_bytes_for_host_policy(policy.name())
}
```

Supply different input bytes for a BLS target's host policy:

```
fn policy_call(ctx: &Context, default: Vec<u8>, local: &[u8]) -> Result<InferenceRequest, Error> {
    let mut call = InferenceRequest::new(ctx.server(), "minimal_backend_target", -1)?;
    call.add_input_with_data("INPUT0", DataType::Fp32, &[1, 10], default)?;
    call.append_input_data_with_host_policy("INPUT0", local, "cpu")?;
    Ok(call)
}
```

Each input above contains ten FP32 values (40 bytes). A policy without supplied data uses
the ordinary input. [Policy selection and zero-copy appends](https://github.com/rdcm/triton-ng/blob/main/docs/request_metadata_and_tracing.md#appending-policy-specific-input-data).

## Sequence state and iterative requests

Count requests in a sequence. Declare a state tensor with an initial value of zero,
read its `StateConfig` with `Model::sequence_states`, then update it on each request:

```
fn increment(mut request: Request, config: &StateConfig) -> Result<(), Error> {
    let previous = request.get_input(config.input_name())?.as_fp32_vec()?;
    let previous = previous.first().copied().ok_or("state has no counter")?;
    let mut state = State::new(&mut request, config, &[1])?;
    state.write_bytes(&(previous + 1.0).to_ne_bytes())?;
    state.update()?;
    let mut response = Response::new(request)?;
    response.create_output("OUTPUT", DataType::Fp32, &[1])?.write_fp32_vec(&[previous + 1.0])?;
    response.send()?;
    Ok(())
}
```

This example uses `max_batch_size: 0` and state dimensions `[1]`.
[Complete sequence-state configuration](https://github.com/rdcm/triton-ng/blob/main/docs/model_management_and_configuration.md#sequence-state).

Return a partial result and schedule another step of a decoupled iterative sequence:

```
fn next_step(request: Request) -> Result<(), Error> {
    let mut sender = request.into_sender()?;
    let mut response = sender.response()?;
    response.create_output("STEP", DataType::Int32, &[1])?.write_i32_vec(&[1])?;
 
rdcm10
🟧 echo.github ⭐The GitHub repository README describes it as “A Rust SDK for writing custom backends for NVIDIA Triton Inference Server,” and provides code rdcm (GitHub account; HN submitter is rdcm)——

Interpretation history

Decision trace