mlflow-triton
Log a trained scikit-learn, PyTorch or Hugging Face Transformers model to MLflow with the files needed to serve it using NVIDIA Triton.
Intended for demos and proofs of concept. Before production use, an ML engineer must review, validate and optimize the generated serving implementation.
Installation
pip install mlflow-triton
Requires Python 3.10+ and MLflow >=3.14,<4. Install your model's framework and other dependencies separately. Configure your MLflow tracking URI and experiment before logging if you use a remote server.
Log your trained model
Pass an already-trained model and a representative prediction input. These examples assume the model and input variables already exist. For a complete runnable example, see quickstart.py. You can also run the example in Google Colab, including installation and a listing of the generated Triton artifact paths.
scikit-learn
from mlflow_triton import sklearn
info = sklearn.log_model(
fitted_pipeline,
name="classifier",
input_example=example_dataframe,
registered_model_name="classifier", # Optional: create a Registry version
)
print(info.model_uri)
Include preprocessing in the fitted estimator or Pipeline.
PyTorch
from mlflow_triton import pytorch
info = pytorch.log_model(
loaded_model.eval(),
name="network",
input_example=example_numpy_array,
)
Pass an instantiated torch.nn.Module with trained weights loaded and all
submodules in evaluation mode. For GPU serving, add device="gpu".
If your model needs custom architecture code or dependencies, supply them with
code_paths=["inference_architecture"] and
pip_requirements="requirements-serving.txt", replacing these paths with your own.
Hugging Face Transformers
from mlflow_triton import transformers
info = transformers.log_model(
loaded_generation_pipeline,
name="text_generator",
input_example=["Explain what a model signature describes."],
task="text-generation",
model_config={"max_new_tokens": 32, "do_sample": False},
)
Pass a supported pipeline or a component dictionary such as
{"model": model, "tokenizer": tokenizer}, including the task's processor assets.
Use model_config for prediction settings.
All three calls return MLflow ModelInfo. The model and generated Triton files
are stored at info.model_uri; no additional save or load call is needed.
info.registered_model_version identifies the Registry version when requested.
Logging does not start Triton or deploy a service.
Log API reference
Pass the model positionally or by the parameter name below. All other arguments must be keyword arguments.
Required arguments
| Module | Model parameter | input_example |
|---|---|---|
sklearn |
sk_model: fitted estimator or Pipeline |
DataFrame or NumPy array accepted by the model. Preserve column names, order and dtypes. |
pytorch |
pytorch_model: trained module in evaluation mode |
NumPy array or named tensor input accepted by MLflow's PyTorch prediction interface. Match input dtype and dimensions. |
transformers |
transformers_model: pipeline or component dictionary |
Task input accepted by MLflow's prediction interface, such as a list of strings or a DataFrame. |
input_example must be non-empty and is required even with an explicit signature.
It is prediction input, not a Triton HTTP request. Its values are saved in the
artifact and generated request files, so use non-sensitive examples.
Common optional arguments
| Argument | Default | Purpose |
|---|---|---|
name |
"model" |
MLflow model name; also the Triton model name unless overridden. |
triton_model_name |
None |
Override the Triton name. Start with an ASCII letter or _; remaining characters may also include digits and -. |
device |
"cpu" |
Triton serving target: "cpu" or "gpu". sklearn supports CPU only. Does not move the supplied model or select a GPU index. |
signature |
None |
MLflow ModelSignature with input and output schemas. Inferred from the example and prediction when omitted; False is unsupported. |
validate_saved_model |
False |
When True, reload the saved model on CPU for validation. See validation. |
registered_model_name |
None |
Create a version in the MLflow Model Registry. |
await_registration_for |
300 |
Registration wait timeout in seconds. |
run_id |
None |
Associate the model with an MLflow run; otherwise MLflow applies its default run behavior. |
metadata |
None |
Model metadata dictionary. |
tags |
None |
Logged-model tags dictionary. |
params |
None |
Tracking parameters dictionary. For Transformers generation settings, use model_config. |
The Triton directory always uses version 1, independently of the MLflow
Registry version. Use name for the logged model; artifact_path is unsupported.
Model saving options
Pass these options to the same log_model() call to include code, specify
dependencies or configure serialization.
| Argument | Framework | Default / purpose |
|---|---|---|
code_paths |
All | None. Local inference-code files or directories to bundle. Preserve their importable package structure. |
pip_requirements |
All | None. Requirements list or file path; otherwise uses MLflow's default framework dependencies. |
extra_pip_requirements |
All | None. Add dependencies to the default or inferred requirements. |
conda_env |
All | None. Environment dictionary or file path. Follow MLflow's restrictions on combining environment arguments. |
pyfunc_predict_fn |
sklearn | "predict". Prediction method, for example "predict_proba". Also determines the output used to infer the signature. |
serialization_format |
sklearn | Uses the installed MLflow version's default format. |
serialization_format |
PyTorch | "pickle". Alternatives require MLflow support; use validate_saved_model=True to check reloading. |
pickle_module |
PyTorch | None. Python module used for serialization. |
task |
Transformers | None. Task such as "text-generation"; provide it if MLflow cannot infer the task. |
processor |
Transformers | None. Task-specific processor, when required. |
model_config |
Transformers | None. Prediction settings dictionary, such as {"max_new_tokens": 32}. |
save_pretrained |
Transformers | True. Must remain enabled to include local model and tokenizer assets. |
architecture_init_kwargs |
PyTorch, Transformers | None. Constructor settings recorded as documentation; not used to reconstruct the model. See the architecture report. |
Include custom dependencies explicitly: default logging skips automatic dependency
detection to avoid reloading weights. With validate_saved_model=True, MLflow's
dependency detection is enabled when no explicit environment is supplied.
code_paths bundles local code; requirement arguments record installable dependencies.
Additional saving options and version-specific defaults follow the installed
MLflow version's mlflow.<framework>.save_model API, which the library uses
internally to write model files. Options exclusive to MLflow's log_model are
not automatically supported.
Validation and limitations
By default, logging runs an example prediction with your model on its current device, infers or checks its signature, and validates the Triton input/output mapping. Invalid inputs, unsupported schemas and failed predictions raise errors.
Set validate_saved_model=True to instead reload the saved artifact on CPU and
validate it. This requires memory for an additional model copy. The result is
recorded in validation.json. Test actual Triton serving and GPU execution separately.
- Serving uses Triton's Python backend and MLflow's prediction interface. PyTorch models are not automatically exported to a graph backend; streaming is unsupported.
- Preprocessing and postprocessing must be included in the supplied prediction interface. Custom architecture code must be bundled or installed.
- Supported schemas contain NumPy-compatible numeric/string tensors or required scalar DataFrame columns. Nested/object schemas, optional or datetime columns, and scalar tensors need a separate adapter.
- Generated configuration uses
max_batch_size: 0. Supply an explicit signature for dynamic dimensions that cannot be inferred from the example. - Sharded/device-mapped models and tasks unsupported by MLflow's prediction interface need a separate adapter.
Generated Triton files
log_model() stores the generated Triton directory in the MLflow artifact store
alongside the native model. Inspect it through the MLflow artifact browser.
List the generated files in the artifact store without downloading them:
from mlflow import MlflowClient
triton_path = info.flavors["triton"]["data"]
for artifact in MlflowClient().list_logged_model_artifacts(
info.model_id, path=triton_path
):
print(artifact.path, "directory" if artifact.is_dir else "file")
This lists the direct entries. The quickstart examples also walk subdirectories to show the complete generated file list. Paths are relative to the logged model; they are not local filesystem paths or direct S3 addresses.
Generated directory layout:
<triton_model_name>/
config.pbtxt
requirements.txt
request.json # Or request.bin + request.headers for binary inputs
validation.json
1/
model.py
artifact/ # Self-contained MLflow model, code and assets
The serving requirements.txt is standalone: requirements and constraints from
MLflow's saved environment are combined into package requirements, without -r
or -c file references. Constraint-only packages become explicit serving
dependencies and will also be installed. Version restrictions and environment
markers are retained. Unsupported pip options or local file dependencies fail
packaging rather than producing an unusable deployment file. MLflow's native
environment files inside the saved artifact remain unchanged.
If MLflow is specified only conditionally, the serving file also requires
mlflow>=3.14,<4 unconditionally. Applicable conditional version restrictions
still apply, so MLflow remains available on other serving Python versions too.
Install the recorded dependencies in a serving environment compatible with
Triton's Python backend. Logging stores two model copies so the Triton directory
can be deployed independently; allow enough disk space for both and temporary files.
MLflow's framework and pyfunc loaders remain usable for the logged model.
Further documentation
- Advanced serving guide: validation details, device behavior, configuration mapping, architecture reports and resource requirements.
- Examples and validation.
- Send a generated request after deploying your model to Triton.
- Optional Triton Control deployment.
Metadata
Release files for mlflow-triton 0.4.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mlflow_triton-0.4.4.tar.gz | 26.5 kB | With provenance | Details for mlflow_triton-0.4.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mlflow_triton-0.4.4-py3-none-any.whl | Python 3 | none | any | Details for mlflow_triton-0.4.4-py3-none-any.whl |
Total release size: 53.9 kB
Release files / mlflow_triton-0.4.4.tar.gz
| Download URL | mlflow_triton-0.4.4.tar.gz |
|---|---|
| Size | 26.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
980141d2c87140e1c61a7da27cfbe0c05ff59d86c49d8fcdc475eeb5d017c9fe
|
|
BLAKE2b-256 checksum How to use checksums |
50d1407e6e1cbd5b094d7f5df4b98defffc6119cac8e2ab5a5aee4bfa925a823
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / mlflow_triton-0.4.4-py3-none-any.whl
| Download URL | mlflow_triton-0.4.4-py3-none-any.whl |
|---|---|
| Size | 27.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cd1bde6cf1e28f62a94e782b410aff2d1a2e80b362f2b25696e93b21c67e8ef1
|
|
BLAKE2b-256 checksum How to use checksums |
64971100e1da468b6fa41f51006a7d51b415238263beea7e2ff5d10872d6a378
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logSecurity for mlflow-triton 0.4.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for mlflow_triton-0.4.4.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.