Repository navigation
Bump version to 0.2.9.post1 - #899
Merged
Merged
Conversation
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
Aug 26, 2026
…roject#910 walkdown LRU refresh) into the flip train
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 27, 2026
…stead of clobbering it The re-issue this ticket asked for already existed. A cutover retracts every resident; the retracted request is re-queued through _add_request_to_queue, which calls _prefetch_kvcache, which re-runs prefetch_from_storage -- a fresh radix walk under the CURRENT binding generation, allocating a fresh host span from the currently bound pool. Building a second requeue path would have been redundant machinery on top of a working one. What did not exist was a guard on the registration. prefetch_from_storage ended with an unconditional `self.ongoing_prefetch[req_id] = ...`, so when the post-cutover registration arrived while the pre-cutover one was still ongoing, the incumbent was overwritten outright: its host_indices were lost to every owner (nothing else holds them) and its anchor_lock_params lock ref was never decremented, leaving that node PROTECTED for good. The next cutover's drop_prefix_tree_returning_rows then orphans exactly those device rows -- one request's allocation per cutover, which is the sgl-project#938 forensic shape, and it needs no in-flight write-through to explain it. RETIRE, DO NOT REAP. Freeing the displaced span at the registration site is not available: whether it is safe to release is answered by can_terminate_prefetch, which checks pool_transfers_done and is COLLECTIVE, and HiCacheController.terminate_prefetch is only mark_terminate() -- a flag, not a join -- so the transfer thread may still be writing into that span (sgl-project#913 IMA family). Running that collective there is not available either: whether a clobber happens is RANK-LOCAL, and the site already sits inside the sgl-project#580 participation region. So the record is retired -- terminated, moved out of the req_id slot, nothing freed -- and drain_retired_prefetch reaps it from the per-round site, where collectives are legal. That also DEFINES the ordering instead of leaving it to timing: the re-issue owns the slot, so a late completion resolves through check_prefetch_progress to the new record and cannot reach the displaced one, which is reachable only from the reap. Neither insert nor free happens on a retired record anywhere else. UNIFORMITY IS ENFORCED, NOT INFERRED. It is tempting to argue the retired list is rank-uniform (retirement follows a registration that only happens under the sgl-project#580 positive consensus), but this module refuses arguments of that shape elsewhere -- _prefetch_done_for RAISES rather than assume a request is in the replicated set -- and a wrong inference here hangs three ranks. Both halves are enforced instead: candidates are taken in sorted req_id order (canonical, never insertion order), and the ranks AGREE on the candidate before anyone reaps it, via one all_reduce contributing [d, -d] under MIN so min(d) and max(d) arrive in a single collective. Reaping proceeds only on min == max != 0. A rank that has not retired it yet contributes 0, agreement fails, and the record waits a round. A latecomer delays a reap; it never wedges one. The collective is UNCONDITIONAL -- gating it on a non-empty local list would be the rank-local participation predicate this whole design exists to avoid. Empty contributes zeros; the common case is one two-element all_reduce per round. Not micro-optimised into an existing round collective: correctness first, measure before optimising. The re-fetch budget is a REPORT, not a gate (sgl-project#939 RE-FETCH BUDGET SPENT ... recomputing). Refusing a re-issue would be a rank-local decision taken inside the participation region, which is the one thing this path may not do; the line exists so a cutover cadence faster than a fetch completes is named instead of surfacing only as an unexplained cached=0. Red-first, single process (13 behavioural + wiring pins): retire does not free, the span returns to its MINTING pool and never to the bound one, the drain empties the list with no further event from the request at all (otherwise this trades a clobber for unbounded growth), a completion cannot touch a retired record, and the registration retires before it assigns. Mutants killed: retire frees immediately (5 red), the clobber restored (1 red). MULTI-RANK, and I had this wrong first. I recorded "the agreement only bites multi-rank, which a CPU test can't exercise" -- false, and the user caught it: three gloo processes on localhost exercise it fine, as sgl-project#630/sgl-project#650/sgl-project#653/sgl-project#899 already do here. Only a SINGLE-PROCESS test cannot. The new gloo falsifier runs the real drain and the real _all_reduce_attn_groups over three real ranks with DIVERGENT retired lists. With the agreement every rank reports rounds [0, 1] -- nobody reaps while rank 2 is behind, everybody reaps once it catches up. Removing it does NOT hang, which is worse and is why this needed measuring rather than predicting: gloo pairs ranks 0/1's round-1 all_reduce with rank 2's round-2 one -- same group, same shape, nothing to distinguish them -- so no rank blocks, every rank reports success, and the ranks silently reap in different rounds. That is the sgl-project#580 signature, not a deadlock, and the next collective carrying a differently-shaped payload is the one that corrupts. The test asserts on that divergence (and accepts a timeout too, since another backend may block). Verified to kill the production mutant only once BOTH agreement gates are removed -- the second, `digest != agreed_min`, independently covers the all-but-one-rank case, so a partial mutation leaves it alive. Also fixed here, and it was mine: test_prefetch_participation_desync_580's cache stand-in drives prefetch_from_storage as a real bound method and had no _retire_ongoing_prefetch, so the new call broke 4 of its tests. Carried as the REAL bound method rather than a stub -- production instances always have it, so a defensive getattr would have hidden a genuine missing-method bug. Tests: test/registered/unit/mem_cache/ plus the gloo module -- 2875 passed, 3 failed (test_acceptance_emitters_758 RefillTiming x2, test_kv_row_ownership_822 TestCallSiteAdapters), all three identical by name and count on the pristine file at HEAD, i.e. pre-existing. ruff clean on both new modules and unchanged on the two production files (unified_radix_cache 0/0, scheduler 103/103 pre-existing); black clean. The gloo module spawns real ranks, so it belongs in the narrow RANKS lane. gate_partition.tsv is generated and sha256-checked, so it is not hand-edited here; gate_partition_build.py has to be re-run for the classification to land. Stage-A interaction, so a reader does not misdiagnose it: a retired-but-unreaped record still holds its lock ref, so sgl-project#938 PROTECTED RESIDUE ORPHANED can show it TRANSIENTLY. Healthy is a counter that RETURNS across reap rounds; monotone growth is still a leak.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Sep 3, 2026
…mainders; quiescence is an arm precondition; followers execute every launched pass under the arm or STOP weg1b4 08:07:50Z: PP0 launched fwd_ct=81 slot=1 for rid b64dc1cb (extend 1912), posted its sgl-project#631 PROXY-SEND t6, and ONE LINE LATER armed pp_to_tp on a DRAINED verdict reading "0 tok remaining" -- the sgl-project#1153 starvation shape with no designed STOP. D1 THE DRAINED PREMISE COUNTS EVERYTHING STILL TO PREFILL. Scheduler._pending_prefill_tokens now carries an in-flight microbatch term: for every request the PP ring launched but has not returned, it prices len(origin_input_ids) - extend_range.start (NEVER - end: end is advanced at PREPARE time, so pricing from end reads 0 for exactly the request that is still running). Deduped against _queued_ids so a request cannot be billed twice; the chunked and resident terms skip _inflight_ids for the same reason. _pending_prefill_terms records the breakdown and its producer, and all four pp-exit arms print it: "[sgl-project#1173 pending terms: queue=.. inflight=.. chunked=.. arriving=.. resident=.. total=.. (producer Scheduler._pending_prefill_tokens, include_health=..)]". On the weg1b4 numbers the ring reads 1912 for b64dc1cb where it read 0 before. D2a QUIESCENCE IS A PRECONDITION OF THE ARM, NOT A HOLD AFTER IT. PhaseFlipRuntime.arm() takes launched_passes_fn (build_launched_passes_fn reads the same _pp_launched_pending the sgl-project#1020 void guard reads, so arm and guard cannot disagree about what is outstanding). With any slot outstanding the arm is DEFERRED, not taken-and-held: "sgl-project#1173 ARM DEFERRED: launched passes outstanding slots=[..] fwd_ct=.. direction=.. deferrals=..". The check sits after the rank!=0 early return (PP0-only by construction, no new rank-local verdict, no new sync point) and before the side-effecting _prearm_floor_relief. An unreadable probe never defers. The mbs quiescence hold is KEPT, not deleted: it stays reachable on followers, which take the arm as an order and never run this precondition, and for a pass launched around the order's arrival -- its reason text now says so. D2b FOLLOWERS EXECUTE WHAT PP0 LAUNCHED, ARM OR NOT. _pp_flip_hold_slot released the ring only when every slot was None, so a proxy frame for a launched pass sitting in the typed inbox parked the follower on an order it could not obey while the launcher waited for a frame that never came. The hold now releases while such a frame is stashed (_pp_flip_stashed_frame_forces_advance reads the typed inbox ONLY -- never the "provably in flight" counter half of _pp_row_any_proxy_signal, which a transit frame would false-positive during the armed spin) so the loop walks the ring to the slot the frame names. A frame that never leaves is a group STOP through the launcher, never a park and never a silent spin: RuntimeError("sgl-project#1173 LAUNCHED PASS UNEXECUTED UNDER ARM STOP rank=%d slot=%d fwd_ct=%d rid=%s arm_epoch=%d reason=%s") after 2*ring+2 armed visits. Small item: the phase_policy hold that says the premise was verified on the STORE WITNESS now prints the witness STATE census (pending|hit|bounded|cold|unprobed) via phase_purity.store_witness_census. EVIDENCE new test/registered/unit/managers/test_arm_quiescence_1173.py: 14 passed on this tree, 11 failed / 1 passed on parent f58a71b (scratch worktree, same file copied in) = red-first. Mutants, each applied to this tree and reverted: price the in-flight pass from extend_range.end -> 2 red (D1); neutralise the ARM DEFERRED block -> 1 red (D2a); restore the unconditional park in _pp_flip_hold_slot -> 3 red (D2b). All three died. test_pp_flip_slot_hold_631.py: the drained-ring pin is NARROWED, not withdrawn (its docstring says why) and gains the release companion test_does_not_hold_while_a_launched_passs_frame_is_stashed. Touched test files, fixed vs parent: 54 failed / 152 passed vs 54 failed / 151 passed, comm diff EMPTY both directions. test/registered/unit/managers bounded once each: fixed 247 failed / 4684 passed / 5 errors, parent 246 failed / 4670 passed / 5 errors; comm names exactly one extra failure, test_load_snapshot_backends.py::TestZmqRoundTrip ::test_read_returns_latest, which passes SOLO on BOTH trees = the sgl-project#899 box -timing class, not this diff. The 5 collection errors are the pre-existing sgl-project#1044 import-broken *_631 modules on both sides. ruff on the touched files: 104 errors before, 104 after.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Sep 3, 2026
…the stashed-frame budget is keyed to the frame and counts arrivals at its own slot Both reviewer BLOCKERS fixed at their root, not at the symptom. BLOCKER A -- the launched-pass set survived the ring rebuild. `_pp_launched_pending` is ring-scoped bookkeeping (slot numbers of the ring that launched them), but `pp_flip_forget_ring_scoped_slots` -- the function whose own sgl-project#829 docstring claims to own exactly that class -- did not clear it. A retraction rebuilds the ring, `arm()`'s quiescence precondition then reads a slot from the DEAD ring and defers for ever: the TP-sticky shape the reviewer named. Fix is one statement in the designated authority, and it CLEARS rather than intersects with `range(pp_loop_size)` -- the ring is rebuilt EMPTY two statements after the call, so an in-range survivor would be exactly as wrong as an out-of-range one. BLOCKER B -- the stashed-frame budget could stop the group falsely. The counter was neither keyed to a frame nor to an armed window, and counted loop VISITS. Three corrections, each with its own test: (a) keyed to (arm epoch, frame stamp) -- back-to-back frames each get their own budget instead of summing into a false STOP, and a disarm cannot leave a count for the next window. Every early return of `_pp_flip_hold_slot` now forgets the window through `_1173_forget_stashed_frame`; in the TP phase the bound is 4, so a single inherited visit changes the verdict. (b) a visit counts only when the loop ARRIVES AT THE SLOT THE FRAME NAMES. That is what the STOP claims -- "the receive kept getting the chance and still did not take it" -- and it is the only form that is reachable on the TP ring: `pp_loop_size` is 1 there, `mb_id` is 0 on every iteration and never CHANGES, so an mb_id-change detector would have been structurally unfireable exactly where the bound is smallest. Own mutant M6 proves it. (c) unreadable live slot or unreadable frame slot => the budget does not advance at all. An instrument that cannot measure the chance it counts must never fire a group stop. Arm side: the deferral was unbounded and its warning unrated. It is now bounded on FORWARD PROGRESS -- a frozen (outstanding slots, fwd_ct) for longer than `launched_pass_stall_s` (default 120 s) escalates to the same named STOP, ring progress restarts the clock. Bounding on deferral COUNT was rejected: `arm()` is driven from the receive poll, so a count bound fires at a rate set by client traffic. The ARM DEFERRED warning is rate-limited like the sibling sgl-project#1020 guard (<=3 or every 512) and carries `deferrals=` and `streak=` so a suppressed gap stays readable. Non-blocking items taken: N4 (the reported `queue=` term is the same reading the verdict used, not a re-derivation), N5 (the sgl-project#731 argument restated for all three in-flight pairs at the loop), N8 (`pending_prefill_terms` declared rank-DIVERGENT by construction -- weg1b4 measured 5739 on PP0 vs 3827 on PP1 -- reporting only, no cross-rank ballot), N9 (the in-flight billing test now uses a request whose `extend_range.end` is below its total, so removing the resident dedup guard actually changes the number). EVIDENCE red-first, reviewed HEAD c32eac6 (test file copied into a scratch worktree): 16 failed / 8 passed of 24. 13 are blocker-targeted; 3 are collateral (the file now passes `launched_pass_stall_s` to the runtime constructor, which does not exist there) -- named, not hidden. fixed tree: 24 passed. mutants, all against the fixed tree, all DEAD: M1 launched-set clear removed -> 2 failed M2 count every visit, not arrivals -> 1 failed M3 frame identity dropped from the key -> 1 failed M4 arm-side escalation neutralised -> 1 failed M5 early returns no longer forget -> 1 failed M6 mb_id-change detector instead of arrival-> 2 failed M7 stall clock never restarts on progress -> 1 failed M3 and M5 SURVIVED a first round and drove two of the corrections above -- recorded, not quietly re-run. sibling test_pp_flip_slot_hold_631.py: 8 failed / 11 passed on both the reviewed HEAD and the fixed tree (its stand-in now binds `_1173_forget_stashed_frame`; without that it was 15 failed). ruff check parity over python/sglang/srt/managers/ + test/registered/unit/managers/: 466 == 466 errors on both trees (all pre-existing); ruff format: the three production files were already dirty on the parent, both new test additions are formatted. matched check (D1) re-run on the fixed tree: the three tests of TestTheDrainedPremiseCountsLaunchedWork pass -- an empty waiting_queue with chunked remainder 1912 and a launched slot reads pending == 1912, not 0. Its mutant M-D1 (drop the in-flight remainder term at scheduler.py `pending += inflight_tokens`) turns exactly those assertions red: 2 failed / 22 passed. Tree restored and re-verified byte-identical afterwards. bounded suite, test/registered/unit/managers, -n 8, one run each: parent scratch c32eac6: 263 failed / 4678 passed / 18 skipped / 12 errors / 565 subtests passed (568.75 s) fixed tree: 248 failed / 4693 passed / 18 skipped / 12 errors / 565 subtests passed (573.82 s) comm of the sorted FAILED/ERROR node-id sets: 16 names cured (all of them the red-first test_arm_quiescence_1173.py cases -- the count matches the red-first tally exactly), and ONE name appears only on the fixed side: test_pp_proxy_readiness_contract_789.py::PPProxyReadinessContract789 ::test_shipped_gate_raises_named_diagnostic_instead_of_wedging That is NOT a regression and was verified, not assumed: run solo, that test PASSES on the fixed tree while a DIFFERENT member of the same file fails -- and the parent scratch produces the identical solo result (1 failed / 3 passed, same member). The failing member of that module wanders between runs; this diff touches neither the module nor its production file. Known sgl-project#899/sgl-project#895 PP-proxy family (NOT_CROWDING_PROVABLE). DEVIATIONS N2 is implemented here, not deferred as the earlier report said. N3 (drain-and-flip queue axis) stays open by design; N6 (D2b is a rank-local refinement of a rank-local predicate) and N7 (two authorities for one notion: `_inflight_ids` slot occupancy vs `_pp_launched_pending` launch bookkeeping) stand as named residue. N11: the earlier report's red-first arithmetic was wrong and is re-measured above. N12: the follower-side raise is rank-local by construction and its message now says what it counted. No boot. Desk only.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Sep 3, 2026
…follower speaks before it can be stuck
boot_855_weg1b5_cd5bb69607_0903_115008, rid 0c34259f, 11:55:13-11:55:30.
All three ranks issued the same re-admission prefetch (gen 4, keys=13224,
byte-identical FETCH CAP lines). PP0's completed in ~3 s, printed
completed_synced=12288, and ADMITted prefix_lens=12288. PP1's and PP2's had
not terminated. PP1 took the forwarded row into execute_scheduled_prefix and
raised the designed group STOP 14 s later. The number PP0 admitted on was
rank-local by construction: the MIN reduce behind "completed_synced" runs
only under tp_world_size > 1, and this boot is --tp-size 1 --pp-size 3 --
attn_reduce_world=1 on 307/307 HICACHE-ROUND lines of the whole log.
E1 managers/pp_prefetch_completion.py (new, pure, no I/O, no clock) plus a
per-rid completion carrier on the sgl-project#791 ring lap, modelled exactly on
sgl-project#968's parked-continuation table (stamp on the way up, absorb at PP0).
No new all_reduce, no new message, no new blocking point on the
admission path -- the PP0-authority order records a collective there as
fatal. PP0 admits only when the group floor covers what it wants to
schedule; a peer that is silent or still running contributes NO NUMBER
(INCOMPLETE, never a zero), otherwise the rid is DEFERRED by name while
other work proceeds. When the same length-priced bound the follower's
own wait uses expires, PP0 CLAMPS to the group floor through the
existing sgl-project#1059 note_observed_coverage channel instead of over-telling.
want <= 0 (no store span) admits unconditionally, so a boot with no
storage hit takes exactly the pre-sgl-project#1175 path. Kill switch
SGLANG_PP_GROUP_COMPLETION=0 restores the old admission for an A/B.
completed_synced now prints synced=yes|no and attn_reduce_world=N beside
itself, so the field can no longer claim a sync it did not do.
E2 pp_admission_congruence.execute_scheduled_prefix now DRIVES the writer it
used to suspend: after each poll it calls check_prefetch_progress when
the tree reports that path collective-free (world 1 = every all_reduce
skipped by construction), and the expiry text carries
prefetch_driven_in_loop=<bool> so an expiry can never be read as "the
bytes were not there" when nothing drove the sole writer. Bounds
unchanged. The sgl-project#1157 reaper's comment now states where it structurally
cannot fire (it reports terminations; a prefetch that never terminates
produces no line, so 0 REAPED is not evidence that nothing was reaped).
E3 Every follower prints one bounded "sgl-project#1175 PREFIX-EXEC UNDER-COVERAGE"
line at ENTRY, before any bound can expire, naming rid/local/scheduled/
deficit/bound. PP2 printed nothing at all about this rid and its silence
was indistinguishable from health. The line also states honestly that a
rank which never RECEIVES a decision row never calls this function and
therefore still emits nothing -- that case is what E1+E2 remove.
E4 (a) the healthy local == scheduled path no longer returns silently: one
bounded, counted "sgl-project#968 PREFIX-EXEC no-op" line, so "0 materialised lines
on the whole boot" reads as "never needed" rather than "never reached"
(INDIKATOR-GESETZ). (b) the sgl-project#939 census line now names its population
(population=retract_closure_only) -- SEAM_READMIT_ATTR is stamped only
by the retract closure, so the two 13225-token queue-occupant
re-admissions of this boot produced not one census line. The field is
placed BEFORE fence_proceeds so sgl-project#1068's tail pin still holds.
EVIDENCE (DESK-PROVEN; no boot, no GPU)
red-first, parent cd5bb69 + only the three new test files:
16 failed, 3 passed, 1 collection error (pp_prefetch_completion absent)
fixed tree: 36 passed (25 managers + 11 mem_cache)
mutants: 12/12 killed, >= 3 per decision (E1 x4, E2 x3, E3 x3, E4 x2)
matched checks re-run on the fixed tree: test_pp_admission_congruence_791,
test_968_starvation_umbau, test_968_deletion_falsifiers,
test_producer_phase_census_631, test_double_prefill_census_fence_1068,
test_producer_phase_census_wiring_1061 -> 114 passed, 1 failed
(test_the_module_imports_no_torch_at_all -- identical failure on the
parent, "import torch" count 1 on both trees: pre-existing)
bounded suite once, -n 8, hermetic, managers + touched mem_cache files:
parent 262 failed / 5435 passed / 12 errors
fixed 286 failed / 5472 passed / 12 errors
name-level comm: 35 "regressions" and 11 "cures", ALL of them inside
test_unified_radix_cache_unittest.py; 0 outside it, 0 involving the new
files. That module run SOLO and SERIAL is 642 passed / 860 skipped /
0 failed on BOTH trees -- the delta is the known -n 8 crowding family
(sgl-project#862/sgl-project#899), not this diff.
ruff --select=F401,F821,UP037: 2 errors on both trees, the same two
pre-existing ones; black/isort per file identical on both trees for all
five touched production files, all four new files clean.
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.
Fix issue related to FastAPI update