Triton-hf-builder: Generate NVIDIA Triton repositories from Hugging Face checkpoints

Hi everyone! I’m sharing triton-hf-builder, an open-source Python library and CLI that generates NVIDIA Triton model repositories from local Hugging Face checkpoints.

It creates model configuration, runtime adapters and dependency files for Transformers, vLLM and TensorRT-LLM. Repository generation runs without a GPU and does not load model weights.

The project includes a Docker quickstart that downloads a small checkpoint, starts CPU serving and sends an inference request.

pip install triton-hf-builder

Currently in beta, licensed under Apache-2.0. Model and hardware compatibility depends on the selected serving backend.

Feedback, bug reports and experiences with different model architectures are welcome!

I gave it a quick try in Colab:


A real-checkpoint generation check on Colab CPU

I tested the Python API of triton-hf-builder in a Google Colab CPU runtime, using an actual, revision-pinned Hugging Face checkpoint rather than a mock model directory. Checkpoint inspection, repository generation, and the subsequent static checks all passed. This part of the workflow worked without a GPU, Docker, or a running Triton server.

The run used Python 3.13.18, triton-hf-builder==0.1.2, and HuggingFaceTB/SmolLM2-135M-Instruct at commit 12fd25f77366fa6b3b4b768ec3050bf629380bac. I used the transformers adapter with device="cpu". This is one reproducible checkpoint/environment combination, not a compatibility claim about Llama-family models in general.

Step Observation
Install/import Passed; builder 0.1.2
Obtain checkpoint Passed; nine selected files totaling 272,444,345 bytes of file content
inspect_model(...) Passed; LlamaForCausalLM, inferred text-generation, recognized tokenizer
generate_repository(...) Passed; model repository and supporting files written
Check config.pbtxt Passed; parsed with Triton’s ModelConfig protobuf; Python backend, CPU instance, string input/output with dims [1]
Check serving.json and generated files Passed; manifest contents matched after JSON normalization, and expected files were present
Check exported Safetensors Passed; source/export SHA-256 hashes equal
Start Triton, load weights, or send inference requests Not tested

The generated serving.json made the test boundary explicit:

{
  "validation": {
    "static": "passed",
    "serving": "not_run",
    "dependencies": "unlocked"
  }
}

Scope of the result: a real checkpoint was inspected and exported, and its generated files passed static verification. The Colab probe did not load model weights into a framework, launch Triton, install the serving dependencies, or test inference. I saw no builder defect in the path I actually exercised.

The lightweight Colab path is simple: download a complete pinned checkpoint, run inspect_model(...), generate with runtime="transformers" and device="cpu", then inspect config.pbtxt, serving.json, and the copied assets. The documented Python API already supports these steps.

The project already provides a CPU Docker quickstart that actually performs inference, as well as opt-in serving tests. An optional generation-only Colab example could complement those rather than duplicate them: it would give users without a Docker setup or GPU a low-cost way to provide a first compatibility report. The existing serving tests remain the appropriate route for inference claims.

Environment, checkpoint, and evidence from the Colab run

Environment and versions actually observed

The returned diagnostic report identified a Colab-managed Linux x86_64 CPU runtime. The subprocess performing the generation and verification reported:

Component Observed value Interpretation
Python 3.13.18 Python used for the executed probe
triton-hf-builder 0.1.2 Inspection and generation API
huggingface-hub 0.36.2 Revision-pinned checkpoint retrieval
tritonclient 2.73.0 ModelConfig protobuf type for static checks
protobuf 6.33.6 Parsing/serialization support
hf-xet 1.8.0 Present in the probe environment
Runtime adapter transformers Creates a Triton Python model adapter
Selected serving device cpu CPU instance requested in the generated configuration
Model name smollm2_probe Generated Triton model directory/name
max_new_tokens 16 Saved for possible later inference; not exercised here
Target image reference nvcr.io/nvidia/tritonserver:26.06-py3 Recorded in manifest; not pulled or run

One Colab-specific detail: the Notebook’s first venv attempt failed at ensurepip. Its fallback installed the builder into a private pip --target directory and invoked a separate subprocess using that location; the probe then passed. Pip also warned about packages in the host image. I did not treat either message as a builder failure. A plain %pip installation may work in another Colab session, but its outcome was not separately tested here.

The checkpoint and why it was a useful first target

The source was the public SmolLM2-135M-Instruct model, fixed to the full commit above. It offers a small single-file Safetensors checkpoint with ordinary text-generation metadata; the author’s CPU Docker example uses the same pinned model. This makes it a useful first smoke test, but my Colab result does not independently verify the Docker serving result.

The actual metadata inspection reported:

model_type:           llama
architectures:        [LlamaForCausalLM]
inferred_task:        text-generation
tokenizer_present:    true
custom_code:          false
quantization:         null
multimodal:           false
inspection_warnings:  []

The source config.json reported transformers_version="4.42.3", an informational checkpoint field, not evidence that this version was used in a serving process. The Colab probe never loaded the model for inference.

The nine selected files comprised 272,444,345 bytes of file content:

model.safetensors         269,060,552
README.md                      6,772
config.json                    861
generation_config.json         132
merges.txt                 466,391
special_tokens_map.json        655
tokenizer.json            2,104,556
tokenizer_config.json        3,764
vocab.json                  800,662

Those numbers describe the local files, not the network bytes transferred; caching can change download traffic. Larger ONNX-related artifacts in the model repository were intentionally excluded. The diagnostic ZIP contained metadata, small generated files, hashes, and logs, not the model weights.

This inventory is only for this revision. A different model may need shard indexes, additional weights, another tokenizer format, or license files. A weight file by itself is not enough. The official Hub download guide explains how to pin revision and select files; the file filters below should not be reused indiscriminately for other models.

What the recorded checks establish

All five recorded stages passed: environment, download, inspect, generate, and verify. The final stage checked required generated paths, the JSON-normalized manifest against serving.json, the parsed Triton ModelConfig and relevant CPU/IO fields, and SHA-256 equality for the copied weight file.

For the 269,060,552-byte model.safetensors, both source and exported copies produced:

5af571cbf074e6d21a03528d2330792e532ca608f24ac70a143f6b369968ab8c

The matching hashes establish that this exported weight file was byte-for-byte identical to the source. They do not establish loadability, backend support, numerical equivalence, or inference quality.

The generated repository also contains a copy of the checkpoint assets, so adequate disk space matters even for CPU-only generation. In this one session, the filesystem’s used-space change was roughly consistent with one downloaded copy and one exported copy; it is not a universal estimate of required space or network traffic.

The precise result is static generation passed for one pinned Llama-family checkpoint in Colab CPU. The serving outcome remains unknown, not failed.

Reproduce the lightweight generation-only path

The minimum useful sequence

The following compact example preserves the API calls, pinned model revision, and generation options from the passing run. It omits the probe’s isolation fallback, diagnostics, and ZIP-return code; it is a reproducibility starting point, not a claim that these exact simplified cells were separately rerun. In a clean Colab notebook:

%pip install "triton-hf-builder==0.1.2" "huggingface_hub==0.36.2"

If the hosted environment reports installation conflicts, separate those from problems in inspect_model or generation. The passing run used the private-target fallback described above.

For this particular model revision, the core Python operations are:

from pathlib import Path
from uuid import uuid4

from huggingface_hub import snapshot_download
from triton_hf_builder import inspect_model, generate_repository

model_id = "HuggingFaceTB/SmolLM2-135M-Instruct"
revision = "12fd25f77366fa6b3b4b768ec3050bf629380bac"

work = Path.cwd() / f"triton_hf_colab_{uuid4().hex[:8]}"
work.mkdir(parents=True)

# This allow-list belongs to the pinned SmolLM2 revision, not arbitrary models.
files_for_this_model = [
    "config.json", "generation_config.json", "model.safetensors",
    "tokenizer.json", "tokenizer_config.json", "special_tokens_map.json",
    "vocab.json", "merges.txt", "README.md",
    "LICENSE", "LICENSE.*", "NOTICE*",
]

source = Path(snapshot_download(
    repo_id=model_id,
    revision=revision,
    cache_dir=str(work / "hf_cache"),
    allow_patterns=files_for_this_model,
    max_workers=2,
    token=False,
))
assert source.name == revision, "Unexpected resolved checkpoint revision"

for filename in ("config.json", "model.safetensors", "tokenizer.json"):
    assert (source / filename).is_file(), f"Missing: {filename}"

info = inspect_model(source)
print(info.model_type, info.architectures, info.inferred_task)
print("Warnings:", info.warnings)

output = work / "model_repository"  # Must not already exist.
result = generate_repository(
    source=source,
    output=output,
    name="smollm2_probe",
    runtime="transformers",
    image="nvcr.io/nvidia/tritonserver:26.06-py3",
    device="cpu",
    max_new_tokens=16,
)
print(result.repository)
print(result.manifest["validation"])

For this example, a few conditions are easy to miss:

  • source must be a sufficiently complete local checkpoint directory, not a Hub ID; snapshot_download(...) supplies it.
  • output must be new and outside source. Retry in a fresh directory to avoid mixing results.
  • device="cpu" describes the proposed serving instance; generation does not run that instance.
  • image is a target-image string recorded in metadata; no Docker image is pulled.
  • Adapt the download allow-list to the model. A missing shard or tokenizer is a source-asset issue, not proof of general incompatibility.

Expected generated files

For the verified checkpoint and Transformers adapter, the resulting repository had this essential structure:

model_repository/
├── smollm2_probe/
│   ├── config.pbtxt
│   └── 1/
│       ├── model.py
│       ├── settings.json
│       └── model/
│           ├── config.json
│           ├── generation_config.json
│           ├── model.safetensors
│           ├── tokenizer.json
│           ├── tokenizer_config.json
│           ├── special_tokens_map.json
│           ├── vocab.json
│           ├── merges.txt
│           └── README.md
├── requirements.txt
├── serving.json
├── README.md
└── LICENSE.triton-hf-builder

The 1 is the Triton model-version directory. Different checkpoints will have different assets and possibly different notices. The original model’s license and the generator’s support-code license are separate.

The generated adapter settings were:

{
  "task": "text-generation",
  "max_new_tokens": 16,
  "tensor_parallel_size": 1
}

This is configuration for a future serving process: the generator wrote the files, but Triton did not import model.py or load the weights in this Colab probe, and the generated serving dependencies were not installed in a Triton image.

Optional static validation

A successful return from generate_repository was not the only check. This shortened validation excerpt captures the important extra assertions before any serving attempt:

import hashlib
import json

from google.protobuf import text_format
from tritonclient.grpc import model_config_pb2

saved = json.loads((output / "serving.json").read_text(encoding="utf-8"))
normalized = json.loads(json.dumps(result.manifest))
assert saved == normalized
assert saved["validation"] == {
    "static": "passed", "serving": "not_run", "dependencies": "unlocked"
}

config = model_config_pb2.ModelConfig()
text_format.Parse(
    (result.model_directory / "config.pbtxt").read_text(encoding="utf-8"),
    config,
)
assert config.name == "smollm2_probe"
assert config.backend == "python"
assert config.max_batch_size == 0
assert len(config.instance_group) == 1
assert model_config_pb2.ModelInstanceGroup.Kind.Name(
    config.instance_group[0].kind
) == "KIND_CPU"
assert [(item.name, list(item.dims)) for item in config.input] == [
    ("text_input", [1])
]
assert [(item.name, list(item.dims)) for item in config.output] == [
    ("text_output", [1])
]
assert all(
    tensor.data_type == model_config_pb2.TYPE_STRING
    for tensor in list(config.input) + list(config.output)
)

def sha256_file(path):
    digest = hashlib.sha256()
    with open(path, "rb") as stream:
        for chunk in iter(lambda: stream.read(1024 * 1024), b""):
            digest.update(chunk)
    return digest.hexdigest()

src_weight = source / "model.safetensors"
dst_weight = output / "smollm2_probe/1/model/model.safetensors"
assert src_weight.is_file() and dst_weight.is_file()
assert sha256_file(src_weight) == sha256_file(dst_weight)
print("Static checks passed")

JSON normalization matters because the Python manifest can contain tuples, whereas JSON stores arrays as lists. Comparing the in-memory object directly with deserialized JSON can give a false mismatch; comparing JSON-equivalent values passed here.

The Protobuf parser checks syntax and selected configuration fields against the installed client schema. SHA-256 checks the copied bytes. Neither test launches Triton or establishes model readiness.

A small failure-classification guide

If someone tries another checkpoint, identifying the first failed stage is more informative than reporting only a generic Colab failure:

Failing stage First thing to distinguish
Package installation/import Colab host package conflicts, interpreter path, available wheel/build, and isolated dependencies
Download Access to the exact revision, network/cache issues, or an incomplete file allow-list
inspect_model Missing/invalid config.json, missing weights/shards, tokenizer assets, or metadata warnings
generate_repository Requested runtime/task compatibility, output path already present, or unsupported configuration options
Manifest/Protobuf check Wrong expected field, schema interpretation, or serialization comparison versus an actual malformed artifact
Copy/checksum Source-versus-exported asset identity; verify which file was compared and whether it was modified
Later Triton model load A different phase involving target image, Python Backend, installed packages, and model runtime support
How to interpret the generated repository and its validation boundaries

Three different kinds of success

There are three separate validation layers: static repository generation, framework-level execution, and actual Triton serving. Each answers a different question:

Layer What it can establish What it does not establish
Static generation Source metadata was inspected; configuration, adapter files, copied assets, and declared dependencies were produced and checked That a framework can load the checkpoint or a server can run it
Framework execution A specific Transformers/vLLM/TensorRT-LLM installation can load and use a model in a stated environment Triton model readiness, request contract, or backend integration
Triton serving A selected image/backend loads the exported repository and returns model inference via HTTP/gRPC Other model versions, other hardware, performance limits, or universal correctness

My Colab result covers only the first row. The project’s serving guide separately covers deployment and runtime requirements.

Reading config.pbtxt

The actual file in the returned evidence was:

name: "smollm2_probe"
input {
  name: "text_input"
  data_type: TYPE_STRING
  dims: 1
}
output {
  name: "text_output"
  data_type: TYPE_STRING
  dims: 1
}
instance_group {
  count: 1
  kind: KIND_CPU
}
backend: "python"

This parsed successfully. The parsed max_batch_size was 0; the text may omit this default-valued field. Consequently, the dimensions describe the entire tensor shape, with one string in text_input and one in text_output, each of shape [1]. NVIDIA’s model configuration guide explains these fields.

Parsing catches malformed Protobuf text and mismatched fields without launching a server. It cannot verify Python Backend availability, actual model loading, or runtime support in a specific Triton image.

Reading serving.json and requirements.txt

The relevant subset of the generated serving.json was:

{
  "schema_version": 1,
  "generator": "triton-hf-builder",
  "generator_version": "0.1.2",
  "model_name": "smollm2_probe",
  "runtime": "transformers",
  "task": "text-generation",
  "image": "nvcr.io/nvidia/tritonserver:26.06-py3",
  "device": "cpu",
  "gpu_count": 0,
  "tensor_parallel_size": 1,
  "requirements_file": "requirements.txt",
  "requirements": [
    "numpy", "torch", "transformers<5,>=4.51", "safetensors"
  ],
  "validation": {
    "static": "passed",
    "serving": "not_run",
    "dependencies": "unlocked"
  }
}

The full manifest also carried the inspected architecture, tokenizer/weight metadata, and warnings about unverified runtime/hardware compatibility and dependency resolution. Those warnings describe unverified conditions, not failures observed here. The image value is a recorded deployment target, not an image that was pulled or tested.

The requirements.txt file contained:

# Extra serving dependencies; resolve and pin against the target image.
numpy
torch
transformers<5,>=4.51
safetensors

These are starting requirements for the intended serving environment, not a lockfile and not proof of an installation in that environment. Installing the builder into Colab supplies generation-side dependencies such as tritonclient and protobuf; the actual Triton serving environment must separately have compatible torch, transformers, and other necessary packages.

The source metadata’s transformers_version="4.42.3" is informational, whereas the builder’s transformers>=4.51,<5 entry is a requested serving dependency range. The difference is not itself evidence of a defect; a concrete load or inference test would be needed.

The Triton Python Backend documentation is relevant if one later packages the runtime. The Python version and environment used by the server/backend stub need not be the same as the Python version that generated the repository in Colab. The project’s serving guide explains dependency installation before deployment.

What the generated Transformers adapter expects

For runtime="transformers", the builder writes a Triton Python Backend model.py. If deployed, it would construct a Transformers pipeline from the local checkpoint/tokenizer, use triton_python_backend_utils to receive requests and return tensors, and run inside Triton’s Python Backend process. The builder package itself is not required in that serving image after generation.

The documented contract is intentionally narrow: a UTF-8 text_input tensor of shape [1], with a UTF-8 text_output tensor of the same shape. Text-generation results exclude the input prompt; classification and feature results are JSON encoded. The Python adapter handles requests serially, without streaming or dynamic batching. These are documented design choices, not bugs exposed by this test.

For an instruction/chat model, apply the appropriate chat template on the client where needed: this string API does not automatically interpret role/content messages. A later unexpected completion might reflect prompting or generation settings rather than an artifact-generation error. The serving guide documents the request contract.

What checksum equality adds, and what it cannot add

Matching source/export SHA-256 hashes demonstrate byte preservation, not tensor integrity beyond that comparison, license compliance, model loadability, or equivalent inference. For a sharded checkpoint, compare every relevant shard and the index rather than assuming a single model.safetensors.

Public reports usually do not require checkpoint weights or unfiltered logs. Model/revision, environment, adapter/task, first failed stage (or passing checks), relevant hashes, and a sanitized error often suffice. The project’s security guidance notes that generated repositories and reports may expose local paths, prompts, or sensitive content.

Conditional follow-ups for other models and actual serving

If the next goal is another compatibility observation

If extending this particular experiment, a useful low-cost step would be a second small model with a different task, before introducing a GPU. The author’s existing serving test matrix already uses distilbert/distilbert-base-uncased-finetuned-sst-2-english for classification and google/flan-t5-small for text-to-text tasks. Such a probe would exercise different task-inference and artifact-generation paths. There is no need to duplicate those existing tests merely to produce a longer checklist.

I checked some public metadata for those models, but did not run them through Colab with real weights. They remain candidate cases, not observed passes. Each additional result should have its own pinned revision, complete file inventory, task, warnings, generated configuration, and validation status.

Some conditions change the interpretation of an inspection or generation result:

Input condition Useful distinction or next check
Task cannot be inferred safely An explicit task is a declared choice; it is not proof that the target framework supports the model
Sharded checkpoint Check all shards and references from the weight index; do not apply a single-file assumption
Custom auto_map / model code Generated adapters disable trust_remote_code; avoid casually executing arbitrary repository code to bypass warnings
Quantized checkpoint Hardware, quantization method, framework and image versions need their own serving compatibility test
Adapter-only/PEFT assets A standalone full checkpoint is not necessarily present; resolve the base-model relationship separately
Multimodal/image/audio model Modality-specific preprocessing and request contracts are outside the initial text-only path
Upstream architecture table lists a family Evidence of upstream documented support, not an independent passing test with this exact builder and checkpoint

The project’s compatibility catalog records documented upstream candidates; it is not a list of checkpoints verified with this builder. The runtime limitations provide the relevant scope.

If the next goal is actual CPU serving

The author’s existing CPU Docker quickstart is the natural next route on a suitable Docker host. It downloads a pinned SmolLM2 checkpoint, generates the repository, builds a serving image with the generated dependencies, starts Triton, waits for readiness, and sends a real HTTP inference request. Its README reports that this pinned path ran successfully on Linux x86_64 CPU on October 30, 2026. That is the author’s documented result, not an independently replicated serving run from my Colab session.

The quickstart notes that its Triton base image alone occupies approximately 23 GB unpacked, before dependencies, caches, and duplicated model assets. That is a different resource profile from a small CPU-only generation check; I would not assume that a hosted Colab session is the best place to reproduce the full Docker example.

For a real serving observation, the extra checks would be:

  1. Select a compatible image/backend and record its exact release, identity or digest where possible, Python version, and installed dependency versions.
  2. Start Triton with the generated repository mounted as the model-repository root; check both server readiness and the named model’s readiness.
  3. Send a valid inference request using that adapter’s documented shape and endpoint, and preserve the response or sanitized error.
  4. Check at least one task-specific output condition. Where useful, compare against direct Transformers inference with aligned prompt formatting and decoding settings.
  5. If a failure occurs, distinguish missing files, install problems, model-load exceptions, request-contract errors, and wrong outputs. These are not interchangeable failures.

The project’s existing E2E runner already covers these layers, including dependency checks, model readiness, requests, and comparisons with direct Transformers inference for relevant cases. It is a better starting point than creating a separate serving harness. Server health alone does not establish a valid model response.

If the target is the native vLLM backend

The vLLM adapter is a separate route: it produces model.json and prepare_repository.py instead of a Transformers Python model.py. The serving guide explains path preparation for the actual container mount; a relative ./model path in a generated file should not be taken as verified for every deployment layout.

Native vLLM also uses its own generate API and request-time max_tokens. A GPU validation would require a compatible image and hardware/software stack, followed by actual readiness and inference. I did not test vLLM, T4, or L4.

If the target is TensorRT-LLM

The current tensorrt-llm adapter is documented as a Python adapter calling TensorRT-LLM’s LLM API with backend="pytorch", not a legacy workflow that first builds a compiled TensorRT engine. NVIDIA’s Triton LLM guide makes the same modern-versus-legacy distinction. A comparison needs to specify the actual runtime version and execution path.

That describes the adapter’s design, not a TensorRT-LLM passing result. A model-specific claim would still require the right release/image, GPU access, dependencies, supported architecture/settings, successful loading, and a returned inference response. Quantization and tensor parallelism should be tracked as separate experimental conditions.

If the intention is a persistent endpoint

A persistent endpoint is a deployment concern, not an implication of this notebook test. Hosted notebooks have changing resource availability and session lifetimes; Google’s Colab FAQ also sets usage restrictions. A bounded generation/verification experiment is a different use case from providing an unattended public service.

What I would retain in a future report

For future readers, the most useful compact record is: model ID + full commit, Python/builder/client versions, runtime/device/image reference, checkpoint file inventory, inspection warnings, artifact layout, and explicit static/serving/dependencies status. A sanitized error at the first failing stage, or a genuine model inference response if one was produced, can then be attached without sharing full checkpoints or sensitive logs.

Thanks for the detailed test and the suggestion! We’ve added a minimal Colab notebook using the same pinned SmolLM2 checkpoint. It walks through downloading, inspection, repository generation, and viewing the generated configuration.

The example stays generation-only, as you proposed. The existing Docker quickstart and serving tests cover inference.