Skip to content

feat(global-router): least-in-flight places pools by affinity's rule - #17990

Open
nnshah1 wants to merge 1 commit into
nnshah1/gr-core-a2-lif-corefrom
nnshah1/gr-core-a3-lif-locality
Open

nnshah1 wants to merge 1 commit into
nnshah1/gr-core-a2-lif-corefrom
nnshah1/gr-core-a3-lif-locality

Conversation

@nnshah1

@nnshah1 nnshah1 commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Overview

This PR intentionally changes the current least-in-flight selector. Today least-in-flight ignores regions and each pool's capacity, so a request can leave its region for a pool that has just one fewer request in flight. Least-in-flight now places pools by affinity's rule on both paths (the current selector and the router core plugin):

  • nearest region first;
  • then lower load, where load is requests in flight over the pool's capacity (from its Relay);
  • leave the nearest pool only for one with more than --headroom-factor times its spare room.

Builds on #17989; the diff shows only this PR.

Key Changes

  • placement.rs: the placement rule (order, leading_ties, headroom, distance) is now in one place. AffinitySelector, LeastInFlightSelector and the core's LeastInFlightPicker all use it. Affinity's behavior does not change.
  • LeastInFlightSelector::new(in_flight, signals, region, headroom_factor): uses the rule above. A pool with no capacity report counts as full, so without --pool-relay requests stay on the nearest pools, fewest in flight first.
  • PoolSignals::capacity: requests the pool's workers can run at once, from the freshest Relay report.
  • Core: SelectionCorePolicy::LeastInFlight(LeastInFlightConfig { signals, region, headroom_factor }). The directory now also records each pool's region.
  • CLI: --router-policy least-in-flight now needs --region, and it follows the Relays (--pool-relay) as affinity does.

Validation

  • cargo test --release -p dynamo-global-router -p dynamo-global-frontend -p dynamo-global-common: all pass (common 10, router 29, frontend lib 12 + main 4 + forwarding 14).
  • The existing affinity tests pass unchanged against the shared rule.
  • New tests:
    • The current selector stays in its region until another region has twice the room, and counts an unknown capacity as full.
    • The core picks the same pool as the current selector on the same counts, capacities and round trips.
    • Argument parsing requires --region for least-in-flight.
  • cargo fmt --check and cargo clippy --release --all-targets -- -D warnings are clean.

Issues and Ongoing Work

Pull Request Checklist
  • I used Dynamo's /pr-checklist skill.

🤖 Generated with Claude Code

@nnshah1
nnshah1 requested a review from a team as a code owner November 3, 2026 22:20
@github-actions github-actions Bot added feat documentation Improvements or additions to documentation labels Nov 3, 2026
@nnshah1
nnshah1 force-pushed the nnshah1/gr-core-a2-lif-core branch from a97c545 to bdf7f37 Compare November 3, 2026 23:49
@nnshah1
nnshah1 force-pushed the nnshah1/gr-core-a3-lif-locality branch from 6b43bb1 to 25a5025 Compare November 3, 2026 23:49
@copy-pr-bot

copy-pr-bot Bot commented Nov 3, 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.

@devin-ai-integration

devin-ai-integration Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ Dynamo PR CI passed — run 41869914796 (attempt 1) on e3374fbd79

Gate checks: ✅ backend-status-check · ✅ deploy-status-check · ✅ dynamo-status-check

Posted automatically by Devin for run 41869914796. Updated on every full-CI run of this PR.

@nnshah1
nnshah1 force-pushed the nnshah1/gr-core-a3-lif-locality branch from 25a5025 to e81d6f4 Compare November 4, 2026 01:29
@nnshah1
nnshah1 force-pushed the nnshah1/gr-core-a2-lif-core branch from bdf7f37 to 33e7083 Compare November 4, 2026 01:29
Least-in-flight ignored regions and each pool's capacity, so a request
could leave its region for a pool with one fewer request in flight. It now
uses affinity's placement rule on both paths: nearest region first, then
the lower load (requests in flight over the pool's capacity, from its
Relay), and it leaves the nearest pool only for one with more than
--headroom-factor times its spare room. The rule moves to placement.rs,
shared by affinity and both least-in-flight implementations, and
--router-policy least-in-flight now needs --region.

This intentionally changes the current least-in-flight selector.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: nnshah1 <neelays@nvidia.com>
@nnshah1
nnshah1 force-pushed the nnshah1/gr-core-a3-lif-locality branch from e81d6f4 to e3374fb Compare November 4, 2026 16:41
@nnshah1
nnshah1 force-pushed the nnshah1/gr-core-a2-lif-core branch from 33e7083 to d645229 Compare November 4, 2026 16:41

This branch has not been deployed

No deployments
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 size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant