Skip to content

fix(rollouts): write the run manifest at most once per second during dispatch - #6214

Merged
yashaswikarnati merged 5 commits into
mainfrom
wprazuch/throttle-run-manifest
Nov 19, 2026
Merged

yashaswikarnati merged 5 commits into
mainfrom
wprazuch/throttle-run-manifest

Conversation

@wprazuch

@wprazuch wprazuch commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Collection rewrote the run manifest about once per finished rollout. Every admitted request reserved its attempt with an atomic rewrite of the manifest and of the unchanged configuration identity file: a temp file, fsync, rename and directory fsync, twice. On a shared parallel file system that is a steady stream of metadata operations for the whole run.

  • Reservations admitted within dispatch_reservation_interval_s (new collection setting, default 1 s) now share one manifest write. Each request still starts only after its own reservation is durable, so resume and the allocation-ended accounting are unchanged. After a quiet interval, the write is immediate. The dispatch budget and drain margin are checked again when a delayed batch is due: a row the budget ran out on while it waited is drained, neither reserved nor sent.
  • A reservation no longer rewrites the configuration identity. Opening the store already saved it, and a reservation does not change it.
  • The rollout timer starts after the reservation, so the wait is not reported as rollout latency.

Target rate: at most one manifest write per second per run, about 10 metadata operations per second, far below the per-job rates cluster admins act on.

Cost: an admitted request may wait up to the interval (0.5 s on average at 1 s) inside its concurrency slot before it is sent. In a time-scaled simulation from review, that is about 0% for 10-120 s rollouts, about 8% for 1-10 s rollouts, and up to about 1.6x for 0.5 s rollouts. Runs of very short rollouts can set dispatch_reservation_interval_s: 0, which writes once per event-loop turn as before.

Validation

  • New tests/unit_tests/rollouts/test_dispatch_reservations.py: first write is immediate, requests within the interval share one write and none starts before it, a quiet interval is not delayed, cancelled waiters are skipped, a write failure reaches every waiter.
  • New store test: a reservation leaves the configuration identity file untouched.
  • pytest tests/unit_tests/rollouts tests/unit_tests/eval tests/unit_tests/telemetry tests/unit_tests/artifacts -n 8: 4213 passed. The remaining failures fail identically on main on this macOS machine (spawn-timeout tests, macOS-only telemetry tests, optional extras not installed).
  • Tests that dispatch rows one by one set dispatch_reservation_interval_s: 0 in their config; every other test runs at the default. New tests: a row's latency excludes its reservation wait, and each request sees its reservation saved when the write is delayed.
  • pre-commit run --files <changed files> passes.

Rollouts

N/A: collection bookkeeping only; rollout requests and results are unchanged.

Compatibility and benchmark impact

None for results. Manifest format is unchanged. dispatch_reservation_interval_s does not change the configuration digest, so earlier runs resume. RunManifest.write gains a keyword-only write_config_identity argument (default True).

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally.
  • Documentation added or updated, or N/A with justification: N/A, internal timing only.
  • Pre-commit checks pass locally (on the changed files).
  • New source files include the required Apache-2.0 SPDX header.
  • All commits have DCO sign-off (git commit -s).

…patch

Every admitted request reserved its attempt with an atomic rewrite of the
run manifest and of the unchanged configuration identity, so a run
rewrote both files about once per finished rollout. Reservations admitted
within 5 s now share one write, each request still waits for its own
reservation, and a reservation no longer rewrites the identity.

Signed-off-by: Wojciech Prazuch <[email protected]>
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 16, 2026 10:23
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHIP WITH CARE

I found one RISK: the reservation delay lets budgeted collection dispatch rows after their deadline or with insufficient drain margin.

I inspected all seven changed files and traced the affected dispatch, cancellation, and recovery paths. This was a source-only review; I did not execute tests.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

Comment thread nemo_gym/rollouts/rollout_collection.py Outdated
f"row={json.dumps(_rollout_request_debug_summary(row), sort_keys=True)}",
flush=True,
)
await reserve_dispatch(row)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RISK: Recheck dispatch eligibility before persisting delayed reservations

The budget check runs before this new wait. With one concurrent slot, two fast rows, dispatch_budget_s=1.0, and the production five-second interval, row 0 dispatches immediately. Row 1 passes the check, waits until approximately five seconds, and still sends /run. It should drain without reserving or starting an attempt. The same failure occurs when the wait leaves less than the configured or adaptive drain margin. This affects budgeted collection because the production caller supplies the reservation callback and budget together, allowing work to start too late to finish within the allocation.

Could you re-evaluate the deadline and current drain margin when the delayed batch becomes eligible to flush, exclude ineligible rows before calling store.record_dispatches, and return _dispatch_drained_result for those waiters? Checking only after await reserve_dispatch(row) would prevent HTTP but leave a durable reservation. Recovery treats reservations without outcomes as interrupted work. The invariant is that a row drained while waiting neither sends HTTP nor increments next_attempt. The helper's result plumbing needs to distinguish drained and reserved waiters, so I am not suggesting an unverified replacement patch.

Proposed acceptance checks, not executed:

  • Use two input rows, one concurrent slot, immediate valid fake responses, an explicitly restored nonzero reservation interval such as 0.2, dispatch_budget_s=0.05, and drain_margin_s=0. Expect only row 0 to reach HTTP, row 1 to return _ng_dispatch_drained, and the manifest to contain only row 0's reservation.
  • Add a positive-margin case where the delayed flush occurs before the deadline but leaves insufficient headroom. Expect the same unreserved drain behavior; cover the adaptive margin too.
  • Retain immediate first dispatch and generous-budget or unbudgeted collection. Eligible rows must still batch and observe durable reservations before HTTP. Keep cancelled waiters unreserved, write failures from dispatching HTTP, and reservation waiting out of rollout latency. The existing durability and write-failure tests must retain their manifest-before-HTTP and no-HTTP-on-write-failure assertions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. The budget and drain margin are checked again when the delayed reservation is due, and a row that ran out is drained unreserved. Test: test_a_row_the_budget_runs_out_on_while_its_reservation_waits_is_drained_unreserved.

…reservation waits

The drain check ran before the reservation wait, so a row could still start
after the deadline or inside the drain margin. The check now runs again when
the batch is due; a drained row is neither reserved nor sent.

Signed-off-by: Wojciech Prazuch <[email protected]>
Comment thread nemo_gym/rollouts/rollout_collection.py Resolved
Comment thread tests/unit_tests/conftest.py Resolved
Comment thread nemo_gym/rollouts/rollout_collection.py Resolved
Comment thread nemo_gym/rollouts/rollout_recovery.py Resolved
@svcnvidia-nemo-ci svcnvidia-nemo-ci added area:core Shared APIs, servers, telemetry, health, and registries needs-review PR is ready for code review and waiting on a reviewer labels Nov 16, 2026
dispatch_reservation_interval_s replaces the 5 s module constant and
defaults to 1 s. Each rollout may wait up to the interval in its
concurrency slot before its request is sent. 0 writes once per
event-loop turn. The field stays out of the resume digest.

Tests that dispatch rows one at a time set it to 0 in their config, so
the autouse fixture is gone. New tests cover a delayed write that still
precedes HTTP and the rollout timer starting after the reservation.

Signed-off-by: Wojciech Prazuch <[email protected]>
Bound the awaits that hang on a regression with asyncio.wait_for, and
check the flush after a quiet interval by event-loop turns instead of a
wall-clock bound.

Signed-off-by: Wojciech Prazuch <[email protected]>
…e_config_identity

The keyword controls the configuration identity file, not a rollout
identity, which is what the name read as at its caller.

Signed-off-by: Wojciech Prazuch <[email protected]>
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 16, 2026 18:12
@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 17, 2026
@wprazuch wprazuch changed the title fix(rollouts): write the run manifest at most once per 5 s during dispatch fix(rollouts): write the run manifest at most once per second during dispatch Nov 17, 2026
@wprazuch
wprazuch requested a review from ananthsub November 18, 2026 09:24
@wprazuch

Copy link
Copy Markdown
Contributor Author

/review

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHIP

I verified that the prior RISK is fixed. Delayed batches now recheck dispatch eligibility before persisting reservations, and drained rows return without sending HTTP. The regression cases assert that deadline expiry and insufficient explicit or adaptive margin leave the waiting row unreserved.

I reviewed the changes since the previous bot review, including configurable interval wiring, timing, and resume compatibility. The interval is configurable, rollout timing still excludes reservation waiting, and the manifest keyword rename is consistent with its caller. I found no unresolved prior findings or new regressions eligible above the existing moderate-impact threshold.

This was a source-only follow-up review. I inspected the affected callers and regression tests but did not execute tests.

Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.

),
)

dispatch_reservation_interval_s: float = Field(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: the command reference does not mention this setting

This field is now how a user trades manifest writes against start latency. A run of very short rollouts that slows down needs it set to 0, and a run that must write the manifest less often needs it raised. The collection options in the command reference describe the neighboring settings +dispatch_budget_s, +drain_margin_s and +dispatch_longest_first, but not this one, so a user who sees the slowdown has no page that names the setting. The PR checklist still marks documentation as not applicable because the change was "internal timing only", which no longer holds now that the interval is a user setting.

Could you add a bullet after Dispatch budget in fern/versions/latest/pages/reference/cli-commands.mdx? For example:

- **Manifest writes.** `+dispatch_reservation_interval_s=<seconds>` (default 1) is the shortest time between the run manifest writes that reserve attempts before their requests are sent. Rollouts admitted within the interval share one write, so each one may wait up to the interval inside its concurrency slot before it starts. Set it to 0 for runs of very short rollouts. The manifest is then written once per event-loop turn, as before this setting existed.

The bullet belongs in a file this PR does not touch, so it is not a suggestion block.

@yashaswikarnati
yashaswikarnati added this pull request to the merge queue Nov 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44457771751

Merged via the queue into main with commit 155b27d Nov 19, 2026
78 checks passed
@yashaswikarnati
yashaswikarnati deleted the wprazuch/throttle-run-manifest branch November 19, 2026 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core Shared APIs, servers, telemetry, health, and registries bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants