Repository navigation
fix(lead cap): K = 1 waits for a fixed window of global steps; deterministic give-up tests - #914
Merged
Merged
Conversation
michaellchung
force-pushed
the
fix/verl-lead-cap-flake
branch
from
November 26, 2026 20:43
cc09aa9 to
799c35b
Compare
…it itself The lead wait pushed every PULL that arrived while it polled from the cut the island had already pushed. With K = 1 that pair is itself a lead blocker, so each such PULL held the wait one more merge. On a slow island this chained: its pushes complete the merges a fast island already pushed to, each merge opens a round whose PULL the slow island answers from inside its wait, and the fast island trains a round per merge meanwhile. The fast island's lead was unbounded; the verl parity lead cap case failed on CI with 11 fast rounds against 8. A lead wait poll now opens a new pair only where it cannot block the wait (K >= 2) or for the push the wait waits for (lead_unpushed). Held PULLs are answered at the next boundary from the newer cut. Replays, harvests, broadcast applies and peer snapshots are unchanged; the cap off (default) is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-clock bounds test_the_wait_for_a_late_pull_gives_up_at_half_the_wait_timeout failed once on a loaded host (four parallel shards, load about 58): it and test_the_wait_gives_up_at_half_the_wait_timeout_and_never_times_out_itself asserted that a wait with real 50 ms polls ends within 0.4 s. A loaded host stretches real sleeps, so the upper bound fails while the give-up logic is right. The pairing module's clock is now replaceable as a whole: the one place that bound time.monotonic at class definition (PairedSubmission.retained_at) reads it at construction through the module's time, like every other call. The default clock stays time.monotonic and is read at the same moment, so production timing is unchanged. The tests install a clock that only the module's own sleeps (the wait's polls) advance and assert the give-up time exactly; the two new K = 1 / K = 2 wait cases use it too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The K = 1 rule of the first fix (a wait opens no pair that would hold it) left two holes. Crossed PULL orders, as a sharded head delivers them, made two islands each wait for a push the other makes only after training (both waits escaped at half the wait timeout). PULLs that arrived in order but late were answered one boundary later, from a newer cut, so the lead grew with the run. K = 1 now cuts the global steps into fixed windows of P (the pipeline depth) steps. Each local round takes the window of the smallest open step, pushes every PULL of that window from its cut (also late and out-of-order ones, during the wait), holds the others, and trains the next round once the window closed. With a fixed roster every island pushes window b from a cut of round b or later, so a fast island stays at most one local round ahead of the slowest for any order and delay of PULLs and broadcasts, and no wait holds a step another island needs. A window closes without the island when its steps can (quorum below the island count, soft deadline, an island that left): no lock and no escape, but no lead bound then. A joining or relaunched process takes the window of its first open step. The terminal phase ends any wait and lifts the window, so the final cut answers every PULL left. K >= 2 and the cap off are unchanged. Tests: window, crossing, quorum, join, terminal, replay and held-PULL cases on fakes; the verl parity lead cap case under late broadcasts, late PULLs and crossed PULLs, with quorum 1 of 2, and with an island that leaves and catches up. The flag help and CLI reference state the bound and the cost (one window in flight per local round, also with several syncer shards). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…>= 2 Review follow-ups: - A fake test for the core K = 1 rule: step 1 merged, step 2's PULL comes late; the next round waits until step 2, pushed from this cut, merged. The K >= 2 blocker rule trains on there (the linear lead growth). - Versions (7, 6) give the fixed window 7..8, not 8..9. - K = 2 keeps the lead_unpushed case (rounds trained after the last retained push count once nothing is in flight). - The deferred-capture case frees two pipeline slots, so a missing window filter would materialize the held step. - The flag help, CLI reference and wait docstring state where the give-up clock starts and that the lead is no longer bounded after a give-up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
michaellchung
force-pushed
the
fix/verl-lead-cap-flake
branch
from
November 26, 2026 22:41
799c35b to
838a0b4
Compare
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.
Four commits:
fix(lead cap): the first product fix for the verl parity lead cap flake (superseded by commit 3, kept for the history of the review).tests:a separate, unrelated flake intests/test_sync_lead_cap.py, made deterministic with an injectable clock.fix(lead cap): K = 1 waits for a fixed window of global steps: replaces the K = 1 rule of commit 1 after review found two holes in it.tests(lead cap): review follow-ups (tests that guard the window wait, the window alignment and K >= 2; the give-up clock in the docs).Problem
tests/test_verl_miles_parity.py::test_the_lead_cap_holds_a_fast_verl_island_to_the_slow_onefailed on CI withAssertionError: (11, 8). The bound counts local rounds, not wall-clock time, so the product broke the guarantee: with--rl-sync-max-local-rounds-ahead 1and a fixed roster, a fast island must stay at most one local round ahead of the slowest island.Root cause on origin/main:
RolePairing.wait_for_leadanswered every PULL that arrived during the wait from the cut it had already pushed. With K = 1 such a pair is itself a lead blocker, so on the slow island each merge opened a new round, the wait answered it, and the new pair held the wait again, while the fast island trained a round per merge. Fault injection (the slow island's broadcasts 60 ms late) fails origin/main 21 of 100 runs.Why commit 1 was not enough
Commit 1 stopped the wait from opening pairs that would hold it. Review showed two holes:
Fix: a fixed window of global steps per local round (K = 1)
Options considered, in the requested order:
local_step, but the syncer never sends it back.The rule (
RolePairing.lead_window):1..totalare cut into fixed windows of P consecutive steps, P =--rl-sync-fragment-pipeline(the effective pipeline depth). The last window ends at the last step.Bound, fixed roster: every step needs every island's push. An island pushes at most one window per local round, and a window can close only after it pushed it, so the window it takes at round r has index at most r: every island pushes window b from a cut of round b or later. When an island starts round b + 1, window b closed, so every other island trained at least b rounds. A fast island is at most one local round ahead of the slowest, for any order and delay of PULLs and broadcasts, and on a sharded head (step t merges fragment (t - 1) mod F on every shard, and a fragment's version is the step that last merged it). Every island waits for the same window, so no wait can hold a step another island needs: crossed orders cannot lock.
Membership and phases (each has a test):
docs/CLI_REFERENCE.mdand the docstring.any_finalizingends any wait and lifts the window, so the final cut answers every PULL left, also those past its window. The last rounds' PULLs can start the terminal phase while a wait holds an earlier window. A window filter kept there left both islands waiting on each other; the stress run found this (see below) and it is fixed and tested.--rl-sync-wait-timeout-s(with none in flight, since the island last retained a pair).Cost of K = 1: one window of P steps is in flight per local round, also on a sharded head whose shards could run P steps each. This is in the flag help and
docs/CLI_REFERENCE.md.K >= 2 keeps the existing
lead_blockers/lead_unpushedrule. With the cap off (the default) nothing changes: the window filter returns its input unchanged.Impact
--rl-sync-max-local-rounds-ahead; it needs--rl-sync-full-parameter-rounds async.--rl-single-island-no-syncand never builds aRolePairinglead window. Customer gate below.Tests
Rewritten fake tests, and why:
test_with_k_1_the_wait_opens_no_pair_that_would_hold_it(commit 1) is removed. It asserted the rule of commit 1, which is what H1 and H2 break: the wait now does push late PULLs of its window from the current cut.test_the_wait_also_covers_rounds_trained_before_the_next_pull_arrivesnow uses thelead_clockfixture and the window rule (window 1..2 merges, then the PULLs of window 3..4 arrive late).New fake tests in
tests/test_sync_lead_cap.py:tests/test_verl_miles_parity.py, real syncer:tests/test_rl_full_parameter_dynamic_members.pyare unchanged).Mutations: each old or broken variant of
full_parameter_sync.pyrun against the new tests:Review follow-ups (commit 4)
lead_unpushedcase: after a merge nothing is in flight, and two rounds trained since the last retained push stop the next round (fails when<=becomes<).prepare_submissionsmaterializes the held step (fails without the filter).docs/CLI_REFERENCE.mdand the wait docstring now say where the give-up clock starts (the last push of the oldest pair in flight; with none in flight, the first pair retained in the island's last retaining round) and that the lead is no longer bounded after a give-up.Each of the four mutants above fails exactly the new or changed test. The lead cap files (
tests/test_sync_lead_cap.py,tests/test_verl_miles_parity.py,tests/test_verl_full_parameter_launch.py) pass on the rebased head: 74 passed. Customer gate on the rebased head: 52 goldens pass, dry-run diff against origin/main none. The stress numbers below were measured on commit 3; commit 4 changes only tests, docs, help text and one docstring.Verification (local, CPU only)
All under 32
yesprocesses, 8 parallel shells, host load 100 to 160:tests/test_sync_lead_cap.py, whole file (fakes and real syncer)_max_lead <= 0), no injection and each injectionThe first version of commit 3 kept the window in the terminal phase. The same run failed 8 of its first 373 jobs: the last rounds' PULLs arrived while a wait held an earlier window, started the terminal phase, and stayed filtered, so both islands waited for each other until the pair timeout. Lifting the window in the terminal phase fixed it (the table above is the fixed code), and
test_with_k_1_the_terminal_phase_lifts_the_window_so_the_final_cut_answers_every_pullfails without the fix.The real-syncer capped test in
tests/test_sync_lead_cap.pynow asserts the bound of the window rule: the fast island never starts a round before the slow island completed as many (it was "at most two ahead").max_lead (fast island's started rounds minus the slow island's trained rounds, at every start of the fast island), parity case:
A max_lead of 1 is the bound itself: the fast island starts round b + 1 right after window b closed, when the slow island has trained b rounds. Both islands train the same number of rounds in every run. An earlier probe of origin/main under load recorded a lead of 4.
Regression: rebased head, no load, every test file that exercises the pairing or the full-parameter sync session (73 files that import
full_parameter_sync,full_parameter_streamor build aFullParameterSync), each file in its own process: 1431 passed, 0 failed, 20 skipped (Miles-only cases skip without Miles). The Rust syncer is unchanged.Customer gate
test_k31_customer_plan_golden+tests/golden/breakers: 52 passed, golden files unchanged.examples/k31/run*.jsonwent throughyeto run up --dry-runand the pool--dry-runand was compared line by line, with timestamps and--source-sha256normalized. The trainer launch was rc=0 on both sides. The only failures were the expected offline model_pull and sandbox status checks.Not merged.
🤖 Generated with Claude Code