Repository navigation
Conversation
Harness CLIs never send the session cookie back, so each call got a fresh session and a random endpoint with a cold prefix cache. Route by the /ng-rollout/<id> rollout id when present and keep session routing otherwise. Signed-off-by: Christian Munley <[email protected]>
Contributor
khazic
pushed a commit
to khazic/Gym-lao
that referenced
this pull request
Oct 13, 2026
…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]>
Contributor
Author
|
Closing: main already keeps every call of a rollout on one endpoint. vllm_model routes on the rollout id (current_rollout_id() or the session), and main's tests cover it (test_calls_of_one_rollout_share_an_endpoint_whatever_their_session, test_rollouts_spread_across_endpoints). |
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.
Problem
vllm_model._resolve_clientpicks the endpoint by hashing the session id, which comes from a cookie. Harness CLIs (Claude Code, OpenCode and otherharness_agent/opencode_sandboxed_agentharnesses) never send the cookie back. Each call gets a freshuuid4session, lands on a random endpoint, and re-prefills its full context with a cold prefix cache. Only matters with more than one endpoint behindvllm_model.Fix
These calls already carry
/ng-rollout/<rollout_id>/in their URL, and_CaptureMiddlewarestrips it before routing._CaptureMiddlewarekeeps the rollout id in the ASGI scope asng_rollout_id.vllm_model._resolve_clientroutes byrollout:<id>when present, else by the session as before.route_around_failing_endpointsfailover is unchanged and sees a stable key._session_id_to_clientnow grows per rollout instead of per call for cookie-less clients.Measured
48 endpoints, Claude Code subagent RL (Lightning 30B-A3B, TP4, 256k context), same config before and after:
After the change, the busiest of 48 servers peaked at 49 of 64 running sequences, so none hit
max_num_seqs. Main agent and subagents of a rollout share an endpoint. Heavy swarms put more sequences on one endpoint, so watchmax_num_seqs.Tests
vllm_model/tests/test_app.pyandtests/unit_tests/test_base_responses_api_model.py: 300 passed.Not covered
Calls without a rollout prefix (for example evals with no rollout id) still scatter.