[rollout] feat: re-evaluate sticky sessions against replica load - #7435
Open
ralovets wants to merge 1 commit into
Open
[rollout] feat: re-evaluate sticky sessions against replica load#7435ralovets wants to merge 1 commit into
ralovets wants to merge 1 commit into
Conversation
acquire_server returns on a sticky-session cache hit before consulting load, so in a multi-turn rollout every turn after the first stays on the replica picked for turn 1. A replica that draws several long conversations keeps receiving all of their later turns while its peers drain. Adds rollout.affinity_break_margin: the session moves to the least-loaded replica once its current one holds that many extra in-flight requests. Defaults to null (never move), so behavior is unchanged for existing callers; full_determinism keeps hash routing. Also reports affinity_kept / affinity_broken in get_status. python -m pytest tests/workers/rollout/test_sticky_affinity_on_cpu.py -q -> 20 passed
ralovets
marked this pull request as ready for review
August 15, 2026 18:17
ralovets
requested review from
PeterSH6,
eric-haibin-lin,
tongyx361 and
vermouth1992
as code owners
August 15, 2026 18:17
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.
What does this PR do?
GlobalRequestLoadBalancerpins all turns of a conversation to one replica for prefix-cache reuse, but never re-evaluates that choice. Long conversations can therefore remain concentrated on a few replicas while others go idle.This PR adds an opt-in
affinity_break_margin. On a sticky hit, the request stays pinned while its replica is withinmarginin-flight requests of the least-loaded replica; otherwise, the conversation is re-pinned to the least-loaded replica. The default isnull, so existing behavior is unchanged. The option is ignored underfull_determinismto preserve deterministic routing.PR #6533 addresses the same problem with a global dual-threshold imbalance gate. This PR instead evaluates each sticky session against a per-session tolerance band, allowing sessions already near the minimum to remain pinned. In #6533, aggressive thresholds caused frequent migrations and regressed its long-context workload, while conservative settings were near baseline. Here,
margin=2improved all paired workloads below. The workloads are not directly comparable, but together the results suggest that migration selectivity is important.Checklist Before Starting
[rollout] feat: ...format.Test
CPU unit tests:
The 20 tests cover unchanged default behavior, margin boundaries, re-pinning, counters, invalid values, removed replicas, and
full_determinism.End-to-end paired A/B tests used Qwen2.5-32B on DAPO-Math-17k, 8 H200 nodes per arm, 16 vLLM replicas, a frozen policy, and
affinity_break_margin=2. The result is the paired median change intiming_s/generate_async.All four results have
p <= 0.004. With the large KV pool, prefix reuse remained high (99.7% to 97.6%) while generation improved by 5.4%. Replica starvation and queue skew also decreased. These tests do not cover real tool-calling latency, instruct-tuned models, or contexts beyond approximately 20K tokens.API and Usage Example
get_status()exposesaffinity_keptandaffinity_brokencounters.Design & Code Changes
GlobalRequestLoadBalancer.RolloutConfig.affinity_break_marginand generated trainer configuration entries.Checklist Before Submitting
ci-requestchannel.