dynamo-llm 1.7.0

Dynamo LLM Library
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
// 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;
}