Repository navigation
Conversation
Contributor
|
Thanks for your help. It has already been fixed by 444a024 |
hhhh1252023
added a commit
to hhhh1252023/sglang_public
that referenced
this pull request
Jun 6, 2026
- Split qwen3_6_35b_a3b aime26 accuracy into separate test case - Update qwen3_6_35b_a3b 1p_in3k5_out1k5_50ms envs and args - Update prefix90 input/output len - Remove commented-out omni test case - Dashboard: show multi-node rows, FAIL only checks single-node
cherryblo
added a commit
to cherryblo/sglang-project
that referenced
this pull request
Jul 2, 2026
modify 397b env
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…hat actually wedged flip_blocking_guards refused flip arming whenever enable_hierarchical_cache was set at all. That made the phase flip and prefix retention mutually exclusive, and the deployment resolved the conflict the only way it could: by running with enable_hierarchical_cache=False, i.e. with NO cache tier of any kind on the serving line. The wedge that earned the guard was the DISK tier at warmup, and it is fixed. 9da9dfd bounded the collectives (mem_cache/hicache_collective.py); that commit is an ancestor of the currently deployed 9925a2e, and its suite passes. The guard outlived its defect by several months of deploys. The fix shape is not invented here -- it is three lines below, in the same function. The kv-session-offload clause was already converted from "is it CONFIGURED" to "what is it DOING" (sgl-project#656, kvso_flip_contract) for exactly this reason. This applies the same correction to HiCache: the guard now names the storage backend, so the device+host-local configuration can carry a prefix cache across the flip while the disk tier stays refused pending its own evidence. Deliberate invariant change: test_phase_flip_runtime.test_guards asserted the old "enabled => refused" contract and is updated in this commit rather than left to break, with the reason recorded at the assertion. Tests, hermetic (CUDA_VISIBLE_DEVICES=""): test_hicache_flip_guard_703.py ......... new, red first (red: "Lists differ: ['hierarchical cache (sgl-project#630: ...)'] != []") test_phase_flip_runtime.py ............. updated contract test_hicache_bounded_waits_630.py ...... 14 passed + 14 subtests test_kvso_flip_contract_631.py ......... precedent clause unaffected -> 106 passed, 17 subtests passed, 53.59s Can-fail proof: test_storage_backend_still_blocks asserts the guard STILL fires for file/mooncake/hf3fs. A change that merely deleted the clause passes the enabling test and fails that one. Not claimed: that this restores cache HITS. Measured on the live instance, the device radix tree currently retains zero KV tokens (kv_evictable_tokens=0 on all three ranks, cache_hit_rate=0, 15861/15861 prefill lines at cached-token 0, including three byte-identical requests). This commit removes the blocker; whether a tier on top then hits is a separate open defect. Lint: ruff/codespell findings in this file (lines 2255, 6276, 1439-1443) are pre-existing and outside the changed region; not touched.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…r the flag stays unusable The previous commit narrowed flip_blocking_guards, which gates flip ARMING. A live boot then proved that insufficient: ValueError: --enable-phase-flip V1 refuses: --enable-hierarchical-cache (sgl-project#630: PP x disk HiCache wedges at warmup). _handle_phase_flip carries its own copy of the same stale clause and refuses at ServerArgs parse time, before a scheduler exists. Two guards, one defect; narrowing either alone leaves --enable-hierarchical-cache unbootable, so they move together and now say the same thing: the DISK tier is what wedged, and that is what stays refused. The can-fail test earned its place here. Its first version passed vacuously -- the fixture never reached the blocker list, because the validator walks the whole phase-flip surface first and returned early on a stub with the flip disabled. It failed with "'hierarchical' not found in ''", which is exactly the signal a can-fail assertion exists to produce; the fixture now supplies a minimal valid flip config so the HiCache clause is genuinely exercised. Tests, hermetic (CUDA_VISIBLE_DEVICES=""): test_hicache_flip_guard_703.py ......... 6 passed + 3 subtests TestHiCacheFlipGuard703 ............ runtime clause TestHiCacheFlipV1Blocker703 ........ boot-time clause (new) test_phase_flip_runtime.py ............. updated contract test_hicache_bounded_waits_630.py ...... sgl-project#630 root fix still green -> 87 passed, 17 subtests passed, 51.46s ruff clean on the changed test file. Still not claimed: that HiCache now HITS. The device radix tree retains zero KV tokens on the live instance (kv_evictable_tokens=0 on all three ranks, cache_hit_rate=0). These two commits remove the blockers; retention is the open defect behind them.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…ing my own stage-1 conservatism Stage 1 narrowed both copies of the guard to refuse only when a storage backend was configured, "pending its own evidence". That reservation does not survive contact with the evidence: it is the SAME evidence that cleared the host tier. The sgl-project#630 wedge was PP x disk HiCache at warmup, its root fix is 9da9dfd (bounded collectives), that commit is an ancestor of every deployed commit since, and test_hicache_bounded_waits_630.py passes 14 tests + 14 subtests hermetically. A guard cannot be justified by a defect a green suite says is fixed. Keeping the disk tier refused was conservatism rather than caution, and it blocked the thing the retention design actually depends on. Host RAM cannot be the retention store: the flip's own host weight images take 20.50 GB of the 25.87 GB usable, leaving ~5.37 GB, which is a staging buffer and not a store. Disk is the store. WHAT REMAINS GATED, and why it is not this list: the KV key's _{pp_size}_{pp_rank} suffix. That suffix is a claim about BYTES -- a PP-written page really does hold only one stage's layers -- and it drops only when sgl-project#706's whole-page format makes a page complete across stages. Refusing the backend never protected those bytes; it only prevented anyone from reaching them. The two decisions were conflated in stage 1 and are separated here. Tests, hermetic (CUDA_VISIBLE_DEVICES=""): test_hicache_flip_guard_703.py ......... rewritten for the stage-2 contract test_phase_flip_runtime.py ............. contract updated a second time test_hicache_bounded_waits_630.py ...... the fix this rests on, still green test_kvso_flip_contract_631.py ......... precedent clause unaffected -> 106 passed, 25 subtests passed, 52.10s. ruff clean. Can-fail proofs, both copies: test_other_guards_still_fire pins dual-group, tree-cache-without-enumeration and PD disaggregation; test_other_v1_blockers_ still_fire pins --dp-size and --dual-group-lane. A change that returned no guards unconditionally passes every removal assertion and fails these. Still not claimed: that HiCache hits. The device radix tree retains zero KV (kv_evictable_tokens=0 on all three ranks, cache_hit_rate=0). That defect is upstream of all of this and gates the acceptance test.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…is gone Review-gate addition to e141dab. Removing the sgl-project#630 refusal was right -- the defect it named has an ancestor root fix and a green can-fail suite -- but this path did wedge once for real, and silence is not the same as confidence. Corridor canon is warning-not-blocker, so the first flip arm that carries a disk tier says so exactly once, naming the defect (sgl-project#630), the commit that fixed it (9da9dfd, bounded collectives), and the suite that keeps it fixed (test_hicache_bounded_waits_630.py). The point is attribution: if a warmup hang ever reappears on this path, that line turns a bisect into one grep. Once, not per arm: a per-arm line on an auto-policy flip would be noise, and noise is how a real warning gets filtered out. Tests, hermetic (CUDA_VISIBLE_DEVICES=""): test_warns_once_and_does_not_block ..... fires, carries all three attribution tokens, and returns NO guard -- the warning must never become a blocker test_silent_without_a_disk_tier ........ can-fail boundary: host-only HiCache must not trip it. An unconditional warning passes the test above and fails this one. test_silent_when_hierarchical_cache_is_off -> 109 passed, 27 subtests passed, 52.05s across the guard + sgl-project#630 + kvso suites. ruff clean.
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
…r onto the existing owner rule ## The shared layout contract is agreed, with two additions that are load-bearing The sgl-project#706 strand agreed the same-key contract, framing it as the stronger form of his sgl-project#241 invariant: canonical bytes depend on no geometry, therefore the key carries none. DESIGN_704 sec 4.2c now carries the AGREED text, to be identical in both docs. Two additions he required, without which sgl-project#703 is not structurally solved: (a) DRAFT PAGES EXCLUDED BY NAME. {hash}.draft cannot be made geometry-neutral by any suffix rule: draft KV is the exact MIRROR of target KV -- head- SHARDED and token-COMPLETE -- and the draft worker exists only in the TP decode phase. Draft pages stay phase- and rank-specific and the draft pool starts COLD after a flip or reboot. A partial #cached-token share is the DESIGNED shape, not a defect. (b) THE MAMBA CANONICAL FORM IS DEFINED BY HIS SPEC AND IS NOT RESTATED HERE. 48 of 64 layers are GDN, so my attention ordering is silent on most of the model and must not be read as covering it. The definition is MambaPool.get_conv_subblock_spec (memory_pool.py:1226) with layer_extents() / MambaBlobSpec.for_layers() (sgl-project#706, e77a1e3). Implementations MUST call it rather than compute offsets locally. The trap it prevents: a mamba layer range is TWO DISJOINT byte ranges -- temporal and conv -- and the conv region is three independently head-sharded [query_key | query_key | value] sub-blocks, so a rank's conv shard is three concatenated ranges, not one contiguous slice. Cutting it flat returns the right NUMBER of bytes and the WRONG channels: silent corruption, not a crash. Recorded with it: the KNOWN GAP that the existing spec cuts by HEADS (for TP mismatch) while the PP phase shards LAYERS, so a layer cut for mamba composing with the head cut is new work and is the largest piece in his design. #704b depends on it for any prefix surviving a phase change, since a prefix cannot be resumed from attention KV alone when 48 of 64 layers are GDN. ## Page shape: OPTION A, settled A page carries all 16 attention layers for its token range, layer-major. page_size==1 is mandatory (dcp_owner_mode: a multi-token page would span owner ranks), so a page is ONE token: 32,768 B under Option A against 2,048 B per-(layer,token) objects, which would mean ~7.0M sub-4-KiB objects below the filesystem block size -- ~2x space amplification and IOPS making disk-L3 slower than re-prefill. memory_pool_host.py:793 already allocates (num_host_pages, layer_num, item_bytes), so Option A widens layer_num to 16 and globalises start_layer. Cost stated honestly: the WRITER pays, each PP stage partial-writes its layer slots at byte offsets, and a per-page completeness marker (slot bitmap header or rename-on-complete) is required and does not exist yet. ## The attention-layers rule is now confirmed on absolute grounds The restored boot (bdd777a) reports cell_size = attn_layers x 2048 EXACTLY, per rank, 7/5/4 x 2048. That is no longer a fit reproducing a pool nor an inference from allocator source: it is the live sizer agreeing with the rule term for term. Recorded in sec 2.2. ## The share quantiser: fractions onto the EXISTING owner rule The owner rule already exists and is reused rather than reinvented: distributed/utils.py:407 defines the token axis as INTEGER ratios, slot L belongs to rank r iff (L % S) in [lo_r, hi_r) with S = sum(ratios), so the realized share is exactly ratio_r / S. set_cp_token_ratios installs it and dcp_weighted_owner_bounds derives the per-rank range. Our solver emits FRACTIONS, so the bridge is quantisation -- and rounding is not neutral: rounding a tight rank UP buys rows it cannot hold, and the resulting OOM would read as a decoupling bug rather than a rounding bug. quantize_shares() is therefore a ROUNDING step and refuses to be anything else. An infeasible target is REFUSED, not repaired into something feasible but unrelated -- the caller is expected to have obtained a feasible target from vector_feasibility or fixed_vector_for_ladder, and silently substituting a different vector would hide that it did not. Largest-remainder apportionment gives an exact sum with minimal drift; only rounding-INDUCED infeasibility is repaired, by moving slots from the over-committed rank to the one with most slack. A rank quantising to zero slots is refused rather than silently dropped: it would hold no rows while still being asked for Q and a partial output, paying full collective cost for nothing. ## Test results 126 passed, hermetic (CUDA_VISIBLE_DEVICES=""), ruff clean, codespell clean. test_decoupled_kv_704b.py grows to 22: ratios sum to the period and realize the target; a finer period tracks more closely; rounding may not push a tight rank over its free memory (checked against the [44,10,10] free vector where rank0 has 2.97 GiB); an infeasible target is refused rather than rounded into place; a zero-slot rank is refused; and the even split round-trips exactly, since all-equal ratios are the classic even-DCP fast path that distributed/utils.py keeps bit-identical.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…t#706 lanes) into the tool-call argument-loss fix Brings the branch onto the commit the 30030 tree currently holds so the deploy is a fast-forward. No conflicts with the adapter or detector changes -- the incoming commits touch KV sizing and mamba slicing.
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
…-chunk, the failure is per-total
A chunked request's own committed prefix fills the pool its own next chunk must
allocate from, and it cannot evict itself to make room. Analysis, hermetic
falsifier, and priced options. NO BUILD -- the recommendation touches admission
policy and is held for GO.
## (a) Reachability, at file:line in the deploy tree
1. Each committed chunk LOCKS its prefix. radix_cache.py:546 --
cache_unfinished_req ends with inc_lock_ref(new_last_node), moving the
prefix from evictable to PROTECTED.
2. The admission budget EXCLUDES protected space. schedule_policy.py:809-825 --
rem_total_tokens is available_size() + evictable_size(). Nothing protected
counts.
3. So every chunk shrinks the budget its own successor is checked against. The
request eats its own runway, one locked chunk at a time.
4. Eviction cannot recover it. radix_cache.py:569-575 -- evict walks
evictable_leaves only, and the request's own prefix is locked. THE REQUEST
CANNOT EVICT ITSELF TO FUND ITSELF.
THE TREE ALREADY KNOWS. schedule_policy.py:993-995 names it: "the prefill input
must transiently fit the device. If not, this is the DEEP case (PS2) -> reject,
today's wedge/wait behaviour", and the born-spill admission logs that it admits
a request whose "full lifetime would wedge". What was missing is the arithmetic
saying exactly when.
THE CONDITION. With budget A at admission and chunk C, a request of length L
commits chunks until A - k*C < C, so a single request deadlocks IFF L > A. The
sharp edge: ADMISSION IS PER-CHUNK, THE FAILURE IS PER-TOTAL. Concurrently the
condition is on the SUM -- several individually-admissible requests deadlock
collectively, which no per-request check catches. It presents as a hang rather
than a reject because the request gets MOST OF THE WAY first (the falsifier
shows >= pool - C committed before stalling).
## (b) Falsifier
Hermetic, no GPU. Pins: a fitting request completes; L > pool self-deadlocks
after near-complete progress; the threshold is the POOL not the chunk (a bigger
chunk changes granularity, not outcome); and two individually-admissible
requests deadlock COLLECTIVELY.
## (c) Options, priced
A admission gate (refuse unless full L fits, and RESERVE it)
stops wedge: yes | serves L>pool: NO | needs: nothing
cost: refuses long prompts; reservation held for the lifetime, so
long-prompt concurrency drops sharply
B self-evictable prefix to host (sgl-project#703 composes)
stops wedge: yes | serves L>pool: YES | needs: the host tier
cost: host traffic; USELESS WITHOUT HOST BUDGET -- the falsifier shows it
still deadlocking at zero budget, so sgl-project#703 is a real dependency
C preempt/retract another request
does not help the single-request case: the only holder IS the victim
A subtlety the model makes explicit: the gate must RESERVE the full length, not
merely check it. Checking without reserving lets two requests both pass and then
collide -- the very shape it exists to stop.
## Recommendation: A first as a safety property, then B as a capability
The reasoning is about failure SHAPE, not throughput. A wedge is the worst
available outcome because it is SILENT -- sgl-project#699 established that /health reports
200 through it and the watchdog is disarmed by the very condition that defines
it. A refusal is loud, diagnosable and attributable. Converting a silent wedge
into a noisy refusal is a strict improvement EVEN WHEN THE REFUSAL IS
UNWELCOME, and option A does that with no new subsystem.
A alone is not a sufficient end state: it makes prompts longer than the device
pool permanently unservable, and on this rig a 327,680-token context against a
436,278-token pool leaves no room for a second concurrent long prompt. B follows
because it is the only option that keeps SERVING the request, and it is exactly
what sgl-project#703's host tier is for. They are complementary, not alternatives.
269 tests green, hermetic, ruff + codespell clean. Traffic hold honoured.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…re before the seam WHERE PREFIXES DIE ACROSS A FLIP, traced rather than assumed: * The radix tree survives. `scheduler.tree_cache` is assigned once (scheduler.py:726) and the cutover never reassigns it. * Device rows survive by design: build_flip_live_slots_fn enumerates "radix tree values UNION parked requests' rows" and the sgl-project#297 reshard relocates them BY ROW ID between the two phase pools. * THE HOST TIER DOES NOT, and not through a missing call. There are two device KV pools (phase_flip_runtime.py:1788); the TP stack builds with pp_size=1 (phase_flip_boot.py:174,248) so it spans all 16 attention layers while a PP stage spans 7/5/4. HiRadixCache binds its host pool to the pool that existed when it was BUILT -- the boot one -- and the scheduler's allocator is likewise assigned once and never reassigned. In the phase that did not build it, the host tier therefore mirrors a pool that is not live. So a prefix's only route across a flip is the geometry-free disk tier, which is what sgl-project#706 slices 1-2 made nameable from both phases. THE WRITE-BACK GAP: it is opportunistic, and nothing closes it at the seam. Device->host is eager only under write_through (threshold 1) or write_through_selective (2); under write_back a prefix is staged ONLY under eviction pressure. Host->storage is a separate asynchronous stage on the backup thread. The flip neither forces the staging nor waits for the queue: grepping the whole flip path for cache_controller / write_backup / hiradix returns ZERO hits. And no existing API can be leaned on -- writing_check only completes writes already issued, detach_storage_backend DROPS pending backups, HiCacheController.reset() clears every queue outright (pending backup work is lost, not drained), and flush_cache is a wipe despite the name. THE HOOK (mem_cache/hicache_flip_writeback.py, flag-gated, default off): stages the tree's un-backed prefixes, lets the storage stage run, and WAITS for the acknowledgements under a deadline. Placed BEFORE anything moves in PhaseFlipRuntime._execute -- ordering is the whole content of the hook, since that is the last moment at which reading the bound pool reads live bytes. Two refusals, at the two right altitudes: * PARSE time (ServerArgs): --phase-flip-writeback requires --phase-flip-canonical-kv-page and --enable-phase-flip. Without the neutral format the pages written at the seam still carry the geometry of the phase that wrote them, so the IO would be spent for a hit that cannot happen. * SEAM time: the hook NEVER raises into the flip. With requests already parked, a raise climbs into the event loop and takes down an instance that was serving fine in its current phase; a prefix that misses the store costs a later cache miss, which is the cheaper failure. Logged, not thrown. The wait is bounded for the same reason (sgl-project#630 wedge shape): whatever is not acknowledged in time stays in flight and is reported, and the flip proceeds. Tests (hermetic, CUDA_VISIBLE_DEVICES=""), 16 new: * test_flip_writeback_703.py (10) -- a flip-shaped sequence run twice against the REAL canonical store through the REAL file backend, with the tree and controller faked to the write_back policy's timing. RED: without the hook the store is empty at the seam and the post-flip TP-geometry reader misses every key. GREEN: with the hook in the same slot, the reader gets the prefix back byte for byte. Plus both refusals, the deadline bound under a fake clock, idempotence, and the off-by-default gate. * test_canonical_kv_page_args_706.py (+6) -- the argument-time refusals. Regression, same env, base c3e9487 vs this commit: unit/mem_cache 940 failed / 779 passed -> 940 failed / 862 passed (+83) unit/server_args 1 failed / 626 passed -> 1 failed / 639 passed (+13) unit/managers 4 failed / 2145 passed -> 4 failed / 2145 passed scheduler/test_phase_flip_runtime.py: 67 passed (the file the hook edits) SIZING ESTIMATE for what this can be worth is in evidence-665-f1/PLAN_PERF_PIPELINE_2026-08-16.md, labelled as an estimate: GDN state is 74.8 MiB per retained node against 32,768 B/token of KV, so retention is state-dominated below 2,394 tokens of prefix; restore beats re-prefill by 8-10x (8k prefix 0.17s vs 1.35s, 50k 0.86s vs 8.42s). The 12 GDN slots are a SIZING cap that retention does not raise -- what retention changes is the price of exceeding it. No speedup number is claimed for the 5-9 queue: the traffic's true prefix-reuse rate is not measured here, and today's realised share is zero (#cached-token: 0 on 41,952 batches). Live A/B is boot-gated and belongs to F4-r4's window list. CAN-FAIL PROOF (mutation applied, suite re-run, reverted; named tests are the ones that went red): N1 hook stages nothing -> test_with_the_hook_the_prefix_survives, test_the_hook_is_what_made_the_difference, test_already_staged_nodes_are_not_rewritten, test_a_backup_that_never_acknowledges_does_not_hold_the_flip N2 canonical-store refusal removed -> test_refused_without_the_canonical_format, and ONLY that one N3 storage stage never started (writing_check not called) -> test_with_the_hook_the_prefix_survives, test_the_hook_is_what_made_the_difference, +1 N4 deadline ignored (bound multiplied by 1000) -> test_a_backup_that_never_acknowledges_does_not_hold_the_flip N5 gate removed (hook runs with the flag off) -> test_gate_is_off_by_default, test_no_scheduler_is_a_safe_no_op Restored tree re-verified green after every mutation (10 passed). Note on scope discipline: black/isort reformatted unrelated imports in phase_flip_runtime.py on the first pass. That file is under a minimal-change constraint, so it was reverted and the hook re-applied by hand; the diff there is 30 insertions, 0 deletions.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
… it is not bound to REACHABILITY VERDICT FIRST: LATENT, not live -- and it stops being latent on exactly the boot sgl-project#703/sgl-project#706 are aiming at. `HiCacheController` exists only when a hierarchical cache is built, and today's serving flagset (evidence-665-f1/argv_*.txt) carries --enable-phase-flip with its whole family and NO hicache flags, so no controller is constructed and none of this I/O is reachable on the live line. What makes it reachable is the combination flip + hierarchical cache, which nothing refuses any more: the sgl-project#630 blocker was deliberately removed from both the boot-time and the runtime guard lists so that a prefix cache could ride the flip. That is the intended configuration of the next boot. FAILURE SHAPE: silent corruption, BOTH directions -- not a dead cache. `cache_controller.__init__` captures the device pool once (`token_to_kv_pool_allocator.get_kvcache()`), the scheduler's allocator is likewise assigned once, and the cutover reassigns neither. Both transfers name the captured object directly: * WRITE (`backup_from_device_all_layer(self.mem_pool_device, ...)`, :866) during the TP phase reads the PP pool's rows -- the stale cutover snapshot at best, unbacked pages under the flip's VA-backed pools at worst -- and those bytes are keyed by TOKEN CONTENT and, under sgl-project#706, persisted to disk. A page claiming tokens it does not hold is a wrong ANSWER later, in either phase, and it survives a reboot. * LOAD (`load_to_device_per_layer(self.mem_pool_device, ...)`, :994) fills rows in the PP pool that the model does not read, while the radix tree reports the prefix resident -- so the scheduler skips recomputing it and attention reads rows nobody filled. Also a wrong answer, also silent. THE CUT (minimal, per the fix-direction call): refuse device-tier I/O while the flip routes to its TP stack. A refused write is a prefix not cached; a refused load is a prefetch that does not land. Misses are the correct failure here and they are cheap; both alternatives are wrong output. The host and storage tiers are untouched, and the PP phase resumes normal staging after the next flip -- which is also why sgl-project#703's flip-time writeback (running at the seam, in the bound phase) composes with this rather than being blocked by it. NO FLAG, deliberately: `phase_flip_tp_routing_active()` is False whenever the flip's secondary groups were never built, so every deployment without --enable-phase-flip is byte-identical by construction and cannot enter the guarded state. An off switch would exist only to restore the corrupting behaviour. The predicate encodes "the binding belongs to the boot phase" in ONE place, so the real fix (rebinding the controller's pool at the cutover, which touches a once-assigned binding) has a single site to update. Tests (hermetic, CUDA_VISIBLE_DEVICES=""), 11 new: * test_hicache_phase_guard_718.py -- the guard is invisible when the flip is not routing (proved by an EXPLODING pool that the real prologue reaches); both directions are refused when it is; the refusal happens BEFORE any pool is touched (the executable form of "it does not copy against the wrong pool"); each direction warns once and names its own hazard; an unreadable phase module fails OPEN, since disarming every deployment on an import error would be a bigger outage than the hazard. * TestReachability -- the premise, pinned so it cannot rot: hierarchical cache is off by default, and flip + hierarchical cache is ACCEPTED. If a refusal is ever added back, that test says the guard's premise changed. Regression, same env, base c3e9487 vs this commit: unit/mem_cache 940 failed / 779 passed -> 940 failed / 873 passed (+94) unit/managers 4 failed / 2145 passed -> 4 failed / 2145 passed cache_controller.py diff: 14 insertions, 0 deletions. NOT done here, and named: rebinding the controller to the active phase's pool is the real fix and would make the device tier usable in BOTH phases instead of one. It touches the once-assigned binding that three other subsystems read, so it wants its own slice and its own flag. CAN-FAIL PROOF (mutation applied, suite re-run, reverted): P1 guard removed from write() -> test_write_is_refused_while_the_flip_routes_to_tp, test_the_refusal_happens_before_any_pool_is_touched P2 guard removed from load() -> test_load_is_refused_while_the_flip_routes_to_tp, +1 P3 predicate never disarms -> 5 failures, i.e. every claim the guard makes P4 warns on every operation (the once-set bypassed) -> NOTHING FAILED at first. Real test gap: the once-test counted the FIRST call's output and then made a second call whose silence it never asserted, so a warn-every-time regression would have passed. Closed with assertNoLogs on the repeat call, for both directions; the mutation now fails test_each_direction_warns_once. P5 fails CLOSED on an unreadable phase module -> NOTHING FAILED at first, and for a worse reason: the test named the import-failure path but never exercised it -- it called the real predicate, which returns False here because no flip groups exist. So it was pinning a different fact under a misleading name. Split in two: the honest one (no flip groups -> not disarming) keeps its assertion under an accurate name, and a new test replaces the phase module with one that cannot supply the predicate, which is what an import failure looks like from inside the guard. The mutation now fails test_an_unreadable_phase_module_fails_OPEN. Restored tree re-verified green after every mutation (12 passed).
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
… nothing to register Spec note answered for the sgl-project#706 store, with the reasoning recorded rather than the conclusion alone. DECISION: the canonical store allocates NO host memory of its own, so it registers nothing with the process-wide pinned budget (pinned_host_budget.check_and_register_pinned_post; today's consumers are the kvso host pool, the HiCache host pool and the phase-flip weight images). Both directions take CALLER-OWNED buffers -- write_extents reads the payload it is handed, read_extents fills the target it is handed -- and the file I/O is os.pwrite / os.pread against those. There is no steady-state buffer of the store's to account for, so "register at attach/resize" does not apply here rather than having been overlooked. Pinned by CONTRACT, which is the part that can rot: TestNoStoreOwnedBuffers asserts the read fills the caller's tensor and the write does not relocate it. A future change that gave the store its own staging buffer breaks those two tests, and that is precisely the change that would have to register. FLAGGED FOR WHOEVER OWNS sgl-project#550, and NOT fixed here because it is not ours: the file backend takes its read target from host_pool.get_dummy_flat_data_page(), which allocates a fresh PINNED tensor PER READ on both pool families (pin_memory=self.pin_memory -- pool_host/mha.py:471, memory_pool_host.py:563). It predates this work and the joint budget cannot see it. It scales with concurrent reads rather than with tier size, so it is a per-operation spike rather than a missing pool -- but on a prefetch-heavy path it is real pinned memory nobody counted, and the budget refuses over-commitment on numbers that do not include it. Recorded in evidence-665-f1/PLAN_PERF_PIPELINE_2026-08-16.md. Tests: 32 in the store suite (2 new), 119 across the sgl-project#706/sgl-project#703/sgl-project#718 family.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…t the cutover; bound the read spike sgl-project#719 -- THE REBIND, and the finding that shapes it. A REBIND IS NOT A POINTER SWAP. The host pool is CONSTRUCTED FROM the device pool (hybrid_pool_assembler.build_kv_host_pool(kv_pool=...)), so its layer_num and buffer sizes are that phase's. The two phases have different per-rank layer counts -- a PP stage holds 7/5/4 of the 16 attention layers, the TP stack holds all 16 -- so repointing the controller at the other phase's device pool while its host pool still describes this phase's is a NEW corruption wearing the fix's clothes: matching row ids, mismatched widths, and the copy RUNS. The rebind therefore refuses unless handed a host pool whose shape matches the incoming device pool, and phase_pools_for refuses when the boot did not build one -- which is today's real state, reported with its reason instead of proceeding onto the wrong pool. Supplying that second host pool is a boot-time question (it costs host RAM, the binding constraint per DESIGN_706 C1) and is named, not mocked away. THREE READERS, ALL OR NONE. The pool identity is captured in three places (controller: mem_pool_device / _hybrid / _allocator; radix cache: hybrid_kv_cache / kvcache / host pool; scheduler: token_to_kv_pool_allocator). A rebind that moves some and not others is strictly worse than none: the readers then name different memory for the same row id and EVERY CALL STILL SUCCEEDS. So the rebind stamps a generation on each reader and a coherence check compares them afterwards -- the failure is invisible to inspection, so it is verified by counter. A stamp that fails mid-way rolls the state to a generation nothing can match, so the tier cannot re-arm onto a torn binding. THE PAYOFF, wired through sgl-project#718's predicate: "disarmed" now asks whether the ACTIVE phase is the BOUND phase, not whether TP is active. With no rebind those are the same question (the binding is always the boot phase), so the default path is byte-identical -- sgl-project#718's 12 tests pass unchanged. After a coherent rebind the device tier is usable in the phase it moved to. Call site: after the stack swap in _cutover (the mirror of sgl-project#703's writeback, which runs before anything moves because it reads the OUTGOING pools). Refusal is logged, not raised: a refused rebind is SAFE by construction because the binding does not move and sgl-project#718 keeps the tier disarmed, while a raise at the seam takes down an instance that was serving fine. sgl-project#720 -- THE READ SPIKE, bounded and charged. Every storage read took its target from host_pool.get_dummy_flat_data_page(), a fresh pinned tensor per read that the joint budget cannot see (it accounts pools declared at attach; this is neither). ReadBufferPool is a fixed ring, allocated once, declared through check_and_register_pinned_post and unregistered on close. Exhaustion falls back to a fresh allocation -- today's behaviour, counted -- rather than blocking, because stalling a prefetch worker to save memory trades a bounded spike for unbounded latency. SGLANG_HICACHE_READ_BUFFERS=0 (default) keeps the current path exactly. Tests (hermetic, CUDA_VISIBLE_DEVICES=""), 18 new, 137 in the family: * test_hicache_rebind_719.py (11) -- all three readers move together; a reader left behind is CAUGHT (planted deliberately, since without generations that state is invisible); an absent reader refuses the whole rebind; a failing stamp leaves the set unusable rather than half-moved; shape mismatch and unmeasurable shapes refused; a phase with no host pool refused WITH the reason; the disarm lifts only after a coherent rebind and re-arms on the return leg; unarmed is byte-identical. * test_read_buffer_pool_720.py (7) -- the falsifier pair (25 reads = 25 allocations today, 4 with a ring of 4), bounded overflow, a raised read still returns its buffer, the registry sees the ring and stops seeing it on close, off by default. Regression, same env, base c3e9487 vs this commit: unit/mem_cache 940 failed / 779 passed -> 940 failed / 894 passed (+115) unit/server_args 1 failed / 626 passed -> 1 failed / 639 passed (+13) unit/managers 4 failed / 2145 passed -> 4 failed / 2145 passed scheduler/test_phase_flip_runtime.py: 67 passed (the file the call site edits) phase_flip_runtime.py diff: 23 insertions, 0 deletions. Live validation of both joins F4-r4's window list; the flip+hicache boot they need is exactly the boot sgl-project#719 makes safe -- and sgl-project#719 cannot arm until that boot also builds the second phase's host pool. CAN-FAIL PROOF (mutation applied, suite re-run, reverted): Q1 coherence check always passes -> test_a_reader_left_behind_is_caught, test_a_failing_reader_leaves_the_set_unusable_not_half_moved Q2 shape check removed (the pointer-swap trap) -> test_shape_mismatch_is_refused, and ONLY that one Q3 partial rebind allowed (absent readers ignored) -> test_an_absent_reader_refuses_the_whole_rebind, and ONLY that one Q4 predicate ignores the binding (reverts to the raw TP-active test) -> 6 failures spanning BOTH suites, incl. test_disarm_lifts_only_after_a_coherent_rebind, test_the_return_leg_rebinds_back, and sgl-project#718's own test_disarmed_is_false_without_the_flip -- i.e. the tie between the two features is load-bearing in both directions Q5 ring never reuses (release drops every buffer) -> test_green_the_ring_allocates_once_and_reuses, test_concurrent_borrows_beyond_the_ring_fall_back, test_a_raised_read_still_returns_its_buffer Q6 ring not declared to the pinned registry -> test_the_ring_is_declared_to_the_pinned_registry, and ONLY that one Restored tree re-verified green after every mutation (30 passed).
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…the manifest desk-build DESIGN FIRST, and the design's first move is to notice what is already built. The sgl-project#706 canonical store IS a per-token-content snapshot of exactly the two things a conversation checkpoint needs: {hash} for a token's KV (all attention layers, geometry-free, cut at read time) and {hash}.mamba for the GDN state, both keyed by content alone and therefore already surviving a phase flip and a reboot. So slice 1 designs no payload format. What was missing is the SESSION level: which pages, which blob, at which position, under which sampling and template state. DESIGN_410_session_checkpoints.md carries the full document. THE sgl-project#212 LESSON IS THE LOAD-BEARING CONSTRAINT, not a caveat. A KV-only prefix is worth ZERO usable tokens on this hybrid checkpoint (sgl-project#703 re-derived it structurally and pinned it: the storage hit is the MINIMUM across pools with mamba registered TRAILING_PAGES, and the device-side match advances only at nodes carrying mamba_value). Three rules follow, and the module ENFORCES all three rather than documenting them: 1. the GDN anchor is REQUIRED on a hybrid model and refused at WRITE time -- a manifest describing a prefix that resolves to nothing is a bug best caught where it is created, not at branch; 2. a checkpoint may only claim a position where state exists. With --mamba-checkpoint-interval that is an absolute grid, so the position is SNAPPED DOWN and BOTH positions are recorded: a checkpoint that quietly covers fewer tokens than asked for is a wrong answer, not a rounding. A request that snaps to 0 is refused outright; 3. completeness is VERIFIED against the store before a branch seeds anything, because a manifest holds references and the tiers evict. FORMAT: versioned (refuse unknown versions rather than best-effort parse -- that refusal is what makes sgl-project#411 a converter question instead of a silent field-drop), deterministic serialisation so a manifest hashes reproducibly, and CONTENT-ONLY: a test asserts the serialised form contains no tp_rank, tp_size, pp_rank, pp_size or layer anywhere. That is what sgl-project#706 earned and what makes a manifest portable across phases, rigs and reboots. API + REFUSALS (sgl-project#510 canon, ADMIN_OPTIONAL on all four -- the level 51 existing state-changing routes use): POST /session_checkpoint, /session_branch, /session_rewind, GET /session_checkpoints. Mid-generation policy defaults to REFUSE (a checkpoint taken while tokens are appended describes a moving target and its tail pages may not be in the store yet); the permissive mode quiesces first, never snapshots concurrently. "Branch from a non-checkpoint" is impossible by construction rather than by check: branch takes a checkpoint_id, and those exist only for manifests that were written and verified. TIER TARGET: the manifest is metadata and does NOT live in the KV tiers; the payload it references follows the existing sgl-project#407 ladder with no new mechanism, with TieredGdnBlobStore (sgl-project#711) as the blob-half precedent. Named consequence, not smuggled: a checkpoint stays branchable only while its references survive eviction. PINNING them is slice 2 work. DESK BUILD (mem_cache/session_manifest.py): the versioned manifest, build with grid-snapping and the stateless refusal, deterministic dumps/loads, verify_against_store, verify_model_identity, and seed_plan -- the ordered fetch list a branch executes, verified UP FRONT, with the recurrent state fetched LAST so its absence can never look like a completed seed. Not built and not pretended: the radix prefix insert and blob restore themselves need live pools. Tests (hermetic, CUDA_VISIBLE_DEVICES=""), 18 new, 168 in the family. The completeness half runs against the REAL backend in canonical mode, three PP stages writing real pages, so sgl-project#706's invisible-until-complete rule is part of what is tested: a page only two of three stages wrote counts as MISSING, not as partial. The named red-first case -- a manifest whose page was evicted must refuse at branch rather than seed a silent partial prefix -- is test_a_manifest_whose_page_was_evicted_refuses_at_branch, with its sgl-project#212 twin test_a_missing_gdn_blob_refuses_too. BYTE-GATE SPECED, NOT RUN (section 7 of the design): A-vs-A first to establish the determinism floor, then straight-through generation vs checkpoint-branch- continue, compared as token IDS not text -- a divergence at P+1 is a state-restore bug, a later one is a sampling/template bug, which is why the comparison is per-token. Judge ids, never timing: the draft pool starts cold after a branch by design (sgl-project#706 C7). BOOT DEPENDENCIES, explicit (design section 8): canonical store flags + file backend + page_size 1; hierarchical cache with the disk tier; --mamba-checkpoint-interval for the grid; the flip+hicache boot sgl-project#719 makes safe (plus its second host pool) if checkpoints cross phases; deterministic sampling for the byte-gate itself. CAN-FAIL PROOF (mutation applied, suite re-run, reverted): S1 the sgl-project#212 rule dropped (a stateless hybrid manifest is allowed) -> test_a_hybrid_checkpoint_without_state_is_refused_at_build S2 no grid snapping (the checkpoint claims an off-grid position) -> test_the_position_snaps_down_to_the_grid_and_says_so, test_a_checkpoint_before_the_first_grid_point_is_refused S3 branch skips verification -> test_a_manifest_whose_page_was_evicted_refuses_at_branch, test_a_missing_gdn_blob_refuses_too (the named red-first case and its sgl-project#212 twin, and only those) S4 unknown format_version parsed best-effort -> test_an_unknown_version_is_refused_not_best_effort_parsed S5 the recurrent state fetched FIRST instead of last -> test_the_plan_is_the_branch_order, test_a_complete_checkpoint_verifies_and_plans S6 model identity mismatch tolerated -> test_a_foreign_model_identity_is_refused, and ONLY that one Restored tree re-verified green after every mutation (18 passed). Regression, same env, base c3e9487 vs this commit: unit/mem_cache 940 failed / 779 passed -> 940 failed / 925 passed (+146)
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…the first Flip+HiCache boot Everything mechanical is landed (canonical format 04c6736, GDN blob a38f39f, sharded backend 19f4c68, cutover rebind ec117fa, ReadBufferPool, sgl-project#718 disarm). This is the boot that composes them, and its one open cost, priced. THE OPEN COST, stated first and found by inspection: sgl-project#719's rebind refuses unless the incoming phase owns a shape-matched host pool, and that pool HAS NO BUILDER -- phase_pools_for reads scheduler.phase_flip_host_pools (hicache_phase_binding.py:287) and nothing in the tree writes it. So the rebind refuses at every cutover today, logged and never raised, with sgl-project#718 keeping the device tier disarmed in the phase that did not build the binding. That is a safe state, and the design recommends booting IN it. HOST-RAM BUDGET, from the deployed [32,16,16] cut. A host row is that rank's OWN layers x 2048 B, so PP rows are 16,384 / 8,192 / 8,192 B while a TP row is 32,768 B on every rank -- multipliers 2.00x / 4.00x / 4.00x, i.e. 16/own_layers. Against the MEASURED pinned load (C1 at 591add2: 25.87 GB usable, 20.50 GB of flip weight images, 5.37 GB remainder): rows fitting in 5.37 GB rank0 rank1/2 PP pool only (today) 327,759 655,518 BOTH pools 109,253 131,104 So the second pool cuts the host tier to a third on rank0 and a fifth on ranks 1-2 at fixed budget; at the 9.01 GB the C1 boot actually requested it needs ~27 GB on rank0's ratio against 5.37 available -- it does not fit, and not marginally. WHICH INSTRUMENT BINDS, because reasoning from free -g gives the wrong answer: the PINNED budget refuses first (it already refused 29.51 GB at C1), while the sgl-project#721 available floor of 24.3 G has ~12.7 G of slack today (available 37 G). A second host pool is refused by the pinned check long before it threatens the OOM floor. MARKED ABSENT rather than estimated: whether the 9.01 GB host-pool figure is one rank's or an aggregate, and the per-rank split of the three weight images. The refusal message does not say and no ledger entry resolves it, so every number is given per rank AND against the shared 5.37 GB remainder, so the conclusion does not depend on the ambiguity. RECOMMENDATION: the first boot does NOT add the second pool. It does not fit, and the cross-phase path does not need it -- sgl-project#706 made the DISK tier geometry-neutral, sgl-project#703 pushes warm prefixes there before the cutover, and both phases resolve the same content key (100 GB disk = 3,051,758 canonical-page tokens against a 5.37 GB host staging tier). The safe states are the DEFAULT states, so nothing has to be remembered. Also in the document: the exact flag set and env (including why --phase-flip-rebind-hicache is deliberately NOT set), the boot-before-hold sequence with the two log lines whose ABSENCE is the stop condition, the sgl-project#630 PP=3 x disk-HiCache warmup wedge with its root fix (9da9dfd) and what to watch anyway, acceptance (byte-identical cross-phase continuation with A-vs-A first -- the sgl-project#718 shape is a WRONG ANSWER, not a miss; hits counted from log lines because cache_hit_rate reads 0.0 with real hits; ReadBufferPool overflow counter zero; the sgl-project#720 falsifier pair), and the ranked risk list. Design only. No boot, no GPU. The boot goes on the window list. Symlinked beside the other DESIGN_706 docs in evidence-665-f1/.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…k tier PREMISE FIRST, at the code, because it is nuanced and the nuance is the ticket. There IS a path to disk today, but it is INSERT-driven, not eviction-driven: * under the default write_through policy a node is staged device->host at insert (_inc_hit_count -> write_backup) and the storage write rides the write-through ACK (_finish_write_through_ack -> write_backup_storage, hiradix_cache.py); * device eviction either DEMOTES a node that already has a host copy (_evict_backuped) or DROPS one that does not (_evict_regular). Neither writes to storage; * host eviction (evict_host) frees the host rows and unlinks the node. It does not write to storage either; * under write_back, staging happens only at eviction and, when the host pool is full, write_backup returns 0 and the subtree is dropped outright. So eviction is where prefixes are LOST: a node that never reached the host tier (below threshold, or host full), and any node whose host copy is evicted while it is not already on disk (storage attached late, an earlier storage write refused by the evictor's cap, a backend detached and reattached). For those, eviction is pure loss. The pre-cutover sweep (sgl-project#703's flip writeback, e0bc260) already existed and is NOT this: it fires at the flip seam, not under pressure. THE BUILD closes exactly that gap at the two eviction seams, with three properties that are the design: 1. NEVER BLOCKS THE SERVING PATH. Demotion enqueues onto the controller's existing backup queue -- the same asynchronous stage insert-time writes use -- and returns. Eviction runs while the scheduler is admitting work; a synchronous disk write there turns memory pressure into latency. 2. BOUNDED, DROPS LOUDLY. Beyond a cap on OUTSTANDING demotions the request is dropped and counted, warned once and then every 1000. A dropped demotion is a lost cache entry -- a later miss -- and never corruption, since the page it would have written is content-addressed and simply absent. Unbounded queueing under eviction pressure is how memory pressure becomes an OOM. 3. OFF BY DEFAULT (SGLANG_HICACHE_DEMOTE_ON_EVICT=0), so the default path is byte-identical. Placement matters at the host seam: the hook runs BEFORE cache_controller.evict_host, because that frees the very bytes the storage write reads. Tests (10, hermetic, against the REAL canonical store -- three PP stages, real keys, real bytes, sgl-project#706's invisible-until-complete rule included): * RED: test_without_demotion_the_evicted_prefix_is_gone -- evict, and nothing is on disk. Today's behaviour. * GREEN: the round trip returns IDENTICAL BYTES, and in the other geometry -- demoted by three PP stages, served to a TP-shaped reader through the same content key via the sgl-project#706 read-cut. * the guards: off by default; backpressure drops and counts instead of queueing; a node without bytes or without a key is not a candidate; no storage tier is a no-op; a failing write never escapes into the eviction path; the device seam shares the bound. HONEST LIMIT: no boot, so the decode-bs-1.30-at-queue-5-9 claim stays UNVALIDATED on metal. DESIGN_706_BOOT.md section 3.5 now carries the acceptance this needs, including the metric: cache_hit_rate reports 0.0 despite real hits (known separate defect), so the hit rate is counted from PREFILL LOG LINES carrying "#cached-token: > 0", before/after at the same offered load, and the rise must hold while the device pool is at its cap -- which is the state the ticket is about. If decode bs does not move, the retention hypothesis is wrong for this traffic, and that is the finding rather than a failed boot. Regression, same env: unit/mem_cache 940 failed / 938 passed -> 940 failed / 948 passed (+10); unit/managers 4 failed / 2155 passed unchanged. CAN-FAIL PROOF (mutation applied, suite re-run, reverted): Y1 demotion never writes (the gap reopened) -> test_demotion_puts_the_prefix_on_disk, test_the_round_trip_returns_identical_bytes, +1 Y2 the bound removed (unbounded queueing under eviction pressure) -> test_backpressure_drops_and_counts_instead_of_queueing, test_the_device_evict_seam_uses_the_same_bound Y3 the gate removed (would run by default) -> test_off_by_default Y4 a failing write escapes into the eviction path -> test_a_failing_write_never_escapes_the_eviction_path, and ONLY that one Y5 the host seam demotes AFTER evict_host frees the bytes -> test_the_host_seam_demotes_before_the_bytes_are_freed Restored tree re-verified green after every mutation (11 passed). TWO GAPS THE MUTATIONS EXPOSED IN MY OWN TESTS, both closed: * Y3 caught nothing at first. The gate is DOUBLY enforced -- with it removed the call still returned False, because an unset cap is 0 and everything then drops. Fail-closed and welcome, but it left the gate untested, so test_off_by_default now also asserts nothing was COUNTED as backpressure, which only holds if the gate short-circuited first. * Y5 had no coverage at all: the seam ORDER (demote before evict_host frees the host rows) is load-bearing and nothing tested it. The live loop needs a real tree and real pools, which this hermetic suite cannot build, so the order is now pinned at the SOURCE and labelled as structural -- weaker than behavioural, and better than the nothing that let a two-line swap pass.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…hybrid-GDN family stops being resize-only ANCESTRY CHECK FIRST, as asked, and it passes. The 5 routes and the 21-test resize suite both come from 470b88e (2026-08-04), which IS in this branch's ancestry AND on the serving line 5fed8a6. No train branch touches unified_radix_cache.py, and MERGE_TRAIN_2026-08-17 lists fix/717-rebuild as merging CLEAN (held for its own review boot). So the sgl-project#545 conclusions were not missing train-carried changes. PREMISE: WHY THE STUBS EXISTED. The open question was whether attach on this cache is a GROUP operation. It is: _symmetrize_prefetch_capacity enters an all_reduce across DCP/TP ranks to derive the prefetch limit from the MIN host pool, and its own guard refuses a rank-local early return because that "would leave the other ranks in the all_reduce with no partner". A single-rank attach would hang. That turned out NOT to be a blocker. attach_hicache_storage fans out through FanOutCommunicator (tokenizer_control_mixin.py:125,:360) to EVERY rank and merges the results, so the group runs it together, and the scheduler refuses a non-idle scheduler by name first. The stubs were unimplemented, not blocked. BUILT, mirroring the shipped HiRadixCache pair: same validation with no side effects on refusal, same named refusals, same "same backend is success, a DIFFERENT backend is refused rather than silently swapped" rule (a swap would strand every page written under the old backend), plus _symmetrize_prefetch_capacity AFTER the config is applied -- the limit is the cross-rank MIN and can only be derived once each rank knows storage is on. DETACH ORDER IS THE CONTRACT, taken from HiRadixCache: drain the control queues BEFORE tearing the controller down, or acks and releases can no longer be matched to their nodes and host pages and locks leak; drain again after to sweep what the shutdown produced. The drain is LOCAL (None limits = everything on this rank) because the steady-state path derives its counts from an all_reduce and a detach may not depend on a collective its peers may already have left. A detached tier's pages become MISSES, never corruption -- keys are content-addressed, the same argument sgl-project#703 uses for drops. NO SILENT PARTIAL CAPABILITY (sgl-project#268): the MAMBA/state component is COVERED, not refused. _get_hybrid_storage_attach_kwargs passes cache_controller.mem_pool_host.entries, which spans every component the controller owns -- the same set the boot-time attach passes -- so a hybrid attach is whole rather than KV-only wearing a success message. Pinned. Tests, hermetic (CUDA_VISIBLE_DEVICES="", no server, no CUDA): test_unified_attach_detach_545.py 16 passed -- SIBLING to the resize file, not merged into it: that file owns the resize authority, one authority per behaviour (my own sgl-project#536 rule). RED-FIRST: restoring the stubs fails 15 of 16. + the existing resize suite: 37 passed together. test/registered/unit/mem_cache/ 940 failed / 819 passed -- the 940 are the unchanged pre-existing baseline on this base (lacks the sgl-project#585 conftest); passes moved 803 -> 819, exactly the 16 new pins. No regressions. ruff + codespell clean. ACCEPTANCE UPDATED in NOTE_545: attach/detach on a hybrid-GDN model are now EXPECTED TO SUCCEED with the state component covered; the previous "expect the named refusal" acceptance is struck through as superseded. STILL OPEN, named not fixed: the ENOSPC injection test, and tokenizer_control_mixin.py:370's own "# TODO: partial rollback if failed" -- if some ranks attach and others do not, nothing rolls back. The fan-out merges results so the caller learns it failed, but the group can be left inconsistent. That gap predates this change. Desk only, no boot, no model load, no serving contact.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…not fixed Withdrawing my own sgl-project#703 removal, on measurement. WHAT HAPPENED. On 2026-08-16 I retired this clause in four steps (58658aa, 7336c08, e141dab, 61d7572), arguing verbatim that "the wedge's root fix is 9da9dfd (bounded collectives) ... A guard cannot be justified by a defect that a green suite says is fixed." Both halves were wrong. * 9da9dfd BOUNDED the wait. It converted a silent two-hour gloo hang into a named 600 s HiCacheCollectiveTimeoutError. That is valuable and it is exactly what fired below -- but a deadline is not a repair, and I called it a root fix. * test_hicache_bounded_waits_630.py asserts only that the bounded calls raise ON SCHEDULE and post the same operation `recv` would, against mocked Work objects and fake groups. It proves the wait is bounded. It never proves two real ranks rendezvous, which is the thing that fails. I rested a removal on a suite that proved something weaker than the claim. MEASURED, 2026-08-17 10:57:50 -> 11:08:39, first event round after startup, on --enable-hierarchical-cache --hicache-storage-backend file over PP=3 -- exactly the configuration this clause used to refuse: PP0 pp_sync/isend[0]->pp1 waited 649.1 s PP1 pp_sync/recv<-pp0 waited 649.2 s PP2 pp_sync/recv<-pp1 waited 649.1 s All three ranks were INSIDE the collective. PP0's send and PP1's matching receive were both posted -- same group, same tag (P2PTag.HIRADIX_PP_SYNC), same 0-dim int payload -- and they did not rendezvous. So the hypotheses on offer are refuted: not a missing participant, not an unconstructed handler, not an init-order race (PP1 had posted), not sgl-project#259's numel mismatch (the payload is a scalar), and not a tag collision (HIRADIX_PP_SYNC is disjoint from GRAMMAR_PP_SYNC and DEFAULT). The mechanism is still unrooted. That is precisely why the honest response is a guard and not a comment. WHY THE GUARD RATHER THAN FIXING THE COLLECTIVE, which would be preferable: fixing it is not desk-fundable today. Both ranks post correctly, so there is nothing to correct from static reading; naming the mechanism needs a live multi-process reproduction, and I will not ship a speculative change to a collective on a serving line. NARROWER THAN THE ORIGINAL. The pre-sgl-project#703 clause refused ANY storage backend under a flip, which made the phase flip and any prefix retention mutually exclusive -- the state whose only answer was serving with no cache tier at all. This one refuses only what has wedged on metal: a PIPELINE (pp_size > 1) carrying a storage-backed tier. Device+host-local tiers and single-stage flips stay reachable, and tests pin that so it cannot quietly widen back. WHY THE REMOVAL LOOKED SAFE, which is the part worth keeping: my sgl-project#703 suite covers pp_size=3 with NO backend, and a disk backend at pp_size=1 -- never the combination this rig actually runs. The configuration that wedges was never tested, so the suite was green and uninformative about it. COST, named because a restored guard is a real loss: the sgl-project#706 disk-tier validation is blocked again until the collective is rooted. The trade is eleven minutes of wedge and a dead instance versus an immediate refusal that names the reason -- and the boot it blocks could not complete anyway. Remove this only when a test proves two ranks RENDEZVOUS, not when one proves a wait expires. TESTS test/registered/unit/managers/test_pp_disk_hicache_guard_630.py, 7 passed + 4 subtests. Mutation-proven: disabling the clause turns 3 red. Can-fails pin what sgl-project#703 unblocked -- device+host-local tier, pp_size=1 with a disk tier, and hierarchical cache off must all still arm -- so a future widening fails here. Regression: managers 12 failed / 2302 passed, the 12 baseline unchanged and the +7 are these; test_hicache_flip_guard_703 and test_phase_flip_runtime stay green (74 passed), because the narrowing preserves every case they cover.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
Merged the serving lineage in. Three doc conflicts: exec won two on CONTENT, not category -- its edits correct my own run-card (--hicache-size takes an integer number of gigabytes, so my '5G' would have failed the boot the card exists to drive) and retract a NOTE_545 claim with a real attach/detach run behind it. Docs-keep-mine would have shipped a bad flag value. sgl-project#630 did NOT clear, and the reason is a cross-lane contradiction rather than a missing patch: sgl-project#703 removed the PARSE-TIME blocker because the runtime twin was gone (7336c08), exec restored the runtime twin (90e84ad), and restoring the parse-time one would refuse the very boot this train's own run-card tells F4-r4 to perform. Left failing with the decision named. sgl-project#612 declared, sgl-project#584 both constants filed with differentiated verdicts. New: exec's double-billing fix reds two sgl-project#550 admission tests. Its credit-back is sound only under the invariant its own comment states (registration follows allocation); sgl-project#550's fixture registers without allocating. Not patched -- either the fixture is impossible or the credit-back under-charges, and rewriting one lane's test to match another's model would erase the question. Zero UNEXPLAINED new failures: three remain, each with cause and owner.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…ct the sgl-project#550 fixtures sgl-project#630: the parse-time blocker is back, narrowed to match 90e84ad EXACTLY (pp_size > 1 AND enable_hierarchical_cache AND a storage backend), with the same reason string and a pointer to the runtime twin. Refusing at parse costs a second; the runtime twin fires after a full weight load, which cost 11 minutes and a dead instance. The sgl-project#703 comment is rewritten to the new truth with its provenance: 9da9dfd BOUNDED the wait and never rooted the desync, and test_hicache_bounded_waits_630.py proves only that a bounded call raises on schedule against mocked Work objects. test_v1_blockers_named now names a storage backend, because the narrowed guard deliberately no longer refuses the device+host-local tier. DESIGN_706_BOOT.md gains PRECONDITION 0 -- this boot is BLOCKED until the pp_sync rendezvous is rooted -- so the refused boot and the run-card that describes it cannot drift apart, and it names what stays reachable meanwhile. sgl-project#550 DETERMINATION, from the producers rather than from either model. Every consumer except one goes through check_and_register_pinned_post. The exception is weights_arena.py:428 (_register_image_post), and it registers BEFORE it allocates -- lines 439-460 do the allocation -- so exec's stated invariant 'registration FOLLOWS allocation for every producer' is literally inaccurate. But the gap closes inside the same call, so any LATER checker sees bytes that are already allocated and the credit-back is sound where it is used. No producer leaves a registered-but-unallocated post standing on a success path. So the fixtures encoded an impossible machine, and they are corrected on physics: is read LIVE, so an allocated 30 GB post cannot coexist with a static 40 GB available, and it cannot stay 40 GB after 20 GB is allocated. Both tests keep their exact intent -- a post must not be admitted on its own arithmetic, and the second post must see the first -- with numbers a machine can actually be in. Residual, named not buried: on the weights_arena allocation-FAILURE path the post stays registered with nothing allocated, and there the credit-back would under-charge. Narrow, real, and owned by sgl-project#706/sgl-project#695.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…, and a lift has THREE twins Part 2 completes the sweep begun in 46e3e30. Scope as stated there: 181 candidate lines over python/sglang/srt (tests excluded), 170 fork-owned. HEADLINE: the TREE is healthy on this axis. Zero DANGLING guards -- every ticket citation resolved to a real commit history or a checkable artifact -- and zero guards needing a lift decision. The rot is concentrated in the planner's REJECTION REGISTER, which part 1 covered. THE ONE VERIFIED STALE-TEXT, fixed: server_args.py:2275 said park-tier routing happens at exhaustion sites "once the sgl-project#236 budget lands". sgl-project#236 landed; park_instead_of_demote is live and called at kv_session_offload.py:3404. The conditional clause is dropped. A CLASSIFICATION I REJECTED AFTER CHECKING IT MYSELF, and the reason it matters more than the row does. The sweep flagged barlink_path_rates.py:21 ("the measurement does not exist yet") as stale because sgl-project#278 closed and load_nccl_reference is implemented. That is wrong: the LOADER existing is not the MEASUREMENT existing. The scripts that would produce the data exist (scripts/gpu_battery/s06_nccl_reference.*, scripts/probe/nccl_reference.py), no data file does, and the consumer at :448 explicitly handles that case by keeping the paths PLACEHOLDER. The docstring is CORRECT. Fixing it would have replaced a true statement with a false one -- which is the exact failure mode this axis is most likely to commit, so it is recorded rather than quietly dropped. THE SHARPEST FIND, and it is on this audit's own axis turned against the test suite: test/registered/unit/server_args/test_phase_flip_args.py:88 still asserts that enable_hierarchical_cache=True raises a ValueError matching "sgl-project#630". sgl-project#703 stage 2 REMOVED that blocker. The test is RED on train/0817-control right now -- verified failing at the untouched base commit with both my edits reverted, so it is not this sweep's doing. That upgrades a lesson the sgl-project#703 lift already half-knew. That lift was careful about TWINS: it moved the parse-time and runtime clauses together because "fixing only the runtime clause is not enough ... both must move together or the flag is still unusable". THERE WAS A THIRD TWIN. The test pinning the gate did not move, so a careful lift still left behind a red test asserting the presence of what it had just deliberately removed. So the lift-evidence bar in the audit gains a fifth item: the tests that pin a gate move WITH it. Two twins were not enough; there are three. NOT FIXED HERE: rewriting a test assertion is not behaviour-neutral for the suite, so it falls outside this sweep's one permitted write. Filed as its own item, with the repair named (drop the sgl-project#630 row from that loop and point at test_hicache_bounded_waits_630.py, which the code comments already name as the active protection). COUNTS, with one discrepancy I am NOT resolving by picking a side: I counted 21 provenance-shaped lines inside my 181-line candidate union; the sweep counted 187 across the whole tree without that pre-filter. Different denominators, both defensible, neither reconciled line by line. Both agree on the shape -- the large majority of #NNN mentions are settled narration and only a handful are live conditions that could expire. Stated rather than averaged. STILL-VALID substantive set spot-checked: the HiCache phase-rebind refusal (nothing in the tree ever sets the host pool it waits for), the sgl-project#578 stage-table refusal (reads liftable in isolation; the full trace shows sgl-project#584's canon fills what it can and this raise is the designed fallback for what it cannot), the sgl-project#452 CUDA-graph refutation (reconfirmed three times, never reversed), the KVSO/HiCache opt-in gate, and topk>1 under uneven DCP. Two loose citations named: layers/dcp/owner.py:127 and layers/attention/triton_backend.py:432 both cite "sgl-project#76", which is an unrelated ticket -- scale analogies written as if they were pointers. The guards are valid; the citations misdirect a reader exactly as the drifted anchors do. Suite: server_args 663 passed, 91 subtests, 1 failed -- the pre-existing test_v1_blockers_named above, verified identical at the untouched base. Catalog updated same step. codespell clean.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 19, 2026
…at outlive their phase TWO HOLES, ONE WINDOW. The sgl-project#718 guard read the parallel_state routing global, which is toggled INSIDE the cutover -- one step among many -- so for the whole seam (waves moving KV rows, movers releasing the outgoing backing, the cutover rebuilding topology) the guard named a phase while pool bytes were in motion. And even a perfect predicate cannot recall a copy that is already riding the controller's private CUDA streams: write() and start_writing() run in the same Python instant (start_writing is called synchronously from write, its only caller), so the previous commit's consume-time re-check re-asks the question at the same moment it was first asked. The torn window is the STREAM's asynchrony, not the queue's: a device->host copy enqueued legitimately in PP outlives its Python call by seconds under load, and the seam releases the pool under it. Both crash specimens died exactly there -- 3 s after a pp_to_tp cutover, inside backup_from_device_all_layer, below the Python seam. THE FIX, in the two halves the window has: 1. AUTHORITY. PhaseFlipRuntime registers itself (weakly) as the phase guard's authority. Its _phase field is what the PHASE-FLIP DONE line reports -- truthful by the 3 s crash correlation -- and it alone knows the seam's extent: hicache_seam_active is raised at the no-return point (after the unanimous-abandon verdict, before the first wave) and cleared after the cutover installs the new phase, with a finally in the caller as insurance. During the seam the guard refuses device-tier I/O for EVERY binding. Outside it, the authority's phase wins over the routing global, and a disagreement logs the sgl-project#754-shape instrument line that settles whether that global was ever stale here. No authority registered (no flip runtime built) falls back to the routing global: non-flipping deployments stay byte-identical. 2. QUIESCE. At the same no-return point the runtime drains the controller's write_stream and load_stream while every pointer they hold still names live memory. Finishing those copies is correct (they become durable cache entries) and bounded (PCIe transfer of the backlog; this thread is the only device-tier producer, so nothing refills behind the drain; rank-local, so it cannot wedge the group). Ordered after the sgl-project#703 flip-writeback hook, whose staging copies are the largest legitimate producer of exactly such in-flight work. Tests: test_flip_seam_guard_760.py, 10 tests, red-first (all 10 fail on the parent commit: seam disarm and authority-wins are impossible there, quiesce/_quiesce_hicache do not exist). With the fix: 14/14 green including the sgl-project#760 stamp tests. Full mem_cache+managers sweep: 4057 passed, 43 failed -- the 43 are the pre-existing sgl-project#772 class (PhasePolicyConfig lacks idle_locked_settle_s), zero regressions, +10 passed vs the parent's 4047. ruff clean on the new code (the 13 E402 in cache_controller.py pre-exist on HEAD); codespell clean. Metal gate next: the 2-SIGSEGV repro arm must hold >=2 cutovers under 4-way load with 0 segfaults and logged seam refusals.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 24, 2026
…uild the plan empty THE RETIREMENT, performed by making the mover's INPUT empty rather than by deleting a wave loop whose extent bookkeeping (finalize_wave, span release, id-space retirement) still has to run. SEAM ORDER, now wired: fence (sgl-project#703 writeback) -> HiCache quiesce -> RETRACT ALL + DROP THE TREE -> plan rebuilt EMPTY -> weights refill -> cutover. Every downstream figure (total_slots, send/recv rows, staged bytes) derives from `tr`, so an empty `tr` is a flip that provably moves nothing. The retraction runs AFTER the fence, so every prefix worth keeping is already in the canonical store, and BEFORE the plan is rebuilt, so there is nothing left to move. `offload_kv=False`: the fence already paid for those bytes and copying them again at the one instant the instance is blocked would pay twice. REFUSES INSTEAD OF DEGRADING. No scheduler, or a tree with no `reset()` (a ChunkCache), raises SeamOrderError. Entering the next phase with a tree naming rows that hold no KV is a WRONG ANSWER, and the seam's rule is that a wrong answer is worse than a loud failure. There is deliberately no fallback to the mover. TWO QUESTIONS, TWO NAMES -- and the churn of getting this wrong is what taught it. `_staging_bytes` answers "what would this MOVE need?", and its formula is still exactly right for that question: it stays, unchanged, with every one of its pins intact (test_phase_flip_staging_reserve_631, test_seam_arena_tail_additive_656, both validated against measured corridor events). It is simply no longer the question the gate asks. `_seam_reserve_ bytes` answers "what does the SEAM reserve?" -- arena tail + draft restore + cold-stack restore, with `wave_peak` retired -- and the gate asks that. Collapsing the two under one name is the defect this build keeps removing; my first attempt did exactly that and broke 16 tests that were right. THE MOVE'S PRICE IS STILL COMPUTED AND RECORDED (`_retired_wave_peak_bytes`), because the difference between the two IS the funding claim the proof window checks, and a term that vanishes silently cannot be shown to have been retired. WHAT THIS IS EXPECTED TO REMOVE, in W25's numbers: a 2339.11 MiB tp_to_pp staging ask on PP0, behind 33 refused arms (25 on the staging rate limit) and 17 FLIP ABANDONED. TESTS REWRITTEN TO THE NEW CONTRACT -- a flip that still moves KV now FAILS: `TestStagingFormulaMatchesReality` -> `TestTheFlipCarriesNoKv`. The retired contract was "staging must cover the bytes the mover holds", asserted three ways. The new one asserts the seam's transient storage is EXACTLY ZERO in both directions (the probe measured 3.8-27.7 MiB on this fixture before), that every rank drops its prefix tree exactly once, and that the seam reserve is identical for a full plan and an empty one. The fixture still builds a real non-empty live set, which is what makes "it moved nothing" a result rather than a tautology. `test_the_unwaved_seam_cannot_afford_the_wedging_request` -> `test_the_wedging_request_is_now_affordable` -- the funding win as one assertion, on the same spendable budget that used to refuse it. `test_waving_divides_the_peak_by_about_the_wave_count` -> `test_waving_no_longer_changes_the_price_at_all` -- the wave split existed to divide a transient that no longer occurs. HONESTY NOTE: `TestMoverLiveSetIsBounded` now passes VACUOUSLY (peak 0 is below any bound) and can no longer fail. It is subsumed by the strictly stronger `test_the_seam_moves_no_kv_at_all` and is left in place only because it still guards the mover component if it is ever invoked directly. It should not be cited as evidence of anything. TESTS (hermetic, CUDA_VISIBLE_DEVICES=""): managers -k "phase_flip or seam or flip_cost or band or economy or layout_conf or uncached or takeable" 759 passed, 29 subtests, 0 failed ruff format clean; phase_flip_runtime.py ruff check clean Refill call sites (weights_arena.py, phase_flip_boot.py) untouched -- W26's refill-root diagnostic owns them on fix/856-refill-root.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 24, 2026
…ure what warm-up costs TWO PIECES THE DESIGN OWES, both consequences of carrying no KV. 1. VALIDATE-EARLY REFUSAL (sgl-project#806 pattern, ServerArgs.__post_init__). The flip retracts every resident request and DROPS the prefix tree, so the next phase starts with an empty device tier and restores prefixes by read-through. With --enable-hierarchical-cache off there is nothing to read through: the sgl-project#703 flip-time writeback has nowhere to persist, the retracted prefixes are gone, and every conversation re-prefills from scratch on every flip. That is a correctness-shaped cost, not a tuning one, and it is INVISIBLE at runtime -- the flip completes, the requests complete, and only the token bill says anything happened. A silent, expensive, correct-looking failure is what a launch gate is for. Placed beside sgl-project#806's own check and after `materialize_declarations`, for the reason sgl-project#806 documents: the hierarchical cache is switched by handlers above, so an earlier check would pass a launch this one refuses. sgl-project#806 refuses the flip that cannot ENUMERATE what it must move; this refuses the flip that cannot RESTORE what it deliberately drops. NO FALLBACK IS OFFERED AND THE MESSAGE SAYS SO -- a test asserts the phrase. Reviving the mover here would reintroduce the seam this ticket retired, the staging reserve behind W25's 33 refused arms, and the resident carry that crashed three ranks in sgl-project#825. Both exits are named instead, because which one is right depends on what the operator wanted. 2. THE WARM-UP LEDGER (managers/warmup_latency.py), the metric the user named: not "rows carried" but served-request latency by rounds since cutover. PRIOR ART CHECKED AND IT IS A NEAR MISS, not a hit: `regime_classifier.PhaseDwellGate.rounds_since_flip` has the rounds-since-flip concept but is a GATE deciding whether a flip may happen, and carries no latency. Also searched: phase_flip_runtime for warm/latency/post-cutover, the seam census (times the seam, not what follows it), the sgl-project#605 flight recorder (the seam's own peaks). Nothing measures this. Geometric bands (<=1, <=4, <=16, <=64, steady) because the CLAIM is that the cost concentrates in the first rounds and decays; a mean cannot be right or wrong in a way that shows that. Every band reports as a ratio against THIS instance's own steady state, so the figure needs no remembered number from another boot to be readable. The can-fail directions are the file's point. `None` survives wherever nothing was compared -- a ratio against an absent control reads as "no warm-up cost" while meaning "nothing was compared", the sgl-project#606 shape in the one number this ticket is judged on. "Has not flipped" never folds into "has flipped and settled". An empty ledger still says it has nothing to say. HALF-WIRED, AND SAID PLAINLY. `note_cutover` is wired at the cutover. The request feed is NOT: request latency is assembled in `tokenizer_manager`, a DIFFERENT PROCESS, so feeding it is a cross-process change rather than a line. Recorded as an open integration point instead of guessed at -- a wrongly-wired instrument reports a number, which is worse than reporting none, and this is the number the proof window judges the design on. TESTS (hermetic, CUDA_VISIBLE_DEVICES=""): test_phase_flip_needs_hicache_856.py in server_args/ -- 776 passed overall test_warmup_latency_856.py 13 passed, 5 subtests managers -k "phase_flip or seam or warmup or uncached" 564 passed, 28 subtests, 0 failed ruff format clean; ruff check adds ZERO errors -- verified per file from the repo root against HEAD: server_args 358 -> 358, phase_flip_runtime 0, warmup_latency 0, corridor_admission 0. RUFF MEASUREMENT CORRECTION, since a previous commit reasoned from it: ruff must be run FROM THE REPO ROOT or it does not find pyproject.toml and reports a different rule set entirely (phase_flip_runtime.py read as "110 errors" from a stray cwd and "All checks passed" from the root). The earlier 144-vs-144 comparison was taken with the same cwd on both sides, so its conclusion -- zero added -- stands; the absolute number was just scheduler.py's 102 plus schedule_batch.py's 42.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 24, 2026
…ip deferred with its invariant named W27-retry leaked 152 rows per retract+drop cycle and died on the third. This is the root, derived from the tree code rather than from an API guess. `MambaRadixCache.reset` (mamba_radix_cache.py:555) installs a NEW `TreeNode()` as root and zeroes `full_evictable_size_` / `full_protected_size_`. It frees no device row -- the old tree is simply dereferenced, and the rows its nodes held are orphaned. It is a BOOKKEEPING reset: right for a teardown where the pool is reset too, wrong for a seam that keeps serving. That is why the detector saw `evictable=22` (the NEW tree) while 152 rows belonged to nobody, visible only as a total mismatch. The call that actually returns rows is `evict` -> `evict_full`, whose leaf path frees through `token_to_kv_pool_allocator.free`. So the drop is EVICT-THEN-RESET (`drop_prefix_tree_returning_rows`). THE EVICTION IS LEGITIMATE ONLY BECAUSE OF THE FENCE. sgl-project#703 has already persisted these prefixes to the canonical store and the new layout re-reads them; without that, this would be data loss. That is why the seam order is fence -> retract -> drop and not any permutation of it, and it is written into the function so a later reader cannot reorder it innocently. BOTH DANGER DIRECTIONS ARE PINNED, because only one of them is loud: * orphaning -- the metal defect, modelled with the accumulate-per-cycle shape it actually had (it fired on the THIRD cycle, not the first); * DOUBLE-RETURN -- silent where the leak was loud. The test allocator raises on a second free, so an evict-and-also-free implementation fails here rather than corrupting the pool quietly. A deliberate contract change: `build_cutover_release` no longer hands back the bare `tree_cache.reset`, and `test_seam_order_856` was updated to assert that it does NOT -- the bare reset is the tempting one-liner and it is exactly what leaked. THE EMPTY WAVE LOOP IS DEFERRED, WITH THE INVARIANT NAMED. W27-retry measured 16 empty waves costing ~314 ms plus 753.6 ms for retract+consume+drop. Skipping the loop looks like free seam time and is not safe yet: `finalize_wave` calls `dst.restore_backing(layers)`, which marks the destination layers RESIDENT independently of whether any KV moved. Skipping would leave the pool answering NO to `backing_is_resident`. The cheap successor is one `restore_backing(all layers)` outside the loop; it changes backing semantics and needs its own test, so it is a follow-up and not a line here. THE LOAD DRIVER IS FIXED, and its bug was a measurement trap worth recording. W27-retry's driver reported real token counts on requests that never connected: curl failed (dead-port smoke confirms code='000', rc=7, NO file written) and the parser then read `/tmp/w26_resp_<tag>.json` -- a LEFTOVER from the W26 window, same tag scheme, same prefix -- and reported W26's numbers as this run's. Two fixes: a unique prefix plus `rm -f` before the curl, so a failure can only ever yield a MISSING file and never someone else's numbers; and a health check that ABORTS after 3 consecutive failures. Mock-smoked against the dead server: exit 3 at round 4, instead of the 640 rounds in 45 s the broken one spun. GATE (foreground, family-batched, per the sgl-project#749 lesson; no background waiters): managers core (45 PP files excluded) 3554 passed, 18 skipped, 336 subtests, EXIT=0 PP family, one file per process 45/45, 0 failures mem_cache 1710 passed, 361 subtests, 0 failed server_args 776 passed, 191 subtests, 0 failed model_executor 763 passed / 15 failed The 15 are the pre-existing sgl-project#815 family, verified earlier against HEAD (identical 15/754 set). ZERO new failures.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 24, 2026
…retracted for
W30 ran the strict-batch acceptance and found two blockers behind the pool
leak it had come to prove fixed. Neither is in the pool accounting, which
was clean across 150 flips.
FIX A -- `_live_reqs` enumerates `last_mbs`.
Arm 2 died on all three ranks in 21 s:
ResidentCarryError: PHASE-FLIP-CARRY 1 request(s) are reachable only
through last_mbs/last_batch at the cutover: ['56fddcc3c0ef...']
Two functions disagreed about what "resident" means. `_live_reqs`, the
authority the RETRACTION uses, read running_mbs / running_batch /
last_batch / chunked_req. `orphan_resident_reqs`, the cutover guard,
checks last_mbs AND last_batch. So `last_mbs` was a route the retraction
could not see and the guard did check: a request freshly prefilled under
event_loop_pp sits in last_mbs[slot], was never retracted, and the guard
correctly refused.
Fixed at the authority, exactly as the W27 fix was -- it simply stopped
one route short. TWO sites needed it: enumerating without CLEARING would
retract the request and leave the guard's reference intact. The guard is
untouched and stays as strict as it was; its docstring rule holds ("a bug
to raise, not a carry to widen").
FIX B -- the seam re-admission is FLIP TRANSPORT, and only that.
Arm 1: 150 flips in 17 minutes, 129 prefill batches, ZERO decode batches,
28 of 28 client requests timing out at 600 s. The arm auditor called it
12 times: "armed pp_to_tp (... 1 req decoding ...), the cutover COMMITTED
into the target layout, and it still built no batch in 8 rounds".
Every link is a shipped decision. The policy arms pp_to_tp BECAUSE a
request is ready to decode; the sgl-project#856 seam then retracts that very request
(no-carry); re-admitting it in TP needs a read-through prefill; strict
purity forbids prefill in TP absolutely (`Prefill batch phase=tp` count
for the whole arm: 0); so TP builds nothing and the policy flips back.
The arm's justification is destroyed by the arm's own execution.
The re-admission recomputes NOTHING -- the tokens were prefilled in the
PP window and their KV is in the canonical store from the sgl-project#703 fence. It
is a cache restore: seam mechanics, the same category as the KV the flip
moves. So it is exempt BY NAME rather than by a purity stand-down, which
would let ordinary prefill into TP and be counted a violation by both the
sgl-project#838 detector and w29_score.py -- making the acceptance unpassable by our
own instruments and dishonest about the user's rule.
THE MARKER IS SEAM-SPECIFIC ON PURPOSE. `is_retracted`/`retracted_stain`
already existed and were readable at the gate, but `reset_for_retract` is
reached from four paths: decode-OOM preemption, the PD prefill path and
the PP void path set the identical booleans. Keying on them would exempt
every preempted request's re-prefill, which is real work. So the cutover
stamps its own `Req.seam_readmit_epoch`, spent on the one re-admission it
licenses. The builder additionally keeps an exempt batch to stamped
requests only, so a new arrival cannot ride along inside it.
Rank-uniform: the stamp comes from a group-unanimous cutover and is read
off the replicated waiting_queue.
THE LIVELOCK SAFETY NET. The purity valve arms on flips that are guarded,
abandoned or refused. W30's flips all COMMITTED, so the valve was blind to
it and stood down 0 times through a ten-minute livelock. The signal it
needed was already being written to a log with no consumer:
ARM-VERDICT-WRONG is now booked as a streak and read as a fourth cause.
Its rank-uniformity is the weakest of the four and says so -- it is
bounded away, ~32 batchless rounds deep, past anything transient.
w29_score.py now counts it as a HAZARD, so if this net fires the run fails
loudly: it is a net under the acceptance, never a way to satisfy it.
Verified both ways -- 13 hazards on the W30 arm-1 specimen it previously
scored as 0, still 0 on the W29 specimen.
FIX C -- an arm may not destroy its own justification.
`PhasePolicyConfig.seam_readmit_available`, static boot config. The
DRAINED branch refuses with a named reason when the target cannot
re-admit what the cutover retracts. NOT gated on `inp.target_can_admit`,
the tempting one-liner: at arm time the residents are not yet retracted
and so not yet stamped, so that term is False for the very arm that would
make it true, and gating on it deadlocks the other way.
TESTS
15 new (test_seam_transport_exemption_w30.py) + 4 new
(test_retracted_leaves_live_universe_856.py), red-first.
CAN-FAIL, the dangerous direction: a genuine new request, an
OOM-preempted request, and an empty queue must ALL still be blocked in
TP; the round flag must not latch; exactly one site in python/sglang/
may write the stamp.
CAN-FAIL, the guard direction: `assert_no_orphan_resident_reqs` must
STILL raise without the consume -- if it stops, the guard was widened
rather than satisfied.
DRIFT-DETECTOR: every residency route the guard checks must appear in
both the authority and the consume path.
managers unit suite: 8 failed / 4035 passed, against 8 / 4016 before
this slice and 9 / 4004 at e8bce97. Same 8 pre-existing failures
throughout; +19 passes = the 19 tests added here.
Targeted policy/purity/flip family: 283 passed. ruff clean, delta 0.
Window record and specimens: /spinning/gpu-arb/W30-RESULT.md
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 25, 2026
The missing half of sgl-project#856. `retract_all` returned the list it retracted, `_release_residents_for_cutover` returned it upward, and its caller discarded it. No seam path ever called `_add_request_to_queue`. The seam's own log line promised on every flip of every boot that "the new layout re-admits them and serves the prefix by read-through"; nothing performed the re-admitting. W31 arm 2 measured the cost: 28 distinct rids, each admitted EXACTLY once ever (three ADMIT lines apiece, one per rank), 14 requests prefilled once, 78 requests retracted across 42 cutovers, and ZERO completions -- every client waited out its 600 s timeout. W30 and W31 were both read as a flip "livelock"; they were the flip ping-ponging over an instance whose work it had already dropped on the floor. `Scheduler.readmit_seam_residents`, called from the release site. ORDERING: consume FIRST (inside `_retract_and_consume`), requeue SECOND. A request that is simultaneously live-referenced and queued is double-billed by every consumer that sums the two -- the sgl-project#731 shape. QUEUE POSITION: FRONT, as a block, in original arrival order. These are the oldest work AND the flip's own justification -- the tp-ward arm fires because they are ready to decode. Appending them behind arrivals that landed during the ~6 s flip lets a busy instance starve the bundle it just flipped for. Order is restored from `kv_arrival_seq`, which `_add_request_to_queue` already preserves across a retracted re-queue. ABORT PATH: correct by construction, because the requeue happens AT the release site. There is no window in which the list exists and is owned by nobody -- if the cutover raises after this point the flip abandons, the layout is unchanged, and the requests are already on the SOURCE layout's queue, which is where an abandoned flip should leave them. Deferring this to the end of the cutover would recreate the defect for exactly the abort case. sgl-project#703 FENCE: asserted, not assumed. `_writeback_fence_ms` returns None for "NO FENCE RAN" -- a real state, since the fence is skipped without a canonical store -- and that must never read as "fenced, cost 0 ms". The seam names it when it re-admits unfenced: not a wrong answer, but the silent cliff this no-carry design exists to avoid. ONE MOVER, NOT TWO: it calls `_add_request_to_queue(req, is_retracted=True)` and then moves that block to the front, so it inherits the priority validation, the queued-limit abort, the retract timestamp and -- load-bearing here -- `_prefetch_kvcache`, which is what makes the promised read-through hit. RETRACTED MUST EQUAL READMITTED: the seam compares and logs `RE-ADMISSION MISMATCH` on any difference, so the next boot's first check is arithmetic rather than inference. TESTS (14, red-first; the stand-in binds the REAL method) * all N return, exactly once, queued as retracted; * FRONT of newer work; arrival order restored even though the seam enumerates residents by slot, which is not arrival order; * a request the queue legitimately refuses is not conjured into the block; a client that gave up is not re-admitted; the count reports what LANDED, not what was tried; * the stamp SURVIVES the round trip, checked through the real `seam_readmit_candidates` -- stripping it would put the requests back where strict purity still refuses them, i.e. the W30 livelock again; * rank-uniformity: two ranks given the same requests in different slot-enumeration orders rebuild the identical queue; * abort path and consume-before-requeue pinned by source order. CAN-FAIL, proven by probe: re-applying the original defect (discarding the return value) turns 3 tests red; restoring makes all 14 green. Full managers suite 8 failed / 4054 passed -- the same pre-existing 8; the strand reads 9/4004 -> 8/4016 -> 8/4035 -> 8/4054. ruff clean. Window record: /spinning/gpu-arb/W31-RESULT.md
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 25, 2026
…althy fence W37-G (boot_w37g_0825_1326.log): 39 cutovers in 5.5 min, ZERO completions, and `#cached-token: 0` on all 209 prefill batch lines. The inherited framing for sgl-project#783 was "the radix tree holds rows, match returns 0" -- a dark READ path. That is falsified in both halves. Every fence of the entire boot: 33 x eligible=0 staged=0 already_staged=0 acked=0 outstanding=0 elapsed=0.000s/2.000s 3 x eligible=3 staged=0 already_staged=3 acked=0 outstanding=2 elapsed=0.000s/2.000s 3 x eligible=1 staged=0 already_staged=1 acked=0 outstanding=1 elapsed=0.000s/2.000s `acked=0` in every one. Nothing was ever confirmed into the canonical store. `eligible = len(_hashed_nodes(tree_cache))`, so eligible=0 means the device tree carried no hashed node at fence time -- and the tree drop independently returned 0 rows on 36 of 39 cutovers, including cutovers that retracted 6 and 7 requests. Two independent measures agree the tree was EMPTY. A read path cannot be the root when there is nothing to read. WHY NOTHING SAW IT. The seam's guard is headed "sgl-project#703 FENCE COVERAGE, ASSERTED RATHER THAN ASSUMED" and warns only when `_writeback_fence_ms(...) is None`. That helper returns `elapsed_s`, and an empty fence returns 0.0, not None -- silent on all 33. `FlipWritebackReport.complete` is `outstanding == 0`, so those same 33 also logged at INFO as COMPLETE. Two instruments, both correct, both blind to the one state that matters: a cheap fence and a healthy fence are indistinguishable BY COST, because the healthy case is also cheap. `test_writeback_fence_ms_856.py` names this exact outcome in its own docstring -- "a defaulted zero would report such a flip as fully fenced while nothing was persisted" -- and then pins the wrong variable. It guards a DEFAULTED zero; W37-G produced a GENUINE zero from an empty tree and reached that outcome by a path the test never considered. THIS COMMIT IS THE DETECTOR ONLY. `FlipWritebackReport.persisted_nothing` asks the question the read-through actually depends on -- is anything retrievable after the tree is dropped -- from counts the report already carried and nothing read. Deliberately narrow: true only when NEITHER route survives (no storage ack AND no pre-existing host copy), so the 6 lapsed fences that already draw the "deadline reached with backups still in flight" warning are not double-reported. Wired into the seam so it is not another desk-written instrument. Tests: red confirmed before the fix (AttributeError on `persisted_nothing`). The wiring is proven BY EXECUTION, not by `inspect.getsource` as all four existing tests of `_release_residents_for_cutover` do -- source inspection cannot tell a guard that runs from one that is unreachable. Both directions pinned (empty fence warns / healthy fence silent / lapsed fence silent), and an `if False` mutant on the guard kills the wiring test. 79 passed across the seam neighbourhood plus the #861l reachability gate. black/isort/ruff (--select=F401,F821,UP037, the repo gate) clean on the changed files; codespell and UP037 hits in phase_flip_runtime.py are pre-existing on HEAD and untouched. Also included: isort reordered two pre-existing imports in phase_flip_runtime.py. Gate-mandated, unrelated to sgl-project#783, named here rather than left silent. NOT FIXED HERE. The root is a closed loop: retention is finish-only since ff5651a, the flip retracts every resident before it finishes, `retract_all` -> `release_req(offload_kv=False)` frees that KV without tree insert or writeback, so the tree stays empty, the fence has nothing eligible, the store is never written, re-admission finds neither tier and recomputes in full, which does not finish before the next cutover. `build_cutover_release` justifies `offload_kv=False` as "the FENCE has already persisted the prefixes ... so a second device->host copy would pay twice" -- a premise W37-G falsifies, and the same false premise is load-bearing in two places.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 25, 2026
…not by handover THE DEFECT. The sgl-project#856 cutover retracts every resident and keeps nothing, so the state a phase transition must preserve simply does not survive it: * PHASE-FLIP-GDN moved 0 slot(s) on ALL 228 flips of the W37 series. The GDN mover reads `flip_mamba_slots` = resident mamba slots UNION tree checkpoints, and BOTH are destroyed at phase_flip_runtime.py:10829, one seam step before the mover runs at :11139. * The sgl-project#703 fence walked an empty tree: eligible=0 on 78 of 85 cutovers, acked=0 on every fence of the boot. * #cached-token: 0 on 403 of 403 prefill batch lines (W37-H arm A, the control on this tree). WHY NOT AN INSERT. Persisting at that instant by inserting into the tree was tried and measured: W37-H arm B died 33 s after ready, all three ranks, `pool memory leak detected! total=468981, available=108565, evictable=1, withheld=360437` -- 108565+1+360437 = 469003, i.e. 22 rows claimed twice. `readmit_seam_residents` brings the population straight back ("W31: RE-ADMIT THEM") and it resumes on rows the tree had taken. Ownership transfer is structurally wrong for a population that returns; `cache_finished_req` is the finish CODE PATH, not a finished request. THE FIX, IN TWO HALVES THAT ONLY WORK TOGETHER. Half 1 -- copy at the cutover retraction. `release_req(..., copy_state=False)` calls `offload_kv_cache` BEFORE `release_kv_cache`, while the rows still hold live bytes. Row ownership is untouched, so the arm B double claim cannot recur (`is_insert` stays False). Threaded through `retract_all` and set True at EXACTLY ONE line, `build_cutover_release._retract`. That single-site property is load-bearing: `retract_all`'s only other caller is the decode-pressure path, whose rate is load-dependent, and the host budget (0.585 GiB/cutover, ~57 MiB/s aggregate) is priced at the flip cadence. "Ungated by design" means no flag -- the condition is structural. Half 2 -- restore where the rows come back. NOT in `readmit_seam_residents`, which only re-queues: by then `reset_for_retract()` has cleared `req_pool_idx`. `restore_seam_state` runs in `prepare_for_extend`'s per-req loop, after `alloc_for_extend` (rows exist) and before `is_retracted` is cleared -- the same shape as the proven disagg path, `_pre_alloc` then `load_kv_cache`. The guard is the PRESENCE OF THE COPY, not `is_retracted`: the flag is also true for pressure retractions that never copied, so keying on it would request a restore that does not exist. The copy is consumed, so a second pass cannot re-apply stale bytes. Enabling change: the mamba half of the copy did not exist on this rig's pool. `Req.offload_kv_cache` promised "copies over both the kv cache and mamba state" and passed `mamba_indices`, which `UnifiedSWAKVPool` accepts and never reads -- correctly, since a KV pool with no mamba pool has nothing to copy. Only `HybridLinearKVPool` honours it, because it owns one. So the capability is now DECLARED (`supports_mamba_cpu_copy`, default False on `KVCache`, True on `HybridLinearKVPool`, forwarded by the allocator to its `_kvcache`) and `Req` dispatches on the declaration, covering exactly the pools that have no owner to delegate to. Exactly one mover per payload, enforced rather than promised. The form reuses the house idiom (`BasePrefixCache.supports_mamba` / `supports_swa`); the allocator tree had none of its own. The declaration must take the SAME hop as the payload: allocators implement `get_cpu_copy` as `self._kvcache.get_cpu_copy(...)`, so a declaration that did not forward would let `Req` read the base False while the pool underneath copies mamba -- copying it twice. The getattr default is kept there because `UnifiedKVPool` and `DeepSeekV4UnifiedKVPool` declare no base class and genuinely cannot answer; it is removed at the `Req` callsite, where every allocator inherits the method and a missing attribute is a real defect. TESTS test_seam_state_copy_783 4 copy fires at the cutover and nowhere else; pressure retraction unchanged test_seam_state_restore_783 6 restore round-trips, is consumed, and is wired after alloc / before the clear test_seam_ownership_ledger_783 8 drives the PRODUCTION invariant (SchedulerInvariantChecker._check_pool_ invariant) over a claim ledger; gates the COMBINATION, and its can-fail shows half 1 alone balanced while the pair leaks -- the arm B shape, at the desk test_unified_mamba_cpu_copy_783 8 the declaration is pinned, including a pool that declares True and lies Each file carries at least one assertion that passes without the change, so a broken fixture cannot masquerade as a finding (it caught three of mine). Serial managers battery, cards visible (this gate is not hermetic): 4358 collected = 4348 passed + 8 failed + 2 skipped, 356 subtests, 721.20s Failure set identical BY NAME to the standing 8: staging_reserve_631 x4, rank_prefill_log x1, hisparse_unit x2, draft_cuda_graph_removal x1 Zero unexpected names, zero standing failures missing. Collected == ran, so the run is complete -- including test_pp_retracted_pass_void_797, which wedged in an earlier run while arm A was still winding down. black/isort applied, ruff gate (F401,F821,UP037) clean, codespell clean. NOT PROVEN HERE: that the prefix actually survives a flip on metal. That is the boot, and its acceptance lines are #cached-token > 0 after a flip against 403/403 zeros, and PHASE-FLIP-GDN moved > 0 against 228 zeros.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 27, 2026
…ker per abort The abort path is the leading candidate for the rank-local slot divergence behind the PP output-ring wedges, and the code says why itself. `abort_request` carries sgl-project#631 pin 4 verbatim: "an abort applied on one rank before its peers DIVERGES THE REPLICATED LIVE SET mid-flip" -- and the guard that prevents it is conditional, `if window is not None and window.active`. The `phase_flip_abort_window` is activated only on arming and drained after the cutover, so OUTSIDE an armed flip `_abort_request_now` runs directly, on whichever rank processes it, in whichever pass it lands. The hazard is recognised, named, and closed only inside the flip window. THE CHECK COULD NOT BE MADE, WHICH IS THE POINT OF THIS COMMIT. Grepping the three wedge logs for an abort near the onset returns nothing -- and that nothing is worthless. Every marker inside `_abort_request_now` is `logger.debug` and the boots run `log_level='info'`: measured, ZERO DEBUG lines in boot_accept2e0827_0827_0454, boot_accept2e0827b6_0827_0613 and boot_802f_staged1_0822_1716. So "no abort before the wedge" is a LOGGING GAP, not a finding. This is the marker-absence trap sgl-project#843 hit on this same path ("the only refusal marker was a logger.debug on a boot running log_level='info', so it could never appear"), and reporting the null as evidence would have been the second instance. ONE SUMMARY LINE, not the per-request ones. `abort_all` can name the whole live set, so promoting those would trade a blind spot for a flood -- the sgl-project#801 void-streak shape in reverse. This says an abort happened, when, whether the flip window deferred it, and what it targeted, which is everything the discriminator needs to place it against a wedge onset. `deferred` is now read once into a local and used for both the log and the branch, so the line cannot disagree with the path taken. WHAT THE SAME SWEEP DID FIND, recorded because it is real and does NOT support the abort hypothesis: * Boot 1's wedge onset (last progress 05:08:59) is preceded by EIGHT SECONDS by `sgl-project#905 HOST-POOL DOUBLE-FREE about to raise ... 8192 of 8192 index(es) are in range but not allocated, span [3530, 14937]` on all three ranks, and the `[sgl-project#703 flip-writeback]` drain fails with it. Boot-1-specific: zero such lines in boot 6 and zero in 1712. The magnitude is the same 8192 the sgl-project#927 hit prefix carries, on the HOST pool rather than the device one, which is worth linking rather than filing twice. * Specimen 1712 shows a rank-local admission-congruence retraction (`sgl-project#797 PP-ADMISSION pass voided on rank 1 ... told=147456 local=139264`) -- that is the in-loop site, already covered by the void relay whose default sgl-project#801 widened. * So the three wedges do NOT share one proximate cause in these logs, and the single-class assumption should not be carried further without evidence. NO BEHAVIOUR CHANGE. The branch is byte-identical; only the marker is new. Import smoke + wiring check green (the marker precedes both branches, and the branch reads the same `deferred` the line printed).
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 31, 2026
…t waited for a chunk the gate refuses to build BOOT-PROVEN EDGE (boot_855_1050dev_0840f82601_0831_115825, the boot 20 livelock). The open question of the handover was WHY the broken chunk never completes before the 30 s abandon. It is not a race: inside the armed window 12:22:19-12:22:49 PP0 logged ZERO `Prefill batch` lines and 15 `Decode batch` lines. The chunk was never attempted, and the re-arm is in the SAME SECOND as the abandon (12:22:49), so no unarmed window existed in which it could be. N9's remaining candidate (abandon deadline vs chunk completion time under growing backlog) is therefore FALSIFIED. THE BINDING TERM, with file:line. `prefill_blocked_here` (phase_purity.py:1087-1095) grants the sgl-project#887 one-chunk exception only when BOTH `prefill_allowed_in_tp_now(spent)` AND `tp_compute_fits_in_one_chunk` hold -- deliberately, so the gate and the sgl-project#838 detector permit the same batches (REGISTER_OPEN_876 on sgl-project#887). `tp_compute_fits_in_one_chunk` is `0 < pending < chunked_prefill_size`. The last grant was 12:22:11 with new_tokens=3392 against a 4096 cap; the backlog then crossed the cap and never came back (12347 -> 48866 -> 101075 tok), so the gate refused on every later round, SILENTLY, at its final `return not _relaxed(...)`. The grant is spent AT the grant (`_spend_tp_compute_chunk`), so a refusal on the `fits` term leaves the budget untouched. The hold (`prefill_runnable_in_current_layout`, phase_flip_runtime.py:156) read ONLY that budget, kept answering "TP can still make progress", and `chunk_blocks_quiescence` kept the rank un-quiescent for ever: PP0 armed 29 / committed 4 / abandoned 48, `this rank ready=0` in all 72 abandon lines, backlog 4618 -> 101075 tok. CLASS: a hold predicate that predicts another gate's decision in a different currency. SIBLING SWEEP over the three consumers of the sgl-project#887 grant: the gate itself reads both terms; `maybe_arm_phase_policy` (sgl-project#942, scheduler.py:13611- 13632) reads both terms and says so in its own comment; the flip hold read one. The fix makes the third consistent with the two that were already right, by passing the gate's OWN side-effect-free probe rather than a second copy of it. FUTURE CHECK: a new reader of `tp_compute_budget_remaining` that makes a runnability claim must also read `tp_compute_fits_in_one_chunk`. AND THE OPERATOR'S CONDITION, which turns this from a deletion into a replacement. Once the hold correctly reports "this layout cannot finish the chunk", the cutover commits over the broken chunk. That is licensed by sgl-project#988 riding the prefix across (loss <= 1 chunk = the sgl-project#939 grant) ONLY while the COMPLETED pages are settled in the store. The old strict arm blocked on "incomplete"; it now blocks on the real hazard -- an unacked prefix -- read from the EXISTING sgl-project#792/sgl-project#703 fence (`ongoing_write_through`, the same counter sgl-project#1050's `reclaim_rows_for_drop` and `on_idle` gate on), never a second ledger. Unknown is refusal, never permission. The hold is bounded by the ack (milliseconds), with the 30 s park deadline still the outer backstop; no second clock. UNTOUCHED AND PINNED BY TEST: mid-admission (no pool row -> still blocks), non-strict (residual, still filed not solved), and pp_to_tp drain-and-flip (runnable HERE -> still blocks, which is what keeps all prefill in PP). The PP-microbatch-in-flight half has its own predicate and is not read here. DETECTION: `_why_not` returned one string for three different holds. It now names which term is holding, including the new unacked-prefix case. DESK CHECK (matched to the error class of this edit -- a control-flow inversion in a restructured predicate, which py_compile and import smoke are structurally blind to): devtools/check_1033_quiescence_edge.py, 24 cases, hermetic CUDA_VISIBLE_DEVICES="", all pass. Includes a RED-FIRST arm that evaluates the PRE-FIX expressions on the measured boot-20 state (budget 2, pending 48866, cap 4096) and asserts they produce the wedge, and the POST-FIX expressions on the same state and asserts they commit only against an acked prefix. Plus compile + import + an order proof that both probes are assigned before either read inside get_next_batch_to_run. NOT YET BOOT-PROVEN. This is DESK-PROVEN at the predicate; the metal proof is boot 21.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Sep 4, 2026
…ee adversarial lenses found in the six cuts WHAT WAS RED, and every finding was re-verified at the tree before it was acted on. Two of the eleven reported were REFUTED and are named at the end. 1. sgl-project#1202 added `mbs` to the residency AUTHORITY and not to the retirer. `_live_reqs` walks `mbs`; `consume_retracted_from_live_universe` did not. That is the W30 asymmetry re-opened, and it is the W27 death: the release frees a request the authority then re-enumerates, and `resident_mamba_slots` (gdn_flip_mover.py:620) raises KvReshardError on a live request with no mamba slot -- inside the no-return region, where the only outcome is a dead rank. The mbs-only shape is ordinary, not exotic: under event_loop_pp a freshly planned prefill batch sits in `mbs[slot]` while `running_mbs[slot]` holds the decode set. RED: the property test "authority and retirer walk the same containers" reported authority-only = ['mbs']; the concrete test read "0 != 1 : the mbs route retired no reference". Pinned as a PROPERTY over the two walks, so the next route added cannot reintroduce it. The stale present-tense collateral at scheduler_pp_mixin.py:5121 ("_live_reqs does NOT enumerate mbs", dated 2026-09-04) is rewritten as the dated fact it now is. 2. sgl-project#1203 A5 spent three ESCALATION budgets in the group's abandon currency. A5's premise is right and is kept: a rank-local counter that zeroes itself when this rank's own objection clears can never reach its limit while ranks take turns objecting. But `flip_host_headroom_verdict` and `flip_seam_budget_verdict` do not merely stop deferring at the limit -- they return (allow=True, escalated=True), "PROCEEDING WITH EYES OPEN" under a failed sgl-project#721 host floor -- and the writeback arm proceeds with an incomplete sgl-project#703 fence. `_seam_abandons_in_a_row` is incremented on EVERY reduced-fit abandon or frame divergence, so three unrelated abandons disarmed all three guards and the next GENUINE shortfall escalated on its first firing, having deferred zero times. A bound may be widened to the group's currency; an escalation that permits the hazard may not. REPAIR: each guard is bounded by its own count again, and that count is refunded ONLY by a completed flip (beside the abandon book, whose own comment already states the rule) or by the guard's own escalation. The whole reset policy is `flip_defer_budget_after`, one pure function, so the three copies cannot drift again. RED: 8 of 10 A5 tests failed at the parent. Three instruments that named the wrong counter are corrected with it: "consecutive" becomes "in this abandon run", and the host-RAM defer is booked BEFORE its own log line instead of after. 3. sgl-project#1204's abstain discarded a term the rank had successfully read. Both reads shared one `try`, so a rank whose `backed_rows()` succeeded and whose `live_floor_rows()` then raised contributed `_UNBOUNDED_ROWS` in slot 0 -- the MIN identity, i.e. "I am not the poorest". Slot 0's MIN becomes the level the peers cap to and the ceiling `book_deferred_grow` clamps to, so erasing a poor rank makes the group agree an id level it cannot map, which `backed_rows`' docstring calls a cudaErrorIllegalAddress that kills every rank. The hang the commit removed would have been traded for a wrong group answer -- the corrupting direction bought to avoid the refusing one. REPAIR: abstain PER SLOT. Each slot carries this rank's own measurement or that slot's neutral, unchanged for a wholly unreadable relief. RED: "30 != 1099511627776". 4. sgl-project#1205's `seam_refused` measured a population its label does not name -- the sgl-project#1205 defect class, committed inside the sgl-project#1205 fix. The fence read `seam_refusals()` with NO direction, summing "load" refusals raised on the controller's own background threads while the fence runs, and printed the delta as "of refused_silently, the share the FLIP SEAM refused". REPAIR: `seam_refusals("write")`, and the log line and the field comment now say what it is: process-wide write-direction refusals during the fence, not a subset of `refused_silently` and not per-node (consume_gate refuses a whole queue and counts one). RED: "1 != 3" when the direction-less read is put back. 5. `assert_future_map_identity` was REACHED and CANNOT-FAIL. Measured: four combinations of (algo NONE|EAGLE) x (pool pp|tp), ZERO fires. `create_future_map` passes `self` as `spec_algo` and the scheduler's pool straight into `ConfidenceRelay`, so both stamp arms are construction invariants at a call site 57 lines after the rebuild; the two suite tests that are green hand-mutate a map no code path produces. REPAIR: the registry's obligation is "a probe proving the rebuild ran", so the probe now takes `previous` -- the map held BEFORE the rebuild -- and refuses when the rebuild did not replace it. A memoised build, a deleted assignment or a rebuild moved out of the cutover all land there and none of them are visible to the stamp arms. The tautology is pinned as a fact so the green is not read as coverage. 6. MambaRadixCache got the sgl-project#1201 assertion but not the sgl-project#1201 fix. It caches `req_to_token_pool` as a plain attribute and has no `bind_req_pool_owner`, so `_restamp_phase_handles`' hasattr guard skipped it and the handle stayed on the outgoing pool -- and `assert_req_pool_identity`, added to both classes, then raises ReqPoolRebindRefused at the END of every cutover. Reachable: registry.py hands back this class for a hybrid-SSM model WITHOUT hierarchical cache. The boot went from flipping wrongly to not flipping. REPAIR: the same owner property and bind hook UnifiedRadixCache got. 7. The sgl-project#1203 A1 group vote moved a non-pure function onto a new cadence. `seam_transport_premise_holds_locally` writes the edge-triggered `_seam_premise_refused_announced` latch and emits SEAM TRANSPORT REFUSED; the vote runs once per loop iteration while the consumer returns at `_active_phase != PHASE_TP` before it asks. The latch was therefore set in the PP phase, swallowing the gate's own first engagement in TP. REPAIR: `announce=False` for the vote; the gate's own read still announces. Also: the anchor at overlap_utils.py:81-83 had drifted onto the line that REFUTES its sentence -- scheduler.py:13174-13177 is now the overlap call inside `if self.enable_overlap:`, while the non-overlap spec branch is the sibling `elif not batch.spec_algorithm.is_none():` arm. The claim is true; the number sent the next reader to the wrong branch. Named by branch, no number. WHAT KILLED WHICH MUTANT (planted in place, restored by sha256): M1 retirer over-clears (frees a row a live req owns, the corrupting direction) -> test_an_mbs_only_resident_is_retired_by_the_retraction M2 host bound back on the group abandon book (disarms sgl-project#721) -> test_the_host_headroom_bound_reads_its_own_defer_count M3 a cleared vote refunds its own budget (the A5 wedge) -> test_this_rank_clearing_does_not_refund_the_budget + test_a_taking_turns_run_still_reaches_the_limit M4 refund moved back into the gate's cleared-vote branch -> test_a_completed_flip_returns_every_budget_beside_the_abandon_book M5 sgl-project#1204 discards a measured backing again (claims not-poorest, the fleet-death direction) -> test_a_readable_backing_reaches_the_group_min M6 MambaRadixCache loses the rebind hook -> test_both_classes_expose_the_rebind_hook + test_the_handle_follows_the_owner_and_falls_back_without_one M7 the seam stops handing the probe the outgoing map -> test_the_seam_hands_the_probe_the_outgoing_map M8 the A1 vote announces again -> test_the_vote_leaves_the_announcement_latch_alone 8 planted, 8 killed, 0 survived. VERIFIED: 146 passed + 7 subtests over the six touched test files plus test_1157_seam_witness.py and test_seam_census_double_905.py (the joint pin over both sgl-project#1202 functions), hermetic, CUDA_VISIBLE_DEVICES="" with the serving venv. Import smoke over all seven edited modules. ruff parity with the parent on the touched files: 31 findings both sides, all pre-existing. NOT VERIFIED: nothing on metal. No boot, no GPU claimed, no collective. The sgl-project#1204 and A5 repairs are DESK-PROVEN only -- neither has run against a real reduce or a real host-RAM shortfall. REFUTED, and left untouched: (a) `assert_req_pool_identity`'s tree-cache arm is not decorative -- it is a construction invariant for UnifiedRadixCache BECAUSE the owner property is the fix there, and a live check for every other holder class, which is exactly what caught finding 6; (b) `seam_refused` was already read as a delta across the fence run (hicache_flip_writeback.py:700), not as an absolute, so only its direction and its label were wrong.
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.
Thank you for your contribution, we really appreciate it. The following instructions will help improve your pull request and make it easier to receive feedback. If there are any items you don't understand, don't worry. Just submit the pull request and ask the maintainers for help.
Motivation
Please explain the motivation behind this PR and the goal you aim to achieve with it.
Modification
Briefly describe the changes made in this PR.
Checklist
pre-commit run --all-filesor other linting tools are used to fix potential lint issues.