Skip to content

gRPC API Reference

This page provides the complete technical specification for SnoozeML’s gRPC Inference and Health Checking API, including both the native snoozeml.v1.InferenceService and the NVIDIA Triton / Open Inference Protocol v2 (inference.GRPCInferenceService).


1. Protocol Buffer Specification

The native Protocol Buffer definition is located in the repository at proto/snoozeml/v1/inference.proto, and the official Triton / Open Inference Protocol v2 definitions are located under proto/third_party/ (grpc_service.proto, model_config.proto, health.proto):

syntax = "proto3";
package snoozeml.v1;
// Service providing low-latency tensor inference over gRPC.
service InferenceService {
// Executes unary inference for a registered model.
rpc Infer(ModelInferRequest) returns (ModelInferResponse);
// Executes bi-directional streaming inference for a registered model.
rpc StreamInfer(stream ModelInferRequest) returns (stream ModelInferResponse);
}
// Supported tensor element data types.
enum DataType {
DATA_TYPE_UNSPECIFIED = 0;
DATA_TYPE_FP32 = 1;
DATA_TYPE_FP16 = 2;
DATA_TYPE_BF16 = 3;
DATA_TYPE_INT32 = 4;
DATA_TYPE_INT64 = 5;
DATA_TYPE_UINT8 = 6;
DATA_TYPE_BOOL = 7;
}
// Multi-dimensional tensor payload with raw byte buffer.
message TensorData {
// Binding identifier of the tensor node (e.g. "input_ids", "logits").
string name = 1;
// Tensor dimensions (e.g. [1, 3, 224, 224]).
repeated int64 shape = 2;
// Primitive element data type (defaults to FP32).
DataType data_type = 3;
// Contiguous little-endian byte representation (4 bytes per float for FP32).
bytes raw_data = 4;
}
message ModelInferRequest {
// Target model identifier.
string model_id = 1;
// Input tensors.
repeated TensorData inputs = 2;
// Optional client-specified request timeout in milliseconds.
optional uint64 client_timeout_ms = 3;
// Optional execution parameters or routing hints.
map<string, string> parameters = 4;
}
message ModelInferResponse {
// Identifier of the executed model.
string model_id = 1;
// Resulting output tensors.
repeated TensorData outputs = 2;
// Execution latency in milliseconds with microsecond precision.
double duration_ms = 3;
}

2. Services & RPC Methods

snoozeml.v1.InferenceService

Provides synchronous and streaming model execution.

Infer

rpc Infer(ModelInferRequest) returns (ModelInferResponse);

Executes a unary inference pass for the requested model. The model is routed through the internal dynamic micro-batcher. If the model is idle, it is automatically rehydrated into memory.

StreamInfer

rpc StreamInfer(stream ModelInferRequest) returns (stream ModelInferResponse);

Executes bi-directional streaming inference over a persistent HTTP/2 stream, routing each incoming frame through the dynamic micro-batcher.

  • Required Role: Inference (or Admin).
  • Input: stream ModelInferRequest
  • Output: stream ModelInferResponse

inference.GRPCInferenceService (NVIDIA Triton & Open Inference Protocol v2)

SnoozeML implements the official Triton / Open Inference Protocol v2 gRPC service (proto/third_party/grpc_service.proto), enabling drop-in compatibility with tritonclient.grpc.

RPC MethodRequired RoleStatus / Description
ServerLivePublicReturns live: true.
ServerReadyPublicReturns ready: true.
ModelReadyReadOnlyReturns ready: true when the model is registered and has at least one loaded replica (Ready or Busy).
ServerMetadataReadOnlyReturns server name ("snooze-ml"), version, and supported OIP extensions.
ModelMetadataReadOnlyReturns model name, versions (["1"]), backend platform, and tensor metadata.
ModelConfigReadOnlyReturns Triton ModelConfig mapped from SnoozeML’s dynamic batching and replica settings.
ModelStatisticsReadOnlyReturns cumulative per-model inference counts, batch execution counts, and nanosecond durations.
RepositoryIndexReadOnlyLists all registered models (READY, LOADING, or UNAVAILABLE when unloaded via scale-to-zero).
RepositoryModelLoadAdminPreloads or rehydrates model weights into memory.
RepositoryModelUnloadAdminUnloads all replicas of a model to scale to zero.
ModelInferInferenceUnary inference supporting both raw_input_contents and typed InferTensorContents.
ModelStreamInferInferenceBi-directional streaming inference (stream ModelInferRequest -> stream ModelStreamInferResponse).
SystemSharedMemory*, CudaSharedMemory*, TraceSetting, LogSettingsAdminOut of scope; returns canonical UNIMPLEMENTED (12) status code.

grpc.health.v1.Health

SnoozeML implements the official gRPC Health Checking Protocol.

Check

rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
  • Required Role: Public (no authentication required).
  • Supported Service Names:
    • "" (empty string): Overall daemon server status.
    • "snoozeml.v1.InferenceService": SnoozeML native inference service status.
    • "inference.GRPCInferenceService": Triton / OIP v2 inference service status.
  • Serving Status: Returns SERVING (1) when the daemon is operational.

3. Message Types & Fields

ModelInferRequest

FieldTypeRequiredDescription
model_idstringYesIdentifier of the registered model to execute. Cannot be empty or whitespace.
inputsrepeated TensorDataYesArray of input tensors matching model graph bindings.
client_timeout_msoptional uint64NoOptional deadline hint from client in milliseconds.
parametersmap<string, string>NoOptional execution hints or routing flags.

ModelInferResponse

FieldTypeDescription
model_idstringIdentifier of the model that executed the request.
outputsrepeated TensorDataOutput tensors generated by the model forward pass.
duration_msdoubleExecution wall-clock latency in milliseconds (microsecond precision).

TensorData

FieldTypeRequiredDescription
namestringYesInput or output binding name in the model graph.
shaperepeated int64YesArray of positive dimension sizes (e.g. [1, 3, 224, 224]). Dimensions must be >0> 0.
data_typeDataTypeNoPrimitive data type. Must be DATA_TYPE_FP32 or DATA_TYPE_UNSPECIFIED.
raw_databytesYesContiguous little-endian byte array containing binary float values.

Buffer Size Invariant

For FP32 tensors, the length of raw_data must strictly equal:

raw_data.len=(∏i=0N−1shape[i])×4\text{raw\_data.len} = \left(\prod_{i=0}^{N-1} \text{shape}[i]\right) \times 4

If raw_data.len does not match this invariant, the RPC returns Status::invalid_argument.


DataType (Enum)

Enum ValueNumberSupported?Description
DATA_TYPE_UNSPECIFIED0YesDefaults to FP32.
DATA_TYPE_FP321YesStandard 32-bit single-precision IEEE-754 float (4 bytes).
DATA_TYPE_FP162Future16-bit half-precision float (2 bytes).
DATA_TYPE_BF163Future16-bit Brain floating-point (2 bytes).
DATA_TYPE_INT324Future32-bit signed integer (4 bytes).
DATA_TYPE_INT645Future64-bit signed integer (8 bytes).
DATA_TYPE_UINT86Future8-bit unsigned integer (1 byte).
DATA_TYPE_BOOL7FutureBoolean (1 byte).

4. Metadata Headers

Clients can attach metadata headers to gRPC requests:

Request Metadata

Header KeyFormat / ExampleDescription
x-api-keysk-infer-client-654Static API key matching configured Inference or Admin key.
authorizationBearer <token>Static API key or cryptographically signed HMAC JWT token.

Response Metadata

Header KeyFormat / ExampleDescription
retry-after5Present on RESOURCE_EXHAUSTED errors; indicates recommended seconds before client retries.

5. Status Codes & Error Mapping

SnoozeML maps internal engine errors directly to canonical gRPC status codes:

Canonical gRPC CodeCode NumberInternal Domain ErrorEquivalent HTTP CodeRoot Cause & Resolution
OK0Success200 OKRequest succeeded.
INVALID_ARGUMENT3InvalidInput, ShapeMismatch400 Bad RequestEmpty model ID, non-positive shape dimension, unsupported data type, or truncated raw_data buffer.
DEADLINE_EXCEEDED4Timeout504 Gateway TimeoutProcessing queue deadline or batch wait budget exceeded.
NOT_FOUND5NotFound404 Not FoundRequested model_id is not registered in the daemon.
RESOURCE_EXHAUSTED8ResourceExhausted, OutOfMemory503 Service UnavailableGPU/Host memory exhausted and all active models are busy. Response includes retry-after: 5 metadata.
UNIMPLEMENTED12UnsupportedSafetensorsArchitecture501 Not ImplementedModel format or architecture not supported by the execution backend, or out-of-scope Triton shared-memory/trace RPC.
INTERNAL13Runtime, QueueError500 Internal Server ErrorUnexpected backend or engine calculation failure.
UNAVAILABLE14Loading503 Service UnavailableModel is currently loading weights into memory.
UNAUTHENTICATED16Missing/Invalid Credentials401 UnauthorizedMissing x-api-key or authorization: Bearer header, invalid key, or expired JWT.
PERMISSION_DENIED7Insufficient Role403 ForbiddenCaller has ReadOnly role, but Inference or Admin role is required.