Repository navigation
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 25, 2026
…an produce
`bundle_is_mid_flight()` asks "has this phase's decode bundle had a fair
share of steps yet" and answers from `decode_steps_this_phase`. That counter
has exactly one producer -- the decode forward funnel in `run_batch`, under
`batch.forward_mode.is_decode()` -- and is reset to 0 at every cutover
("#861i: the step budget is PER PHASE"). Under strict purity decode is
FORBIDDEN in the PP layout (`PhasePurity.decode_allowed_in_pp` -> False).
So across the whole PP phase the counter is 0 BY CONSTRUCTION, never because
a bundle is young -- which is the only thing the floor can read it as. The
predicate degenerates there to `running_bs > 0`: permanently True whenever
any resident exists, and unable to become False through progress, because the
progress it waits for is the one kind of work that layout may not do.
Three call sites down, that is a disarmed guard:
bundle_is_mid_flight() -> True in PP whenever running_bs > 0
demand_prefill_tokens() -> short-circuits to 0
_strict_holds_pp -> False, so the DRAINED arm runs unguarded
`_strict_holds_pp` is #861d-2's, and its own comment states the property it
exists to provide: "the SAME single read as the tp->pp arm, so the two
directions cannot disagree about whether work exists". It provided that in TP
and merely asserted it in PP.
THE CLASS: a predicate evaluated in BOTH phases whose governing input can only
be PRODUCED in one of them is not a measurement in the other -- it is a
constant wearing a measurement's name, and every guard keyed on it is silently
disarmed in exactly that phase. #861e counted retracted requests as decode
work and deadlocked W37-E; #861f replaced the measure with a step count;
#861i found the step count had no producer and wired one. Three fixes to one
term, each closing an axis, none asking in WHICH PHASE the producer can run.
Keyed on the purity authority (`decode_allowed_in_pp`), not on the phase name:
the phase name would have been a fourth instance of the same sort, and it
would have broken the relaxed-purity mode where PP legitimately does decode.
`decode_blocked_here` is deliberately NOT used despite being the scheduler
phrasing of this question -- it advances the decode-starvation clock as a side
effect, and an input probe that moves a clock makes the snapshot the cause of
the state it reports.
The new field defaults True, so every stand-in and every deployment without
phase purity is bit-for-bit unaffected -- and correct, since without purity
decode runs in whatever layout is up.
TEST RESULTS
test_phase_axis_869.py (new): 14 passed with the fix. With the two fix lines
removed, 5 fail -- including the acceptance `test_the_drained_arm_is_guarded_
again_in_pp` -- so the guard really was disarmed on this tree. Falsification
run done before claiming the pass; count gate held (5 extracted FAILED names
== 5 in the summary).
Full managers suite, run form `-n 8 --dist loadfile`, hermetic (CUDA_VISIBLE_
DEVICES verified empty at the PROCESS on all 9 pids, not at the command):
18 failed / 4354 passed / 18 skipped in 290 s. Count gate held (18 == 18).
The 15 standing hermetic artifacts are present exactly: test_arena_high_
water_631 (7), test_restore_never_rebuild_677 (4), test_phase_flip_rotation_
wiring_809 (4) -- the three modules that need a card and fail under CVD="".
The three beyond them -- test_pp_void_send_contract_801, test_pp_flip_
leftover_proxy_757, test_pp_admission_wraparound_never_blocks -- ALL PASS
serially in isolation on a quiet box (20 passed, 99 s). They carry
load-sensitive deadline asserts and this run drove the box to load 81.
CAVEAT, stated rather than smoothed over: `-n 8 --dist loadfile` is not yet an
approved gate form for this suite, so 18 is NOT directly comparable to the
serial baseline of 15. A serial full run is still owed.
Lint: ruff clean on phase_policy.py and the new test; scheduler.py reads 102
errors before and after this change, i.e. zero added.
NOT CLAIMED: no metal run. This commit is desk-proven only.
MEASUREMENT THIS SUPERSEDES, because it was the premise for the whole night:
"COMPLETIONS 0" on boot_w41_ctrl_0825_2214.log is wrong -- that log holds 25
`"POST /v1/chat/completions HTTP/1.1" 200 OK`, the liveness monitor recorded a
real generation from it at 22:24:01Z, and a live probe at 22:43:16 returned 16
tokens. "189 prefill vs 6 decode batches" is wrong-scale, not incomplete:
`decode_log_interval` defaults to 40, so a "Decode batch" line is 1-in-40
while "Prefill batch" is per batch. There was no livelock. Flips per completed
request on that log, counted at HTTP 200, is 1.46 -- a real cost, not a wedge.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 26, 2026
Two subtractions, one justification, only one of them checked:
scheduler.py `_pending_now -= _seam_transport_now` UNCONDITIONAL
scheduler.py `_seam_serviceable_now = ...` gated on the TP phase
AND on
seam_transport_premise_holds
Both rest on the same claim -- that a seam re-admission is cheap flip transport
rather than real workload, because "their prefixes are served by read-through
from the canonical store". #861j verified that claim for the EXISTENCE term and
never backported the verification to the ECONOMICS term twelve lines above it.
WHEN THE PREMISE IS FALSE those tokens are not transport at all: they are a full
cold prefill of real work, and deducting them tells the policy that work does
not exist. The consumer that pays is the one arm still reading RAW pending --
the sgl-project#677(a) blocked-admission stall escape, whose threshold is
`pending > pp_exit_tokens`. A deflated pending holds a genuine stall below its
own escape, which is the wedge that escape was written to end. Delayed escape,
not a wrong answer: `demand_prefill_tokens()` takes
max(pending, admissible - serviceable) and `admissible_prefill_tokens` is not
reduced by seam transport, so with sgl-project#869 landed `_strict_holds_pp` still sees the
true backlog.
VARIANT (a) OF THE TWO I FILED, chosen because it makes the two subtractions ONE
RULE rather than removing the last raw-pending consumer and leaving the pair
disagreeing. `seam_transport_deduction` is pure and total, so both directions
are falsifiable without a scheduler, and the premise is now asked ONCE per round
and read by both terms -- one predicate, one clock, per that function's own
contract. Asking twice was its own latent defect: the debt clock can lapse
between two calls in the same round.
NOT A DISARM. A verified premise in the TP phase still deducts exactly as
before, which is the #861j/W32 behaviour where it was actually earned. The test
pins that direction too.
CLASS: a subtraction justified by a premise that is never checked -- the same
family as sgl-project#869 (a predicate that does not measure what it claims), different
root. Sibling of, not instance of.
TEST RESULTS
test_seam_transport_premise_869c.py (new): 11 passed.
FALSIFIED IN BOTH DIRECTIONS BEFORE THE GREEN WAS CLAIMED, count gate on each:
fix reverted (deduct unconditionally = today's tree) -> 7 failed, INCLUDING
the specified falsifier test_the_stall_escape_arms_on_the_true_backlog.
7 extracted == 7 in summary.
over-fixed (never deduct, blanket disarm) -> 3 failed, including
test_a_verified_premise_in_tp_still_deducts. 3 == 3.
restored -> 11 passed.
Regression set, 59 files (purity, policy, seam, transport, sgl-project#677, sgl-project#713, sgl-project#861,
sgl-project#871, #869c): 895 passed, 4 failed, 123 subtests passed. Count gate 4 extracted
== 4. All four are test_restore_never_rebuild_677, one of the three standing
card-needing modules whose hermetic count is exactly 4. No new failures.
Hermetic: CUDA_VISIBLE_DEVICES verified EMPTY at the PROCESS (/proc/<pid>/environ).
Lint: ruff 0 before and after on phase_purity.py; scheduler.py 102 before AND
after (pre-existing); new test 0. codespell clean.
Non-flip and non-seam paths are byte-identical: with no stamped re-admissions
`_seam_transport_now` is 0, and the deduction is 0 under every gate combination.
TWO BUGS IN MY OWN TEST, found by running it and reported rather than quietly
fixed. The first draft left the hand-set `pp_window_s` stopwatch enabled, so the
deflated specimen still armed -- for a different reason -- and the test would
have passed without the escape ever being consulted; it now sets pp_window_s=0
and decode_stall_slo_s=0 to isolate the sgl-project#677(a) arm. The second asserted on the
substring "stall" in the reason string, which matched
SGLANG_PHASE_POLICY_DECODE_STALL_SLO_S in an unrelated suggestion line; it now
asserts on the verdict. Same substring-matching family as the ^FAILED trap.
NOT CLAIMED: no metal run. Desk-proven only. The sgl-project#857 acceptance instance was
left running and untouched throughout.
shiyu7
pushed a commit
to shiyu7/sglang
that referenced
this pull request
Nov 9, 2026
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.
No description provided.