Skip to content

fix: bound model request retries - #2527

Open
pplattner wants to merge 4 commits into
NVIDIA-NeMo:mainfrom
elisam0:fix/bounded-model-retries-upstream
Open

pplattner wants to merge 4 commits into
NVIDIA-NeMo:mainfrom
elisam0:fix/bounded-model-retries-upstream

Conversation

@pplattner

@pplattner pplattner commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • cap model-request retries at 120 seconds
  • use exponential backoff and honor Retry-After delay-seconds and HTTP-date values

Context

During a five-shard benchmark evaluation against a hosted endpoint, the model endpoint began returning HTTP 429 responses. Each shard ran with concurrency 10, allowing roughly 50 concurrent agent slots for this evaluation while other hosted-model evaluations were also active.

The retry loop started with MAX_NUM_TRIES = 3, but increased max_num_tries for every rate-limit response. Because both the attempt counter and the maximum increased together, a request could never exhaust its retry budget while the endpoint continued returning 429. Every failed request was then retried after a fixed 0.5-second sleep.

The affected evaluation recorded approximately 6.17 million retry attempts over about 22.5 hours. Individual logical requests reached more than 10,000 attempts, with the longest observed chain reaching 10,895. This produced a sustained lower-bound average of roughly 76 retry requests per second, in addition to normal model calls. Although the workload was a legitimate benchmark, this retry amplification made its traffic resemble a DDoS to the hosted endpoint.

This change adds a hard 120-second wall-clock retry budget so rate-limit responses cannot extend retries indefinitely. It also replaces the fixed delay with exponential backoff and honors server-provided Retry-After guidance in both delay-seconds and HTTP-date formats.

Tests

  • ruff format --check nemo_gym/openai_utils.py nemo_gym/server_utils.py tests/unit_tests/test_openai_utils.py
  • ruff check nemo_gym/openai_utils.py nemo_gym/server_utils.py tests/unit_tests/test_openai_utils.py
  • pytest tests/unit_tests/test_openai_utils.py -q — 128 passed

@copy-pr-bot

copy-pr-bot Bot commented Aug 13, 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.

Signed-off-by: Patrick Plattner <pplattner@nvidia.com>
@pplattner
pplattner force-pushed the fix/bounded-model-retries-upstream branch from 8a4b7b5 to 009d2fe Compare August 13, 2026 09:40
@github-actions github-actions Bot added the sla:triage-overdue Review assignment is over the one-business-day SLA label Aug 14, 2026
Bounded backoff (exponential, Retry-After-aware, capped at MAX_SECONDS_TRIES)
now only applies when the request isn't marked _internal.

_internal already reaches this function today (NeMoGymAsyncOpenAI.internal ->
_request()'s kwargs -> here).

Signed-off-by: Riccardo Roveri <rroveri@nvidia.com>
# Conflicts:
#	tests/unit_tests/test_openai_utils.py
# Conflicts:
#	tests/unit_tests/test_openai_utils.py
@ananthsub

Copy link
Copy Markdown
Contributor

This remains the provider-response implementation candidate for #2845. Before landing, it should consume the single logical request budget defined by #3159, preserve the external-vs-internal ownership added by #3079, honor Retry-After within the remaining budget, and treat terminal input errors separately. A transport retry or changing sequence of status codes must not reset accounting.

@svcnvidia-nemo-ci svcnvidia-nemo-ci added area:model Model servers, inference providers, and model adapters bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer labels Oct 20, 2026

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

area:model Model servers, inference providers, and model adapters bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer sla:triage-overdue Review assignment is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants