Skip to content

[CI] Fix the problem of hf runner too slow - #1202

Merged
Ying1123 merged 1 commit into
mainfrom
fix_unit_test_speed
Aug 25, 2024
Merged

Ying1123 merged 1 commit into
mainfrom
fix_unit_test_speed

Conversation

@Ying1123

@Ying1123 Ying1123 commented Aug 25, 2024 •

Copy link
Copy Markdown
Contributor

@Ying1123
Ying1123 merged commit e61d13a into main Aug 25, 2024
@Ying1123
Ying1123 deleted the fix_unit_test_speed branch August 25, 2024 01:35
timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 4, 2026
…oved, not the set the release re-enumerates

Boot 9 (boot_855_weg1b9_1116175f6d_0904_164023.log) died at the first
pp_to_tp cutover. The measured shape is TEMPORAL, not container-shaped:

  log:1883/:1886/:1888  at-arm  cur_slot_reqs=1 on ALL THREE ranks
                        (cur_slot_reqs IS len(_live_reqs(scheduler)))
  log:2203/:2210/:2213  one second later, RESIDENTS RELEASED 1 / 0 / 0
  log:2189/:2194        PP1+PP2 sgl-project#938 PROTECTED RESIDUE AT DROP: 67 row(s)
                        still locked after a drop that evicted 0
  log:2305/:2351        ReqPoolRebindRefused: 1 of 8 rows are still held in
                        the OUTGOING request pool (free=7, rids=[], rows=[])

The same authority, the same rank, two answers one second apart, and
nothing reconciled them. Four cuts:

1. LOAD-BEARING. `_enter_armed_state` now opens an armed-window resident
   ledger (`_armed_residents`) and `on_round` unions each armed round into
   it; `_release_residents_for_cutover` retracts the release-instant
   enumeration RECONCILED against that ledger (`cutover_resident_set`).
   Snapshot rather than a re-run of the quiescence term at :11564, because
   that point is past the no-return -- PP0's PROCEED has already ridden the
   request stream -- and a quiescence term there could only be a rank-local
   verdict where no rank may hold one (sgl-project#969 SS-W3). A snapshot changes WHAT
   is retracted, never WHETHER the group cuts over.
   The reconciliation is a FILTER, not a union: a snapshot member is carried
   only if it names a row, the row is not in the pool's free list, and no
   live request names the same row. Under-retraction stops the boot loudly
   at the rebind; over-retraction frees a row its owner still holds and
   corrupts silently, so the two are not traded symmetrically.
2. `mbs` is now a route of the ONE authority `_live_reqs`, beside
   `running_mbs`/`last_mbs` (scheduler_pp_mixin.py:7556-7561 builds three
   distinct arrays; `mbs` is written on all three planning paths). Dedup is
   by id(), so the scheduler.py:8354-8362 alias costs nothing.
3. `phase_req_pool_binding` drops its own two-container walk and delegates
   naming to that authority (keeping `waiting_queue`, which the flip has
   not got), and `census_outgoing_req_pool` now derives the HELD ROW IDS
   from the pool's own free list. `escapees=1 rids=[] rows=[]` becomes
   `rows=[N] rids=[...] unnamed=K`. The raise is NOT relaxed -- the module
   docstring :16-30 is right that a request pool has no disarmed state.
4. phase_flip_runtime.py:1202 cited `orphan_resident_reqs` in
   `phase_flip_resident_carry.py` in the present tense; sgl-project#969 deleted that
   module whole. Rewritten in the past tense, naming the deletion.

RED FIRST, at parent 1116175, test/registered/unit/managers/
test_1202_arm_release_residency_reconcile.py: 8 failed, 2 passed.
The follower test failed with boot 9's verbatim refusal
("1 of 8 rows are still held ... free=7, rids=[], rows=[]").
After the cut: 10 passed.

MUTANTS (scratch, all killed):
  M1 drop the reallocation guard (DANGEROUS: frees a row its new owner
     holds) -> test_a_row_reallocated_to_a_live_request_is_not_taken_from_it
  M2 drop the already-free guard (DANGEROUS: returns the same row twice)
     -> test_a_row_already_returned_is_not_retracted_a_second_time
  M3 release ignores the armed ledger (boot 9 restored) -> 4 tests
  M4 remove the mbs route -> test_mbs_is_a_route_of_the_authority
  M5 census rows from the request list again
     -> test_held_rows_come_from_the_pools_own_arithmetic

VERIFIED: siblings at parity, per file, parent vs cut --
test_phase_flip_runtime.py 30 failed / 38 passed at BOTH, identical failure
set (pre-existing); test_1040_req_pool_per_phase + test_seam_order_856 +
test_seam_readmission_w31 + test_tree_drop_returns_rows_856: 78 passed at
both. ruff check clean on both sources at parent and at cut; ruff-format
diff 4 lines at parent and 4 at cut (pre-existing, unchanged). Matched
structural check: all three `self._parked_extent = None` statements sweep
the ledger too (the sgl-project#746 M5 shape on the request axis). Import smoke on
both modules.

NOT VERIFIED: nothing was run on metal. No boot, no GPU, no server. Whether
the request that held the row on PP1/PP2 in boot 9 was reachable through
`mbs` is still PLAUSIBLE only -- an mbs-only resident would have read
cur_slot_reqs=0 at arm and the log reads 1. Cut 1 does not depend on that
attribution. test_quiescence_no_carry_858.py could not be run: it fails to
import at the parent commit too (`cannot import name
prefill_runnable_in_current_layout`), a pre-existing breakage.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 4, 2026
…hichever rank asked first

A1, A4, A5 of the WEG-1 review's family A: three consumers where the group
branches on a number one rank computed. A2 is deliberately NOT here and A3 is
verified-and-recorded, both for reasons stated below.

A1 -- THE SEAM-TRANSPORT PREMISE. `phase_purity.seam_transport_premise_holds`
decides whether the TP layout may build a transport prefill batch; True builds
an extend batch, False yields no batch at all under strict:3 with drain mode,
so the two branches carry different collectives. Its whole read set was
rank-local: the store witness reads the tree cache's prefetch records, whose
reduced half exists only under `UnifiedRadixCache.tp_world_size > 1`, and that
field is bound once at cache construction (unified_radix_cache.py:522) and
never rebound at the cutover -- while `scheduler.tp_cpu_group` IS rebound to
world N (phase_flip_runtime.py:3201-3202). On the shipping form
(--tp-size 1 --pp-size 3) the cache's world is 1 in BOTH phases.

The divergent input is on this rig's metal at the parent commit, one second
before the cutover of boot_855_weg1b9_1116175f6d_0904_164023: log:1900 PP0
`absent=67` against log:1977 / :2067 PP1 and PP2 `assembling=67` -- same 67
stems, same second, two answers about presence.

The cut is one AND-slot on the packed MIN `_update_uniform_pool_budget`
already takes once per iteration, head-indexed and placed ahead of the
tail-indexed ballot so both readings stay intact. No new collective. The read
site is `local AND group`, in that order: a published verdict can only ever
REFUSE, so a stale or wrong 1 cannot license a rank whose own reading says no,
and `None` (PP loop, single-rank group, the kv-session-offload branch that
takes no reduce of its own) is byte-identical to the pre-sgl-project#1203 path. The
verdict is cleared, not left standing, on both early returns -- sgl-project#823 W9b's
rule for `_uniform_head_inputs`.

A4 -- `check_prefetch_progress` published `completed_tokens`, the TRANSFER,
as this rank's completion; PP0 MINs those into a group floor and CLAMPS the
told prefix to it. A rank whose insert declined the fetched tail moved the
bytes and retained none, so the floor licensed a prefix no rank holds. Now
`insert_result.prefix_len + loaded_from_storage`, the retention. Both sides of
the comparison read the same accessor, so the unit stays consistent.

A5 -- the writeback, host-headroom and seam-budget defer bounds counted on
rank-local counters while the abandon they bound is group-unanimous; three
ranks taking turns objecting never spend a budget between them (the
411-abandon decode wedge, through the mechanism that exists to prevent it).
All three now read `self._seam_abandons_in_a_row.get(direction, 0)`, booked
from the already-reduced fit verdict -- the form the seam-margin term twelve
hundred lines up has used since it was written. Read-site change only; the
local counters stay as per-rank instruments.

FALSE TEXT, corrected in the same edit rather than left for the next reviewer:
  * `prefill_blocked_here`'s docstring claimed rank-uniformity "by
    construction" and `get_next_batch_to_run` repeated it. Claimed twice,
    enforced nowhere. Both now state what A1 makes true (the seam term is a
    group fact wherever the reduce runs) and what is STILL unenforced
    (`seam_transport_exempt` and `running_bs` are read locally; the offload
    branch is a named gap; nothing walks the input set and asserts).
  * `store_witness`'s "RANK UNIFORMITY of the inputs (review N3)" paragraph
    rested on the packed MIN that does not run on the shipping form --
    retracted with the measurement that falsifies it.
  * `unified_radix_cache.py` "N1: the reduced value, never the local stamp" --
    same falsification, corrected in place.

A3 -- VERIFIED, NOT FIXED, and why is recorded at the site.
`_admission_held_for_deferred_prefetch`'s `pp_size > 1` follower exemption is
still inert in the TP phase (phase_flip_runtime.py:3193 writes pp_size=1 on
every rank), so all N ranks withhold on their OWN mark, which is set from this
rank's prefetch budget and this rank's monotonic clock. The group machinery
that exists -- the prefetch ballot -- covers only the queue head and answers a
different question; conflating them would make a wrong predicate uniform,
which is exactly the failure recorded for A2. The honest close is a
group-uniform defer budget or a second per-rid ballot arm, both larger than
this commit.

A2 IS NOT ATTEMPTED. Moving the decode-stall SLO stamp out from behind
scheduler.py's empty-batch branch fixes the stamp and leaves family C's
divergent residency underneath -- a uniform reading of a wrong state. Left to
the sgl-project#1202/sgl-project#1203 follow-up.

WHAT WAS RED, at parent 4a1da47:
  test_1203_group_branches_on_one_rank.py -- 11 failed, 3 passed.
  The 3 that passed are the can-fail floors (the fixture's local premise holds;
  no group verdict leaves today's answer alone; the seam-margin term still
  reads the abandon book). Green after the cut: 14 passed.

MUTANTS, planted in a scratch copy at /tmp/w1mut, four on the corrupting
direction:
  M1 ignore the group verdict (the pre-cut behaviour)
     -> test_a_peer_without_a_restore_refuses_for_the_whole_group
  M2 group verdict alone, local check bypassed
     -> test_a_group_yes_can_never_override_a_local_no
  M3 publish a constant yes instead of the reduced slot
     -> test_one_peer_voting_no_pulls_the_group_to_no
  M4 publish the transfer again instead of the retention
     -> test_the_published_completion_is_the_retained_prefix,
        test_the_transfer_count_is_not_what_is_published
  M5 writeback bound back on the rank-local counter
     -> test_the_writeback_bound_reads_the_group_book
  M6 append the AND-slot AFTER the tail-indexed ballot
     -> test_a_unanimous_yes_survives_the_reduce,
        test_one_peer_voting_no_pulls_the_group_to_no
  None survived.

VERIFIED: the reduce is unconditional and pre-branch in `get_next_batch_to_run`
(scheduler.py:8617) and precedes the prefill gate in the same pass; all four
callers of the premise now take the group wrapper; ruff parity with the parent
(103 + 1 pre-existing findings before and after, 0 in the new test file);
siblings run once -- 7 failed / 263 passed against the parent's identical
7 failed / 249 passed (test_1189_sweep_a2, a hardcoded line-number census, and
two test_tp_decode_formation_861j cases were already failing at the parent).

NOT VERIFIED: nothing was run on metal. A4 and A5 are pinned by AST tests, not
execution -- the A4 write site sits inside `check_prefetch_progress`, which
needs a cache controller, a host pool and a live storage backend, and the A5
sites sit inside `_execute_body`. Their arithmetic is argued, not measured. The
co-occurrence rate of A4's PP0-adopts/follower-declines lap is still unmeasured,
as the review recorded.

test_1157_seam_witness.py's premise-source pin follows the half of the split
that still holds the check, and now asserts the delegation too, so it cannot be
evaded by dropping it.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 4, 2026
…ee adversarial lenses found in the six cuts

WHAT WAS RED, and every finding was re-verified at the tree before it was
acted on. Two of the eleven reported were REFUTED and are named at the end.

1. sgl-project#1202 added `mbs` to the residency AUTHORITY and not to the retirer.
   `_live_reqs` walks `mbs`; `consume_retracted_from_live_universe` did not.
   That is the W30 asymmetry re-opened, and it is the W27 death: the release
   frees a request the authority then re-enumerates, and
   `resident_mamba_slots` (gdn_flip_mover.py:620) raises KvReshardError on a
   live request with no mamba slot -- inside the no-return region, where the
   only outcome is a dead rank. The mbs-only shape is ordinary, not exotic:
   under event_loop_pp a freshly planned prefill batch sits in `mbs[slot]`
   while `running_mbs[slot]` holds the decode set.
   RED: the property test "authority and retirer walk the same containers"
   reported authority-only = ['mbs']; the concrete test read
   "0 != 1 : the mbs route retired no reference".
   Pinned as a PROPERTY over the two walks, so the next route added cannot
   reintroduce it. The stale present-tense collateral at
   scheduler_pp_mixin.py:5121 ("_live_reqs does NOT enumerate mbs", dated
   2026-09-04) is rewritten as the dated fact it now is.

2. sgl-project#1203 A5 spent three ESCALATION budgets in the group's abandon currency.
   A5's premise is right and is kept: a rank-local counter that zeroes itself
   when this rank's own objection clears can never reach its limit while
   ranks take turns objecting. But `flip_host_headroom_verdict` and
   `flip_seam_budget_verdict` do not merely stop deferring at the limit --
   they return (allow=True, escalated=True), "PROCEEDING WITH EYES OPEN"
   under a failed sgl-project#721 host floor -- and the writeback arm proceeds with an
   incomplete sgl-project#703 fence. `_seam_abandons_in_a_row` is incremented on EVERY
   reduced-fit abandon or frame divergence, so three unrelated abandons
   disarmed all three guards and the next GENUINE shortfall escalated on its
   first firing, having deferred zero times. A bound may be widened to the
   group's currency; an escalation that permits the hazard may not.
   REPAIR: each guard is bounded by its own count again, and that count is
   refunded ONLY by a completed flip (beside the abandon book, whose own
   comment already states the rule) or by the guard's own escalation. The
   whole reset policy is `flip_defer_budget_after`, one pure function, so the
   three copies cannot drift again.
   RED: 8 of 10 A5 tests failed at the parent.
   Three instruments that named the wrong counter are corrected with it:
   "consecutive" becomes "in this abandon run", and the host-RAM defer is
   booked BEFORE its own log line instead of after.

3. sgl-project#1204's abstain discarded a term the rank had successfully read. Both
   reads shared one `try`, so a rank whose `backed_rows()` succeeded and whose
   `live_floor_rows()` then raised contributed `_UNBOUNDED_ROWS` in slot 0 --
   the MIN identity, i.e. "I am not the poorest". Slot 0's MIN becomes the
   level the peers cap to and the ceiling `book_deferred_grow` clamps to, so
   erasing a poor rank makes the group agree an id level it cannot map, which
   `backed_rows`' docstring calls a cudaErrorIllegalAddress that kills every
   rank. The hang the commit removed would have been traded for a wrong group
   answer -- the corrupting direction bought to avoid the refusing one.
   REPAIR: abstain PER SLOT. Each slot carries this rank's own measurement or
   that slot's neutral, unchanged for a wholly unreadable relief.
   RED: "30 != 1099511627776".

4. sgl-project#1205's `seam_refused` measured a population its label does not name --
   the sgl-project#1205 defect class, committed inside the sgl-project#1205 fix. The fence read
   `seam_refusals()` with NO direction, summing "load" refusals raised on the
   controller's own background threads while the fence runs, and printed the
   delta as "of refused_silently, the share the FLIP SEAM refused".
   REPAIR: `seam_refusals("write")`, and the log line and the field comment
   now say what it is: process-wide write-direction refusals during the fence,
   not a subset of `refused_silently` and not per-node (consume_gate refuses a
   whole queue and counts one).
   RED: "1 != 3" when the direction-less read is put back.

5. `assert_future_map_identity` was REACHED and CANNOT-FAIL. Measured: four
   combinations of (algo NONE|EAGLE) x (pool pp|tp), ZERO fires.
   `create_future_map` passes `self` as `spec_algo` and the scheduler's pool
   straight into `ConfidenceRelay`, so both stamp arms are construction
   invariants at a call site 57 lines after the rebuild; the two suite tests
   that are green hand-mutate a map no code path produces.
   REPAIR: the registry's obligation is "a probe proving the rebuild ran", so
   the probe now takes `previous` -- the map held BEFORE the rebuild -- and
   refuses when the rebuild did not replace it. A memoised build, a deleted
   assignment or a rebuild moved out of the cutover all land there and none of
   them are visible to the stamp arms. The tautology is pinned as a fact so
   the green is not read as coverage.

6. MambaRadixCache got the sgl-project#1201 assertion but not the sgl-project#1201 fix. It caches
   `req_to_token_pool` as a plain attribute and has no `bind_req_pool_owner`,
   so `_restamp_phase_handles`' hasattr guard skipped it and the handle stayed
   on the outgoing pool -- and `assert_req_pool_identity`, added to both
   classes, then raises ReqPoolRebindRefused at the END of every cutover.
   Reachable: registry.py hands back this class for a hybrid-SSM model WITHOUT
   hierarchical cache. The boot went from flipping wrongly to not flipping.
   REPAIR: the same owner property and bind hook UnifiedRadixCache got.

7. The sgl-project#1203 A1 group vote moved a non-pure function onto a new cadence.
   `seam_transport_premise_holds_locally` writes the edge-triggered
   `_seam_premise_refused_announced` latch and emits SEAM TRANSPORT REFUSED;
   the vote runs once per loop iteration while the consumer returns at
   `_active_phase != PHASE_TP` before it asks. The latch was therefore set in
   the PP phase, swallowing the gate's own first engagement in TP.
   REPAIR: `announce=False` for the vote; the gate's own read still announces.

Also: the anchor at overlap_utils.py:81-83 had drifted onto the line that
REFUTES its sentence -- scheduler.py:13174-13177 is now the overlap call
inside `if self.enable_overlap:`, while the non-overlap spec branch is the
sibling `elif not batch.spec_algorithm.is_none():` arm. The claim is true; the
number sent the next reader to the wrong branch. Named by branch, no number.

WHAT KILLED WHICH MUTANT (planted in place, restored by sha256):
  M1 retirer over-clears (frees a row a live req owns, the corrupting
     direction) -> test_an_mbs_only_resident_is_retired_by_the_retraction
  M2 host bound back on the group abandon book (disarms sgl-project#721)
     -> test_the_host_headroom_bound_reads_its_own_defer_count
  M3 a cleared vote refunds its own budget (the A5 wedge)
     -> test_this_rank_clearing_does_not_refund_the_budget
      + test_a_taking_turns_run_still_reaches_the_limit
  M4 refund moved back into the gate's cleared-vote branch
     -> test_a_completed_flip_returns_every_budget_beside_the_abandon_book
  M5 sgl-project#1204 discards a measured backing again (claims not-poorest, the
     fleet-death direction)
     -> test_a_readable_backing_reaches_the_group_min
  M6 MambaRadixCache loses the rebind hook
     -> test_both_classes_expose_the_rebind_hook
      + test_the_handle_follows_the_owner_and_falls_back_without_one
  M7 the seam stops handing the probe the outgoing map
     -> test_the_seam_hands_the_probe_the_outgoing_map
  M8 the A1 vote announces again
     -> test_the_vote_leaves_the_announcement_latch_alone
8 planted, 8 killed, 0 survived.

VERIFIED: 146 passed + 7 subtests over the six touched test files plus
test_1157_seam_witness.py and test_seam_census_double_905.py (the joint pin
over both sgl-project#1202 functions), hermetic, CUDA_VISIBLE_DEVICES="" with the serving
venv. Import smoke over all seven edited modules. ruff parity with the parent
on the touched files: 31 findings both sides, all pre-existing.

NOT VERIFIED: nothing on metal. No boot, no GPU claimed, no collective. The
sgl-project#1204 and A5 repairs are DESK-PROVEN only -- neither has run against a real
reduce or a real host-RAM shortfall.

REFUTED, and left untouched: (a) `assert_req_pool_identity`'s tree-cache arm
is not decorative -- it is a construction invariant for UnifiedRadixCache
BECAUSE the owner property is the fix there, and a live check for every other
holder class, which is exactly what caught finding 6; (b) `seam_refused` was
already read as a delta across the fence run (hicache_flip_writeback.py:700),
not as an absolute, so only its direction and its label were wrong.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant