Repository navigation
feat(model): route sessions around failing engine endpoints - #3979
Conversation
The vLLM model server pins a session to one engine endpoint by a hash of its session id, for the whole run. When that engine dies (its HTTP server can keep answering with a 500 for every call) every session pinned to it fails every call until the run ends, and new sessions keep hashing onto it. With route_around_failing_endpoints on, the server tracks each endpoint's consecutive 5xx and connection-error answers. An endpoint that reaches endpoint_failure_threshold stops receiving sessions: the sessions pinned to it re-pin to a serving endpoint on their next call (the same digest picks among the serving endpoints, so the assignment stays a function of the session id and of which endpoints have failed), and new sessions spread over the serving endpoints only. Once per endpoint_retry_after_s one call is tried on the failed endpoint; a good answer puts it back in the pool and a moved session returns to its own endpoint. A 4xx counts as a live engine and resets the count. All three settings default to today's behavior (off, 3, 60 s) and are listed in the example config. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: alexandery <[email protected]>
Signed-off-by: Lin Jia <[email protected]> # Conflicts: # responses_api_models/vllm_model/app.py
linj-glitch
left a comment
There was a problem hiding this comment.
Reviewed deterministic session routing, failure thresholds, cooldown/recovery, default behavior, and capture integration against current main and the existing model-server contract. No blocking findings remain.
Validation: 221 focused tests passed; full pre-commit suite and git diff --check passed. Model plugin imports were pinned to this review checkout in the shared dependency environment. Additive main merges preserve the author commits and retain the current-main credential-redaction regression tests. No fresh GPU/model rollout was run locally; the author-provided downstream deployment evidence is retained above.
|
/ok to test dd8a2e1 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/37281186164 |
…DIA-NeMo#4365) ## What does this PR do? `VLLMModel._post_init` builds one `NeMoGymAsyncOpenAI` client per `base_url` and passes `endpoint_connection_retries` as the client's `max_connection_retries` only when `endpoint_file` is configured. On `main` the condition reads `self.config.endpoint_connection_retries if self.config.endpoint_file else None` (`responses_api_models/vllm_model/app.py:466-468` on `main`). A deployment that enables `route_around_failing_endpoints` over a static `base_url` list has no endpoint file, so its clients are built with `max_connection_retries=None`. `None` means retry forever. `NeMoGymAsyncOpenAI` forwards the value as `_max_connection_retries` on every request (`nemo_gym/openai_utils.py:1378-1384` and `nemo_gym/openai_utils.py:1468`), and in `_request_with_retries` the `except ClientOSError` branch, which a refused connection reaches as `aiohttp.ClientConnectorError`, re-raises only when `_max_connection_retries` is set (`nemo_gym/server_utils.py:638-654`). Otherwise it sleeps 0.5 s and loops. The endpoint health accounting that NVIDIA-NeMo#3979 added depends on the call raising. `_call_endpoint` awaits the engine call and counts a `ClientConnectionError` against the endpoint only in its `except` branch (`responses_api_models/vllm_model/app.py:1835-1853`), and `_note_endpoint_failure` moves sessions off the endpoint once `endpoint_failure_threshold` consecutive calls have failed (`responses_api_models/vllm_model/app.py:1855-1873`). With an unbounded client the call never returns from the retry loop, the endpoint never records a failure, and every session pinned to a dead endpoint hangs on it for the rest of the run. The feature cannot react to the failure mode it was built for. The change: - `responses_api_models/vllm_model/app.py:469-473`: the clients receive `endpoint_connection_retries` when `endpoint_file` or `route_around_failing_endpoints` is set. A static list without either setting still gets `None`, and the endpoint-file rebind path already passed the bound unconditionally (`responses_api_models/vllm_model/app.py:1756`). - `responses_api_models/vllm_model/app.py:338-342`: the comment on `endpoint_connection_retries` states the condition and why an unbounded client defeats the route-around. - `responses_api_models/vllm_model/tests/test_app.py:6116-6135`: a new test builds the model over a two-URL static list with `route_around_failing_endpoints=True`, no endpoint file and `endpoint_connection_retries=3`, and checks that both clients carry `max_connection_retries == 3`. The same list without either setting yields `None` for both clients. The existing assertion at `responses_api_models/vllm_model/tests/test_app.py:6114` already pinned the single-URL default; only its comment changed, because "static clients retry forever" now holds only without route-around. ## Issue - NVIDIA-NeMo#3979 added `route_around_failing_endpoints`. This PR fixes its static-URL configuration. - NVIDIA-NeMo#2216 reports that the `ServerDisconnectedError` and `ClientOSError` branches of `_request_with_retries` never compare their counter against `MAX_NUM_TRIES`, so a permanently unreachable server loops forever. That unbounded loop is what hides a dead endpoint here. This PR does not change the loop; it makes `vllm_model` pass the per-client bound that the loop does honor. - NVIDIA-NeMo#3914 makes an explicit `_max_connection_retries` cap stop internal callers in the generic `except Exception` branch of the same loop. The `vllm_model` clients are external callers (`internal=False`), so this PR does not depend on it; both concern the same cap. - Draft NVIDIA-NeMo#4262 changes `_resolve_client` in the same file. This PR does not touch those lines, so the two compose. ## Validation - `pytest -q -p no:cacheprovider -o addopts= responses_api_models/vllm_model/tests/test_app.py` with the repository root on `PYTHONPATH` (Python 3.13.14, pytest 9.1.1, aiohttp 3.14.3): 254 passed, 0 failed. The same command on `main` at f128d43 gives 253 passed; the difference is the new test. - The new test fails against the `main` version of `responses_api_models/vllm_model/app.py` with `[None, None] == [3, 3]`. - `pytest -q -p no:cacheprovider -o addopts= responses_api_models/vllm_model/tests/` (the whole directory, three test files): 406 passed, 0 failed. - Unit suite (`pytest tests/unit_tests`, with `test_collect_downstream_junit.py` excluded for a missing local package): 7752 passed, 56 skipped, 17 failed, 5 errors; the 22 failures are the same 22 as on `main` in this environment (telemetry, opensandbox, and local-vLLM tests that need packages this machine lacks). Each other `responses_api_models/<server>/tests` directory, run as its own session, matches `main`. - `ruff check` and `ruff format --check` on both changed files: clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: alexandery <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]>
What does this PR do?
The vLLM model server pins a session to one engine endpoint by a hash of its session id, for the whole run (
_resolve_client). When that engine dies, its HTTP server can keep answering every call with a 500, so every session pinned to it fails every call until the run ends, and new sessions keep hashing onto it. In a training wave this means every rollout pinned to a dead engine spends its whole time budget on retries and scores nothing.Three new settings, all defaulting to today's behavior:
route_around_failing_endpoints(defaultfalse). On, the server tracks each endpoint's consecutive 5xx and connection-error answers in_call_endpoint, the one place every engine call now goes through. A 4xx shows the engine alive and resets the count.endpoint_failure_threshold(default 3). An endpoint that reaches it stops receiving sessions. The sessions pinned to it re-pin to a serving endpoint on their next call; the same digest picks among the serving endpoints, so the assignment stays a function of the session id and of which endpoints have failed, and new sessions spread over the serving endpoints only.endpoint_retry_after_s(default 60). Once per interval one call is tried on the failed endpoint; claiming the trial restarts the interval so concurrent callers do not all land on it. A good answer puts the endpoint back in the pool, and a moved session returns to its own endpoint once it serves again.The three keys are listed in
configs/vllm_model.yamlwith the other endpoint settings.Issue
No issue filed; observed in multi-engine training runs where one engine process died mid-run while its HTTP front stayed up.
Validation
responses_api_models/vllm_model/tests/test_app.py: 184 passed, including seven new tests: a failing endpoint loses its sessions and takes no new ones, the gate off keeps today's pinning, a good answer resets the count, one trial call per retry interval (with a mocked clock), a moved session returns to its endpoint when it serves again, engine 5xx answers move a session through the realchat_completionspath, and an engine 4xx does not count against its endpoint.tests/unit_tests(thetelemetrypackage and theopensandbox/sandbox_stop_retry/profilingtests excluded, which need optional dependencies not installed here): 6228 passed, 27 skipped; the one failure is thetest_slurm_scriptcase that needs a systempip.pre-commit run --files <changed files>: clean.🤖 Generated with Claude Code
Maintainer validation
Reviewed deterministic session routing, failure thresholds, cooldown/recovery, default behavior, and capture integration against current main and the existing model-server contract. No blocking findings remain.
Validation: 221 focused tests passed; full pre-commit suite and git diff --check passed. Model plugin imports were pinned to this review checkout in the shared dependency environment. Additive main merges preserve the author commits and retain the current-main credential-redaction regression tests. No fresh GPU/model rollout was run locally; the author-provided downstream deployment evidence is retained above.