Repository navigation
Fix hang when doing s += None. - #1297
Merged
Merged
Conversation
timethink
pushed a commit
to timethink/sglang
that referenced
this pull request
Mar 9, 2025
Co-authored-by: max99x <[email protected]>
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Sep 9, 2026
… above every branch of `span` Boot weg2dec2 (9b40973) died in group D's decode CUDA-graph capture with `RecursionError: maximum recursion depth exceeded`, `parallel_state.py:1444 return self.all_reduce(input_)` repeated 2966 times (gpu-arb/weg2/BOOT_weg2dec2_0909.md). Root, confirmed at file:line: collective_clock.py:401 return self._slot is not None or self._capture is not None parallel_state.py:1438 if _COLLECTIVE_CLOCK.armed: parallel_state.py:1443 with _COLLECTIVE_CLOCK.span(...): parallel_state.py:1444 return self.all_reduce(input_) The dispatch sites do not merely GATE on `armed`, they RE-ENTER THEMSELVES inside the span and rely on it being false the second time, so the body runs once. 994f0b5 (#1241b, not 6146974 as the boot record reads -- same series, wrong commit) widened `armed` from `_slot is not None` to the OR of two fields, while `span` kept FOUR separate narrower disarms: * capture branch cleared `_capture` only -> `_slot` kept `armed` true * slot path cleared `_slot` only -> `_capture` kept `armed` true * `graph_capture_skipped` early return -> cleared NOTHING * `slot is None` early return -> cleared NOTHING Four reachable (scope x capturing x slot) states therefore never went disarmed and recursed until the stack ended. The widened `armed` is an OR; the disarms were not. The two early returns were correct before #1241b, because `armed` could not be true from `_capture`. FIX: hoist ONE disarm of BOTH fields above every branch, restore both in one `finally`. No new flag and no new field -- the disarm is now EQUAL to `armed` by construction rather than by four correct recollections, and a third scope has to be added in one place instead of remembered in four. `armed`'s docstring states that contract so the next widening carries it. The non-capturing paths are unchanged in behaviour: on them `_capture` is already None, so clearing and restoring it is a no-op, and the slot path acquires the same events, appends the same (start, end, family), and touches the same counters in the same order. RED-FIRST, hermetic, no CUDA (`ClockBackend` fake, `is_capturing()` True). Every existing test in the file calls `span` DIRECTLY; none models the dispatch site's re-entry, which is exactly why the suite was green on the commit that died. `ReentrantDispatch` models parallel_state.py:1438-1444 with no depth cap, so the defect's signature stays `RecursionError`. TALLIES (remote desk cachyllama, junit-authoritative, -n 8 -p no:randomly; local box unavailable: gpuq booking y9jyp8 owner kvtail2 running on 0,1,2): parent 9b40973 + tests only (ce8393f531): tests=1439 failures=32 errors=0 fixed (1627ba11aa): tests=1439 failures=27 errors=0 NEW failures 0; the 5 that flipped are exactly the new ones; identical 1359-node set both runs. 27 pre-existing failures unchanged (9 in test_collective_census_broadcast_families_583, 18 across six weg2 files). Red shape on the parent: 4x RecursionError + 1x `armed` still true inside the span. Files: test_decode_graph_event_nodes_1241b, test_decode_round_clock_1241, test_collective_census_broadcast_families_583, test_pp_bubble_1236, test_rank_prefill_log, test_kvso_tick_graph_614, test/registered/unit/weg2/ MUTANTS, all on the danger direction, all red: M1 early return re-arms the slot (its pre-sgl-project#1297 disarm dropped) -> 1 failure M2 `_capture` dropped from the hoisted disarm -> 6 failures M3 `armed` reads `_capture` only, `_slot` stays live -> 4 failures ruff check clean on both files; ruff format reports 0 hunks in the added lines (the 3 + 4 hunks it does report are byte-identical on 9b40973). UNPROVEN: no boot. This is DESK-PROVEN only -- the recursion is reproduced and closed hermetically, but group D has not reached READY on metal since.
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.
Motivation
SGLang will terminate the worker thread if you append a
Noneto aProgramStatebecauseNoneis used as a sentinel to signal the executor to terminate. This results in the program silently hanging when anything that waits on the worker is read from the state.Repro script:
Modifications
Adding
Noneto aProgramStatewill now raise aValueError.Checklist