Repository navigation
cp: feat(cli): check model endpoints before starting a run (2362) into r0.5.0 - #2381
Merged
Merged
Conversation
Partially addresses #2216, and fixes the quickstart report behind it: `gym env start` prints "All 3 / 3 servers ready" against a `policy_base_url` that nothing is serving, and `gym eval run` then sits at `Collecting rollouts: 0%`. Gym reports ready because `wait_for_spinup` in the env CLI polls only Gym's own servers. The Gym-side model server is a proxy that answers as soon as it starts, whether or not an inference server is behind it, so the endpoint the run depends on is never checked. The existing troubleshooting note for this path blames a bad API key, which fails differently. This collects the model endpoints from the resolved config, waits for each to answer, and stops startup if one never does. Reading the endpoints has to handle every shape the model servers declare: - `base_url` is `Union[str, List[str]]` on vllm_model and both local vLLM servers, where the list spreads load across replicas, so a string-only reader would do nothing at all for a multi-replica training run. - The local servers default to an empty list and are filled in after Gym launches vLLM, so an empty list means "not yet" and is skipped, as is an unset value. - The config key travels with each URL, because the endpoint that fails may be a judge or user model and a message naming `policy_base_url` would then be wrong. Each probe result is sorted by whether waiting could change it. A hostname that does not resolve will not begin resolving because we waited, so it is reported once and not retried; this is what happens to a config left at a placeholder default, which costs one lookup instead of the whole timeout. A refused connection may be a server still coming up, so it is waited on. Any HTTP answer counts as listening, including 401 and 404, and so does a completed TLS handshake against a certificate this machine does not trust. `requests.exceptions.SSLError` subclasses `ConnectionError`, so deciding on the parent class would reject an HTTPS endpoint with an internal certificate authority even though its handshake proved something was there. On failure, the spawned servers are shut down before anything is raised. They hold ports and have neither a process group nor an atexit handler, and every caller reaches its own `shutdown()` only after `start()` returns. The failure is a `ConfigError` that the CLI entrypoints translate into an exit. `RunHelper` is imported and driven directly by NeMo-RL, so the caller decides what an unreachable endpoint means. Probing uses the synchronous `requests` library, matching `poll_for_status` in server utils, because this runs in the CLI process before any event loop exists. ## The change in flow Before: ```mermaid flowchart TD S["gym env start"] --> P["start mcqa, agent, policy_model"] P --> W["wait_for_spinup()"] W --> Q{"do Gym's own servers answer on /?"} Q -->|yes| OK["All 3 / 3 servers ready"] OK --> U["gym eval run"] U --> M["policy_model calls its configured endpoint"] M --> X["nothing listening<br>Collecting rollouts: 0% indefinitely"] ``` After: ```mermaid flowchart TD S["gym env start"] --> P["start mcqa, agent, policy_model"] P --> W["wait_for_spinup()"] W --> N["collect model endpoints from the resolved config<br>string and list base_url, skipping unset and empty"] N --> PR{"probe each endpoint"} PR -->|"any HTTP answer, or a completed TLS handshake"| OK["All 3 / 3 servers ready"] PR -->|"name does not resolve"| REP["report once, do not wait<br>waiting cannot create a DNS record"] REP --> OK PR -->|"connection refused"| WAIT["wait, a server may still be starting"] WAIT -->|answers in time| OK WAIT -->|"still refusing at the timeout"| SD["shut down the spawned servers"] SD --> CE["raise ConfigError naming each URL<br>and the config key it came from"] ``` Signed-off-by: Ananth Subramaniam <[email protected]> Signed-off-by: NeMo Bot <[email protected]>
Contributor
Author
|
/ok to test 1a29b68 |
ananthsub
approved these changes
Aug 6, 2026
ananthsub
enabled auto-merge (squash)
August 6, 2026 15:41
ananthsub
disabled auto-merge
August 6, 2026 21:57
This branch was previously deployed
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.
beep boop [🤖]: Hi @ananthsub 👋,