Skip to content

feat(router): opt-in parent session affinity for initial placement - #11347

Draft
YAMY1234 wants to merge 2 commits into
ai-dynamo:mainfrom
YAMY1234:yamy/parent-affinity-3169427d
Draft

feat(router): opt-in parent session affinity for initial placement#11347
YAMY1234 wants to merge 2 commits into
ai-dynamo:mainfrom
YAMY1234:yamy/parent-affinity-3169427d

Conversation

@YAMY1234

@YAMY1234 YAMY1234 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What

CLOSES: DYN-3521 DGH-1094

Opt-in parent session affinity for initial placement (proof-of-concept for #11343): when DYN_ROUTER_PARENT_AFFINITY=1 and a request's nvext.session_control carries parent_session_id, an unbound session's first request is placed on the worker (and DP rank) currently bound to its parent session. The session then binds its own id on route, so the hint only influences initial placement; parent lookup reuses the existing sticky machinery, including the ineligible-worker fallback. Default off; the new field is optional and wire-compatible.

Why

Agentic workloads spawn subagent sessions that share a large prefix with their parent. On deployments without KV-event prefix indexing, a child session's first request is placed blindly and re-prefills the shared prefix once per child. Details and design discussion in #11343.

Status / scope

  • Draft on the pre-header session_control protocol (base 3169427d) — this is the protocol window we could validate end-to-end with an agentic trace-replay client emitting parent_session_id.
  • Validated live on a 2-node disaggregated SGLang deployment: the policy routes (debug-logged) child first-requests onto the parent's worker/DP-rank as designed.
  • Known follow-ups before this is mergeable:
    1. Port to current main — the sticky coordinator was reworked by feat(router): coordinate session affinity across replicas [DYN-3249] #11079 (session claims); on main the parent id is already parsed from the agentic identity headers, so the policy should consume that instead of a new body field.
    2. Config surface: promote the env toggle to a router config option.
    3. Load-aware guard: adopt the parent placement only under a load threshold, so wide sibling fan-outs don't over-concentrate a single DP rank.
    4. Tests.

Happy to do the main port if the direction looks right — opening early for feedback on the policy shape.

@copy-pr-bot

copy-pr-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@YAMY1234
YAMY1234 had a problem deploying to external_collaborator July 7, 2026 19:16 — with GitHub Actions Failure
@YAMY1234
YAMY1234 temporarily deployed to external_collaborator July 7, 2026 19:16 — with GitHub Actions Inactive
@github-actions github-actions Bot added feat frontend `python -m dynamo.frontend` and `dynamo-run in=http|text|grpc` router Relates to routing, KV-aware routing, etc. labels Jul 7, 2026
@datadog-official

This comment has been minimized.

@YAMY1234
YAMY1234 force-pushed the yamy/parent-affinity-3169427d branch from ff45a4b to a33e574 Compare July 7, 2026 22:22
@YAMY1234
YAMY1234 temporarily deployed to external_collaborator July 7, 2026 22:22 — with GitHub Actions Inactive
@YAMY1234
YAMY1234 force-pushed the yamy/parent-affinity-3169427d branch from a33e574 to 964d531 Compare July 15, 2026 17:30
@YAMY1234
YAMY1234 temporarily deployed to external_collaborator July 15, 2026 17:30 — with GitHub Actions Inactive
YAMY1234 added 2 commits July 15, 2026 11:59
When DYN_ROUTER_PARENT_AFFINITY=1 and a request carries an agent-context
parent_session_id, an unbound session's first request is placed on the worker
bound to its parent session, so subagents co-locate with the prefix they share.
The session still binds its own id on route (via the existing AffinityAcquire),
so the hint only influences initial placement. The parent lookup is a
non-binding peek (AffinityCoordinator::query_target) reusing the coordinator's
eligibility/expiry checks; if placement on the parent worker fails, the request
falls back to normal KV routing. Default off; wire-compatible.

Reworked onto the header-based session_affinity architecture (the previous
sticky/coordinator implementation this PR originally targeted was removed
upstream). Implements ai-dynamo#11343.

Signed-off-by: Yangmin Li <yangminl@nvidia.com>
The per-system support-matrix CSV files were relocated in the aiconfigurator
repo from src/aiconfigurator/systems/support_matrix to
aic-core/src/aiconfigurator_core/systems/support_matrix, so the old link 404s
and fails the repo-wide lychee link check. Point it at the current path.

Signed-off-by: Yangmin Li <yangminl@nvidia.com>
@YAMY1234
YAMY1234 force-pushed the yamy/parent-affinity-3169427d branch from 964d531 to 4bea22b Compare July 15, 2026 19:00
@YAMY1234
YAMY1234 temporarily deployed to external_collaborator July 15, 2026 19:00 — with GitHub Actions Inactive
@dynamo-ops

Copy link
Copy Markdown
Contributor

Unsigned Commits Detected

The following commits are not GPG-signed and must be signed before CI can run:

Commit Reason
9f0e778 unsigned
4bea22b unsigned

Please sign your commits and push again. See the GitHub docs on commit signature verification for help.

Copy link
Copy Markdown

Hi @YAMY1234, thanks for working on this.

I see that commit 9f0e778 already reworked the implementation onto the header-based session-affinity architecture, but the PR is still a draft, has not received reviews, and CI is currently blocked by the unsigned commits.

I have completed additional end-to-end validation for #11343:

  • on 2 physical RTX 4090 GPUs, all 35/35 tested B2 event/predicted trials at fan-out 2/4 and an exact 16k prefix placed siblings across both GPU workers and computed one full prefix per selected worker;
  • on 8 physical RTX 4090D GPUs, all 80/80 B2 event/predicted trials at fan-out 4/8 and exact 16k/32k prefixes selected 4/8 workers and computed 4/8 full prefix copies;
  • the corresponding B1 affinity controls selected one worker and computed one shared prefix;
  • a strict single-worker C2 matrix observed no duplicate full-prefix prefill in 120/120 trials.

I also opened the benchmark-only contribution request #14045 so this behavior can be tested independently of the runtime implementation.

Are you planning to resume and finish #11347? If so, I would be happy to help with benchmark validation, tests, rebasing, or other follow-up work. If not, would you be comfortable with me coordinating with the maintainers on a current-main successor PR, while preserving attribution to your implementation?

I will wait for your and the maintainers' direction before starting a separate runtime implementation.

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 frontend `python -m dynamo.frontend` and `dynamo-run in=http|text|grpc` router Relates to routing, KV-aware routing, etc. size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants