Repository navigation
misc: recommend to use chat model for benchmark - #690
Merged
Merged
Conversation
timethink
pushed a commit
to timethink/sglang
that referenced
this pull request
Mar 9, 2025
cen121212
pushed a commit
to cen121212/sglang
that referenced
this pull request
Nov 10, 2025
* migrate daily build and pr * Update daily-build-test-npu-innersource.yml * Update pr-test-npu.yml * Create pr-test-npu-debug.yml * Update pr-test-npu-debug.yml * Update pr-test-npu.yml * Update pr-test-npu-innersource.yml * Update daily-build-test-npu-innersource.yml * migrate daily build and pr * Update npu_ci_install_dependency.sh * Create pyproject_npu.toml * Update npu_ci_install_dependency.sh * Update pr-test-npu-debug.yml * Update pr-test-npu-innersource.yml * Delete python/pyproject_npu.toml * Update pyproject_other.toml * Update nightly-test.yml * Update daily-build-test-npu-innersource.yml * Update npu_ci_install_dependency.sh * debug testcase
cherryblo
added a commit
to cherryblo/sglang-project
that referenced
this pull request
Jul 2, 2026
fix nightly-test-npu
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…requests hung LIVE, 2026-08-16 08:03, and my own sgl-project#687 fix caused it. An 18-token request hung for two minutes with all three GPUs at 0% while the policy logged, every ten seconds: holding in tp: pending prefill 18 tok <= N=7004, running it in tp (pending prefill 18 tok, running bs 0) THE POLICY WAS RIGHT AND THE SUPPRESSION OVERRODE IT. Below the break-even N a flip costs more than it saves, so the policy deliberately keeps the work in the TP layout and arms no flip at all. The purity valve cannot rescue that case: the flip is not FAILING, it was never asked for, so `flip_unavailable` is false and drain mode held a request that nothing was ever going to run. EVERY METAL PROOF SO FAR HID IT. The 4-carrier runs use 25625-token prompts, which sit far above N=7004 and therefore go to PP and prefill there. Short requests -- the common case on this box -- could not be served at all under drain mode. A 12-token smoke request is what found it, which is the argument for keeping one in the loop next to the heavy load. THE RULE. Drain mode exists to stop a TP window admitting the work it was entered to escape, and that window is defined by A DECODE BUNDLE IN FLIGHT. With `running_bs == 0` the bundle is finished, there is nothing left to drain, and the only thing suppression can still do is idle the instance. So suppression now requires a running bundle. -1 IS NOT ZERO. An unmeasured count must never be read as "no bundle", or the contract quietly stops applying wherever a call site forgets to pass it. The scheduler passes `len(running_batch.reqs)`; the default of -1 keeps the contract. THE CALL SITE, FOR THE FOURTH TIME IN THIS CHAIN. A condition the hook is never told about is a condition that never fires -- after the `phase_policy_config` attribute name, the env knob, and the refusal count. Pinned by source assertions on both the scheduler's call and the hook's forward, not just on the predicate. TESTS: 5 new cases (a running bundle is still protected, an empty one suppresses nothing, -1 is not read as empty, and both ends of the wiring), 983 across every corridor / phase / purity / seam / margin / kv_backing suite.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…requests hung LIVE, 2026-08-16 08:03, and my own sgl-project#687 fix caused it. An 18-token request hung for two minutes with all three GPUs at 0% while the policy logged, every ten seconds: holding in tp: pending prefill 18 tok <= N=7004, running it in tp (pending prefill 18 tok, running bs 0) THE POLICY WAS RIGHT AND THE SUPPRESSION OVERRODE IT. Below the break-even N a flip costs more than it saves, so the policy deliberately keeps the work in the TP layout and arms no flip at all. The purity valve cannot rescue that case: the flip is not FAILING, it was never asked for, so `flip_unavailable` is false and drain mode held a request that nothing was ever going to run. EVERY METAL PROOF SO FAR HID IT. The 4-carrier runs use 25625-token prompts, which sit far above N=7004 and therefore go to PP and prefill there. Short requests -- the common case on this box -- could not be served at all under drain mode. A 12-token smoke request is what found it, which is the argument for keeping one in the loop next to the heavy load. THE RULE. Drain mode exists to stop a TP window admitting the work it was entered to escape, and that window is defined by A DECODE BUNDLE IN FLIGHT. With `running_bs == 0` the bundle is finished, there is nothing left to drain, and the only thing suppression can still do is idle the instance. So suppression now requires a running bundle. -1 IS NOT ZERO. An unmeasured count must never be read as "no bundle", or the contract quietly stops applying wherever a call site forgets to pass it. The scheduler passes `len(running_batch.reqs)`; the default of -1 keeps the contract. THE CALL SITE, FOR THE FOURTH TIME IN THIS CHAIN. A condition the hook is never told about is a condition that never fires -- after the `phase_policy_config` attribute name, the env knob, and the refusal count. Pinned by source assertions on both the scheduler's call and the hook's forward, not just on the predicate. TESTS: 5 new cases (a running bundle is still protected, an empty one suppresses nothing, -1 is not read as empty, and both ends of the wiring), 983 across every corridor / phase / purity / seam / margin / kv_backing suite.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…mall flip and unmeasured
THE MEASUREMENT, from 291 same-regime PHASE-FLIP DONE lines (and 3955 unique
across all logs). The part NOT covered by read+exchange+write is:
123 live slots total 2453 ms unaccounted 1999 ms 81 %
440095 live slots total 4290 ms unaccounted 2287 ms 53 %
FLAT at 2.0-2.35 s across a 3600x range of occupancy (123 -> 440095 live slots,
708 -> 3.4M cells). Regressed: unaccounted ~ live slots has slope 0.0005 ms/slot
and R2 0.255 -- i.e. it barely correlates with size at all, which is what makes
it a fixed cost rather than a small-flip artefact. Total ~ live slots gives
intercept 2754 ms, R2 0.871.
So the fixed cost, not the movement, is what floors every window sgl-project#677's
economics can solve, and it is the term sgl-project#692 must price depth against.
WHERE IT WAS HIDING, and I had it wrong first. My initial reading blamed the
per-wave backing swap (release_wave/restore_wave). It is NOT the residual:
`t_write0` is taken BEFORE those calls and `write_ms` accumulates after them,
so the backing swap has been inside `write_ms` all along. Reading the timer
placement rather than the call order is what corrected it.
The three timers cover the WAVE LOOP ONLY. What fell outside is the tail:
_pool_census("pre-cutover") phase_flip_runtime.py:6538
for fn in self._pre_cutover_fns: fn(...) :6539-6544 EXTRA MOVERS --
the weights arena refill and
the GDN state leg
_cutover_fn(direction) :6545 the group step
_pool_census("post-cutover") :6547
THE MOVERS ARE OCCUPANCY-INDEPENDENT BY CONSTRUCTION -- the weights arena
refill is the same bytes whatever the KV live set holds -- which is the leading
explanation for a residual that does not move with occupancy. That is a
hypothesis this commit makes MEASURABLE rather than one it asserts.
SO THE TAIL IS TIMED, split movers vs cutover because they have different
fixes, and both are reported on the DONE line and in `last_stats`. A residual
that has to be regressed across boots cannot be priced per flip; a reported
number can, and sgl-project#677/sgl-project#692 both need it per flip.
WHAT THIS COMMIT DOES NOT DO. It does not reduce the cost. The reduction
candidate is the wave count -- `_flip_waves` (:4024) is "A PURE FUNCTION OF THE
REPLICATED LAYER MAP AND THE DIRECTION", so W=16 is paid at 123 live slots
exactly as at 440095, even though the staging transient waves exist to bound is
trivial there. The module's own docstring already pre-authorises the landing
spot: "each extra wave costs one more exchange round trip. If a measurement
ever shows the round trips dominating, W=8 is the place to stand, not W=1"
(:4083-4089).
That A/B needs NO code: `SGLANG_FLIP_SEAM_WAVES` (:2568) already overrides W.
It is left unshipped deliberately -- lowering W trades ms for staging MiB,
which lands on the arming floor and the corridor, and sgl-project#602 showed that budget
is regime-dependent. Hard-coding a policy from one regime's numbers is the
mistake that ticket already made once.
HONEST LIMIT ON THE PER-WAVE TERM. Fitting unaccounted = a + b*W across the
W=4 and W=16 populations gives b ~ 66 ms/wave, a ~ 997 ms. That fit is
CONFOUNDED: the W=4 samples are release-first and the W=16 samples
restore-first, so it mixes wave count with regime and must not be quoted as a
per-wave price. The clean number will come from the env A/B above, within one
regime -- which is exactly what the new movers/cutover fields will report.
TESTS. 9 cases, source-level because the alternative is driving a full flip:
the movers clock opening before the pre-cutover census and closing after the
mover loop; the cutover clock wrapping the cutover; the three original timers
untouched; both fields in `last_stats` and in the DONE line. Plus an AST arity
guard on the DONE line -- specifiers counted against arguments -- because a
%-format mismatch raises at the moment the flip completes, the worst possible
place to learn it. Falsified: dropping one argument makes it report "17 format
specifiers and 16 arguments".
managers 2093 passed, 0 failed (2084 before, +9). Hermetic. NO DEPLOY.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…e two commits to hold MERGE_NOTES_602.md rewritten to cover all 18 commits: what each fixes, its test evidence, whether it touches runtime, and whether an equivalent patch is already on the serving line (verified with `git cherry`, not by message matching -- four are: c41645c, ce60358, 658ea3a, 84b0171). DRY RUN: clean. Merged into `integration/r2` -- the live line, since the serving tree descends from its tip a73a0d8 -- in a throwaway worktree, `--no-commit --no-ff`, then aborted and the worktree dropped. Zero conflicts, zero unmerged paths, so nothing was pre-resolved because nothing needed it. Verified semantically as well as textually: on the MERGED tree, managers 2093 passed / 0 failed and planner 2574 passed / 2 failed, the two being the same pre-existing test_rejected_evidence_pins pair that is already red on the base. THE FACT THE OPERATOR NEEDS, and it is not in the commit count: `7936bc4850` is NOT an ancestor of integration/r2, so merging this branch drags in its whole base lineage -- 115 commits, of which 18 are mine and 97 are the hotfix/677 work (sgl-project#662 x20, [PhasePolicy] x18, sgl-project#677 x8, sgl-project#678 x7, sgl-project#679 x6, ...), 129 files, +22731/-762. Approving this merge is approving that lineage, most of which is not mine to vouch for. If only this work is wanted it must be cherry-picked rather than merged. NOT ATOMIC, and it splits cleanly into four groups with an order: (1) the four already on serving -- merging them only reconciles integration with what is already running; (2) the three sgl-project#624 test-only drift guards, which take managers from 4 failures to 0 and should land early so the line stays green during review; (3) desk tool + docs, all planner/pp_cut.py and markdown, imported by no serving path; (4) hold. HOLD, two commits, both runtime and neither on the serving line: * e21e87f (sgl-project#690) touches the seam hot path and changes the PHASE-FLIP DONE format. Already queued to land on deploy WITH the W=8/W=4 probe after the sgl-project#694 soak verdict; merging it into integration first puts it in front of the soak meant to measure it. * 5301b94 (sgl-project#685) touches the boot sizing path. Announce-only today and abstention-guarded, but unsoaked, and the R' decision it waits on is not made. Nothing else in the chain can move serving behaviour. Docs only; no merge performed, no deploy, scratch worktree removed.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
… dry run, and the vouch The notes were written at 3c984ad and had gone stale in three ways. Chain: 18 commits at e21e87f -> 22 at 5939d0e. Added sgl-project#697 (8fb86ef), sgl-project#441 (5e0fa1e), sgl-project#524 (5939d0e) and the revision-1 docs commit. Runtime-touching is now 8 of 22, and sgl-project#441 is recorded as NOT runtime despite its ticket -- it adds a handover script and one test guard. Target: integration/r2 has moved a73a0d8 -> a157bf1, so the dry run was re-run rather than carried over. Still zero conflicts. Scope shrank with the target's advance: 115 -> 109 commits, 129 -> 124 files, +22731 -> +22196. Merged-tree tests: managers 2093 passed / 0 failed; planner plus the three new test files 2594 passed / 2 failed. Those 2 are PpWithSpecEvidenceTest in test_rejected_evidence_pins.py and were re-verified as pre-existing by aborting the merge and running that file on clean a157bf1 -- same 2 failed, 2 passed. The chain introduces no new failure. Because the target tip moved, this was re-checked instead of quoting revision 1's finding. Holds: sgl-project#690 (e21e87f) and sgl-project#697 (8fb86ef) are in F4-r4's bundle, so revision 1's objection to landing sgl-project#690 ahead of the sgl-project#694 soak is spent; both lift to group 1 on his boot commit. sgl-project#524 (5939d0e) joins the hold list -- desk-verified only, never on metal, A/B window-gated. sgl-project#685 (5301b94) stays held on the unmade R' decision. Vouch (new section 5): the four F4-r4 cherry-picks are byte-identical to the originals by git patch-id --stable -- f630947/c41645c8c9, 7c58aba/ce6035884d, f1f31d2/658ea3ac11, de92bb6/84b0171fa6 -- so preferring the originals is free and the only real risk is double attribution. 1073702 is excluded: patch-id 8595e66885ac matches nothing here, it is diagnostic scaffolding and not mine to vouch for. Section 6 records that 5af1531 (sgl-project#696) and c738ef5 (sgl-project#689) are F4-r4's line, not this branch, and are listed only because they lift holds; sgl-project#696 is what was DoSing the lanes. Docs only. No merge performed; the dry-run worktree was removed.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…mall flip and unmeasured
THE MEASUREMENT, from 291 same-regime PHASE-FLIP DONE lines (and 3955 unique
across all logs). The part NOT covered by read+exchange+write is:
123 live slots total 2453 ms unaccounted 1999 ms 81 %
440095 live slots total 4290 ms unaccounted 2287 ms 53 %
FLAT at 2.0-2.35 s across a 3600x range of occupancy (123 -> 440095 live slots,
708 -> 3.4M cells). Regressed: unaccounted ~ live slots has slope 0.0005 ms/slot
and R2 0.255 -- i.e. it barely correlates with size at all, which is what makes
it a fixed cost rather than a small-flip artefact. Total ~ live slots gives
intercept 2754 ms, R2 0.871.
So the fixed cost, not the movement, is what floors every window sgl-project#677's
economics can solve, and it is the term sgl-project#692 must price depth against.
WHERE IT WAS HIDING, and I had it wrong first. My initial reading blamed the
per-wave backing swap (release_wave/restore_wave). It is NOT the residual:
`t_write0` is taken BEFORE those calls and `write_ms` accumulates after them,
so the backing swap has been inside `write_ms` all along. Reading the timer
placement rather than the call order is what corrected it.
The three timers cover the WAVE LOOP ONLY. What fell outside is the tail:
_pool_census("pre-cutover") phase_flip_runtime.py:6538
for fn in self._pre_cutover_fns: fn(...) :6539-6544 EXTRA MOVERS --
the weights arena refill and
the GDN state leg
_cutover_fn(direction) :6545 the group step
_pool_census("post-cutover") :6547
THE MOVERS ARE OCCUPANCY-INDEPENDENT BY CONSTRUCTION -- the weights arena
refill is the same bytes whatever the KV live set holds -- which is the leading
explanation for a residual that does not move with occupancy. That is a
hypothesis this commit makes MEASURABLE rather than one it asserts.
SO THE TAIL IS TIMED, split movers vs cutover because they have different
fixes, and both are reported on the DONE line and in `last_stats`. A residual
that has to be regressed across boots cannot be priced per flip; a reported
number can, and sgl-project#677/sgl-project#692 both need it per flip.
WHAT THIS COMMIT DOES NOT DO. It does not reduce the cost. The reduction
candidate is the wave count -- `_flip_waves` (:4024) is "A PURE FUNCTION OF THE
REPLICATED LAYER MAP AND THE DIRECTION", so W=16 is paid at 123 live slots
exactly as at 440095, even though the staging transient waves exist to bound is
trivial there. The module's own docstring already pre-authorises the landing
spot: "each extra wave costs one more exchange round trip. If a measurement
ever shows the round trips dominating, W=8 is the place to stand, not W=1"
(:4083-4089).
That A/B needs NO code: `SGLANG_FLIP_SEAM_WAVES` (:2568) already overrides W.
It is left unshipped deliberately -- lowering W trades ms for staging MiB,
which lands on the arming floor and the corridor, and sgl-project#602 showed that budget
is regime-dependent. Hard-coding a policy from one regime's numbers is the
mistake that ticket already made once.
HONEST LIMIT ON THE PER-WAVE TERM. Fitting unaccounted = a + b*W across the
W=4 and W=16 populations gives b ~ 66 ms/wave, a ~ 997 ms. That fit is
CONFOUNDED: the W=4 samples are release-first and the W=16 samples
restore-first, so it mixes wave count with regime and must not be quoted as a
per-wave price. The clean number will come from the env A/B above, within one
regime -- which is exactly what the new movers/cutover fields will report.
TESTS. 9 cases, source-level because the alternative is driving a full flip:
the movers clock opening before the pre-cutover census and closing after the
mover loop; the cutover clock wrapping the cutover; the three original timers
untouched; both fields in `last_stats` and in the DONE line. Plus an AST arity
guard on the DONE line -- specifiers counted against arguments -- because a
%-format mismatch raises at the moment the flip completes, the worst possible
place to learn it. Falsified: dropping one argument makes it report "17 format
specifiers and 16 arguments".
managers 2093 passed, 0 failed (2084 before, +9). Hermetic. NO DEPLOY.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…ank0 does not have Stage 4 desk slice. Cost model first (Machbarkeit vor Messung), against census numbers rather than estimates. Two of the plan's numbers move. ## Confirmed, and corrected CONFIRMED: ~25 MiB per attention layer per 512-token chunk. From geometry: Q 6.00 + partial out 6.00 + LSE 0.047 MiB, x2 remote ranks = 24.09 MiB/layer, so 385.5 MiB per chunk across the 16 attention layers. CORRECTED: "+10-20% chunk cost" silently assumes a link rank0 does not have. The same 385.5 MiB against a 320 ms serial chunk is +10.0% at 12000 MiB/s, +20.1% at 6000, and +40.2% at 3000 -- rank0's PCIe x4 class. So on this rig it is +40% raw. The overlap argument is unchanged (48 GDN layers to hide behind) but the quantity to hide is twice what the plan assumed. STRUCTURAL FACT the estimate does not capture: traffic is driven by Q and the partial OUTPUT, not by how much KV is remote. Each remote participant receives a full Q block and returns a full-size partial output plus LSE regardless of whether it holds 1% or 99% of the shard. "Shard less aggressively to save bandwidth" therefore does not work; the only levers are the number of remote participants and chunk size relative to compute. ## The prize and the purpose contradict, quantified The phase-uniform vector is the TP vector [14,10,8] = shares .4375/.3125/.25, which puts 43.75% of all KV rows on rank0 -- the rank a deep PP cut loads with weights. Against free-for-KV measured at the [28,20,16] boot (2*K_size + available_gpu_mem = 10.01/6.19/5.74 GiB): [28,20,16] rank0 free 10.01 vs need 5.83 fits [35,14,15] 6.93 5.83 fits [38,13,13] 5.61 5.83 INFEASIBLE [42,11,11] 3.85 5.83 INFEASIBLE [44,10,10] 2.97 5.83 INFEASIBLE Depth ceiling under vector identity: n0 <= 37, solved not tabulated. So the cuts decoupling exists to unlock are exactly where the phase-uniform vector fails. At [44,10,10] the free-proportional vector is [0.135, 0.483, 0.382], nearly the INVERSE of the TP vector on rank0, because rank0 is weight-rich under a deep PP cut and weight-light under TP width-sharding. The two phases genuinely want opposite vectors. ## The prize splits in two, at different prices - STRUCTURAL uniformity (both phases token-shard the same 16 layers): solves sgl-project#703's key problem. Free. Adopted unconditionally per operator decision. - VECTOR identity (same shares): additionally deletes sgl-project#690's seam byte move. Costs depth. OPEN until slice 1a-i's timing intercept gives the flip-frequency break-even. seam_rebalance_bytes() reports them separately so they cannot be conflated: identical shares return zero, differing shares return a rebalance rather than a re-layout, i.e. the sgl-project#703 prize is retained either way. ## Free-proportional is now PRIMARY, and the vector does not follow the cut Per operator decision the mechanism is designed free-proportional-primary, with vector identity as the special case. That raises a question vector identity did not: the free vector changes with the cut, so does the share vector follow it? It must not, and it need not. Letting it follow costs 0.80-1.07 GiB of KV rebalance per rung step (3.48 GiB across the ladder) and buys nothing. One FIXED vector is feasible at every rung, moves ZERO rows on a rung change, and admits a pool above the coupled incumbent's 436,766 everywhere -- 492,393 at the shallowest rung, 718,930 at [44,10,10]. So a rung change moves neither weights (sec 3.8) nor KV rows, under the primary case as well as the special one. The vector is built from the PER-RANK MINIMUM of free memory across rungs, not from any single rung, because there is no single tightest rung: deepening starves rank0 while FREEING rank1 and rank2, so each rank's binding constraint comes from a different rung. The result is verified per rung rather than asserted -- it is the natural construction, not a theorem. ## Shared layout contract with sgl-project#706, proposed and pending DESIGN_704 sec 4.2c carries the proposed same-key contract for verbatim inclusion in both docs: a key identifies CONTENT and never placement; the host form is canonical and layout-neutral (layer-major, token, kv-head, head_dim); placement travels as a LayoutDescriptor. Sent for agreement via the coordinator, since direct addressing of the sgl-project#706 strand failed. The device-side page-layout code is HELD until he answers whether a page carries all 16 attention layers for its token range or one page per (layer, token-range) -- the latter changes his page count 16x and moves who pays the gather, so it is being matched rather than guessed. ## Test results 120 passed, hermetic (CUDA_VISIBLE_DEVICES=""), ruff clean, codespell clean. test_decoupled_kv_704b.py (16, new): the KV cell against the boot log; traffic independent of shard fraction and linear in participants; the plan's 25 MiB confirmed and its percentage shown to be link-dependent; the TP vector fitting at the incumbent and failing at [38,13,13] onward; the n0<=37 ceiling; the free-proportional arm feasible and larger; one fixed vector serving every rung with zero rebalance; the per-rung alternative costing >3 GiB; and the per-rank binding-rung inversion that forces the per-rank minimum.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…t and load A static window is wrong in both directions -- too short at high load (the backlog never clears) and too long at low load (decodes wait behind an empty prefill window). planner/phase_window.py solves it. ## The amortization argument Over a cycle C = T_p + T_d + flips*F the work arriving in C must clear in C, so T_p = rho_p*C, T_d = rho_d*C and: stability floor C >= flips*F / (1 - rho) latency ceiling C <= (budget - F) / rho_d The floor is where the backlog stops growing however the windows are split; the ceiling is the wait a request meets arriving just after the prefill window shuts. Flip overhead is flips*F/C, which FALLS as the cycle lengthens, so throughput always wants a longer window and THE ECONOMIC CHOICE IS THE LARGEST ADMISSIBLE CYCLE, floored by stability. Not a midpoint, and not a constant. ## The sharpest result, and it reprices sgl-project#690 The two constraints move in OPPOSITE directions with F: the floor rises as flips*F while the ceiling falls as -F/rho_d. A dearer flip does not merely add an overhead line -- IT CLOSES THE FEASIBLE BAND FROM BOTH ENDS, and past some F the band shuts entirely: no window length works, at any split. On this rig with a 10 s TTFT budget: F=2.0 rho=0.30 -> cycle 53.3 s, overhead 7.5% F=2.0 rho=0.50 -> cycle 32.0 s, overhead 12.5% F=3.0 rho=0.50 -> cycle 28.0 s, overhead 21.4% F=4.2 rho=0.50 -> cycle 23.2 s, overhead 36.2% any F, rho=0.80 -> REFUSED, floor above ceiling So at rho=0.8 this rig is already refused at every measured flip cost. Halving the flip cost does not halve an overhead; it REOPENS CONFIGURATIONS THAT ARE CURRENTLY IMPOSSIBLE, which is a far stronger argument for sgl-project#690 than "2-4 s is slow". ## Two refusals, because a policy that quietly does the impossible is worse - THE SEAM MUST BE ABLE TO ARM. If the layout's free column no longer clears its arming floor there is no flip to schedule at any window length. This composes directly with sgl-project#707's closed form and the n0 <= 51 depth bound it implies, and is checked BEFORE any arithmetic. - THE DECODE WINDOW MUST BE WORTH ENTERING. Batch formation (sgl-project#689) collapses toward size 1 below a queue threshold, so flipping early buys a fraction of the decode rate for a full flip cost. That is a floor on the cycle, C >= q/(lambda*rho_p), and AT LIGHT LOAD IT BINDS INSTEAD OF STABILITY -- exactly the regime where a static window over-flips. ## Discipline Every quantity injected; the rig's figures are calibration data in the test. A foreign profile (flip 0.05 s, rho 0.8, 2 s budget, 50 arrivals/s) pins the generality and lands at under 2% overhead, showing the policy is about the RATIO of flip cost to cycle rather than about this rig. 225 tests green, hermetic (CUDA_VISIBLE_DEVICES=""), ruff + codespell clean. test_phase_window_677.py (13): the window as a function of flip cost rather than a constant; the floor diverging toward saturation and refusing rho>=1 as a capacity problem; the band closing from both ends; a dear flip under load admitting NO window; the economic choice being the ceiling; overhead falling with cycle length; halving the flip cost worth more than an overhead line; the batch floor and the case where it binds instead of stability; the seam refusal; a pure-prefill regime with no ceiling; a foreign profile; malformed inputs.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…the MINORITY share The flip has been carried as a scalar (~2.0-4.2 s) with an unexplained residual. It is not a scalar: the runtime already reports a five-way split on every completed flip. 765 unique PHASE-FLIP DONE lines from the boot captures decompose it, with no boot required. read 30.6 ms 0.9% exchange 847.8 25.3% write 302.6 9.0% movers 1458.4 43.4% GDN state + weights arena refill (:1843-1846) cutover 670.7 20.0% group routing, owner refresh, rebuild, swap (:1147) residual 99.2 3.0% Median total 3357 ms (min 2401, max 4874 -- the reported band); both directions agree (pp_to_tp 3298, tp_to_pp 3417). THE PREMISE IS CONFIRMED AND THEN SOME. read+exchange+write -- the part everyone reaches for -- is 35.3%. Sixty-plus percent sits outside it, and the single largest component is MOVERS at 43.4%, which is the H2D copy of the target layout's weight image. The residual is ~3%, so the "unexplained" part is small and the named parts are the story. (Medians do not sum; the composite handed to the solver adds to slightly more than the median total. Per-event median of (movers+cutover)/total is 61.6% against 63.4% for the composite. Both labelled.) ## Levers priced in LOAD, not milliseconds Per sgl-project#677 flip cost sets the stability floor and latency ceiling in opposite directions, so a reduction reopens refused configurations. At a 10 s budget, even phase split: baseline F=3.36s rho_max 0.66 L1 overlap movers behind seam F=2.21s rho_max 0.77 (+0.11) scheduling L1 lower bound (fully contending) F=3.36s rho_max 0.66 (+0.00) L2 phase-uniform vector (#704b) F=2.21s rho_max 0.77 (+0.11) costs depth L3 cutover to observed minimum F=2.73s rho_max 0.72 (+0.06) mechanism unknown L1 + L3 best realistic F=1.58s rho_max 0.84 (+0.18) scheduling THREE FINDINGS, FIRST ONE ACTIONABLE: 1. L1 AND L2 DELIVER IDENTICAL FLIP SAVINGS (1150 ms, rho 0.66 -> 0.77) BUT L1 IS FREE AND L2 COSTS LADDER DEPTH (n0<=37). For flip cost specifically, #704b's phase-uniform vector buys nothing a pure scheduling change does not. It still earns its keep on sgl-project#703's cache-key problem, which L1 does not touch, so they substitute for THIS purpose only. Do L1 first. 2. L1'S SAVING IS BOUNDED [0, 1150] ms AND THE BOUND IS UNMEASURED. movers is H2D and on this no-P2P rig the rank-to-rank exchange stages THROUGH HOST, so both legs traverse the same PCIe direction and may contend. If they fully contend the overlap saves nothing. Which end holds is the single highest-value thing the confirming window can capture. 3. L1 + L3 MAKES rho=0.8 FEASIBLE. sgl-project#677 refuses rho=0.8 at every measured flip cost; at F=1.58 s the ceiling rises to 0.84. That is the concrete form of the repricing: not "save 1.8 s" but "the load the rig currently refuses becomes servable". cutover deserves instrumentation before optimisation: its 24x spread (43.5 to 1041.5 ms) is not the signature of a fixed cost but of a wait or serialisation. Sub-step timestamps would say which; the observed minimum is the honest target. 236 tests green, hermetic (CUDA_VISIBLE_DEVICES=""), ruff + codespell clean. Measured components are inputs; a foreign profile with a differently-shaped split pins that the ranking follows the numbers, not this rig.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…it was switched off
On 2026-08-16 the server sat wedged for 52+ minutes while /health returned 200.
TWO independent blind spots produced that, and the second had not been named.
## 1. /health answers "is the process up", not "is work moving". Known.
## 2. The shipped watchdog is blind to admission wedges BY CONSTRUCTION
create_scheduler_watchdog (managers/scheduler_components/invariant_checker.py:
536-540) wires:
get_counter = lambda: scheduler.forward_ct
is_active = lambda: (scheduler.is_initializing
or scheduler.cur_batch_for_debug is not None)
It arms only WHILE A BATCH EXISTS. An admission wedge is exactly the state where
no batch exists while work is pending (#running-req: 0 on 90.6% of prefill
rounds in the specimen). So is_active is False for the entire wedge and the
timer never starts. The watchdog is not slow -- it is switched off, which is why
a 52-minute wedge produced no alarm from either mechanism.
## The signal
Progress is ANY ONE of three counters advancing over a sliding window:
prefill_chunks the only one that moves in a long pure-prefill run, where a
640-chunk prompt completes nothing for minutes
decode_steps moves in pure decode, where no chunk is admitted
completions moves when requests finish
Requiring all three would call a healthy pure-prefill server wedged; requiring
only completions would do the same. The rule is disjunctive precisely because
that is the trap.
## The refusals, which are what make the alarm worth listening to
- AN IDLE BOX IS NOT A WEDGE. Zero progress with zero pending work is a server
with nothing to do. The progress counters are IDENTICAL to the wedge's; only
queue depth and pending tokens separate them. Alarming here is how a real
alarm gets ignored.
- A DELIBERATE PAUSE IS NOT A WEDGE. A flip is 2.0-4.2 s of legitimate silence
(sgl-project#690); an inhibited sample suppresses the verdict rather than tripping it.
- A COUNTER RESET IS NOT A WEDGE. After a restart the counters return to zero,
so a negative delta means restarted, not stalled. Reading it as a wedge would
make every restart trigger another.
- A COLD START IS NOT JUDGED. Fewer than two samples yields unknown.
## Wiring and policy
build_liveness_is_active replaces the shipped gate: it arms whenever WORK IS
PENDING rather than when a batch happens to exist -- the exact inversion of the
failure above, and the condition that actually distinguishes a wedge from an
idle box.
Escalation is defined rather than implied: confirmations consecutive wedged
windows before an alarm, restart_after_alarms before a restart, and a
restart_cooldown_s so a wedge that SURVIVES a restart does not become a restart
loop. Restart can be disabled outright.
to_monitoring_dict exposes the deltas and pending counts alongside the verdict,
deliberately: an operator who sees only "wedged" cannot tell an admission wedge
from a stalled forward pass, and those need different responses.
## Test results
252 passed, hermetic (CUDA_VISIBLE_DEVICES="", no clock), ruff + codespell
clean. Every threshold is a deployment input.
test_progress_liveness_699.py (16): the 16:23 specimen as a CAN-FAIL PROOF
(health 200 + zero progress + nonzero pending must alarm); idle refused; pure
prefill and pure decode both healthy; deliberate pause; cold start; counter
reset; confirmations; the restart policy and its cooldown; restart disabled;
pending tokens alone meaning work; the replacement gate arming during the wedge
where the shipped one is silent; the monitoring dict; and window sliding so
stale progress cannot keep a dead server looking alive.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…attributed Slot-3's decomposition puts cutover at 20.0% of the 765 flip lines, but its cost spans 43.5 to 1041.5 ms. A 24x spread is the signature of a WAIT or a serialization, not of a fixed cost -- and the DONE line reports only the total, so nothing in the log can say WHICH step moves. 43.5 ms is the honest target; without attribution it is unreachable. Eight marks at the cutover's own existing step boundaries, and one summary line sorted by cost: CUTOVER SUB-STEPS <direction> total=N ms | draft_state=.., components=.., ... Deliberately cheap and inert: one perf_counter per step, no control flow touched, and the summary is wrapped so a timing failure can never break a cutover. Emitted AFTER verify_flip_cutover, so a cutover that failed its completeness check never reports timings as though it had succeeded. DESK WORK, ON PURPOSE. The previous window could not carry this because the instrumentation has to exist BEFORE the boot that measures it -- I had already booted when it was requested, and re-booting would have re-triggered the router's buffered-request replay and cost the quiet window. It now ships in the next boot for free, whenever that boot happens. Verified rather than assumed: module imports clean, 9 _mark call sites land inside build_production_flip_cutover, the summary line is present in the compiled source, `time` was already imported. 82 passed + 20 subtests across the flip-runtime, guard and 708 suites; ruff clean in the changed region. Not yet observed on metal -- no flip has run against this build. The first flip after the next boot is the proof.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…the binding constraint Design only; the flip runtime stays F4-r4's to build. THE HEADLINE REVISES MY OWN LEVER TABLE. I priced L1 as "scheduling only". It is not. phase_flip_runtime.py:4546-4548 states that stacks.refill is a PRE-cutover function and therefore COMMITS WHILE THE WAVE STATE IS STILL OUTSTANDING, and the measured stage walk (evidence-631/remediation-656/ boot_m1.log, tp_to_pp rank 1) shows what that costs: baseline free 2464 MiB backing_restore 1250 | gdn_state 1250 weights_refill 1012 step -238 *** CORRIDOR LAW BROKEN *** cutover 1290 step +278 The wave walk leaves 1214 MiB outstanding and the refill's 238 MiB commit lands on top, ending 12 MiB UNDER the law -- in today's SERIAL ordering. Moving the refill earlier to overlap the exchange lengthens the window in which both are outstanding and makes the trough DEEPER. L1 therefore trades a VRAM peak for wall time, on a card with 12 MiB of margin. WHAT THE SPEC COVERS Stream: the refill is dst.copy_ plus a device-side checksum, both on the CURRENT stream today. Overlap needs an explicit side stream and an event, not merely moving the call. Ordering that must hold: refill -> checksum -> cutover rebinds, fenced by an event waited on at cutover entry. Ordering that must NOT be assumed: refill and seam waves touch different logical memory but compete for the same PHYSICAL page pool under the sgl-project#631 VA-backed backing swap. Independence in bytes is not independence in pages, and that is the correctness edge to verify first. Abort: the arena must never be half-new. The current one-contiguous-copy plus post-copy checksum plus restore= rollback already has the right shape and must be preserved rather than reinvented. Four requirements, including that an overlapped build must NOT split the copy into per-layer pieces for finer overlap -- that would introduce exactly the half-new state the design excludes -- and that a side-stream refill must register with barlink_abort_gate or an abort can be declared while the copy still runs. A/B PLAN: the discriminating quantity is the SUM, not the wall time. If the legs are independent, total_B ~ total_A - min(movers, exchange). If they fully contend, total_B ~ total_A while BOTH legs stretch with their sum conserved. Reporting only the total cannot tell "no saving" from "saving offset by a slower exchange", so both legs must be reported per arm -- plus the VRAM trough per arm. Run Arm B only if Arm A shows margin above the law; if the serial ordering is already at the limit, the right move is to SHRINK the refill (partial residency of tensors common to both layouts), not to overlap it.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…fuses most of it Design only, no build. Persistent file per Feature-Analysen-Pflicht: docs/DESIGN_423_striped_spill.md. ## The prior, answered rather than routed around The rejected register already carries a sibling and it is BLOCKED: planner/rejected.py:469-487, `path_bundling` -- "one transfer striped over both lines" -- with the note that only the CHOICE of line per message class is released (sgl-project#240). Different axis (network lines vs storage tiers), but the reasoning transfers, and this design reaches the same shape independently from arithmetic rather than by analogy. ## Striping unit: the page 32,768 B = one token x 16 attention layers, which is already what BlobStore.put /get speaks (gdn_slot_executor.py:104-133) and already canonical under the sgl-project#706 Option A contract. Per-row striping would need a second index the canonical form deliberately does not have. ## Ratios: proportional to MEASURED bandwidth, bound to identity share_i = bw_i / sum(bw). Rates reuse overlap_schedule.CardLink (NVML UUID + PCI BDF, measured provenance, refuses unknown cards) rather than a second rate table -- keying rates by position instead of identity already cost a full analysis in sgl-project#690. ## THE GATE, and it refuses the motivating case Striping buys parallelism only across DISJOINT links. A spill is device->host, so it leaves ONE GPU and crosses THAT GPU's single PCIe link before reaching any tier. The tiers sit BEHIND the shared link, not beside it, so striping does not widen it. GATE: stripe only when aggregate destination bandwidth is BELOW the source link bandwidth. On this rig (no P2P, all PHB, x4 + x8 + x8; measured 6.4 / 13 / 13 GB/s): GPU0 (x4, 6.4 GB/s) vs host RAM ~10 GB/s -> NO GAIN, link-bound already GPU1/2 (x8, 13 GB/s) vs host RAM ~10 GB/s -> up to ~3 GB/s (~23%) by adding NVMe The RAID-0 intuition ("n tiers, n x bandwidth") holds nowhere on this hardware. The gain is bounded by link - fastest_single_destination, which the tiers cannot widen. ## Failure semantics by volatility class RAID-0 has no redundancy, so the rule follows from what a lost stripe costs: reconstructible KV may stripe (a miss, then recompute); NON-RECONSTRUCTIBLE state -- GDN recurrent state mid-sequence, live conversation state -- may NOT, because striping multiplies failure probability with no recovery, and that is exactly what TieredGdnBlobStore exists to preserve. A half-present blob is worse than an absent one: absent is detectable, half-present may not be. Any striped path therefore needs a per-object completeness marker, the same requirement sgl-project#706 found for partial page writes and for the same reason. ## Recommendation DO NOT build striping for device->host spill. Build the half that pays if anything: tier CHOICE per volatility class -- reconstructible bulk to the slow tier, non-reconstructible state to the fast durable one -- which needs no stripe index, no completeness marker and no multiplied failure probability. Revisit when a source appears whose link exceeds any single destination (host->multi-NVMe is the plausible one). Sections 1, 2 and 4 are reusable as written; only the gate needs re-evaluating, and it is written to be re-evaluated rather than assumed. Held for GO. If the operator wants the mechanism built anyway to be ready for hardware that would benefit, that is a legitimate call -- made knowing the gain here is zero on one card and <=23% on the others.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…alization VERDICT: there is no serialization point to remove. The moves are already concurrent, the spread is an inverted wait, and the critical path is one consistent straggler. NAMING FIRST: the capture says "draft_state"; no such label exists. The pre-cutover movers are labelled at phase_flip_runtime.py:1843-1846 as "gdn_state" and "weights_refill", and the census reports the interval gdn_state->weights_refill. CODE (task 1). GdnFlipMover.move (gdn_flip_mover.py:467-556) is pack-all -> exchange -> verify -> write, and only the exchange is a group step. That exchange is _dist_exchange (kv_reshard.py:939-984): ONE batch_isend_irecv -- every irecv in ascending peer order, then every isend, then polled through bounded_collective. Against the three candidates the brief named: not rank-by-rank (one batch), not host staging (device-native, "payloads never leave the GPUs"), no lock on the path. The fix shape the brief anticipated, concurrent per-rank moves, is already the implementation. LOGS (task 2) -- NOT rotated out. 36 census lines survive, 14 flips x 3 ranks: rank total_ms(mean) segs gdn span min..max mean 0 3134.3 433 1303.9 .. 1349.3 1327.1 1 3112.6 400 1780.8 .. 2049.6 1903.0 2 3127.9 384 974.2 .. 1173.1 1057.0 Two facts settle it. (a) Totals are equal within 0.7 percent while gdn spans differ 1.80x -- equal totals with unequal sub-spans is wait redistributed, not work imbalanced. (b) The ranges DO NOT OVERLAP (rank2 max 1173.1 < rank0 min 1303.9 < rank1 min 1780.8) with small per-rank variance, so it is structural and load-INdependent: always the same rank, answering the brief's question. The spread is INVERTED: at a rendezvous the earliest arriver waits longest, so the longest span marks the earliest arrival. rank 1 arrives first and waits; rank 2 arrives LAST and IS the critical path. The others burn ~270 and ~850 ms per flip waiting on it. rank 2 holds the FEWEST GDN layers (12 vs 21 and 15) and fewest segments, so the delay is not GDN work volume -- what makes it late is upstream of this interval and is the open question. THE 21x FIGURE: within a single flip the spread is 1.80x mean, 2.1x at the extremes. The 8.9-963.3 ms range in Capture-A spans flips of very different sizes, so a ratio across it mixes flip magnitude with rank skew. The within-flip number is the one that bears on serialization, and it is ~2x. DIRECTION (task 3), with the risk stated: do NOT parallelise the move -- it is already batched, and added concurrency risks the deterministic peer ordering that keeps batch_isend_irecv from deadlocking. And the claimable quantity is bounded by rank 2's excess, NOT by the others' wait: the flip's duration is the critical path, so any proposal framed as "reclaim the waiting ranks' time" is arithmetic on the wrong side of a barrier. Next step is one added census mark inside the interval to attribute rank 2's pre-exchange time -- proposed here, not wired, for review first per the brief. Docs only. No sizer or runtime change.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…ensus mark The worst census segment on every rank, gdn_state->weights_refill, is the WEIGHTS REFILL and not the GDN move: marks are taken after each pre-cutover mover returns, so the segment runs from the GDN leg finishing to the refill finishing. refill() is one contiguous H2D of the target layout image -- rank-local, no collective. That retracts this note's first revision, which read the segment as the GDN exchange and its spread as a rendezvous wait with rank 2 arriving last. Corrected reading: every rank copies the same 9614.9 MiB TP image, and the per-rank times track PCIe link width, resolved via the NVML canon rather than by rank index (sgl-project#82 device-order trap): rank 1 -> phys 0, 3080, x4 -> 1903.0 ms -> 4.93 GB/s rank 0 -> phys 1, 5090, x8 -> 1327.1 ms -> 7.08 GB/s rank 2 -> phys 2, 3080, x8 -> 1057.0 ms -> 8.88 GB/s So it is the x4 card, but that is rank 1; rank 2 is the fastest of the three. Equal per-rank totals (within 0.7%) with an 846 ms segment spread put rank 1's refill on the flip's critical path -- ~27% of a ~3.1 s flip attributable to one card in an x4 slot. Unexplained and named as such: two x8 cards differ 7.08 vs 8.88 GB/s, and the 1.80x x4/x8 ratio falls short of the 2.00x pure-link prediction. Both are the size of a fixed cost sharing the segment with the copy -- the arena commit, which grows on ranks 1 and 2 but not on rank 0. The mark separates them: one site in _commit_refill_high_water, firing on both directions, splitting the leg into commit and copy. Marked outside the carrier guard so a no-carrier rank reports a zero-width step instead of dropping the boundary and changing what its remaining bar means. No behaviour change: mark() is a no-op with no census open and swallows its own exceptions, so it cannot be why a flip dies (sgl-project#631 no-return contract, re-pinned here rather than inherited). Tests (hermetic, CUDA_VISIBLE_DEVICES=""): test/registered/unit/managers/test_refill_highwater_mark_690.py 8 passed red-first: 5 of 8 fail without the mark test/registered/unit/managers/ 2119 passed, 18 skipped, 130 subtests ruff clean on both changed files (the pre-existing unused pack_into_arena import at HEAD is left alone as out of scope)
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…seam refuses
Scope (c) was framed wrong and the correction is the headline. The attention
KV ops do NOT route through any process group -- get_kv_buffer/set_kv_buffer
are LOCAL memory operations, and a repo-wide grep for group accessors inside
forward_extend/forward_decode/set_kv_buffer/get_kv_buffer, radix_attention.py,
base_attn_backend.py and forward_context.py returns nothing. The group enters
one level up at the cross-rank LSE merge: cp_lse_ag_out_ar_mha_uneven
(layers/dcp/comm.py:231) takes cp_group as a PARAMETER, and its callers supply
it as `group = get_parallel().dcp_group` (flashinfer_backend.py:5634, :2478,
:5684, :5747, :5863; triton_backend.py:2311).
So B1 needed no new call site. runtime_context.py:392-394 resolves dcp_group
through _v() (:240-242), which calls the getter on EVERY access rather than
caching, and get_dcp_group() already carries the B1 branch (:2744). What this
slice owed was a TEST of that resolution, not a wiring change -- and the test
pins the uncached property specifically, because if dcp_group ever starts
caching, arming would silently stop taking effect after the first read.
There is also no choke point: ~15 attention-backend files call the KV buffers
inline. Ownership is expressed in the POOL SHAPE and the MERGE GROUP, never at
the access sites, which is why that sprawl does not have to be touched.
R6's build anchor was wrong. It cited model_runner_kv_cache_mixin.py:2496-2500,
which is real but lives in _init_unified_mamba_pools (:2467) -- reached only
under --enable-unified-memory (:3194-3200), a path this deployment does not
take. The filter governing our hybrid-mamba config is the classic-path one at
:3929-3934 inside the HybridLinearKVPool construction (:3913). Same logic,
wrong citation, so the byte-identity claim had never been stated against the
path it would be tested on. Corrected in the docstring.
R6 had also DUPLICATED a shipped sizing rule with the wrong rounding.
plan_decoupled computed round(share * C); the shipped rule is
dcp_compact_pool_rows (layers/dcp/owner.py:155-181), already called by this
same build path at :3765-3767, whose docstring says it is written once because
"a sizing rule whose off-by-one has already cost a debugging round must not
exist twice". I had made it exist twice AND rounded the wrong way: the shipped
rule CEILS to a whole owner block, and flooring is what let trailing partial
block slots scatter out of bounds (async illegal memory access, found by the
kv-session-offload S1 test at --max-total-tokens 3000 on cp_S=64). A planner
handing the build a floored row count re-creates that bug at the seam.
plan_decoupled now delegates to dcp_compact_pool_rows. Consequences taken, not
papered over: the plan carries the period it ceiled against, and world
conservation DERIVES the ceil slack from it (at most `period` rows across the
world) rather than being handed a slack that could be widened until it passed;
a zero-row pool became unreachable rather than caught.
Arming point: phase_flip_runtime.py step 1, alongside set_phase_flip_tp_active
(:1196) inside _cutover (:1160) -- after the group-wide quiesce (on_round
consensus :3066, hold :3121-3126, execute :3128) and after the KV wave-move,
before any group handle is re-derived (:1224). B1 is a PP-PREFILL mechanism,
so arm_for_cutover arms into PP and DISARMS into TP; it does not lean on the
flip route out-ranking B1 in get_dcp_group, because precedence is the net and
disarming is the contract. Relying on branch order is how a later reorder
becomes silent capture.
The red-first case: armed routing over a stage-local pool. A rank may be asked
for ANY attention layer, and a stage-local pool has no rows for those it does
not own, so _transfer_full_attention_id (memory_pool.py:3855-3859) misses the
mapping or returns another layer's rows -- wrong output, no error.
record_pool_plan records what the build ACTUALLY built (an intention cannot be
compared against reality), and arm_decoupled_kv refuses unless that plan is
DECOUPLED and covers the full attention set. Disarming is never refused:
requiring a healthy pool in order to STOP using it turns the recovery path
into a second failure.
set_decoupled_kv_active now refuses to arm without an initialized group,
following set_phase_flip_tp_active (parallel_state.py:2670-2687) instead of
the silently-no-oping set_dcp_spill_active. That precedent names the failure
class: "a silent no-op all-reduce, the exact corruption class this routing
exists to prevent". The get_dcp_group fall-through stays as defence in depth
for a state the setter now makes unreachable.
Test results (hermetic, CUDA_VISIBLE_DEVICES="", interpreter
/spinning/htsglang-gpu/.venv/bin/python3):
test_decoupled_kv_arming_704b.py (new) + test_decoupled_kv_pool_plan_704b.py
+ test_decoupled_kv_group_b1.py 40 -> 58 passed
can-fail by breakage: neutering assert_pool_supports_arming and the
set_decoupled_kv_active group check turns EXACTLY 6 tests red; restoring
returns 58. No collateral.
regression measured against a REMOVED-DIFF BASELINE, not assumed:
baseline mem_cache 944 failed / 835 passed, distributed 21 / 2706
with diff mem_cache 944 failed / 853 passed, distributed 21 / 2706
=> same failures, +18 passes, zero new reds.
planner 2805 passed. model_executor clean.
The 965 pre-existing reds are the hermetic-mode consequence ("No accelerator
(CUDA, XPU, HPU, NPU, MUSA, MPS) or platform plugin is available",
utils/common.py:1322), not a repo defect and not caused here. A hermetic run
of these directories can only be read as a delta against that baseline.
BOOT DEPENDENCIES, nothing below is proven without a reviewed boot:
1. phase_flip_runtime.py is NOT wired. arm_for_cutover exists and is tested,
but no call was inserted at :1196, because this worktree's copy (6666
lines, [sgl-project#690]) is BEHIND the deploy tree's (6984 lines, [sgl-project#717], ~355 diff
lines apart) and the deploy tree has no B1 symbols at all. A call against
the stale revision would likely be discarded on merge. The insertion point
is documented in the function docstring.
2. SGLANG_DECOUPLED_KV=1 has never been booted; no pool allocated from it.
3. The share vector at boot is unverified -- whether get_cp_token_ratios()
and cp_token_split_factor(dcp_size) are populated when _init_pools runs is
a boot fact, not a desk fact.
4. The LSE merge has never run over B1; only the resolution chain is pinned.
5. Nothing yet cross-checks that every rank recorded a plan with the same
period and layer set. B1's manifest covers the group, not the pool.
Deploy tree /spinning/wt-678-deploy untouched, as required.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…ensus mark The worst census segment on every rank, gdn_state->weights_refill, is the WEIGHTS REFILL and not the GDN move: marks are taken after each pre-cutover mover returns, so the segment runs from the GDN leg finishing to the refill finishing. refill() is one contiguous H2D of the target layout image -- rank-local, no collective. That retracts this note's first revision, which read the segment as the GDN exchange and its spread as a rendezvous wait with rank 2 arriving last. Corrected reading: every rank copies the same 9614.9 MiB TP image, and the per-rank times track PCIe link width, resolved via the NVML canon rather than by rank index (sgl-project#82 device-order trap): rank 1 -> phys 0, 3080, x4 -> 1903.0 ms -> 4.93 GB/s rank 0 -> phys 1, 5090, x8 -> 1327.1 ms -> 7.08 GB/s rank 2 -> phys 2, 3080, x8 -> 1057.0 ms -> 8.88 GB/s So it is the x4 card, but that is rank 1; rank 2 is the fastest of the three. Equal per-rank totals (within 0.7%) with an 846 ms segment spread put rank 1's refill on the flip's critical path -- ~27% of a ~3.1 s flip attributable to one card in an x4 slot. Unexplained and named as such: two x8 cards differ 7.08 vs 8.88 GB/s, and the 1.80x x4/x8 ratio falls short of the 2.00x pure-link prediction. Both are the size of a fixed cost sharing the segment with the copy -- the arena commit, which grows on ranks 1 and 2 but not on rank 0. The mark separates them: one site in _commit_refill_high_water, firing on both directions, splitting the leg into commit and copy. Marked outside the carrier guard so a no-carrier rank reports a zero-width step instead of dropping the boundary and changing what its remaining bar means. No behaviour change: mark() is a no-op with no census open and swallows its own exceptions, so it cannot be why a flip dies (sgl-project#631 no-return contract, re-pinned here rather than inherited). Tests (hermetic, CUDA_VISIBLE_DEVICES=""): test/registered/unit/managers/test_refill_highwater_mark_690.py 8 passed red-first: 5 of 8 fail without the mark test/registered/unit/managers/ 2119 passed, 18 skipped, 130 subtests ruff clean on both changed files (the pre-existing unused pack_into_arena import at HEAD is left alone as out of scope)
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…or that exists The rung machinery already existed and was NOT rebuilt: layout_ladder.py already solved rungs as a Pareto frontier, indexed them by occupancy (Rung.admit_up_to_tokens) and derived hysteresis bands (descend_below_tokens / ascend_above_tokens). What was missing was the PRICE of a step, and the price was wrong by an order of magnitude. _solve_transitions charged a step as moved_layers x weight_mib_per_layer over the gating link. That prices a cross-rank weight mover, which does not exist and whose absence is explicit (regime_stages.py:100, REACH_NO_WEIGHT_MOVER). The actuator that DOES exist is PhaseFlipStacks.refill (phase_flip_boot.py:361, arena_refill :539, dst.copy_(payload) :576): a CONTIGUOUS host->device memcpy of a whole boot-baked arena image. The bytes on the wire are the same whether one layer moves or six. With sgl-project#690-rev2's 9614.9 MiB per rank over the measured links (13/13/6.4 GB/s, authoritative mapping) and nothing crossing a rank boundary -- so the refills run CONCURRENTLY and the slowest card sets the step -- a rung change costs 1575.3 ms: 10.7x to 21.3x the moved-layer estimate, and 38-79% of a whole phase flip (sgl-project#690's fixed 2.0-4.2 s). The band consequence is real but small (every ascend trigger drops ~30k tokens, under 1% of pool): the mispricing mattered for the DECISION, not for the guard. The consequence that changes how a ladder must be driven: the switch cost is CONSTANT IN THE DISTANCE TRAVELLED. Crossing twelve rungs one at a time costs 12 x 1.575 = 18.9 s; crossing them in one jump costs 1.575 s. A constant-cost actuator inverts the usual intuition -- rungs are choices of destination, not stations to stop at. Per-step value is also wildly unequal: on the draining leg at arena depth 40, one step buys 23% for 1.575 s (payback 8.4 s) and the next buys 1.8% for the same 1.575 s (payback 87.9 s). Arena depth is the master knob and a real trade, since the arena is sized for the deepest reachable rung and resident at every rung: deepest rank0 | rungs | roomiest pool | fastest | end-to-end payback 36 | 2 | 421,894 | 1.0071 | 224.7 s (dead) 38 | 5 | 418,848 | 1.1538 | 11.8 s 40 | 8 | 364,413 | 1.2532 | 7.8 s At depth 36 the ladder is economically dead; at 40 it is live but the roomiest rung has lost 13.6% of its pool purely for holding the option. A defect this found in my OWN new API: the first cut of solve_fill_ladder required ASCENDING fill levels. Rising fill only ever moves to roomier, SLOWER rungs, so the interface could express nothing but forced retreats and reported an infinite payback on every one -- the discretionary step, the one the function exists to price, was unreachable through it. Monotone in either direction now, and both legs are pinned by test. The two kinds of step are distinguished explicitly: ASCEND is MANDATORY (its alternative is not "stay fast" but "stop admitting", so infinite payback is correct and must not be read as "never do this"), DESCEND is DISCRETIONARY and is the only step sgl-project#677 decides. sgl-project#677 integration: a cut jump and a phase flip are both an arena refill, so they spend the SAME budget and a rank cannot do both at once -- the controller ranks them rather than running two policies. A discretionary cut jump is admitted only when it is a jump not a step, its payback fits sgl-project#677's backlog-derived window, it beats a flip for the same stall (a flip changes regime; a cut jump buys a prefill factor within one), and the hysteresis band already permits it -- economics are a veto on top of the guard, never a replacement. Mandatory ascends bypass all four. HONEST LABELLING: no cut is recommended and nothing is added to the user's morning list, which carries sgl-project#702's cut alone. Every pool and speed number is solver output on the STRUCTURAL free-bytes fixture the review gate found was fitted against the incumbent, and inherits the +-500 MiB unbooted arming-floor uncertainty (~7% at 8 attention layers). The cost side rests on measured inputs, but 1575 ms is an arithmetic prediction from measured bandwidth, not a measured switch: the ladder has never performed a rung change on metal. 9614.9 MiB is taken from sgl-project#690-rev2 and assumed uniform per rank. Test results (hermetic, CUDA_VISIBLE_DEVICES="", interpreter /spinning/htsglang-gpu/.venv/bin/python3): test/registered/unit/planner/test_fill_ladder_704a.py (new) 20 passed test/registered/unit/planner/test_layout_ladder_704.py 25 passed test/registered/unit/planner full suite 2825 passed, 123 skipped, 157 subtests passed, 0 failed (2805 before this slice) can-fail by breakage, two independent neuters: summing the per-rank refills instead of taking the max (i.e. denying concurrency) turns 2 tests red reverting the bands to the moved-layer estimate turns test_the_real_cost_makes_the_BANDS_STRICTLY_MORE_CONSERVATIVE red restoring returns 20 passed Desk only. No GPU, no serving, deploy tree untouched.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
… directions MEASURED (sgl-project#713 quantisation table, 06:19). Demand-PULL already worked: C1 arrived 06:19:06.56 and was served by the tp_to_pp at :09 -- 3.14 s, one seam plus overhead. What failed was the step AFTER. The box flipped back at :12, so C2, arriving 06:19:09.71 just as PP began, was not served until :15: arm arrive first token TTFT served by C1 06:19:06.56 06:19:09.71 3.14 tp_to_pp @:09 C2 06:19:09.71 06:19:15.52 5.81 MISSED :12, waited @:15 C3 06:19:15.52 06:19:15.63 0.11 landed ON the :15 flip The layout left on a timer while the prefill that pulled it was still unserved, so TTFT quantised to whole cycles -- 0.1 / 3.1 / 5.9 s, nothing between. The same arriving-tokens signal that PULLS a cutover must also HOLD it until the work it pulled for is served. One rule, two directions, not two rules. LEVER (a) IDLE DWELL IS DELIBERATELY NOT BUILT, on the coordinator's recorded call, because the measurement removed its target: the idle box does not churn. Pre-merge showed ONE flip across 10 idle minutes; post-merge ZERO across 90 s idle (0 running, 0 queued). My earlier "10 flips in 30 s on an idle box" was measured while my own arms were arriving -- the box was not idle and I called it idle. A gate with no measured trigger is dead weight. BOUNDED BOTH WAYS, because an unbounded hold is a starvation bug wearing a fix's clothes -- it trades the prefill side's starvation for the decode side's: (a) hold cannot starve decode: past LAYOUT_HOLD_MAX_ROUNDS the layout releases even with prefill unserved, and says EXHAUSTED; (b) pull cannot preempt an unserved prefill: while a hold is live in PP the verdict stays a hold, whatever the decode queue looks like. The both-sides tie (work pending in PP and TP at once) is routed to the sgl-project#677 economic comparison rather than to the timer, and is bounded by the same rounds. Bound = 8 rounds, derived not round: a cutover costs ~2.6 s of seam (sgl-project#690 measured 2.56-2.59 s), so 8 rounds holds the layout well under the cost of leaving it. Holding longer than it costs to leave is never worth it. SAFETY PRECEDENCE: never mid-flip (a cutover in progress owns the layout); never against an unfunded seam (a pull that cannot pay is an abandon). Tests, hermetic (CUDA_VISIBLE_DEVICES=""): the C2 specimen holds; pp releases when nothing pends (can-fail: the hold must not become a permanent stay); tp pulls; mid-flip and unfunded outrank demand in both phases; both-sides names the tie; the bound releases at the limit and NOT before (can-fail: early release evaporates the C2 fix the moment any decode appears); degenerate inputs -> 14 passed + 17 subtests; 185 passed + 24 subtests with phase-policy, 708, admission-intake and flip-runtime. ruff clean. CAN-FAIL PROVEN BY MUTATION IN THREE DIRECTIONS: never-holds fails 13 of 14, unbounded-hold fails 1, ignores-unfunded fails 2. Reverted and re-verified. NOT WIRED into decide() yet -- this is the decision rule. Wiring changes live flip behaviour and wants its own review; the acceptance (quantisation table collapses) can only be measured once it is wired, so that is the next step and not a claim of this commit.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…ferable vs lazy-fundable The floor was measured once and frozen, never designed, and that is visible in the source rather than a matter of opinion: arming_floor = corridor band floor + seam_entry_reserve, where the first half is a stated policy with a stated tolerance (1024 - 20% = 819 MiB) and the second is one scalar whose own docstring calls it "the shipped allowance". Per-rank it decomposes exactly: rank 0 (5090) 1728 MiB = 819 + 909 seam draw rank 1 (3080 x4) 1825 MiB = 819 + 1006 rank 2 (3080 x8) 2467 MiB = 819 + 1648 Rank 2 holds 81% more than rank 0 with no recorded reason. The defect is not the size of the number, it is that it is ONE number: a monolithic holdback cannot be traded, because trading requires knowing which part buys what. STAGING, AND WHAT ACTUALLY FORCES IT. Under barlink a cross-card transfer is one PCIe crossing, so a host bounce (two) is strictly worse and is not offered there. But the reshard stages in VRAM on both sides regardless of transport, and rollback semantics are NOT why: _dist_exchange allocates a uint8 receive buffer per peer and sends a gathered contiguous buffer (kv_reshard.py:939-995), because the wire format is a flat byte stream per peer while the destination rows are scattered ids. The obstacle to BAR1 landing in-place is the SCATTER, not rollback and not write ordering -- so the cross-card staging term goes to ~zero only under a layout co-design that makes a peer's destination extent contiguous. That is the largest structural reduction available here. RESTORE, NEVER REBUILD adopted as a named invariant: the flip may pay copy time, never build time. Consequence: capture-moment workspace is a BOOT-time component, not a per-flip floor term (both layouts captured once, graph state parked to host and restored per flip, 40-85 ms band, sgl-project#464 coalescing pending). The weights refill already complies. TIME PRICE of host-bouncing, from the H2D rates I measured in sgl-project#690 rather than nameplate: 125 / 199 / 181 ms for the whole seam draw on ranks 0/1/2, i.e. 4-6% of a ~3.1 s flip to return 909-1648 MiB per card permanently. Stated as a FLOOR on the cost, not a wall-clock delta: the refill is already 41-52% of the flip and shares the same link, so bounces queue behind it -- worst on rank 1's x4 card, where reslotting remains the cheapest single intervention. NAMED AS UNMEASURED: the seam draw cannot currently be split into components; nothing records it per component. Until one instrument attributes the peak instant to (send buffers, receive buffers, graph state, allocator transient), any per-component trade is arithmetic on an undivided number -- the same error class as pricing a flip on intention rather than completion. Also records the two honest limits on the rebuilt evict rung (sgl-project#717): it now delivers less than it prices by design, so repricing must key on the DELIVERED amount; and the ~413 MiB it leaves on the table is recoverable only by evicting deeper than the cap. Desk analysis, no code change. Feeds sgl-project#702 repricing and sgl-project#677 economics.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…ribution, rank-2 root 1. RESTORE, NEVER REBUILD -- the pin (test_restore_never_rebuild_677.py). A fence patches the BUILD entry points (weights_arena.allocate_arena, weights_arena.pack_into_arena, torch.cuda.CUDAGraph) to raise, and the REAL production mover PhaseFlipStacks.refill runs under it on both legs, including the checksum-mismatch restore arm -- the one branch that touches the arena twice and is likeliest to reach for a rebuild. arena_refill is deliberately NOT fenced: it is the copy the flip exists to perform, and a pin that fenced it would pass by forbidding the work. Can-fail arms: every entry point is shown to actually raise, and a planted mover calling allocate_arena is caught. Pinning production rather than a re-implemented loop is the point -- a re-implementation keeps passing while production drifts (sgl-project#624). 2. PEAK-INSTANT ATTRIBUTION -- PhaseFlipRuntime._record_seam_peak, emitted on the sgl-project#605 flight-recorder channel (not a new one: it already carries the torch view, the NVML view and the boot id, and is append-only). Placed at _staging_affordable, the instant the flip's demand is weighed against free VRAM -- earlier the buffers do not exist, later the decision is already taken. Carries staging_bytes, refill_destination_bytes, graph_workspace_bytes, the reserve, driver free, allocator cached free, and a SIGNED unattributed_bytes. Two choices, both pinned and both mutation-proven: unmeasured components are None and never 0 (a zero reads as "costs nothing" -- the sgl-project#606 defaulted- measurement defect), and the residual is signed, because a negative one means the named terms OVER-count, a different defect that max(0, ...) would hide. Guarded end to end: an instrument on the seam path may cost a line, never a cutover. 3. THE RANK-2 ANOMALY -- the sgl-project#685 candidate is REFUTED. sgl-project#685 (0e50e48, f1774d7) is an UnboundLocalError use-before-bind on a variable named 'cell' in the cold seam-pricing branch; it has no arena-tail content and no 1456 MiB figure exists anywhere in source or records. The live candidate is arena GROWTH, from the sgl-project#690 image sizes: rank 0 PP 12619.6 TP 9614.9 growth 0.0 seam draw 909 rank 1 PP 9014.0 TP 9614.9 growth 600.9 seam draw 1006 rank 2 PP 7211.2 TP 9614.9 growth 2403.7 seam draw 1648 Rank 0's PP layout is the larger, so it never grows; rank 2 grows four times what rank 1 does. The ordering matches the draws exactly and no other per-rank term does. Stated as a CANDIDATE, not a finding: the excess over rank 0 is 16% of the growth on rank 1 and 31% on rank 2, so growth explains the order and not the size. Instrument 2 settles it without a dedicated experiment -- it emits exactly this quantity at the peak instant. FILED, NOT BUILT: TICKET_718_contiguous_destination_extent.md -- making a peer's destination extent contiguous so a BAR1 write lands in place and the receive buffer stops existing. The largest structural reduction available, and the only one that removes a buffer rather than relocating it; it touches the reshard wire format and the pool allocator together, so it belongs to a deliberate design pass. The ticket names what must be decided, what must not be assumed (it trades allocator freedom for staging bytes, and that freedom is what keeps admission working under fragmentation), and makes a live reading from instrument 2 its prerequisite. Tests, hermetic (CUDA_VISIBLE_DEVICES="", no GPU, no serving contact): test_restore_never_rebuild_677.py 7 passed + 3 subtests test_seam_peak_attribution_677.py 8 passed MUTATION PROOF: null->0 and signed->floored fails 3 of 8 FULL SUITE compared by failing NODE ID against base b786858, ANSI stripped (counts alone hid a real regression earlier in this branch): base 13 failed / 2181 passed; now 13 failed / 2208 passed regressions: NONE. The 13 are pre-existing. ruff + codespell clean on all changed files. Desk only. Live readings ride the later review boot.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 18, 2026
…ce in one harvest plan, with a proven runner Consolidated from the comp4 gate run (progress.662-F4-r5), WINDOW_TICKET_745/755, NOTE_747 par.8-9, NOTE_738/755, TICKET_727 and the operator ledger. Two hard incompatibilities shape the plan: WINDOW_TICKET_745 Arm 1 excludes the checkpoint interval that sgl-project#758's anchor-cadence observable requires (-> ARM I hicache harvest, ARM II = one flag more), and sgl-project#713's TTFT<3s needs a quiet router while every other loaded gate needs the soak backlog (-> sgl-project#713 is the idle sub-phase BEFORE the backlog, not a separate boot; the 06:44Z soak driver is the load source per the Lastprobe rule). ARM I phases: load-time (sgl-project#738 no-99G-plateau, file-backed-image reclaim), idle-quiet (sgl-project#713, health, corridor), loaded (Gates A/B/C, - sgl-project#757 race-holds, sgl-project#748 all three shapes, sgl-project#744/sgl-project#717 rung-funded flip, - sgl-project#690 refill census, sgl-project#758-2 mamba host resume, WT_745's three lines, corridor minima), teardown (image reclaim). ARM II adds --mamba-checkpoint-interval 8192 for sgl-project#758-1 anchor cadence + NOTE_747 par.8.1-8.3. SEPARATE windows named with reasons: sgl-project#727 four-boot A/B, WT_755 slots A/B (pool-geometry confound), sgl-project#755 metal retraction (mechanism not built -- nothing to measure), sgl-project#709, sgl-project#735 Step-2. sgl-project#602 and sgl-project#536/sgl-project#537 carried as HONEST unresolved slots (owner-held detail / not found with acceptance shape) rather than invented readouts. Runner run_window_ladder.sh: PASS/FAIL/UNOBS table from boot log + live server; never boots, never kills, never touches the soak driver; soak-tolerant by construction (loaded checks are log observations, the one latency check runs only in --phase idle, and choosing that phase IS the operator's quiet-router assertion). Missing-emitter cases (anchor cadence) report UNOBS, never FAIL -- absence of an instrument is not absence of the property. Mock-smoked per the desk rule, both directions: a fixture built from the comp4 specimen lines reproduces the real run's verdicts exactly (GATE-C crash, both sgl-project#748 shapes + vacuous relief, sgl-project#757 sentence = 5 FAIL; sgl-project#744/sgl-project#690 PASS; exit 1) and a clean fixture goes fully green incl. the ARM II cadence line (exit 0). bash -n clean, codespell clean. Nothing was booted.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 22, 2026
…ole-flip second count
The REFILL instrument printed each leg's duration beside "the ~3.1 s
pinned baseline". On 2026-08-22 a briefing built on that line concluded
the flip economy was broken, put the cost at 64% of wall clock against an
8x regression, and went looking for a silent host-RAM fallback to blame.
The line invites every step of that reading, and the comparison it offers
is invalid three ways:
SCOPE ~3.1 s is a WHOLE FLIP (NOTE_677_floor_components.md:135-143
uses it as "Against a ~3.1 s flip"), not a refill leg.
PATH sgl-project#690 measured the PINNED image path
(NOTE_690_gdn_state_spread.md:58-85), which predates the
file-backed arm entirely, so it is not a baseline this path
ever held.
BYTES sgl-project#690 moved 9614.9 MiB/rank; these legs move 8574-16363 MiB, and
elapsed time tracks bytes moved (r ~ 0.80 over 45 logged legs),
so seconds are not comparable across them.
There is no regression and no fallback here. The file-backed arm is an
explicit opt-in (--phase-flip-image-file-backed, server_args.py:5818),
and weights_arena.py:441-445 states it REFUSES rather than falls back,
naming the silently-inert-flag class as the reason. The boot log carries
"FILE-BACKED (reclaimable)" nine times and zero fallback warnings. Its
help text names what the slower path buys: without it the images are
~68.7 GiB of unreclaimable host RAM on a swapless box and the boot is
OOM-killed during init.
So the line now reports a rate against a rate and carries the
reference's conditions, which are what make a baseline transferable at
all. It still says the arm is slower, because it is; what it no longer
does is let that read as a defect to hunt.
The instrument is extracted as refill_report() so it can be tested
without a flip. Behaviour is otherwise unchanged: same call site, same
try/except, an instrument may never break a flip.
Tests: test_refill_baseline_honesty_802.py, 6 tests, red first (all six
failed on the missing entry point, then on the bare second-count and the
absent conditions). 55 pass across the refill and sgl-project#796 families.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 22, 2026
…the order does not matter sgl-project#809 asks for a hybrid residency of the phase-flip weight images: a small pinned share (a "hot head, in wave order"), the rest file-backed as today, and a reload with prefetch overlap on the sgl-project#125 double-buffer pattern. The prior-art gate falsified two of those three, and the third rests on a comparison nobody has run. Recording that before writing code, because the cheapest outcome here is the one where nothing is rebuilt. THE OVERLAP IS ALREADY SHIPPED. `_staged_file_refill` (sgl-project#802, landed 2026-08-22, weights_arena.py:522) reads the file-backed image with bounded preadv into sgl-project#720's pinned ring and overlaps the next chunk's read with the previous chunk's H2D DMA -- depth streams, depth events, an inflight flag, and a synchronize before a buffer is refilled. The depth is SGLANG_PHASE_FLIP_REFILL_DEPTH, default 2: literally a double buffer. Rebuilding it would be the sgl-project#720-verbatim mistake in a new place. THERE IS NO HOT HEAD. `arena_refill` copies the whole payload and only then checksums it; nothing reads the arena before that checksum passes. There is no partial publication and no per-wave consumption, so WHICH bytes are pinned cannot matter -- only HOW MANY. sgl-project#254's wave order exists because a MoE forward consumes experts wave by wave; a flip consumes the arena once, whole. A "hot head selection" would be a knob with no effect. TWO OF THE THREE CITED NUMBERS ARE NOT IN THIS TREE. Grepped as rates over python/sglang/srt/ and docs/dev/: zero hits for 2850, 4263, 1763 and 1844 as a MiB/s, MB/s or GB/s figure, and the near-misses are named in the note so the next reader does not "find" them by accident (1763 is a byte budget in an affordability check and an NVML corridor floor; 1844 is a seam-staging free memory delta). The pinned figure IS real: _PINNED_REF_LO_GBPS / _HI_GBPS = 4.93 / 8.88, phase_flip_boot.py:502-509. What the numbers that DO exist say: pinned 4.93/7.08/8.88 GB/s per rank (sgl-project#690) against staged O_DIRECT 2651/2602/ 3751 MiB/s per rank in the real flip on metal (sgl-project#802), i.e. roughly 1.8-2.6x -- but from two separate campaigns, never against each other, and the note says so rather than presenting it as an A/B. COMPRESSION IS DISCARDED, WITH THE ARITHMETIC, not deferred. This tree's own ANALYSE_306 already ends "do not build sgl-project#306 as a codec", and sgl-project#456's sparse write records a 0 byte win on /spinning because ZFS folds the same holes -- which is where the flip images live. Independently, at ratio 1.145 the bytes saved are 12.7%, so a serial win needs decompression at 7.9x the read rate (64 GiB/s synthetic, 20-29 GiB/s at metal rates) and even a fully overlapped one needs 9.29 GiB/s per rank, 10.07 GiB/s aggregate across three concurrent ranks. The measured decompression ceiling in ANALYSE_306 is 4.3-4.8 GB/s. Both bars are out of reach by 2-13x. THE DANGER DIRECTION, AND THE ONE POSITION THIS DOES NOT REVERSE. The file-backed arm exists so ~68.7 GiB of unreclaimable host RAM cannot OOM-kill a swapless boot, and it refuses a missing or tmpfs image dir rather than "silently allocating a pinned image the host ledger would then double-count as reclaimable". The tree has ALREADY decided that image posts are registered but not checked -- "a new refusal path here could break a boot that works today", weights_arena.py:918-924. That decision stands. It does not bind a new, opt-in, default-off pinned share, for its own stated reason: refusing a share no current boot requests cannot break a boot that works today. So only the new share may be checked, and a hybrid image must register exactly its pinned head and nothing else, because the file-backed bytes are deliberately unregistered (the registry sums NON-reclaimable bytes). THE HAZARD ANY IMPLEMENTATION MUST HANDLE, recorded because it is silent: _staged_file_refill takes O_DIRECT only when `at % 4096 == 0`. If reads resume at an unaligned pinned-head boundary, EVERY chunk misses that test, the whole refill falls back to the buffered fd -- 8304 -> 2595 MiB/s, a 3.2x regression with no error and no log line -- and the pinned head costs more than it saves. The head must be floored to _DIRECT_ALIGN. NOT BUILT HERE, deliberately: the share's size is the whole feature, and the comparison that would set it (pinned vs staged-O_DIRECT on ONE binary, same load, same bytes) has never been run. A size derived from the two-campaign mixture above would be the rig-fit the planner rules forbid, and shipping the actuator with the size left as an unmeasured parameter would put a knob in the tree nobody can set -- while a helper with no caller is exactly the defect removed from planner/hicache_staging.py in this same branch. The A/B is named as a window item, with the instrumentation that already exists for it (_timed_arena_refill / refill_report). Analysis only: no code changes, no test changes, no behaviour change. codespell clean.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 24, 2026
The user asked why a tp_to_pp flip takes 11.6 s, and whether 16 waves over
116502 live slots could not just be moved in one parallel shot. The capture
answers the first half and refutes the premise of the second.
THE 116502 LIVE SLOTS AND THE 16 WAVES ARE NOT THE COST. W25's own seam
census names one segment:
seam-census] timing tp_to_pp rank 0: 10466.8 ms across 448 segment(s),
worst 'refill_highwater->weights_refill' 9516.2 ms (91% of the walk)
kv_write->gdn_state 174.3 | cutover->done 152.4 |
flip_writeback->hicache_quiesce 74.8 | kv_pack->kv_local_read 57.4
Three consecutive tp_to_pp flips: 9516.2 / 9496.5 / 12108.2 ms in that one
segment, against totals of 10466.8 / 10568.0 / 13181.2. Meanwhile the ENTIRE
KV movement at the largest observed reshard (epoch 11, 116502 live slots,
995.31 MiB sent / 825.03 MiB received) is read 19.9 + exchange 486.0 + write
394.8 = 901 ms, and the GDN blob is 11.69-18.70 MiB. Across the window live
slots grew 947x (123 -> 116502) while the flip grew 1.26x (5077.9 -> 6416.0
ms). The ranks are already parallel: totals agree within ~40 ms while movers
legs differ by ~600 ms, and the peers absorb PP0's overrun as CUTOVER WAIT
(1313.3 / 1220.8 ms vs PP0's 225.3). A rendezvous, exactly as sgl-project#690 recorded.
SO THE SEAM IS A WEIGHTS-REFILL RATE PROBLEM, and the rate is direction-
asymmetric for reasons nothing in the tree explains. Same rank, within 2.7%
of the same bytes:
pp_to_tp 15925.8 MiB 3214-3915 MiB/s 4.07-4.96 s
tp_to_pp 16362.7 MiB 1351-1723 MiB/s 9.50-12.11 s
FOUR CANDIDATE EXPLANATIONS WERE CHECKED AND ALL FOUR FAIL, and they are
recorded so nobody re-derives them:
* not a path fallback -- SGLANG_PHASE_FLIP_REFILL_STAGED defaults True
(environ.py:348), unset in the boot, and arena_refill dispatches on the
image being file-backed, not on direction. Both take _staged_file_refill.
* not a missing fd -- both sgl-project#802 warning paths ("could not open a read fd",
"O_DIRECT unavailable") appear ZERO times in the 3.45 MB capture, against
9 "flip host image FILE-BACKED" registrations.
* not the O_DIRECT alignment cliff (sgl-project#809's 8304 -> 2595 MiB/s) -- the loop
only issues aligned offsets: chunks are 32 MiB multiples of
_DIRECT_ALIGN=4096 and `want` is rounded down to it; only the trailing
checksum tail is buffered, by design.
* not the pre-sgl-project#802 fault path -- on sgl-project#802's own discriminator the fault path
makes rank rates CONVERGE (821/775 MiB/s on links differing 1.80x). W25
DIVERGES with the link in both directions (1.59x and 1.40x).
THE INSTRUMENT IS WHAT IS MISSING, NOT THE MECHANISM. The leg reports ONE
aggregate MiB/s. The read (os.preadv) and the H2D (copy_ on a stream, depth
2) are pipelined, so that aggregate is min(read_rate, h2d_rate) with no way
to see which bound it hit. That is the sgl-project#851 class -- one number with several
meanings -- sitting inside the term that is 91% of the seam, which is why two
independent readers could not attribute the gap from code.
WHAT SHIPPED. `RefillLegTiming` accumulates, on the existing path:
read_s wall time inside preadv -- storage/ARC bound
h2d_wait_s wall time blocked on a prior DMA -- PCIe/link bound
drain_s the pipeline tail, counted apart so it can never be mistaken
for either bound
They are near-exclusive by construction: the ring only waits on a buffer
whose copy has not landed, so a read-bound leg never blocks there and a
link-bound leg blocks almost every turn.
`refill_bound_phrase` is a PURE function over that record -- no GPU -- so
both directions are falsifiable off metal, the same split sgl-project#852 used for the
allocator-cache estimator and for the same reason: a rule that can only be
exercised on metal is one this corpus has repeatedly shipped inert.
THE CAN-FAIL DIRECTION IS THE WHOLE RISK and is pinned. A phrase that always
named a bound would satisfy every "it says something" assertion while being
exactly as useless as the aggregate it replaces. So "unattributed" (not
instrumented, or no time accounted) and "MIXED" (neither half dominates) are
first-class outcomes, asserted directly, and a 101-point sweep across the
whole read-share range proves the three verdicts neither overlap nor leave a
hole.
NO BEHAVIOUR CHANGE: the timing record is optional and defaults to None, so
every caller that does not pass one runs byte-identically.
ONE PINNING TEST HAD TO MOVE, and it is worth naming because widening it
blindly was the tempting wrong answer. `test_arena_high_water_631.py`'s
`fake_arena_refill` stub replaces `arena_refill` to prove the arena is
committed before it is copied into; it did not accept the new kwarg and all
six of its refill tests failed with TypeError -- the sgl-project#624 stub-drift shape.
The stub now accepts `timing=None` (which is the whole adaptation, since the
record is an instrument with no semantics the test pins), AND it captures
what it was handed, with a new `test_the_refill_leg_is_instrumented`
asserting the caller really does pass a `RefillLegTiming`. Without that, the
signature widening would have silently tolerated the instrument being
unwired again -- a stub that accepts anything proves nothing.
TESTS (hermetic, CUDA_VISIBLE_DEVICES=""):
test_refill_bound_856.py 9 passed, 101 subtests
test/registered/unit/model_executor/ 15 failed / 763 passed, against a
VERIFIED HEAD baseline of 15 failed / 754 passed -- identical failure
set, pre-existing, unrelated to this path (bf16 vendor fallback,
coresidence budget, expert-offload kv regain). Checked by reverting this
change and re-running, not asserted.
ruff format clean; the one F401 in phase_flip_boot.py is pre-existing at
HEAD (verified against git show HEAD:...).
Full ledger, with every figure and every failed search set:
docs/dev/NOTE_856_seam_cost_ledger.md
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 24, 2026
…g but the census Half of the new validation metric. Once the flip carries no KV, cutover-blocking time is FENCE + WEIGHTS REFILL and nothing else. The refill has been in the stats dict since sgl-project#690 and now names its own bound (sgl-project#856 a). The fence had no entry at all. Its cost was visible only as a census SEGMENT -- the delta between the `flip_writeback` and `hicache_quiesce` marks, 74.8 ms on W25's binding rank -- which is a subtraction between two marks that nothing reading `last_stats` can perform. Meanwhile `maybe_flip_writeback` was already RETURNING a `FlipWritebackReport` carrying `elapsed_s`, and the seam used it as a bare truthiness test and dropped the number. So this adds no measurement. It stops discarding one. `writeback_fence_ms` goes in the stats dict and deliberately NOT into the DONE line's parenthesised list, by the same rule `drain_ms` follows and cites: ANALYSE_830 section 10's reproduction regex pins that list ending at "cutover N ms)", and silently breaking a documented grep is the failure sgl-project#830 existed to repair. None, NEVER 0.0, when no fence ran. The fence is skipped outright without a canonical store, and a defaulted zero would report such a flip as fully fenced while nothing had been persisted -- the sgl-project#606 defaulted-measurement shape, in the one place where believing it means losing KV. "This cost nothing" and "this did not happen" are exactly the two readings a seam census must keep apart. THE CAN-FAIL TEST KILLED MY FIRST IMPLEMENTATION, which is the reason it was written. `_writeback_fence_ms` first caught only (AttributeError, TypeError, ValueError); `test_an_instrument_never_raises_into_the_seam` feeds it a report whose `elapsed_s` property raises RuntimeError, and that escaped -- straight into a cutover with requests already parked. The catch is now broad, with the narrowing recorded as the thing that was tried and refuted, because this runs where the module's standing rule is that an instrument may cost a missing line and never a flip. A genuinely free fence still reads 0.0, not None, so the broad catch did not swallow the distinction the file exists to protect. TESTS (hermetic, CUDA_VISIBLE_DEVICES=""): test_writeback_fence_ms_856.py 6 passed, 4 subtests managers -k "flip or seam or phase or writeback or economy or layout or band" 1234 passed, 169 subtests, exit 0 ruff check + format clean Nothing else pins the stats dict's shape: a tree-wide grep for `last_stats` / `drain_ms` / `seam_waves` across test/registered/unit/ returns only this new file.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 28, 2026
window-958-boot died 25 s into the chunked acceptance load at scheduler.py:7010, `AttributeError: 'NoneType' object has no attribute 'end'`, one line after `sgl-project#946 PREMISE RECOMPUTE`. THE ATTRIBUTION IN THE WINDOW CLOSEOUT IS REFUTED, BY TWO INDEPENDENT INSTRUMENTS. It put the null on the sgl-project#906 seam-refusal branch (scheduler.py:8916). * LOG. The full-phrase counter `[sgl-project#906] SEAM CHUNK REFUSED rid=` is 0 in BOTH boots, and `_note_seam_chunk_refused` logs its first three occurrences unconditionally (scheduler.py:5434-5446), so the zero is a measurement and not a rate limit. Other bracketed INFO tags from the same process are present in the same file, so the sink is not the explanation. * COVERAGE, which does not depend on any logging decision. The boot rode `SGLANG_949_COVERAGE=1`; boot 1's three rank databases (evidence-665-f1/trace949_0828/.coverage.24735{12,13,14}) all report scheduler.py:8916 **not executed**, while :8911 (the truncation), :8918 (the adder), :7010 (the reader) and scheduler_pp_mixin.py:2159/:2161 (the ring actuator and the call below it) are all executed on all three ranks. A fix at that branch alone would not have touched this crash. The junction took the ELSE branch every time and re-derived, exactly as sgl-project#946 argued. THE PRODUCER IS IN THE TRACEBACK, two statements above the reader. scheduler_pp_mixin.py:2159 calls `pp_apply_dead_premise_anywhere` -- sgl-project#948's relocated actuator, armed for that boot by `SGLANG_946_ACT_AT_RING=1` in the window's own recipe -- whose terminator runs `truncate_prefix_to(0)`; :2161 then calls `get_next_batch_to_run`. Nothing re-derives in between. sgl-project#946 had justified the truncation by its NEIGHBOURHOOD ("`add_chunked_req` below derives everything from `len(req.prefix_indices)` and only THEN calls `set_extend_range`"); sgl-project#948 moved the act to a site that RUNS, for a measured reason recorded at scheduler_pp_mixin.py:2100-2109 (the old site was entered ~6 times while 9471 passes voided), and the legality argument did not travel with it. FIX AT THE WRITER, ONE PLACE. `Req.truncate_prefix_to` leaves `Range(told, told)` -- zero rows at the prefix that now exists -- instead of `None`. This satisfies `_executed_extent`'s invariant `extend_range.start == len(prefix_indices)` by construction at the only place that can break it, and closes four producers in one cut instead of one branch per boot: the ring actuator (:2159), the seam refusal (scheduler.py:8916), `add_chunked_req`'s hybrid-SWA zero-budget return (schedule_policy.py:1396, which unlike the sgl-project#679 park at :1434-1436 returns without `set_extend_range`), and the sgl-project#791 clamp sites on a `NO_TOKEN` break. None of the four can now receive a null geometry, because none is produced. ONE EDIT WAS WRITTEN AND WITHDRAWN, recorded in the code rather than dropped. Making that hybrid-SWA branch write the park geometry -- so the two park branches say the same thing -- broke `test_prefill_adder.py::test_add_chunked_req_hybrid_swa_defers_when_swa_ below_page`, which pins "returned unchanged" via `set_extend_range.assert_not_called()`. With the writer fixed the branch is no longer a producer, so the edit would have been consistency rather than a fix, and it is not free: it would overwrite the PREVIOUS chunk's range on any path reaching this branch before that chunk is stashed. In production the stash runs earlier in the same pass, so the write would be value-neutral -- but that is an argument, not a measurement, and hybrid SWA is not a configuration this fork boots. Reverted, and the divergence between the two park branches is named at the site as open. sgl-project#958's ARGUMENT IS HONOURED, NOT REVERSED. Its "NONE, NOT A RECOMPUTED RANGE" paragraph refuses `Range(told, old_end)` because keeping the old end would INVENT a pass. `Range(told, told)` invents nothing, and it is not a new state: `_park_chunked_prefill_chunk` writes `Range(start, start)`, the sgl-project#679 park writes it, and `_executed_extent` declares zero-length ranges first-class. The offer still moves -- now WITHOUT the adder: `_executed_extent` reads (0, 0), so PP0 offers told=0, the value `reconcile_pp_admission_decision` admits unconditionally. `reset_for_retract`'s `None` is deliberately untouched: two disposal sites key off that sentinel (scheduler_pp_mixin.py:6061-6075, :7222-7236) and flipping it would have silenced them. The refused-geometry exit stays reachable from that producer and is now pinned by its own test. THE COMMIT'S OWN SAFETY NET WAS DOWNSTREAM OF THE CRASH. `PPScheduleRefused` / `require_executed_geometry` fired 0 times on metal while the unguarded dereference killed the process, because it iterates `can_run_list` and a resident continuation the adder did not add is never in it. It is not made reachable here; it is made unnecessary, and the structural reason is asserted rather than argued. SIBLING, same class, fixed here so this change does not widen it: `_park_chunked_prefill_chunk` handed back the `inflight_middle_chunks` increment whenever it got past its `end is None` gate rather than only when a chunk was actually prepared. Already reachable before this change via the sgl-project#679 park's `Range(prefix, prefix)`. The predicate is now the same `end > start` the KV release beside it already used -- one expression, not two. #962a: THE SEAM PROBE COULD NOT PROVE ITS HOOK RAN. The reachability probe `cutover_participants.py` registers for `latched_batch_flags` was emitted only `if any(_stale.values())`, so "ran and found nothing" and "never ran" were byte-identical -- the sgl-project#719 shape the registry's own docstring forbids. It is now unconditional and reports `reached=`, because W37-C already showed a bare zero is not enough (it logged `checked=0` eighteen times and was still blind). sgl-project#962 ITSELF IS REFUTED, no code change warranted. `batch_is_full` does not survive the tp_to_pp cutover: the hook is unconditional in `_cutover` with no early return before the completion log; it provably ran (`cutover complete: active stack` 6 and `[sgl-project#690] CUTOVER SUB-STEPS` 6 in both boots); it cleared nothing (`#861c cleared latched batch flag(s)` 0/0); PP0 admits 8 times (boot 1) / 4 times (boot 2) after the cutover before the first latched decline; and boot 1 alternates DECLINE/ADMIT eight times in one second while having MORE latched declines (5 vs 3) and NO livelock. #962b registered, not fixed: #888b's `parked_carrier_relief` re-derivation is on the post-flip path (scheduler.py:8587) but inert, because its gate reads `_parked_decode_verdict`, whose only writer (`_note_parked_carriers`, called at scheduler.py:7675) sits behind `not running_batch.is_empty()` and is unreachable at running=0 -- the state the relief exists for. Measured 0/0 against 8 latched declines. Needs its own danger-direction analysis. TESTS. `test_truncation_geometry_961.py`, 15 tests, RED FIRST at the pin (8 failed / 7 passed before the fix). The `:7010` reader is driven through the REAL `Scheduler.get_next_batch_to_run` on an uninitialised instance carrying the five attributes that line needs, so it reproduces the production AttributeError on the production line rather than on a copy of it; `_Req` borrows the real `Req.truncate_prefix_to`. Five CANFAIL mutants pin each reader to the invariant and pass before AND after. Two further readers are driven for real (`_compute_chunked_req_next_prompt_token`, `pp_chunked_local_match`) plus the real producer (`build_pp_admission_decision`). `test_offer_delivery_958.py`: its EXIT_3 test required the refusal this fix makes unproducible; corrected to assert the moved offer, and split so EXIT 3 stays pinned against the `reset_for_retract` producer that still reaches it. `test_latched_batch_flags_861c.py`: 3 tests for the #962a receipt, including a can-fail that a blind seam is not reported as an all-clear. DESK GATE, /spinning/htsglang-gpu/.venv, CVD="". BEFORE (frozen at the pin 78d030e): serial 895 passed / 2 failed, wide 3701, narrow 202. AFTER: see NOTE below. Failure set unchanged: the two pre-existing test_collective_family_siblings_610.py failures, untouched. sgl-project#954 (test_prefetch_progress_symmetry_580.py) is outside gate scope, as before. ruff: no finding on any of the 273 changed lines (all 64 pre-existing); new test file clean and ruff-formatted. codespell: new file clean; the one hit in phase_flip_draft_bootstrap.py:558 is pre-existing. No boot was run. /spinning/gpu-arb/TICKET_961_WINDOW.md carries the boot acceptance and is drivable from that file alone.
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
as titled cc @merrymercy @Ying1123 @hnyls2002
tested with internlm2-7b and internlm2-chat-7b
Modification
as titled
Checklist
pre-commit run --all-filesor other linting tools are used to fix potential lint issues.