Skip to content

fix(stargate): expire reservations after backend RTT - #2295

Draft
efegokdemir wants to merge 5 commits into
NVIDIA:mainfrom
efegokdemir:efegokdemir/fix/stargate-reservation-ttl
Draft

efegokdemir wants to merge 5 commits into
NVIDIA:mainfrom
efegokdemir:efegokdemir/fix/stargate-reservation-ttl

Conversation

@efegokdemir

@efegokdemir efegokdemir commented Oct 5, 2026 •

Copy link
Copy Markdown

TL;DR

Keep each optimistic routing reservation until one clamped RTT of its selected backend has elapsed instead of clearing it on the next registration update. Adds configurable TTL bounds, reservation metrics, and coverage for expiry, updates, release, and backend removal.

Additional Details

An update can briefly double-count a request if Pylon reports it before its reservation expires. Roll out change-driven Pylon stats before deploying this Stargate version.

Three-arm simulator validation

Completed against the discrete-event simulator at NVIDIA/nvcf#2223 head 9e9a86e. Each arm ran three seeds at 80, 160, 240, and 320 offered RPS, with a 60-second warmup and 180-second measurement per scenario. The model uses the five-region topology, one modeled H100-batched worker per backend, and fixed 6,661-token inputs.

Offered RPS Baseline goodput Coalesced stats, reservations cleared Coalesced stats, TTL enabled
80 47.25 43.58 44.03
160 43.93 40.49 40.07
240 43.74 39.45 39.52
320 42.95 39.28 39.08

Values are mean goodput RPS across the three seeds. Mean TTFT p99 (baseline / coalesced-clear / coalesced-TTL) was 13.45 / 14.14 / 13.98 s at 80 RPS, 14.14 / 14.50 / 14.77 s at 160, 14.17 / 14.71 / 14.72 s at 240, and 14.60 / 14.57 / 14.63 s at 320. Timeout counts were 24/1/0, 29/0/0, 33/0/1, and 75/0/0, respectively.

In this model, TTL versus the coalesced-clear arm has mixed, small goodput/latency differences and no clear throughput improvement. The lower goodput versus baseline appears in both coalesced arms, so it is not attributed to TTL alone. These are simulator results, not GPU benchmark measurements; the TTL change is intended to preserve in-flight reservations across stats updates.

The PR remains a draft while maintainers assess this correctness/throughput trade-off.

For the Reviewer

Please focus on reservation expiry and pruning in the routing snapshot lifecycle.

For QA

  • cargo test -p stargate --lib (399 passed)
  • cargo test -p stargate --bin stargate -- --skip occupied_metrics_port_fails_before_runtime_construction (52 passed)
  • cargo test -p stargate --test stargate_integration (149 passed)
  • cargo clippy -p stargate --lib --tests -- -D warnings
  • cargo clippy --locked -p stargate --all-targets -- -D warnings
  • cargo fmt --all -- --check
  • git diff --check
  • Full cargo test -p stargate has one failure in the unchanged occupied_metrics_port_fails_before_runtime_construction test; it also fails when run alone in this environment.

Issues

Relates to #2284

Checklist

  • I am familiar with the Contributing Guidelines.
  • I have signed off my commits for Developer Certificate of Origin (DCO) compliance.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

Signed-off-by: Efe Gökdemir <gokdemirefe1903@gmail.com>
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@FamousDirector FamousDirector left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the reservation lifecycle (reserve, expiry, release, backend removal, cluster generation replacement), the RTT source (per-backend health-check RTT from latest_ready_rtt_or_probe), config validation, metrics, and docs. Expiry logic and pruning look correct; the CAS in deactivate keeps release and expiry from double-decrementing. Two inline findings below.

Minor, outside the inline comments:

  • reservations.rs:117 still says a successful attempt "remains pending until its heartbeat". It now remains pending until its TTL.
  • runtime-stats-interface.md says "before enabling this Stargate behavior", but there is no enable switch; the behavior is unconditional once this Stargate ships. Consider "before deploying this Stargate version".

Local results at 4cb4ac8: cargo test -p stargate --lib 396 passed, --test stargate_integration 149 passed, --bins 52 passed with 1 failure in the unchanged occupied_metrics_port_fails_before_runtime_construction (matches what the PR description reports).

efegokdemir and others added 4 commits October 9, 2026 21:48
Signed-off-by: Efe Gökdemir <gokdemirefe1903@gmail.com>
The existing retired-generation test ends the registration through
StargateState, which deactivates reservations on the routing removal path,
so it still passes with the Drop impl removed. These tests retire the
generation through the registration table only, so the replacement upsert
or Inactive removal drops the old cluster state with a live reservation.
Both fail without Drop. They also check that an earlier release followed
by the drop does not double-decrement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drive proxied requests through a minimal raw QUIC mock tunnel so the
tests observe the expected queue header exactly as Stargate sends it.

Cover that the reservation TTL follows the dispatched backend RTT
rather than the cluster mean, that unexpired reservations raise the
expected queue estimate while expired ones do not, and that only a
queue-mismatch 429 releases a reservation early.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Add a 600 s UNEXPIRING_TEST_RESERVATION_TTL and use it in the cfg(test)
  reserve_backend helper and the reservation tests that previously used a
  1 s TTL, so they no longer depend on finishing within 1 s of wall time.
- Reserve with the long TTL in the expiry boundary test. The registration
  update (which prunes with the real clock) can no longer flake on a slow
  runner; boundary checks stay relative to expires_at via
  routing_snapshot_at, and the test also checks the active gauge.
- Rename consumed_by_heartbeat to released_after_update, since updates no
  longer consume reservations.
- Assert stargate_routing_reservations_active goes from 10000 to 0 in the
  idle expired prune test.
- Describe lazy expiry and backend removal for the
  stargate_routing_reservations_active gauge in the metrics doc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@efegokdemir

Copy link
Copy Markdown
Author

I have left this in draft because the contribution guide requires a DCO sign-off on every commit. The three commits added on 9 October (cecaf8c, a7a5dbe, 4e5bf58) are authored by jcameron and co-authored by Claude, but do not contain Signed-off-by lines. I cannot sign off those commits on their authors’ behalf. Could you add the required sign-offs or advise the acceptable next step?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants