Skip to content

cp: feat(cli): check model endpoints before starting a run (2362) into r0.5.0 - #2381

Merged
ananthsub merged 1 commit into
r0.5.0from
cherry-pick-2362-r0.5.0
Aug 6, 2026
Merged

ananthsub merged 1 commit into
r0.5.0from
cherry-pick-2362-r0.5.0

Conversation

@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor

beep boop [🤖]: Hi @ananthsub 👋,

we've cherry picked #2362 into  for you! 🚀

Please review and approve this cherry pick by your convenience!

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]>
@copy-pr-bot

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

@svcnvidia-nemo-ci

Copy link
Copy Markdown
Contributor Author

/ok to test 1a29b68

@ananthsub
ananthsub enabled auto-merge (squash) August 6, 2026 15:41
@ananthsub
ananthsub disabled auto-merge August 6, 2026 21:57
@ananthsub
ananthsub merged commit 8a6d5c6 into r0.5.0 Aug 6, 2026
15 of 30 checks passed
@ananthsub
ananthsub deleted the cherry-pick-2362-r0.5.0 branch August 6, 2026 21:57

This branch was previously deployed

1 inactive deployment
public — 1a29b68d Deployed Aug 6, 2026 by copy-pr-bot[bot] via release / finalize / notify #1158
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants