Repository navigation
feat(kv-router): session affinity for the standalone service and EPP - #53
Closed
ishandhanani wants to merge 5 commits into
Closed
ishandhanani wants to merge 5 commits into
ishandhanani wants to merge 5 commits into
Conversation
ishandhanani
had a problem deploying
to
external_collaborator
September 4, 2026 03:18 — with
GitHub Actions
Failure
This was referenced Sep 4, 2026
Closed
ishandhanani
force-pushed
the
idhanani/up-9-epp-affinity
branch
from
September 4, 2026 04:00
868bc87 to
6004852
Compare
ishandhanani
had a problem deploying
to
external_collaborator
September 4, 2026 04:00 — with
GitHub Actions
Failure
ishandhanani
had a problem deploying
to
external_collaborator
September 4, 2026 04:00 — with
GitHub Actions
Failure
ishandhanani
force-pushed
the
idhanani/up-9-epp-affinity
branch
from
September 9, 2026 18:30
6004852 to
6e37f0d
Compare
ishandhanani
had a problem deploying
to
external_collaborator
September 9, 2026 18:30 — with
GitHub Actions
Failure
ishandhanani
had a problem deploying
to
external_collaborator
September 9, 2026 18:30 — with
GitHub Actions
Failure
ishandhanani
had a problem deploying
to
external_collaborator
September 9, 2026 18:49 — with
GitHub Actions
Failure
ishandhanani
force-pushed
the
idhanani/up-9-epp-affinity
branch
from
September 9, 2026 18:50
5a6bcf4 to
63e9987
Compare
ishandhanani
had a problem deploying
to
external_collaborator
September 9, 2026 18:50 — with
GitHub Actions
Failure
SelectionServiceBuilder::session_affinity(ttl) gives the core its own SessionAffinity table. A booked selection whose request carries a session id (session_id or session_context) and no explicit pin or affinity target acquires the session first: a bound session steers selection to its worker (exclusive for the default selector) and a new one is bound to the worker the scheduler chose. The lease is held with the booking and released by free_reservation; a bound worker that was not selected (it left) is invalidated and the session rebound. Advisory selects read the binding. Bindings replicate over the existing ZMQ peer mesh on their own topic (dynamo.session-affinity.v1) so peers that do not subscribe never see them; the active-sequence topic and wire format are untouched. The publisher multiplexes both channels onto one socket; PeerManager subscribes to the second topic only when a handler is given. SelectionServiceConfig carries the TTL for the standalone binary. Signed-off-by: Ishan Dhanani <[email protected]>
DYN_EPP_SESSION_AFFINITY_TTL_SECS turns on the selector's session table. The EPP passes x-dynamo-session-id, the same header the frontend reads, as the request's session id, so repeat requests of a session land on the worker that served it and peer EPPs learn the binding over the replica mesh. Hard mode only: the EPP routes by headers and never observes where a request ran. The standalone selection binary and the Python SelectionService gain the same TTL setting (--session-affinity-ttl-secs, session_affinity_ttl_secs). Signed-off-by: Ishan Dhanani <[email protected]>
Signed-off-by: Ishan Dhanani <[email protected]>
…n core Signed-off-by: Ishan Dhanani <[email protected]>
Signed-off-by: Ishan Dhanani <[email protected]>
ishandhanani
force-pushed
the
idhanani/up-9-epp-affinity
branch
from
September 9, 2026 19:06
63e9987 to
b91015f
Compare
ishandhanani
had a problem deploying
to
external_collaborator
September 9, 2026 19:06 — with
GitHub Actions
Failure
ishandhanani
had a problem deploying
to
external_collaborator
September 9, 2026 19:06 — with
GitHub Actions
Failure
This was referenced Sep 10, 2026
Closed
ishandhanani
had a problem deploying
to
external_collaborator
September 10, 2026 00:22 — with
GitHub Actions
Failure
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR 9 of 9 implementing ai-dynamo#14310 (one
SelectionCorefor the frontend, the standalone selection service, and the EPP). Base:idhanani/up-8-affinity-table(PR 8 of this stack).Summary
Adds session affinity to the standalone selection service and EPP, with one affinity table per selection partition and leases owned by reservation records. The final stack also fixes lifecycle bugs found during review so expiry, worker metadata updates and scale-to-zero/rejoin preserve the correct state.
Implementation
DYN_EPP_SESSION_AFFINITY_TTL_SECS; EPP forwardsx-dynamo-session-idand uses hard mode.Durationconversion.Walkthrough
Selection and lease ownership
When affinity is enabled, a booked request with a session ID and no explicit pin or affinity target acquires the partition's session binding before selection. A new binding commits the selected worker; a valid existing binding steers later requests to that worker. If the bound worker has left and another worker is selected, the stale binding is invalidated and rebound. Waiting for another initializer honors cancellation.
The reservation index stores
{ partition, affinity lease }in one record. The record is inserted after fallible endpoint resolution; explicit free, missing-booking cleanup and the stale-reservation sweep all drop the same lease. Advisory selection only reads an existing binding: it does not wait, book or initialize affinity. EPP cannot observe the actual dispatch outcome, so its supported mode is hard affinity.Catalog and replica lifecycle
Upserts prepare their records before taking the catalog mutation lock, allowing independent partition policy construction. Reconciliation publishes committed metadata and changes only removed or modified ranks/endpoints. A valid metadata update preserves surviving bookings and unchanged KV listeners; invalid records become incomplete after cleanup. An empty partition keeps its index so a rejoined worker feeds the index the scheduler still holds.
Standalone bookings retain periodic expiry. The frontend retains
RequestLeaseManagerexpiry ownership, avoiding a second independent expiry task for those requests, and the deferred replica observer preserves startup Add/Free replay. The frontend wraps its partition table once and shares replica initialization and shutdown across coordinator clones. Builtin routing modes that have no selection partition retain their host-owned table.Review decisions
Tom's DEP feedback informed partition ownership. Availability/overload callbacks remain because transport inhibition, immediate overload feedback, backend KV occupancy and the two-signal latch are not represented by catalog/slot state alone. Controller-aware LoRA filtering retains
replica_setandis_activesemantics; loaded-adapter metadata alone is insufficient. ModelManager keeps shared-cache endpoint subscriptions to preserve configuration gates, overrides and reconnect behavior without duplicate listeners.The lease leak, cross-partition binding collision, sole-worker rejoin bug, metadata-update state loss and Python TTL panic were reproduced before their fixes. TTL validation rejects invalid, non-finite and out-of-range values before conversion; Python declarations match the runtime constructor.
Validation
Current stack boundary:
b91015f183bc159e1fbf6968f2cc967cbbc0b23f; the series is based on Dynamo mainab58558c2dff28f4ff1ea4e219030eac5da3f48f.cargo check -p dynamo-kv-router -p dynamo-llm -p dynamo-ext-proc --no-default-features --features dynamo-kv-router/standalone-selection,dynamo-kv-router/standalone-slot-tracker --all-targetsfor this stack boundary.cargo check --manifest-path lib/bindings/python/Cargo.toml --features select-service --all-targetsat this boundary.Final-stack validation
kv-indexer,slot-tracker,select-service. All nine stack boundaries passed the Rust compile check above; bindings withselect-servicealso passed at feat(kv-router): approximate, remote, and hint-aware indexing in SelectionService #46–feat(kv-router): session affinity for the standalone service and EPP #53.Aggregated end-to-end validation
Two B200 GPUs ran two TP1 aggregated SGLang 0.5.19 workers serving Qwen3-0.6B, with a KV-aware Dynamo frontend, hard session affinity and worker ZMQ KV events enabled. Baseline was
ab58558c2dff28f4ff1ea4e219030eac5da3f48f. The GPU candidate was built at63e998744f53194c7a1a6a99adbc6e5c5c6bb317, whose Git tree exactly equals this published headb91015f183bc159e1fbf6968f2cc967cbbc0b23f; the later change only moved a bindings compatibility fix to its earliest stack boundary. Both arms used identical installed package versions, model revision and deployment settings.SelectionServicebooked workers, requests were forwarded through the frontend with explicit worker pins, and every response's actual worker matched the selection. The probe exercised repeated sessions, metadata refresh, catalog withdrawal/failover, catalog scale-to-zero/rejoin and reservation release, finishing with zero active bookings.The standalone probe used approximate indexing and pinned frontend forwarding. EPP was covered by its Rust suite, not a live Envoy/Kubernetes deployment. This validation was aggregated only; no disaggregated serving test or separate DisaggCoordinator work is claimed. All benchmark jobs completed and compute was released.
Benchmark results
AIPerf 0.12.0 used streaming chat, concurrency 16, synthetic ISL 512, forced OSL 128 (
ignore_eos=true,min_tokens=128) and seed 42. Three alternating main/final pairs measured 512 requests after 32 warmups per deployment. A longer reversed-order final/main pair measured 4,096 requests after 256 warmups per deployment, with approximately 73-second observation windows.Prompt artifacts were byte-identical between matched arms. Short-run prompts were 512 client tokens / 520 server tokens after chat framing; two prompts per longer arm retokenized to 513/521, with matching histograms on both arms. Client output retokenization varies slightly around the verified 128 server tokens, so request throughput is the primary comparison.
The small measured throughput reduction consistently favors main. These runs do not establish zero overhead, statistical equivalence or production-scale capacity.
GitHub CI is not green across this series. Recurring failures are the missing fork Fastchecker runner group, helm-tester image and approval-bot token, plus published-docs composition and an unchanged external documentation link. The local compilation and final-stack validation above are recorded separately from those CI failures.
Stack
idhanani/up-1-host-hooksidhanani/up-2-core-indexingidhanani/up-3-embed-coreidhanani/up-4-delete-kvscheduleridhanani/up-5-policy-sourceidhanani/up-6-membershipidhanani/up-7-kv-index-sourceidhanani/up-8-affinity-tableidhanani/up-9-epp-affinity