Repository navigation
Conversation
15 of 29 tasks
timethink
pushed a commit
to timethink/sglang
that referenced
this pull request
Mar 9, 2025
qybnb
pushed a commit
to qybnb/sglang
that referenced
this pull request
Jul 21, 2026
…heck_in code check and update para
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 30, 2026
…here the PP bytes go sgl-project#1011 -- CHECKED THE LIVE LOG FIRST, as the order required, and the honest answer is that most of it needs no rebuild. Across three boots (restore, final, wb): holds in tp with pending prefill > 0 ............ 0 holds citing tp-decode-floor-s or pp-window-s ... 0 holds citing min dwell ......................... 1345 / 1248 / 1 holds citing IDLE-LOCKED "< break-even N tok" ... 1342 / 1234 / 0 The exits are ALREADY work-gated: the policy never holds in TP while prefill work waits, and the two clocks never appear as a hold reason at all. The only reasons that fire are min-dwell (the sanctioned last thrash guard) and the PRICED economy ("0 tok < break-even 27410 tok"), which is exactly the sgl-project#677/sgl-project#819 form the order wants anti-thrash to have. pp_window_s is dead code on this config by construction: phase_policy.py:3840 gates it on `cap <= 0`, and cap > 0 whenever decode_stall_slo_s > 0 (ours is 180). CHANGED, the one place that did actuate against the drain law: the decode stall cap (phase_policy.py:3828). It was the only thing permitted to cut a drain short, and its own message printed "N tok prefill still pending" while doing it. It now DEGRADES TO A DETECTOR whenever pending_prefill_tokens > 0 -- a named WARNING with wait time and backlog -- and actuates only on an empty backlog. THE ONE HONEST CONSEQUENCE, stated and not softened: under a continuous prefill stream the backlog never reaches zero, so carried decodes wait UNBOUNDEDLY. That is the operator's decision; the warning is the whole mechanism that keeps it visible. BOOT-PROVEN: boot up, coherent (Paris / 143-67=76), 39 cutovers under agent-shaped load, 0 detector fires and 0 actuations -- i.e. no regression. The actuation path was already latent (0 fires in the two prior boots), so this boot proves the change is harmless, NOT that the detector fires. Naming that limit rather than claiming a proof I do not have. sgl-project#1014 -- WHERE THE BYTES GO. Answered from the ledger's own per-rank posts, same boot, both phases (GiB): post PP0 pp -> tp PP1 pp -> tp PP2 pp -> tp weights + runtime state 13.572 -> 4.252 7.408 -> 2.719 8.342 -> 3.662 gapped corridor holdback 1.000 -> 1.000 1.000 -> 1.000 1.000 -> 1.000 mamba state pool 0.731 -> 0.731 0.426 -> 0.365 0.304 -> 0.365 speculative intermediate 0.877 -> 0.877 0.511 -> 0.438 0.365 -> 0.438 prefill activation reserve 1.000 -> (none) 1.000 -> (none) 1.000 -> (none) rest (= the KV pool) 13.875 ->24.195 8.014 ->13.837 8.324 ->13.870 COUNT-CHECK PASSES in BOTH phases: 31.055 / 18.359 / 19.335 GiB = 31800 / 18800 / 19800 MiB = rank_gpu_memory_mib exactly. No unattributed MiB. So the entire PP->TP KV gain decomposes into exactly two terms: weights booked differently 18.69 GiB (29.32 -> 10.63 summed over ranks) prefill activation reserve 3.00 GiB (1.0 per rank, PP only) total 21.69 GiB = the measured KV delta (30.21 -> 51.90) AND THE FIRST TERM DOES NOT SURVIVE INSPECTION. The PP-phase weight posts (13.572 / 7.408 / 8.342, sum 29.32) are right: a layer-wise split holds the whole 27.5 GiB checkpoint plus runtime state. The TP-phase posts (4.252 / 2.719 / 3.662, sum 10.63) are NOT: with the flip vector 32,16,16 the expected shards are ~13.75 / 6.9 / 6.9. The TP weight post is low by ~3x. VERDICT per post, as asked: weights + runtime state ... MIS-BOOKED, not mobilisable. The TP phase's larger KV budget is substantially an accounting artifact, and the 1,274,048-token figure rests on it. Corroborating evidence from the same boot: "TP pool sized to the PP id space: 616670 tokens" and the earlier "max_total_tokens=616670 is larger than the profiled value 450402 -- use the profiled value" -- the inflated budget is largely NOT spent. prefill activation reserve NEEDED-IN-PP (prefill runs there; absent in TP by construction). 3.00 GiB, not free. gapped corridor holdback NEEDED, flip-functional, and per sgl-project#707 the floor is itself measured. Arming floor is 1037 MiB solver-derived (band floor 819 + seam entry 218 + arming margin 192). Shrink-by-measurement only. mamba / speculative NEEDED, and they are already near-identical across phases (<= 0.073 GiB delta). CONSEQUENCE FOR THE 1M CHALLENGE, computed rather than aspired: the world per-token cost is 32,768 B and is layout-invariant (ANALYSE_799 §5.2). 1M tokens therefore needs ~31,250 MiB of KV world-wide against the ~20,300 MiB the PP phase holds today -- about +10,950 MiB of REAL bytes. The ledger above shows no idle posten of that size: the only 18.69 GiB "difference" is a mis-booking in the other phase, not memory sitting unused in this one. So PP does not reach 1M by copying the TP budget. Whether it can reach it at all is a question for the post-#1009a solver with the FA split solved budget-proportionally instead of pinned 8/4/4 -- and the token axis alone is capped at 639,800 (+6.51%) at this cut, also from ANALYSE_799. I am not projecting a number I cannot source.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 30, 2026
… the allocator HOLD. This branch is prepared and deliberately parked off the shipping line until the sgl-project#855 kv-floor boot has landed and reported metal, because it moves the KV budget on every uneven-memory boot. Do not merge it into fix/1009-census-invariant before then. THE SEAM IS ANSWERED, from the code, which is what unblocked this. phase_flip_boot.py:1441-1447 states the invariant outright: # 2. Snapshot the PP checkpoint weights to host, free device originals # (VRAM ledger: PP originals + TP originals + arena never coexist). image_pp = snapshot_and_free(pp_named, layout_pp, pin=True) torch.cuda.empty_cache() So the TP stack materialises its OWN fresh shards (TpModelWorker at :1473, is_phase_flip_tp_stack=True) and the PP weights are snapshotted to pinned host and freed on device first. They never coexist by construction -- which is why 13.50 + 13.75 GiB of weights on a 31800 MiB card was never the real state, and why the correct TP post is the TP stack's own shard bytes rather than a re-view. World weight mass 29831.3 MiB puts rank0 at 32/64 near 14916 MiB. THE DEFECT. `used_by_me_gb` was `pre_model_load_memory - available_gpu_memory` -- a free-memory DELTA, which measures a WINDOW, so anything freed inside the window is credited against this rank's own bill. The weight free at :1445 lands BEFORE the TP worker build and so falls outside; the PP KV BACKING release (9632 MiB, "for the TP stack's allocation and graph capture") falls INSIDE. Measured: pp0 booked 4.252 GiB against 13.50 GiB resident, a 9.320 GiB under-report against 9.406 GiB freed, residual 0.086. pp1/pp2 under-reported 4.689/4.680 -- near-identical on two cards with different layer counts, the signature of one shared freed quantity rather than a weight difference. WHY NOTHING OOMed, AND WHY THE FIX IS SAFE. The TP pool is separately capped to the PP id space (phase_flip_boot.py:1452-1460, "the surplus a self-sized TP pool would take is unaddressable"). The slack this under-booking created was never spendable, so removing it takes away headroom no allocation could reach. That cap is also what kept a real accounting defect invisible. THE FIX. Read the allocator's own live figure alongside the delta and book the MAX. max() is the conservative operator: a larger weight post means a smaller `rest`, so this can only shrink the KV budget relative to today and can never grow it -- it cannot introduce an OOM. It also keeps the delta authoritative wherever it is larger, which covers device memory held outside the torch allocator (NCCL buffers, CUDA context) that memory_allocated does not see. The allocator is read post-weights and pre-pools, which is where it is clean: the graph-capture inflation found in #1009a enters later, during capture. Never silently corrected -- a gap logs at WARNING naming both figures, the difference, and that the KV budget shrinks by it. DESK-PROVEN, arithmetic replay against the sgl-project#1014 diff (GiB): rank PP post TP delta TP expected booked=max gap pp0 13.572 4.252 14.570 14.570 +10.318 pp1 7.408 2.719 7.280 7.280 +4.561 pp2 8.342 3.662 7.280 7.280 +3.618 booked >= delta on every rank, so `rest` shrinks or is unchanged, never grows. Import smoke clean; ruff "All checks passed" on this file. TEST SHAPE for when this lands (not run here -- speed mode keeps batteries out of the hot path): one targeted case per direction. (a) delta > allocator -> delta is booked, no warning, byte-identical to today: the default non-flip path. (b) allocator > delta -> allocator booked, warning names both figures: the flip TP stack. (c) allocator read raises -> falls back to delta, boot unaffected. The metal check is the flip boot's own "KV budget posts" line: "weights + runtime state" should land near 14.6 / 7.3 / 7.3 GiB instead of 4.252 / 2.719 / 3.662, and the TP pool should be unchanged because the id-space cap already bound it.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 30, 2026
…s ~2x and breaks serving d7c3736 (sgl-project#1015) was merged, booted, and REVERTED (a204832). It is not a mis-scoped refactor -- it takes serving down. MEASURED, boot_855_cons1_0840f82601_0830_073758 vs the same tree without it: TP-phase "weights + runtime state" (GiB) before sgl-project#1015 with sgl-project#1015 PP0 4.252 26.581 PP1 2.719 14.788 PP2 3.662 15.435 sum 10.633 56.804 The checkpoint is 27.5 GiB. sgl-project#1015 swung the post from under-booking (10.63, the defect I reported in sgl-project#1014) straight past correct to ~2x OVER-booking: 56.8 GiB of weights charged for a 27.5 GiB model, i.e. roughly the WHOLE model on EVERY rank instead of that rank's shard. Consequence, same boot: TP-phase PP0 KV budget "rest" 24.195 GiB -> 1.867 GiB EFFECTIVE max_total_num_tokens 615,434 -> 185,344 (-70 %) per-rank capacities 597210/448290/449378 -> 61152/57920/68724 coherence probe (/generate, greedy, "capital of France") -> NO RESPONSE The recalibrator then reacted to the collapsed capacities and moved the token vector [30,17,17] -> [21,20,23], which is correct behaviour on wrong inputs and would have written a garbage vector into the next boot's hint. REVERT VERIFIED: a204832 restores TP world 615,434 and the probe answers "Paris". One file, 60 lines (model_executor/model_runner_kv_cache_mixin.py) -- so the runtime blast radius of d7c3736 is exactly the weight post, which isolates the attribution. WHAT I GOT WRONG AND SHOULD HAVE CAUGHT FIRST: I supplied the sgl-project#1014 diff that motivated this fix, including the expected TP shard figures (~13.75/6.9/6.9 GiB from the 32,16,16 vector). I flagged at the time that I had NOT verified whether the flip re-materialises weights or re-views the PP residency, and that if it re-views them the "correct" TP post may legitimately be smaller than shard arithmetic. That caveat turned out to be the whole question, and a fix built on the arithmetic alone overshot. A boot-time falsifier -- assert the summed TP weight post lies between the largest single rank shard and the whole checkpoint -- would have caught this at the desk. The rest of the planner chain (#1009a/sgl-project#1010/sgl-project#1018/sgl-project#1019) is NOT reverted: it came in via cc70a6d and the earlier merges and is unaffected. ALSO ON THIS BOOT, and it works: sgl-project#778 cold-post-spill (5379340) is live and its markers fire on the real seam -- "phase-release LEND pp_to_tp: 65536 rows (~1024 MiB)" on PP0, 131072 rows (~1024 MiB) on PP1 and PP2 (row counts differ because the PP cell differs: 16384 B on PP0, 8192 B on PP1/PP2), "phase-release REPAY tp_to_pp: loan -> 0 rows" on all three before the prefill leg resumes. REPAY reports "0 MiB returned" -- the dial had not yet grown into the credit at that seam, so the repayment had nothing to hand back. That is the convergence behaviour the author described, not a leak, but it means the LEND's token effect is NOT yet demonstrated on metal and must not be counted in any ladder until a boot under load shows the pool actually taking it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.