Repository navigation
fix(rollout): two dispatch-budget correctness bugs - #3853
Conversation
_validate_dispatch_concurrency incorrectly rejected dispatch_budget_s + max_resident_rollout_tasks without num_samples_in_parallel. The guard exists because unbounded dispatch POSTs the whole queue before the drain check can fire, but _BoundedCompletionIterator (used when max_resident_rollout_tasks is set) admits tasks one at a time, so the drain check fires synchronously before each POST. Allow either limit as sufficient. tracker.record() was called only in the success branch of _post_subroutine, so timed-out or failed tasks did not feed into the adaptive p75 drain margin. Under high failure rates the margin could be underestimated, causing tasks admitted near the deadline to be killed by the allocation boundary instead of finishing. Move the call to a finally block so all started tasks contribute their duration. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> Signed-off-by: Marta Stepniewska-Dziubinska <[email protected]>
Kh4L
left a comment
There was a problem hiding this comment.
Fix 1 is right: max_resident_rollout_tasks bounds in-flight requests and the drain check runs as each task starts, so it is a valid concurrency bound. Fix 2 also helps for late failures. One gap: instant failures are recorded too and can pull the adaptive p75 margin toward zero (5 x 600 s successes then 20 x 0.2 s failures: 600 s -> 0.2 s). I put that follow-up in #3891, stacked on this branch, so this can merge as is.
|
/ok to test d7d5985 |
… margin (#3891) ## Summary Follow-up to #3853, stacked on its branch (GitHub retargets it to `main` when #3853 merges). #3853 records every started task in the adaptive drain margin, including failed and timed-out ones. That helps when tasks fail late, but instant failures (a flaky endpoint answering 502 at once) are recorded too and drag the p75 margin toward zero: five 10-minute successes give a 600 s margin, and twenty 0.2 s failures take it to 0.2 s, so tasks are admitted right up to the deadline. - `DispatchLatencyTracker.record_failure`: a failed attempt counts only when it ran at least as long as the current median, so a failure can raise the margin but never lower it. Failures before any completed rollout are ignored. - `_post_subroutine` records successes with `record` and every other outcome with `record_failure`. - The run summary no longer says "completed rollouts" or "task-time delivered", since it now includes late failures. ## Test plan - `TestRecordFailure`: a long failure raises the margin, a burst of instant failures leaves it unchanged, failures before any completion are ignored. - `test_a_failed_run_feeds_the_margin_only_when_it_ran_long`: through `_run_examples_with_metadata` with a failing `/run`, parametrized on a long and a short median. - Reverting `record_failure` to record everything fails 3 of these 5 tests. - `tests/unit_tests/test_rollout_collection.py` and `test_dispatch_latency.py`: 350 passed. Signed-off-by: Serge Panev <[email protected]>
|
/ok to test 5bf7e8d |
yaoyu-33
left a comment
There was a problem hiding this comment.
LGTM. 350 targeted tests passed locally; CI is green. One non-blocking wording nit below.
| p75 toward zero, so it is ignored, as is any failure before a real completion exists. | ||
| """ | ||
| median = self.quantile(0.5) | ||
| if median is not None and seconds >= median: |
There was a problem hiding this comment.
Non-blocking nit: filtering at the median can still lower p75 (e.g. [10, 20, 30, 400, 500] plus a 30s failure lowers it from 400s to 307.5s). This seems acceptable for a heuristic; consider softening the nearby claim that failures only raise the margin. No algorithm change needed for approval.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/37387492308 |
…margin (NVIDIA-NeMo#4134) ## What does this PR do? Updates the **Dispatch budget** bullet under `gym eval run --resume` in `reference/cli-commands.mdx` to match the behaviour merged in NVIDIA-NeMo#3853: - `+dispatch_budget_s` now works with `--concurrency` **or** `+max_resident_rollout_tasks` (`_validate_dispatch_concurrency` in `nemo_gym/rollout_collection.py`). The page still said it requires `--concurrency`, so a run that sets only the task window looked unsupported. - When `+drain_margin_s` is unset, the adaptive p75 margin now also records failed or timed-out attempts that ran at least as long as the median so far (`DispatchLatencyTracker.record_failure`). The page said the margin uses the p75 of finished rollouts. The closing latency summary is computed over the same recorded attempts, so that sentence is adjusted too. No issue: this is a docs follow-up to NVIDIA-NeMo#3853, which changed the behaviour but not this page. Not changed here: GDPVal's multistage mode (`++multistage.enabled=true`) keeps its own `num_samples_in_parallel` check (`resources_servers/gdpval/multistage_orchestrator.py:2440-2444`). That is correct there, because that driver does not use the task window. ## Validation - Checked each sentence against `upstream/main` (197b192): `_validate_dispatch_concurrency` (`rollout_collection.py:1578-1588`), `DispatchLatencyTracker.record_failure`, `drain_margin` and `summary` (`:1206-1263`), and the `finally` block in `_post_subroutine` that records every started attempt (`:3705-3712`). - `pytest tests/unit_tests/test_fern_docs_links.py`: 18 passed. - `pre-commit run --all-files`: all hooks pass (none of them check `.mdx`); `git diff --check` is clean. - `fern check` was not run locally (Fern CLI not installed); relying on CI and the docs preview. ## Rollouts N/A: docs-only change. No environment, agent or model behaviour changes. ## Compatibility and benchmark impact None. ## Checklist - [x] I have read the [contributing guidelines](https://github.com/NVIDIA-NeMo/Gym/blob/main/CONTRIBUTING.md). - [x] The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs. - [x] Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable). - [x] Documentation added or updated, or N/A with justification. - [x] Pre-commit checks pass locally (`pre-commit run --all-files`) (so CI lint/format checks pass). - [x] New source files include the required Apache-2.0 SPDX header. (N/A: no new files) - [x] All commits have DCO sign-off (`git commit -s`) (so the DCO check passes). cc @marta-sd (NVIDIA-NeMo#3853) @Kh4L (NVIDIA-NeMo#3684) Signed-off-by: Tsvetan (Sven) Rankov <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
…DIA-NeMo#4324) ## What does this PR do? Corrects a sentence I added in NVIDIA-NeMo#4134 to the **Dispatch budget** bullet (`gym eval run --resume`) in `reference/cli-commands.mdx`. It said: > Completed rollouts are always recorded; a failed or timed-out attempt is recorded only if it ran at least as long as the median so far, so long timeouts raise the margin and early failures do not shrink it. Two parts of that don't match `main`: - **Which attempts count as failed.** `_post_subroutine` calls `record()` whenever the agent's `/run` returns a usable reply (status below 400 and a JSON body), and `record_failure()` only when the call itself fails (`nemo_gym/rollout_collection.py:3670-3713`, `succeeded` is set at :3677). A rollout that the agent reports as failed or timed out inside a normal reply, such as `nooa_agent`'s `timeout_exceeded` (`responses_api_agents/nooa_agent/app.py:262-268`), is therefore always recorded, however short it was. - **Which way the margin moves.** A recorded attempt can lower the p75 as well as raise it. Using @yaoyu-33's example from NVIDIA-NeMo#3853: with recorded durations [10, 20, 30, 400, 500] s the margin is 400 s; a failed `/run` after 30 s (at the median) brings it to 307.5 s, and so does an agent-reported timeout after 5 s. The new sentence states the rule without claiming a direction: > An attempt whose agent `/run` returns a usable reply is always recorded, even when the agent reports the rollout itself as failed or timed out; an attempt whose `/run` fails (an error status, or no usable reply) is recorded only if it ran at least as long as the median so far, because a quick failure says nothing about how long rollouts take. No issue: this is a docs follow-up to NVIDIA-NeMo#4134. The frozen `fern/versions/v0.7.0` snapshot doesn't contain the sentence (and `r0.7.0` has no `record_failure`), so only `latest` changes. Not changed here: the comment above the `finally` block (`rollout_collection.py:3707-3708`, "but only by raising it") makes the same directional claim. I left it alone to keep this PR docs-only; happy to send a one-line follow-up if you'd like it changed too. ## Validation - Checked against `upstream/main` (7204f6b): `DispatchLatencyTracker.record`, `record_failure` and `drain_margin` (`rollout_collection.py:1203-1244`), `_post_subroutine` (`:3641-3713`), and `raise_for_status` (`server_utils.py:685-686`, `response.ok`). - Ran the real `DispatchLatencyTracker` with the durations above: baseline margin 400.0; `record_failure(5)` leaves 400.0 (ignored); `record_failure(30)` gives 307.5; `record(5)` gives 307.5; `record_failure` before any recorded attempt records nothing. - `python tests/unit_tests/test_fern_docs_links.py`: 18 passed. - `pre-commit run --all-files`: all hooks pass (none of them check `.mdx`); `git diff --check` is clean. - `cd fern && npx -y fern-api@latest check` (the `npm run check` command, fern-api 5.151.0): 0 errors; the only warning is the redirects check being skipped because I'm not logged in to Fern. ## Rollouts N/A: docs-only change. No environment, agent or model behaviour changes. ## Compatibility and benchmark impact None. ## Checklist - [x] I have read the [contributing guidelines](https://github.com/NVIDIA-NeMo/Gym/blob/main/CONTRIBUTING.md). - [x] The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs. - [x] Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable). - [x] Documentation added or updated, or N/A with justification. - [x] Pre-commit checks pass locally (`pre-commit run --all-files`) (so CI lint/format checks pass). - [x] New source files include the required Apache-2.0 SPDX header. (N/A: no new files) - [x] All commits have DCO sign-off (`git commit -s`) (so the DCO check passes). Proposed labels (I cannot apply labels): docs, area:evaluation, needs-review cc @Kh4L (NVIDIA-NeMo#3891) @yaoyu-33 (NVIDIA-NeMo#3853) Signed-off-by: Tsvetan (Sven) Rankov <[email protected]>
Summary
_validate_dispatch_concurrencyrejecteddispatch_budget_s + max_resident_rollout_taskswithoutnum_samples_in_parallel. The guard exists because unbounded dispatch can POST the whole queue before the drain check fires, but_BoundedCompletionIterator(used whenmax_resident_rollout_tasksis set) admits tasks one at a time so the drain check fires synchronously before each POST. Either limit is now accepted as sufficient.tracker.record()was called only in the success branch of_post_subroutine, so timed-out or failed tasks did not feed into the adaptive p75 drain margin. Under high failure rates the margin could be underestimated, causing tasks admitted near the deadline to be killed by the allocation boundary. Moved to afinallyblock so all started tasks contribute their duration.Context
Found during review of #3684 (merged today). Neither bug affects any benchmark that does not set
dispatch_budget_s; for GDPVal, bug 1 blocks a valid configuration and bug 2 risks wasted compute at the tail of a budget window.Test plan
test_dispatch_budget_requires_finite_concurrencyto match new error messagetest_dispatch_budget_accepts_max_resident_rollout_tasks_without_num_samples_in_paralleltest_rollout_collection.pytests passValidation
N/A for rollout evidence — no environment or agent behaviour changed.
🤖 Generated with Claude Code