Repository navigation
fix(rollouts): write the run manifest at most once per second during dispatch - #6214
Conversation
…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]>
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
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.
| f"row={json.dumps(_rollout_request_debug_summary(row), sort_keys=True)}", | ||
| flush=True, | ||
| ) | ||
| await reserve_dispatch(row) |
There was a problem hiding this comment.
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, anddrain_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.
There was a problem hiding this comment.
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]>
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]>
|
/review |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44457771751 |
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.
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.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
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.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 onmainon this macOS machine (spawn-timeout tests, macOS-only telemetry tests, optional extras not installed).dispatch_reservation_interval_s: 0in 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_sdoes not change the configuration digest, so earlier runs resume.RunManifest.writegains a keyword-onlywrite_config_identityargument (defaultTrue).Checklist
git commit -s).