// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
syntax = "proto3";
package dynamo.kvrelay.v1;
// v1 is a compatibility major, not a schema revision. Additive fields keep
// protocol_version=1 and contract_marker=0x4B565231. Preserve field numbers,
// types and meanings; reserve deleted field numbers and names. Incompatible
// semantics require a new package. See ../docs/grpc-contract.md.
// Unknown safety-relevant types make the affected pool/topology unsupported,
// not the entire catalog. Never interpret unknown values as a known default.
service KvEventRelay
{
rpc GetRelayInfo(RelayInfoRequest) returns (RelayInfo);
rpc WatchKvPoolCatalog(WatchKvPoolCatalogRequest) returns (stream KvPoolCatalogUpdate);
rpc SubscribeKvPool(SubscribeKvPoolRequest) returns (stream FilterUpdate);
rpc SubscribeServingReadiness(SubscribeServingReadinessRequest) returns (stream ServingReadinessUpdate);
rpc SubscribeKvPoolLoad(SubscribeKvPoolLoadRequest) returns (stream KvPoolLoadUpdate);
rpc SubscribeServingLoad(SubscribeServingLoadRequest) returns (stream ServingLoadUpdate);
}
// Relay application errors carry this enum's exact symbolic name in the
// ASCII trailer kv-relay-error-reason. Missing/unknown reasons fall back to
// the gRPC status code; messages are diagnostic text, never a retry API.
enum RelayErrorReason {
RELAY_ERROR_REASON_UNSPECIFIED = 0;
RELAY_ERROR_REASON_CONTRACT_MISMATCH = 1;
RELAY_ERROR_REASON_INVALID_REQUEST = 2;
RELAY_ERROR_REASON_UNSUPPORTED_FEATURE = 3;
RELAY_ERROR_REASON_POOL_NOT_FOUND = 4;
RELAY_ERROR_REASON_PRODUCER_CHANGED = 5;
RELAY_ERROR_REASON_RESOURCE_LIMIT = 6;
RELAY_ERROR_REASON_SUBSCRIBER_LAGGED = 7;
RELAY_ERROR_REASON_SNAPSHOT_PROGRESS_TIMEOUT = 8;
RELAY_ERROR_REASON_PUBLICATION_UNAVAILABLE = 9;
RELAY_ERROR_REASON_INVALID_PUBLICATION = 10;
RELAY_ERROR_REASON_INTERNAL = 11;
}
enum IdentitySource {
IDENTITY_SOURCE_UNSPECIFIED = 0;
IDENTITY_SOURCE_DEFAULT_DERIVED = 1;
IDENTITY_SOURCE_EXPLICIT = 2;
}
enum FilterUpdateKind {
FILTER_UPDATE_KIND_UNSPECIFIED = 0;
FILTER_UPDATE_KIND_SNAPSHOT_CHUNK = 1;
FILTER_UPDATE_KIND_DELTA = 2;
FILTER_UPDATE_KIND_HEARTBEAT = 3;
}
enum ServingReadinessState {
SERVING_READINESS_STATE_UNKNOWN = 0;
SERVING_READINESS_STATE_UNAVAILABLE = 1;
SERVING_READINESS_STATE_READY = 2;
}
enum WorkerRole {
WORKER_ROLE_UNSPECIFIED = 0;
WORKER_ROLE_PREFILL = 1;
WORKER_ROLE_DECODE = 2;
WORKER_ROLE_ENCODE = 3;
WORKER_ROLE_AGGREGATED = 4;
WORKER_ROLE_LEGACY = 5;
}
// One atomic, executable token-to-sequence-hash pipeline. Consumers must reject
// unspecified or unknown formats rather than combining independently versioned steps.
enum KvQueryHashFormat {
KV_QUERY_HASH_FORMAT_UNSPECIFIED = 0;
KV_QUERY_HASH_FORMAT_DYNAMO_STANDARD_V1 = 1;
KV_QUERY_HASH_FORMAT_DYNAMO_EAGLE_V1 = 2;
}
message RelayIdentity
{
fixed64 drt_instance_id = 1;
fixed64 relay_incarnation = 2;
}
message DigestIdentity
{
bytes digest = 1;
IdentitySource source = 2;
}
message IndexerDomainId
{
DigestIdentity cache_semantics = 1;
DigestIdentity routing_scope = 2;
}
message KvPoolId
{
uint32 identity_version = 1;
IndexerDomainId indexer_domain = 2;
fixed64 dc_id = 3;
}
message CkfFormat
{
uint32 format_version = 1;
fixed64 seed = 2;
uint64 bucket_count = 3;
uint32 fingerprint_bits = 4;
uint32 slots_per_bucket = 5;
}
// Frozen v1 subscription key: all existing fields, recursively, participate
// in equality. Add descriptive metadata to KvPoolDescriptor, not this key.
// Changing identity composition or CKF interpretation requires a new contract.
message ProducerIdentity
{
KvPoolId pool_id = 1;
fixed64 producer_incarnation = 2;
uint64 layout_generation = 3;
CkfFormat ckf_format = 4;
}
message DynamoEndpointId
{
string namespace = 1;
string component = 2;
string endpoint = 3;
}
message BaseModelTarget
{
string base_model = 1;
}
message LoraModelTarget
{
string base_model = 1;
string adapter = 2;
}
message ModelTarget
{
// An unset target may be an unknown future oneof variant. Treat the
// affected pool as unsupported; never fall back to a base-model target.
oneof target
{
BaseModelTarget base = 1;
LoraModelTarget lora = 2;
}
}
message ModelRegistration
{
string canonical_model_id = 1;
ModelTarget target = 2;
repeated string aliases = 3;
}
message KvQuerySemantics
{
uint32 kv_block_size = 1;
KvQueryHashFormat hash_format = 2;
}
// Extensible descriptive metadata, separate from the frozen producer key.
// New fields must be optional in meaning and preserve v1 defaults.
message KvPoolDescriptor
{
ProducerIdentity producer = 1;
DynamoEndpointId serving_endpoint = 2;
repeated ModelRegistration registrations = 3;
KvQuerySemantics query_semantics = 4;
// Roles declared by the endpoint's current base-model cards, independent of liveness.
repeated WorkerRole pool_roles = 5;
}
message KvPoolCatalogSnapshot
{
repeated KvPoolDescriptor pools = 1;
}
message RelayInfoRequest
{
fixed32 contract_marker = 127;
}
message RelayInfo
{
uint32 protocol_version = 1;
RelayIdentity relay = 2;
fixed32 contract_marker = 127;
}
message WatchKvPoolCatalogRequest
{
string subscriber_id = 1;
fixed32 contract_marker = 127;
}
message KvPoolCatalogUpdate
{
uint32 protocol_version = 1;
RelayIdentity relay = 2;
uint64 revision = 3;
KvPoolCatalogSnapshot snapshot = 4;
fixed32 contract_marker = 127;
}
message SubscribeKvPoolRequest
{
string subscriber_id = 1;
ProducerIdentity expected_producer = 2;
fixed32 contract_marker = 127;
}
message FilterUpdate
{
uint32 protocol_version = 1;
RelayIdentity relay = 2;
ProducerIdentity producer = 3;
uint64 base_sequence = 4;
uint64 sequence = 5;
uint64 send_ts_us = 6;
FilterUpdateKind kind = 7;
bytes payload = 8;
fixed32 contract_marker = 127;
}
message SubscribeServingReadinessRequest
{
string subscriber_id = 1;
fixed32 contract_marker = 127;
}
message TopologyMember
{
DynamoEndpointId endpoint = 1;
repeated WorkerRole roles = 2;
// Stable pool link. Absent when this topology endpoint has no materialized KV pool.
optional KvPoolId pool_id = 3;
}
message AdapterReadiness
{
string canonical_model_id = 1;
ServingReadinessState state = 2;
repeated WorkerRole missing_roles = 3;
}
message TopologyEntry
{
// Stable serving-topology key. Producer generations are resolved through members.pool_id.
string namespace = 1;
string canonical_model_id = 2;
ServingReadinessState state = 3;
repeated WorkerRole present_roles = 4;
repeated WorkerRole missing_roles = 5;
repeated TopologyMember members = 6;
// Unique typed roles advertised by more than one endpoint in this topology.
// Only PREFILL and DECODE are valid values.
repeated WorkerRole duplicate_role_endpoints = 7;
bool legacy_fallback_active = 8;
repeated AdapterReadiness adapters = 9;
}
message ServingReadinessUpdate
{
uint32 protocol_version = 1;
RelayIdentity relay = 2;
uint64 revision = 3;
repeated TopologyEntry entries = 4;
fixed32 contract_marker = 127;
}
message SubscribeKvPoolLoadRequest
{
string subscriber_id = 1;
fixed32 contract_marker = 127;
}
message KvPoolLoadEntry
{
ProducerIdentity producer = 1;
uint64 kv_used_blocks = 2;
uint64 total_kv_blocks = 3;
uint32 kv_observed_ranks = 4;
uint32 kv_expected_ranks = 5;
}
message KvPoolLoadUpdate
{
uint32 protocol_version = 1;
RelayIdentity relay = 2;
uint64 window_sequence = 3;
uint64 observed_ms = 4;
uint64 window_ms = 5;
repeated KvPoolLoadEntry pools = 6;
fixed32 contract_marker = 127;
}
// ---------------------------------------------------------------------------
// SubscribeServingLoad (additive to v1)
// ---------------------------------------------------------------------------
// Coverage of an aggregate in a ServingLoadUpdate.
enum DataStatus {
DATA_STATUS_UNSPECIFIED = 0;
// Every expected source reported recently; every gauge for this view kind is set.
DATA_STATUS_COMPLETE = 1;
// Some expected sources did not report, or the set of expected sources is
// unknown; gauges are unset because a partial sum would read as lower load.
DATA_STATUS_DEGRADED = 2;
// No expected source reported.
DATA_STATUS_UNAVAILABLE = 3;
}
message SubscribeServingLoadRequest
{
string subscriber_id = 1;
fixed32 contract_marker = 127;
}
// Request counts reported by frontends. Present on models only.
message RequestLifecycleStats
{
// Cumulative over every frontend the Relay has heard from during its
// relay_incarnation, including frontends that have since left. Start at zero
// with each relay_incarnation and count what it observed; monotonic within
// one incarnation, so compute rates only within one incarnation.
// Set even when the view is not COMPLETE. Each started request ends exactly
// once: completed counts successes only and failed excludes cancellations,
// so started = completed + failed + cancelled + in flight.
uint64 requests_started_total = 1;
uint64 requests_completed_total = 2;
uint64 requests_failed_total = 3;
uint64 requests_cancelled_total = 4;
// Admitted requests that have not produced their first output token yet:
// being tokenized, queued, routed, or prefilled. Requests that never stream
// tokens (embeddings, images, videos, tensors) stay here until they finish.
// Set only when COMPLETE.
optional uint64 requests_awaiting_first_token = 5;
// Requests producing output tokens. Set only when COMPLETE.
optional uint64 requests_generating = 6;
}
// Token load. Each field names the view that carries it.
message TokenLoadStats
{
// Pools: uncached prompt tokens the routers' schedulers have assigned to the
// pool and that are waiting for or undergoing prefill. This is the
// schedulers' live estimate; with a prefill model configured it decays as
// prefill progresses.
optional uint64 active_prefill_tokens = 1;
// Pools: KV blocks the routers' schedulers attribute to running requests.
optional uint64 active_decode_blocks = 2;
// Models: prompt tokens of requests_awaiting_first_token.
optional uint64 awaiting_first_token_input_tokens = 3;
// Models: prompt tokens of every in-flight request.
optional uint64 inflight_input_tokens = 4;
// Models: cumulative, with the same rules as the request _total counters.
optional uint64 input_tokens_total = 5;
optional uint64 output_tokens_total = 6;
}
// Prompt token counts are known once a request has been tokenized; requests
// still being tokenized contribute zero input tokens. Gauges are set only when
// status is COMPLETE.
message LoadView
{
// Unset for pools.
RequestLifecycleStats requests = 1;
TokenLoadStats tokens = 2;
DataStatus status = 3;
// Producer wall clock of the oldest contributing source report; 0 when none.
uint64 source_observed_ms = 4;
}
// Derived from the pool's live worker membership. Both fields are unset while
// the pool's runtime configuration is invalid.
message PoolDeploymentStatus
{
optional uint64 live_workers = 1;
// Sum over workers of max concurrent sequences times data-parallel size. Set
// while every worker declares its limit.
optional uint64 max_concurrency = 2;
}
// Scheduler load of one pool as seen by the routers that schedule onto it:
// COMPLETE when every expected router reported every expected rank recently,
// DEGRADED when coverage is partial, UNAVAILABLE when no router reported.
// Expected routers are those that reported recently plus those that registered
// for the pool's scheduler-load subject within the last three publish
// intervals; routers that predate this RPC are not counted.
message PoolServingLoad
{
ProducerIdentity producer = 1;
LoadView load = 2;
PoolDeploymentStatus deployment = 3;
}
// Expected frontends are those that published recently plus those that
// registered in discovery within the last three publish intervals, in the
// model's namespace and, for frontends without an exact namespace, the
// Relay's. A frontend that does not list the model is not serving it and
// contributes zero.
message ModelDeploymentStatus
{
uint64 expected_frontends = 1;
// Expected frontends that published recently.
uint64 observed_frontends = 2;
// Observed frontends that list the model and are ready to serve.
uint64 ready_frontends = 3;
// Stable links to catalog pools serving the model in this namespace.
repeated KvPoolId serving_pools = 4;
}
// Frontend load of one model. Key: (namespace, canonical_model_id), as in
// TopologyEntry; alias traffic is counted under the canonical model.
// COMPLETE when frontend discovery succeeded and every expected frontend
// published recently, DEGRADED when some are silent or discovery failed,
// UNAVAILABLE when none published recently.
message ModelServingLoad
{
string namespace = 1;
string canonical_model_id = 2;
LoadView load = 3;
ModelDeploymentStatus deployment = 4;
}
// Complete window: a pool or model absent from the next window is gone.
message ServingLoadUpdate
{
uint32 protocol_version = 1;
RelayIdentity relay = 2;
uint64 window_sequence = 3;
uint64 observed_ms = 4;
uint64 window_ms = 5;
repeated PoolServingLoad pools = 6;
repeated ModelServingLoad models = 7;
fixed32 contract_marker = 127;
}