Skip to content

feat(kv-router,sidecar): worker leases, static workers file, and sidecar catalog registration - #21

Closed
ishandhanani wants to merge 2 commits into
idhanani/p3-disagg-coordinatorfrom
idhanani/p4-catalog-heartbeat
Closed

ishandhanani wants to merge 2 commits into
idhanani/p3-disagg-coordinatorfrom
idhanani/p4-catalog-heartbeat

Conversation

@ishandhanani

@ishandhanani ishandhanani commented Sep 3, 2026 •

Copy link
Copy Markdown
Owner

Phase 4 (contract 4: registration and liveness), slices 1 and 2. Stacked on #20.

Summary

Two commits that together make worker registration runtime-free end to end: the selection catalog becomes a lease-based registry, and the vLLM sidecar registers into it over HTTP.

Slice 1: leases + static workers file (kv-router)

  • WorkerRequest.ttl_secs starts a lease; POST /workers/{id}/heartbeat renews it (optional {"ttl_secs": N} changes it; unleased worker without TTL -> 400; unknown -> 404). Response carries the record and lease_secs.
  • Lease sweeper wakes at the earliest deadline (min 100 ms, 1 s idle). Expiry drains and deregisters through the existing delete_worker path and leaves the record unschedulable with reason lease expired; a later POST /workers revives it. expire_leases() exposed for hosts/tests.
  • Static catalog feeder: SelectionServiceBuilder::initial_workers / initial_workers_file, SelectionServiceConfig.workers_file, --workers-file on dynamo.select_service.

Slice 2: sidecar catalog agent (sidecar-common + vLLM sidecar)

  • dynamo_sidecar_common::catalog: CatalogRegistration (the POST /workers body), CatalogClient (register/heartbeat/deregister), CatalogAgent (heartbeats at TTL/2, re-registers on 404, deregisters when cancelled).
  • vLLM sidecar --selection-catalog-url (+ --selection-catalog-ttl-secs, --selection-catalog-routing-group), requiring --advertise-grpc-endpoint. The record's dispatch endpoint is the advertised gRPC address; vLLM's own KV-event ZMQ publishers are rehosted onto that host as kv_events_endpoints, so the selector subscribes to the engine directly. Registration runs in start() with the runtime-issued worker id; cleanup() cancels the agent and waits up to 3 s for deregistration.
  • With feat(router): direct native-gRPC dispatch beside the request plane #19's direct dispatch, a worker registered this way needs no etcd/NATS between it and a selector. Docs: standalone-selection.md, sidecar-backends.md, vLLM sidecar README.
  • Also fixes the expect_err on a non-Debug type in the vLLM mocker direct-dispatch test (amended into feat(router): direct native-gRPC dispatch beside the request plane #19 as well).

Still to come in Phase 4: own ZMQ replay for the agent path, the Kubernetes pod feeder generalized from the EPP reflector, model-card source independent of discovery, and the frontend assembly with no DistributedRuntime.

Validation

  • cargo test -p dynamo-kv-router --features standalone-selection --lib: 1080 passed (new lease/heartbeat/workers-file tests).
  • cargo test -p dynamo-vllm-mocker -p dynamo-vllm-sidecar -p dynamo-sidecar-common: all pass, including sidecar_registers_with_a_selection_catalog_and_deregisters_on_cleanup against a real selection-service router and the mock vLLM gRPC server (record fields, rehosted KV endpoints, heartbeats outliving a 0.4 s TTL, unschedulable after cleanup, startup rejection without an advertised endpoint).
  • Clippy clean on kv-router (pre-existing registry.rs warning only), sidecar-common, vLLM sidecar, vLLM mocker. cargo check --features select-service for the Python bindings: clean. cargo fmt, docs_lint.py clean.

@github-actions github-actions Bot added feat documentation Improvements or additions to documentation labels Sep 3, 2026
Phase 4 (registration and liveness, contract 4) of the runtime-optional
frontend roadmap: the catalog no longer needs a discovery lease to notice a
dead worker, and a deployment with no discovery plane can register its workers
from a file.

- WorkerRequest.ttl_secs starts a registration lease. POST
  /workers/{id}/heartbeat renews it (optional body changes the TTL; a worker
  registered without a TTL must supply one to start a lease). A lease sweeper
  wakes at the next deadline; an expired worker is drained and deregistered
  through the existing delete path and its record is left unschedulable with
  reason `lease expired` until the worker re-registers. Expiry is exposed as
  SelectionCore::expire_leases so hosts and tests can drive it.
- SelectionServiceBuilder::initial_workers / initial_workers_file,
  SelectionServiceConfig.workers_file, and --workers-file on
  dynamo.select_service register a JSON array of POST /workers bodies before
  the service serves selections; an unparseable file fails startup.

Tests: lease renew/TTL change/validation, expiry drains exactly the expired
worker once and leaves unleased workers alone, re-registration revives the
lease; HTTP heartbeat round trip incl. 404 and 400 paths; builder registers
initial and file workers and rejects a bad file.

Signed-off-by: Ishan Dhanani <[email protected]>
Phase 4 (registration and liveness), second slice: the runtime-free
registration path. A sidecar can register its worker with a selection service
instead of (or alongside) Dynamo discovery, so no etcd or NATS sits between the
worker and the selector.

- dynamo-sidecar-common gains a catalog agent: CatalogRegistration (the POST
  /workers body), CatalogClient (register / heartbeat / deregister), and
  CatalogAgent, which heartbeats at half the TTL, re-registers when the catalog
  reports the worker unknown, and deregisters when cancelled.
- The vLLM sidecar takes --selection-catalog-url (+ TTL and routing-group
  flags). It requires --advertise-grpc-endpoint: the record's dispatch endpoint
  is the advertised gRPC address, and vLLM's own KV-event ZMQ publishers are
  rehosted onto that host as the record's kv_events_endpoints, so the selector
  subscribes to the engine directly. The routing group defaults to the
  disaggregation role. Registration happens in start() with the runtime-issued
  worker id; cleanup() cancels the agent and waits up to 3s for
  deregistration so the selector drains the worker immediately.

Also fixes the direct-dispatch test in the vLLM mocker crate, whose
expect_err needed Debug on the engine type.

Tests: end-to-end against a real selection service router and the mock vLLM
gRPC server: the record carries the advertised endpoint, block size, TTL,
rehosted KV endpoints and is schedulable; heartbeats outlive a 0.4s TTL;
cleanup leaves the worker unschedulable; a catalog URL without an advertised
endpoint is rejected at startup.

Signed-off-by: Ishan Dhanani <[email protected]>
@ishandhanani ishandhanani changed the title feat(kv-router): worker leases with heartbeat and a static workers file feat(kv-router,sidecar): worker leases, static workers file, and sidecar catalog registration Sep 3, 2026
@ishandhanani
ishandhanani force-pushed the idhanani/p4-catalog-heartbeat branch from e312889 to 6d0bf05 Compare September 3, 2026 09:05
@ishandhanani

Copy link
Copy Markdown
Owner Author

Closed while Stack 1 (#45 to #53) and Stack 2 (#40) go upstream; the branch stays for later stacks (direct dispatch, catalog leases, runtime features). See #33.

This branch had an error being deployed

1 failed deployment
external_collaborator — 6d0bf05b Deployed Sep 3, 2026 by ishandhanani via ok-to-test #42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation feat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant