模型配置扩展#

本文档介绍了 Triton 的模型配置扩展。模型配置扩展允许 Triton 返回服务器特定的信息。由于支持此扩展,Triton 会在其服务器元数据的扩展字段中报告“model_configuration”。

HTTP/REST#

在本文档中显示的所有 JSON 模式中,$number$string$boolean$object$array 指的是基本的 JSON 类型。#optional 表示可选的 JSON 字段。

Triton 在以下 URL 公开模型配置端点。URL 的 versions 部分是可选的;如果未提供,Triton 将返回模型最高编号版本的模型配置。

GET v2/models/${MODEL_NAME}[/versions/${MODEL_VERSION}]/config

模型配置请求通过 HTTP GET 请求发送到模型配置端点。成功的模型配置请求由 200 HTTP 状态代码指示。模型配置响应对象(标识为 $model_configuration_response)在每个成功请求的 HTTP body 中返回。

$model_configuration_response =
{
  # configuration JSON
}

响应的内容将是由 model_config.proto 中的 ModelConfig 消息描述的模型配置的 JSON 表示形式。

失败的模型配置请求必须由 HTTP 错误状态(通常为 400)指示。HTTP body 必须包含 $model_configuration_error_response 对象。

$model_configuration_error_response =
{
  "error": <error message string>
}
  • “error” : 错误的描述性消息。

GRPC#

该服务的 GRPC 定义是

service GRPCInferenceService
{
  …

  // Get model configuration.
  rpc ModelConfig(ModelConfigRequest) returns (ModelConfigResponse) {}
}

错误由请求返回的 google.rpc.Status 指示。OK 代码表示成功,其他代码表示失败。ModelConfig 的请求和响应消息是

message ModelConfigRequest
{
  // The name of the model.
  string name = 1;

  // The version of the model. If not given the version of the model
  // is selected automatically based on the version policy.
  string version = 2;
}

message ModelConfigResponse
{
  // The model configuration.
  ModelConfig config = 1;
}

其中 ModelConfig 消息在 model_config.proto 中定义。