Skip to content

Commit 2f767d4

Browse files
committed
chore(runtime): Do not expose etcd lease ID
Instead there is a `connection_id() -> u64` method on `DistributedRuntime`, which is always present. Remove the `Lease` object and the unused lease related methods. Also delete legacy unused `DiscoveryClient`. Signed-off-by: Graham King <[email protected]>
1 parent 6739154 commit 2f767d4

File tree

18 files changed

+46
-261
lines changed

18 files changed

+46
-261
lines changed

components/src/dynamo/sglang/publisher.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,8 @@ def init_kv_event_publish(self) -> Optional[ZmqKvEventPublisher]:
123123
ep = kv_events.get("endpoint")
124124
zmq_ep = ep.replace("*", get_local_ip_auto()) if ep else None
125125

126-
lease_id = self.generate_endpoint.lease_id()
127-
128126
zmq_config = ZmqKvEventPublisherConfig(
129-
worker_id=lease_id,
127+
worker_id=self.generate_endpoint.connection_id(),
130128
kv_block_size=self.server_args.page_size,
131129
zmq_endpoint=zmq_ep,
132130
)

components/src/dynamo/trtllm/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ async def init(runtime: DistributedRuntime, config: Config):
421421
component,
422422
engine,
423423
kv_listener,
424-
int(endpoint.lease_id()),
424+
int(endpoint.connection_id()),
425425
config.kv_block_size,
426426
metrics_labels,
427427
) as publisher:

components/src/dynamo/vllm/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def setup_kv_event_publisher(
135135
).replace("*", "127.0.0.1")
136136

137137
zmq_config = ZmqKvEventPublisherConfig(
138-
worker_id=generate_endpoint.lease_id(),
138+
worker_id=generate_endpoint.connection_id(),
139139
kv_block_size=vllm_config.cache_config.block_size,
140140
zmq_endpoint=zmq_endpoint,
141141
)

examples/multimodal/components/worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def setup_vllm_engine(self, component: Component, endpoint: Endpoint):
163163
).replace("*", "127.0.0.1")
164164

165165
zmq_config = ZmqKvEventPublisherConfig(
166-
worker_id=endpoint.lease_id(),
166+
worker_id=endpoint.connection_id(),
167167
kv_block_size=vllm_config.cache_config.block_size,
168168
zmq_endpoint=zmq_endpoint,
169169
)

lib/bindings/python/rust/lib.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -773,12 +773,9 @@ impl Endpoint {
773773
})
774774
}
775775

776-
fn lease_id(&self) -> u64 {
777-
self.inner
778-
.drt()
779-
.primary_lease()
780-
.map(|l| l.id())
781-
.unwrap_or(0)
776+
// Opaque unique ID for this worker. May change over worker lifetime.
777+
fn connection_id(&self) -> u64 {
778+
self.inner.drt().connection_id()
782779
}
783780

784781
/// Get a RuntimeMetrics helper for creating Prometheus metrics

lib/bindings/python/rust/llm/kv.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -991,14 +991,7 @@ async fn create_kv_router_from_endpoint(
991991
// Get component from endpoint
992992
let component = endpoint.inner.component();
993993

994-
// Verify we're not in static mode
995-
if component.drt().primary_lease().is_none() {
996-
return Err(PyErr::new::<pyo3::exceptions::PyRuntimeError, _>(
997-
"Failed to get primary lease: Cannot KV route static workers",
998-
));
999-
}
1000-
1001-
// Create ModelManager and use it to create KvRouter (ensures etcd registration)
994+
// Create ModelManager and use it to create KvRouter (ensures registration)
1002995
let model_manager = Arc::new(llm_rs::discovery::ModelManager::new());
1003996
let kv_router = model_manager
1004997
.kv_chooser_for(component, block_size as u32, kv_router_config)

lib/bindings/python/src/dynamo/_core.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ class Endpoint:
157157
"""
158158
...
159159

160-
async def lease_id(self) -> int:
160+
async def connection_id(self) -> int:
161161
"""
162-
Return primary lease id. Currently, cannot set a different lease id.
162+
Opaque unique ID for this worker. May change over worker lifetime.
163163
"""
164164
...
165165

lib/llm/src/kv_router.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,7 @@ impl KvRouter {
224224
consumer_uuid: String,
225225
) -> Result<Self> {
226226
let kv_router_config = kv_router_config.unwrap_or_default();
227-
228-
let cancellation_token = component
229-
.drt()
230-
.primary_lease()
231-
.expect("Cannot KV route static workers")
232-
.primary_token();
233-
227+
let cancellation_token = component.drt().primary_token();
234228
let generate_endpoint = component.endpoint("generate");
235229
let client = generate_endpoint.client().await?;
236230

lib/llm/src/kv_router/publisher.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -784,15 +784,7 @@ impl WorkerMetricsPublisher {
784784
}
785785

786786
pub async fn create_endpoint(&self, component: Component) -> Result<()> {
787-
let worker_id = component
788-
.drt()
789-
.primary_lease()
790-
.map(|lease| lease.id())
791-
.unwrap_or_else(|| {
792-
tracing::warn!("Component is static, assuming worker_id of 0");
793-
0
794-
});
795-
787+
let worker_id = component.drt().connection_id();
796788
self.start_nats_metrics_publishing(component.namespace().clone(), worker_id);
797789
Ok(())
798790
}

lib/llm/src/mocker/engine.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,7 @@ impl MockVllmEngine {
246246
tracing::debug!("Component found for KV events publishing");
247247

248248
tracing::debug!("Getting worker_id");
249-
let worker_id = comp
250-
.drt()
251-
.primary_lease()
252-
.expect("Cannot publish KV events without lease") // ← This will PANIC on static!
253-
.id();
249+
let worker_id = comp.drt().connection_id();
254250
// let worker_id = 0;
255251
tracing::debug!("Worker_id set to: {worker_id}");
256252

0 commit comments

Comments
 (0)