Skip to content

bump version to 0.1.23 - #706

Merged
Ying1123 merged 1 commit into
mainfrom
version
Jul 23, 2024
Merged

Ying1123 merged 1 commit into
mainfrom
version

Conversation

@Ying1123

Copy link
Copy Markdown
Contributor

No description provided.

@Ying1123
Ying1123 merged commit 9f94728 into main Jul 23, 2024
@Ying1123
Ying1123 deleted the version branch July 23, 2024 20:53
@merrymercy
merrymercy restored the version branch July 23, 2024 20:53
@merrymercy
merrymercy deleted the version branch July 24, 2024 23:05
timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 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
… trap

The phase flip's PP prefill phase shards LAYERS, but every mamba cut in this
module shards HEADS, for TP mismatch. A PP stage's blob is layer-partial, so a
layer cut has to exist before a whole-page format can be assembled across
stages. This adds it as byte provenance, checkable without a GPU, like the
migration plans beside it.

TWO RANGES, NEVER ONE. MambaBlobSpec lays a blob out as two layer-major regions
back to back: every layer's temporal state, then every layer's conv state. A
contiguous layer range is contiguous WITHIN each region, but the two runs are
separated by the temporal state of the layers this stage does not own. Cutting
[lo, hi) as one flat slice of total_bytes is the layer-axis form of the conv
sub-block trap already documented here -- it takes the right layers' temporal
state, then the WRONG layers' temporal state, and no conv state at all. Same
length, wrong bytes, which is exactly why it fools you.

Orthogonal to the head axis by construction: shard_for_rank changes the SIZE of
a layer's blocks, layer_extents changes WHICH blocks are taken. They never
touch the same dimension, so the layer cut cannot reintroduce the [q|k|v]
trap -- test_layer_and_head_axes_are_orthogonal composes them both ways and
asserts the specs are equal.

CAN-FAIL PROVEN BY MUTATION, not by assertion. layer_extents was temporarily
replaced with the flat-slice bug and the suite re-run: 3 failed, 6 passed. The
file was then restored and re-verified green. A can-fail test that has never
been shown to fail is decoration.

Also fixes an import this change needed: `replace` was not imported from
dataclasses, so MambaBlobSpec.for_layers would have raised NameError on its
first call. Caught before it ran, but it is precisely the desk-written /
never-executed defect, so it is called out rather than folded in silently.

Tests, hermetic (CUDA_VISIBLE_DEVICES=""):
  test_hicache_layer_cut_706.py .......... 9 passed + 3 subtests (new)
      byte provenance by tagged synthetic blob; exact tiling across three
      stages (every byte covered exactly once); empty/full/out-of-range
  test_hicache_migrate.py ................ neighbour head-axis cuts unchanged
  test_hicache_flip_guard_703.py ......... unaffected
  -> 44 passed, 16 subtests passed. ruff check + format clean.

Not wired to anything yet: this is the cut, not the protocol. The whole-page
format, the completeness marker and the pp-suffix drop follow, and none of them
can be validated until device-tier retention lands (kv_evictable_tokens is 0).
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 pushed a commit to efschu/htsglang that referenced this pull request Aug 16, 2026
A third cost term the plan omits and the coupled layout does not pay. Under
decoupling a PP stage computes the layers it owns, but each token's rows are
stored on the rank owning that TOKEN, and those axes are independent. Every row
a stage produces for a token it does not own has to be shipped.

Per attention layer a 512-chunk produces 512 x 2048 = 1.00 MiB, of which
1 - share_of_computing_stage leaves. Summed over the 7/5/4 attention-layer
split at shares [0.135, 0.483, 0.382]: 11.1 MiB per chunk, about 2.9% on top of
the 385.5 MiB Q/output collective. Small, but charged rather than waved away --
it is the kind of term that is invisible in a design and obvious in a profile.

The same arithmetic confirms sgl-project#706's writer-side finding from my side, and
corrects an easy assumption I nearly made: a canonical page holds all 16
attention layers for ONE token, but those 16 slots are produced by THREE
different PP stages (7 + 5 + 4), so every page takes partial writes from three
writers regardless of which rank stores it. Token-sharding the storage does NOT
collapse a page to a single writer, so decoupling does not remove the need for
his per-page completeness marker.

25 tests in test_decoupled_kv_704b.py (3 new), 129 across the 704 suite.
Hermetic, ruff clean, codespell clean.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 16, 2026
…y point

## Merge: one KV cell, one solver

Merged 949a882. The KV-cell helper I added is now converged into pp_cut as
ONE implementation rather than two that must agree; the merge keeps my D1
rationale comment and adds Slot-2's provenance note. solve_rung_pool/PoolContext
land in planner/rung_pool.py and meet all five requirements I asked for. 180
tests green across the merged tree (150 mine, 30 his).

## The canonical KV page, device side

mem_cache/canonical_kv_page.py implements Option A as sgl-project#706 settled it: a page
carries ALL attention layers for its token range, layer-major, and since
page_size==1 is mandatory (dcp_owner_mode: a multi-token page would span owner
ranks) a page is ONE token -- 16 x 2048 = 32,768 B.

CanonicalPageSpec deliberately carries nothing about the cut, the shares or the
phase, and its EQUALITY is the layout contract: two ranks with different
layouts must compare equal or the same key would name different bytes. Asserted
directly rather than assumed.

Two silent-violation modes are guarded:

1. RANK-LOCAL LAYER INDICES. Option A globalises start_layer precisely so a
   slot is addressed by the GLOBAL attention-layer index. Stage 1 owns global
   layers 28..47, whose attention layers are 31/35/39/43/47 = global indices
   7..11; writing them at rank-local 0..4 deposits the right NUMBER of bytes in
   the WRONG slots. Same failure shape as cutting a mamba blob as one flat
   range -- correct length, wrong channels -- and equally silent, since the byte
   total cannot detect it. attn_layer_index takes the model's own attention-id
   list, so the argument is global by construction rather than by convention.

2. UNTRACKED PARTIAL WRITES. Token-sharding the STORAGE does not collapse a
   page to one writer: production is layer-sharded, so the 16 slots arrive from
   THREE PP stages (7+5+4). An unwritten slot reads exactly like a
   legitimately-zero one, so PageCompleteness tracks them, names the missing
   ones rather than counting them, and refuses a double-write -- two writers for
   one slot is a layout bug, not an idempotent retry.

Error messages distinguish a missing SLOT (a completeness problem) from a
wrong-sized buffer (a geometry problem); reporting both as "bytes" would send
the reader to check the wrong thing.

## Test results

180 passed, hermetic (CUDA_VISIBLE_DEVICES=""), new files ruff + codespell
clean. test_canonical_kv_page_704b.py (12): page size; global dense attention
index with non-attention layers refused; byte-identical round trip; contiguous
layer-major slots; the rank-local index hazard; three-stage completeness with no
premature completion; the stage split covering every slot exactly once; missing
slots named; double-write refused; geometry-only equality; and the two distinct
size failures.
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
…oes not

Written against the code with no changes made, so engine work is ready-to-build
when the boot cycle frees.

## The membership is not the problem

Confirmed from the restored boot: tp_size=1, pp_size=3, dcp_size=1. So
world_size=3 and the PP group is built as
range(pp_group_idx, world_size, world_size // pp_size) = range(0,3,1) = [0,1,2]
(parallel_state.py:3355-3372) -- already every stage. Generally, for tp_size>1
there is one PP group per TP position whose members are that position's
pipeline ranks, which is exactly the set across which KV should be
token-sharded. No new rank layout has to be invented at any topology.

## But _PP cannot be used as-is, and the reason is silent wrongness

Attention backends read attn_dcp_size/attn_dcp_rank ONCE in the constructor and
cache them; dcp_enabled is
`get_dcp_group_no_assert() is not None and dcp_size > 1`
(dcp_group_guard.py:14-19). Given a communicator that is not a DCP-TYPED group
they cache dcp_size=1, uneven_dcp_owner_bounds() returns None on EVERY rank,
the owner rule is bypassed, and every rank treats every global slot as its own
local row -- all ranks write the same token to the same row, last write wins,
each reads the whole sequence as local. dcp_group_guard.py:21-27 states it
exactly: "The result is silently wrong output. There is no error and no hang to
follow."

So B1 is a DCP-typed group whose rank sets come from the PP dimension instead
of from chunking TP groups.

## Change point and the ordering constraint

parallel_state.py:3143-3159 builds _DCP by chunking each TP group; with
tp_size=1 every TP group is one rank, so every DCP group is one rank -- which is
why PP prefill runs dcp_size=1 with no usable group.

LOAD-BEARING ORDERING: _DCP is built at :3152, _PP at :3365, AFTERWARDS. The new
construction therefore MUST NOT read _PP; it must recompute the same pure
arithmetic inline. Reading a group that does not exist yet is precisely the
ordering class the DCP guard exists to catch.

The group must exist before attention-backend construction, and
server_args.dcp_size must equal the participating stage count, so that
assert_dcp_group_formed (dcp_group_guard.py:63) is a no-op -- and if the
ordering is ever broken it names the construction step rather than failing
downstream.

## Refusal conditions, each traced to an existing guard

  dcp_size != participating stages -> dcp_group_guard.py:63-100
  page_size != 1                   -> dcp_group_guard.py:170-177
  PD decode without uneven-TP+mooncake -> dcp_group_guard.py:139-166
  tp_size>1 with ambiguous shard set   -> NEW, no existing guard

page_size==1 is already mandatory for Option A independently (sgl-project#706: a
multi-token page would span owner ranks), so the two constraints agree rather
than compete.

## Recorded as unknown rather than assumed benign

The sgl-project#616 group-MIN-floor interaction, whether an extra communicator carries a
budgeted per-group cost, and whether any census/registry must be told about a
new group. Survey in flight.

190 tests green, hermetic, codespell clean. No code changes to engine paths.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 16, 2026
…fuses most of it

Design only, no build. Persistent file per Feature-Analysen-Pflicht:
docs/DESIGN_423_striped_spill.md.

## The prior, answered rather than routed around

The rejected register already carries a sibling and it is BLOCKED:
planner/rejected.py:469-487, `path_bundling` -- "one transfer striped over both
lines" -- with the note that only the CHOICE of line per message class is
released (sgl-project#240). Different axis (network lines vs storage tiers), but the
reasoning transfers, and this design reaches the same shape independently from
arithmetic rather than by analogy.

## Striping unit: the page

32,768 B = one token x 16 attention layers, which is already what BlobStore.put
/get speaks (gdn_slot_executor.py:104-133) and already canonical under the sgl-project#706
Option A contract. Per-row striping would need a second index the canonical
form deliberately does not have.

## Ratios: proportional to MEASURED bandwidth, bound to identity

share_i = bw_i / sum(bw). Rates reuse overlap_schedule.CardLink (NVML UUID +
PCI BDF, measured provenance, refuses unknown cards) rather than a second rate
table -- keying rates by position instead of identity already cost a full
analysis in sgl-project#690.

## THE GATE, and it refuses the motivating case

Striping buys parallelism only across DISJOINT links. A spill is device->host,
so it leaves ONE GPU and crosses THAT GPU's single PCIe link before reaching
any tier. The tiers sit BEHIND the shared link, not beside it, so striping does
not widen it.

  GATE: stripe only when aggregate destination bandwidth is BELOW the source
  link bandwidth.

On this rig (no P2P, all PHB, x4 + x8 + x8; measured 6.4 / 13 / 13 GB/s):

  GPU0 (x4, 6.4 GB/s)  vs host RAM ~10 GB/s   -> NO GAIN, link-bound already
  GPU1/2 (x8, 13 GB/s) vs host RAM ~10 GB/s   -> up to ~3 GB/s (~23%) by adding NVMe

The RAID-0 intuition ("n tiers, n x bandwidth") holds nowhere on this hardware.
The gain is bounded by link - fastest_single_destination, which the tiers
cannot widen.

## Failure semantics by volatility class

RAID-0 has no redundancy, so the rule follows from what a lost stripe costs:
reconstructible KV may stripe (a miss, then recompute); NON-RECONSTRUCTIBLE
state -- GDN recurrent state mid-sequence, live conversation state -- may NOT,
because striping multiplies failure probability with no recovery, and that is
exactly what TieredGdnBlobStore exists to preserve. A half-present blob is
worse than an absent one: absent is detectable, half-present may not be. Any
striped path therefore needs a per-object completeness marker, the same
requirement sgl-project#706 found for partial page writes and for the same reason.

## Recommendation

DO NOT build striping for device->host spill. Build the half that pays if
anything: tier CHOICE per volatility class -- reconstructible bulk to the slow
tier, non-reconstructible state to the fast durable one -- which needs no
stripe index, no completeness marker and no multiplied failure probability.

Revisit when a source appears whose link exceeds any single destination
(host->multi-NVMe is the plausible one). Sections 1, 2 and 4 are reusable as
written; only the gate needs re-evaluating, and it is written to be
re-evaluated rather than assumed.

Held for GO. If the operator wants the mechanism built anyway to be ready for
hardware that would benefit, that is a legitimate call -- made knowing the gain
here is zero on one card and <=23% on the others.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 16, 2026
…our losing side

Survey -> evaluation, desk only. Persistent file: docs/ANALYSE_489_int8_kv.md.
Verdict: do not pursue on this rig.

(a) NOT SUPPORTED, and it is unbuilt rather than unflagged.
server_args.py:1008 choices are ["auto","fp8_e5m2","fp8_e4m3","bf16",
"bfloat16","fp4_e2m1"] -- no int8. A tree-wide search returns ZERO int8-KV
code: none in memory_pool.py, none in the FlashInfer or Triton backends, no
"int8 kv cache" anywhere. (The int8 at server_args.py:3954 is
deepep_dispatcher_output_dtype, a MoE setting -- named here because it is the
obvious false positive when grepping.) So this is a feature to build: pool
storage dtype, quant/dequant paths, backend kernels.

(b) THE INVERSION APPLIES DIRECTLY, because we run FlashInfer.
The live boot reports attention_backend='flashinfer' for the text path.
triton_attn appears ONLY as the multimodal backend ("Multimodal attention
backend not set. Use triton_attn") -- a different selection that must not be
misread as the text path, and the GDN layers take the separate hybrid linear
backend. Adopting int8 would therefore move text attention OFF FlashInfer onto
Triton, which is exactly the trade that produced Whamp's -72% at 58K.

Our regime sits on the losing side and not marginally: context 327,680, pool
~436k, max_running_requests 4. The GAIN regime is short-context high-concurrency
decode (+76-81%); ours is deep context at low concurrency, ~5.6x past the
measured inversion point. The inversion is not a risk to manage here, it is the
expected outcome.

(c) MICROBENCH PLAN, spec not run. Notes the rig is HETEROGENEOUS IN SM
VERSION -- the two 3080s are sm_86, the 5090 is sm_120 -- so an "sm86
microbench" covers two of three cards and must be reported per card, never
averaged. Kernel-level arms (an end-to-end arm cannot be built without the
feature), depths through 58K to reproduce the inversion point on our own
silicon, A-vs-A first against the rig's 14.1% noise floor, and a KILL CONDITION:
if 58K reproduces the inversion on sm_86, the ticket closes.

(d) PER-RANK KV DTYPE is blocked by two independent contracts.
Pool side: nearly expressible -- per-rank cell width is ALREADY per-rank
(logged cell 14336/10240/8192), uniform only because one dtype is passed to
every pool. Seam side: HARD BLOCK, runtime-pinned at
phase_flip_runtime.py:32-35 -- "the receiver derives the expected byte count
from ITS OWN pool's per-layer row width; a sender whose row format diverges is
a loud size/checksum error". Divergent dtypes make every seam exchange a
checksum failure. Canonical-page side: independently blocked -- the sgl-project#706
contract requires the same key to name the same bytes regardless of which rank
wrote them, and a per-rank dtype makes the bytes rank-dependent, which is the
two-geometry problem that contract exists to prevent.

(e) QUALITY GATE, three parts, stated so it cannot be softened: determinism
A-vs-A with CPU-sampled inputs first; accuracy against the fp8 baseline with
tolerances FIXED BEFORE the run; and DEPTH-STRATIFIED reporting (1K/32K/128K/
327K separately), because the failure mode is depth-dependent and an average
would hide exactly our regime. No enable without all three; opt-in regardless.

RECOMMENDATION: close as evaluated-and-declined unless (c) contradicts the
published inversion on sm_86. (c) is the one cheap thing worth doing -- it is
kernel-level, rides any window, and its kill condition closes the ticket on our
own silicon rather than on someone else's.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…nd fold the B1 survey

## sgl-project#545 -- attach, resize and detach the HiCache disk tier at runtime

mem_cache/disk_tier_control.py, flag-gated, 14 hermetic tests. Built through
the existing HiCacheStorage/HiCacheFile abstraction: the controller owns the
BUDGET AND LIFECYCLE, the bytes stay with the backend. No second directory
layout is introduced, so the sgl-project#706 canonical-page store (not on this branch yet)
shares the same backend rather than fighting it.

Three rules, each because its violation is SILENT:

1. SHRINK EVICTS DOWN TO THE BOUND; IT NEVER TRUNCATES. A truncated page is not
   a miss -- it reads back short and wrong, which no cache-hit metric shows.
   Test: 90 MB across nine pages shrunk to 50 MB evicts four WHOLE pages; every
   surviving page keeps its full size.
2. DETACH IS REFUSED WHILE ANY PAGE IS ONLY-COPY HERE, naming the count and an
   example key. Detaching would destroy them and the later miss would have no
   visible cause. force=True exists for an operator who has decided the loss is
   acceptable, and says so loudly in the log.
3. A SHRINK THE EVICTOR CANNOT HONOUR IS REFUSED, NOT PARTIALLY APPLIED.
   Accepting a bound the tier is not under would make the reported capacity a
   lie, and the only way to reach it would be truncation. Capacity is left
   unchanged on refusal.

Also: a second attach is refused (two directories under one controller would
give the evictor two budgets and one bound), operations on an unattached tier
refuse, and the flag gates every mutation because attaching or resizing a live
L3 changes what the evictor is allowed to delete.

## sgl-project#616 -- B1 survey folded into DESIGN_704, revising three things

I verified the survey's two load-bearing claims at file:line before folding.

1. "A DCP-TYPED GROUP" WAS IMPRECISE. There are no typed group classes: every
   group is a bare GroupCoordinator (parallel_state.py:564) via
   init_model_parallel_group (:2550). "Typed" here means exactly a module
   global, a named getter, and a routing flag. B1 subclasses and registers
   nothing -- a smaller and more precise change than the earlier draft implied.

2. THE PRECEDENT ALREADY EXISTS IN-TREE; REUSE IT.
   initialize_phase_flip_secondary_groups (:3422-3517) ALREADY creates a DCP
   group in the same world as a PP group. Verified at :3470-3482: it plans
   flip_tp -> flip_dcp -> flip_pp in fixed order, then :3484-3497 verifies a
   world-wide manifest by all_gather with an equality check BEFORE creating
   anything. My earlier draft proposed reconstructing PP rank arithmetic
   inline; that is unnecessary -- the precedent computes the same
   range(idx, world_size, num_pp_groups) layout and already sequences it.

3. THE ORDERING WINDOW IS NARROWER THAN FEARED. _DCP at :3152, _PP at :3365,
   and only the kvso-spill block (:3185-3188) reads _DCP between them.

   Routing precedence must also be chosen deliberately: get_dcp_group resolves
   flip route first (:2709), then kvso-spill (:2718), then primary (:2720).
   Inheriting whichever branch matches first is how a decoupled read would
   silently land on the flip's secondary group during a phase change.

## NAMED PREREQUISITE, before B1 rather than inside it

pp>1 AND dcp>1 is not refused anywhere in the group path, and
ParallelContext.dcp_enabled (runtime_context.py:331-337) returns True whenever
a DCP group exists with dcp_size>1. Creating B1's group therefore makes
dcp_enabled TRUE ON PP PREFILL RANKS, contradicting the assumption
dcp_group_guard.py:38-42 states in prose.

The failure shape is what makes this worth naming: the guard itself would still
PASS, because both sides would read the same new size. What breaks is every
OTHER consumer of the documented invariant. The combination is unreachable
today, so the contradiction is latent -- and B1 is exactly the change that
makes it live. Decide it before building: either accept pp>1 and dcp>1
deliberately and audit the dcp_enabled consumers, or refuse the combination and
give B1 its own flag instead of overloading dcp_size.

35 mem_cache tests green, hermetic, ruff + codespell clean.
efschu added a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…same protocol

SLICE 1 SHIPPED A KV PAGE NOBODY COULD USE ALONE. The gating question is
answered desk-side and pinned (test_mamba_gates_the_hit_706.py): on a
GDN-hybrid checkpoint a KV-only prefix hit is worth ZERO. batch_exists_v2
takes the MINIMUM across pools and the mamba pool registers TRAILING_PAGES,
so a missing {hash}.mamba blob truncates the WHOLE KV prefix to 0 pages --
not just the GDN part. The device side agrees: MambaRadixCache's
_match_prefix_helper advances best_value_len only at nodes carrying
mamba_value. 48 of this checkpoint's 64 layers are GDN. So slice 2 was
mandatory, not an improvement.

The blob now rides the protocol the KV page already uses:

* One store, expressed in EXTENTS. The KV page is the one-extent case; the
  mamba blob needs two disjoint ranges for its layer cut (temporal region and
  conv region sit far apart) and three sub-block ranges per layer for its head
  cut ([q|k|v], each sharded independently). Same lock, same marker, same
  rename, same invisible-until-complete rule.
* The cut is REUSED, not re-derived: build_mamba_window composes
  temporal_extents + conv_extents (hicache_migrate) and selects the layer
  range. test_full_head_window_is_exactly_layer_extents pins that with full
  heads the composition IS layer_extents(spec, lo, hi) -- the definition sgl-project#706
  named -- so it cannot drift from it.
* Completeness moved from a slot bitmap to BYTE COVERAGE, and the reason is
  structural: a KV layer has exactly one writer (kv-heads replicated, tokens
  sharded), but under TP one GDN layer's bytes arrive from three ranks, so a
  layer-granular marker would call a layer complete with a third of its
  channels present. Bytes are the only unit both axes agree on -- one marker
  format, not one per pool.
* Keys: {hash}.mamba becomes content-only under the same flag. Draft pages
  stay excluded BY NAME (own predicate now), other components keep per-rank
  keys, and a mamba window without a KV window is refused -- half the fix
  still misses.

RIDE-ALONGS
* .part706 orphans are reaped by age at attach (sweep_partials,
  SGLANG_HICACHE_CANONICAL_PARTIAL_TTL_S, default 3600 s). They are invisible
  to readers and untracked by the LRU evictor, which walks .bin only.
* The per-page flock serialisation is recorded as a NAMED UNMEASURED RISK in
  PLAN_PERF_PIPELINE_2026-08-16.md, with what to watch on the first boot and
  the shape of the fix if it bites. Measurement is a window item.

TWO DEFECTS FOUND WHILE BUILDING, BOTH CAUGHT BY TESTS, NOT REVIEW
* Every completed page leaked a .lock706 file forever (a file-count test saw
  6 files where 3 were expected). The lock is now the .part706 file itself,
  which the publishing rename takes away; the lock-the-file-you-opened race
  that buys is handled explicitly (re-check the final path, compare inodes,
  retry).
* cache_controller UNWRAPPED HybridLinearKVPool before storing it, so the
  window derivation would have seen a pool reporting start_layer 0 and a bare
  layer count -- indistinguishable from a rank-local renumbering. On the live
  PP boot that would have refused at attach. The wrapper is now kept
  (mem_pool_device_hybrid); the refusal that surfaced it stays as the guard.

Also from a layout verification pass: MambaBlobSpec models exactly ONE conv
tensor per layer while MambaPoolHost.get_data_page emits one region per tensor
in mamba_cache.conv. Every shape builder in the tree returns a single-element
list, so they agree today; the derivation now CHECKS it rather than assuming,
because a second conv tensor would mis-cut every extent past the first region.

Tests (hermetic, CUDA_VISIBLE_DEVICES=""), 89 in the sgl-project#706 family:
* test_mamba_gates_the_hit_706.py (5) -- the gating answer: KV pages all
  present, blob absent, usable prefix 0; adding the blob unlocks it; today's
  phase-local blob is invisible to the other phase.
* test_canonical_mamba_blob_706.py (20) -- layer_extents equality, the two
  ranges far apart, three sub-blocks per layer, PP-written blob, TP-written
  blob byte-identical to it, PP+TP writers completing ONE blob, each geometry
  reading its own slice, incomplete refused, flat-slice writer refused,
  runtime derivation and its four refusals.
* test_mamba_phase_uniform_706.py (9) -- end to end through HiCacheFile: one
  geometry-free blob key, invisible until all three stages wrote, a TP rank
  reading its head shard of a PP-written blob, and the money line: the FULL
  prefix hits for a geometry that wrote none of it.
* test_canonical_page_store_706.py (30) -- slice 1's suite, unchanged in
  behaviour across the coverage-marker refactor, plus the sweeper's four.
* test_hicache_canonical_key_706.py (10), test_canonical_kv_page_args_706.py
  (7), test_hicache_layer_cut_706.py (9, pre-existing) all still green.

Regression, same env, base c3e9487 vs this commit:
  unit/mem_cache   940 failed / 779 passed -> 940 failed / 852 passed (+73)
  unit/server_args   1 failed / 626 passed ->   1 failed / 633 passed (+7)
  unit/managers      4 failed / 2145 passed -> 4 failed / 2145 passed
Pre-existing failures are GPU-required tests under CVD="", identical on both.

Still unverified by boot, and written to refuse rather than guess: the runtime
derivation of both windows from the live pools. A hybrid model whose GDN blob
cannot be made canonical fails at attach instead of silently running KV-only,
which would look enabled while hitting nothing.

CAN-FAIL PROOF, slice 2 (mutation applied, suite re-run, reverted):
  M7  mamba key not neutralised
      -> test_mamba_key_is_geometry_free_and_shared,
         test_the_full_prefix_hits_in_the_other_phase,
         test_tp_rank_reads_its_head_shard_of_a_pp_written_blob, +2
  M8  draft exclusion guard removed
      -> NOTHING FAILED at first, and that was the finding: the guard was
         redundant, because the '.' rule already excluded draft. Slice 2 had
         just widened one dotted-key predicate (.mamba), so leaving draft
         safety to "no future predicate happens to match it" is two half
         rules. The guard stays as the ONE named exclusion, checked first,
         and test_draft_stays_excluded_even_if_a_shared_rule_widens now pins
         its real contract by widening a shared predicate to every dotted key
         -- with the guard removed, that test fails.
  M9  mamba layer cut flattened (conv range taken from layer 0)
      -> test_full_head_window_is_exactly_layer_extents,
         test_pp_stages_assemble_one_blob,
         test_an_incomplete_blob_is_never_served
  M10 any coverage counts as complete
      -> 6 failures across all three suites, incl.
         test_incomplete_page_is_refused, test_an_incomplete_blob_is_never_served,
         test_a_half_written_prefix_still_hits_nothing
  M11 sweeper ignores file age
      -> test_a_live_partial_is_left_alone, and ONLY that one
  M12 one-conv-tensor guard removed
      -> test_a_pool_with_two_conv_tensors_is_refused, and ONLY that one
Restored tree re-verified green after every mutation.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
The inversion this slice exists for. Today
model_runner_kv_cache_mixin.py:2496-2500 filters the model's attention layer
ids to [start_layer, end_layer) BEFORE the pool is built, so a rank has no
row-space for a layer whose weights it does not hold:

    stage-local:  own_attn_layers  x  ALL tokens
    decoupled:    ALL attn_layers  x  own token share

13 hermetic tests. PLANNING AND VALIDATION ONLY -- no pool is built and nothing
is armed; caller wiring stays out of scope until this lands, as instructed.

## Neighbours: nothing to reuse, and I checked before deriving

git log --all --grep for [sgl-project#646] and [sgl-project#635] returns NOTHING reachable from this
branch, and no design docs exist for either in docs/ or evidence-665-f1/. So
the flat-half-split fix and the handover analysis are not available to me here.
I did not re-derive them; R6 stands on the ownership filter I located directly.
If those commits live on another strand's unfetched branch, this plan should be
re-checked against them before wiring.

## The invariant worth holding

World total is CONSERVED between modes: stage-local sums to
sum(own_attn_i) x T = 16 x T, decoupled to 16 x sum(share_i) x T = 16 x T.
Decoupling REDISTRIBUTES capacity; it does not create it. A share vector that
does not sum to one silently shrinks the world pool, so
validate_world_conservation catches it by name.

## The share is NOT the layer fraction, and that is the point

rank0 owns 7 of 16 attention layers (43.75%) but takes a 13.5% token share --
the free-proportional vector from #704b. Deriving the share from layer count
would rebuild exactly the ownership coupling this removes, so plan_for_rank
REFUSES to default it: armed without a share raises, and a share supplied while
unarmed raises too (a share that silently does nothing is how a decoupled pool
ends up sized like a stage-local one).

## Loud failure, proven by breakage not asserted

A rank holding only its own layers cannot answer a read for a layer another
stage owns, and that surfaces as WRONG OUTPUT rather than a missing row.
validate_plan rejects it by name. Proof it bites: neutering the two checks
turns exactly two tests red (wrong-sized armed pool, under-summing share
vector); reverting restores 13 passed.

Unarmed byte-identity is pinned positively -- attention counts 7/5/4, tokens =
T, bytes = attn_i x T x cell -- not merely "similar".

## Seam to sgl-project#706, stated precisely because two nearby facts point opposite ways

layer_extents() expresses the plan in the canonical store's terms and uses the
GLOBAL attention slot index, never a rank-local one -- the same silent failure
shape the canonical-page work already found.

Under decoupling a rank covers every slot, so RESIDENCE IS A WHOLE PAGE: a page
never straddles ranks, which is what the canonical store wants. That does NOT
remove the completeness marker. PRODUCTION stays layer-sharded -- stage 0
computes layers 0-27, stage 1 the next span -- so a page's 16 slots still
arrive from three writers. Residence is whole; authorship is not. Both of my
earlier statements hold; they were about different things.

Coordinated via this spec only; sgl-project#706's branch is untouched.
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
… the general mechanism

VERDICT FIRST: the exclusivity is LIFTABLE and was already lifted. Nothing to
build; this commit closes a test gap the lift left behind.

CHECKED BEFORE BUILDING, as instructed. The refusal at server_args.py:7385-7395
is not a hard exclusion -- it is an OPT-IN gate. KVSO_ALLOW_HICACHE=1 reaches
the pair, the default is still a refusal, and the message states the reasoning:
the two host pools are independent objects with disjoint key spaces, and their
pinned host RAM is summed by one joint budget guard instead of each validating
alone. It also names what is genuinely open, and names it correctly: "a
measurement, not a mechanism" -- the contention between kvso's in-critical-path
spill copies and HiCache's backup/prefetch transfers over the same link. That
is window work, not desk work, so I built no mechanism for it.

That half is well covered: test_kvso_hicache_exclusion_547.py, 22 tests green,
including one that pins the message does NOT claim a physical impossibility.

THE GAP. The arg-parse check sums the two CONFIGURED pools. It structurally
cannot cover pools allocated at runtime, and those go through a different door:
a process-wide registry (register_pinned_post), where
check_and_register_pinned_post admits "this pool PLUS every pool already
registered in this process instead of this pool by itself". The phase-flip host
weight images already register through it (weights_arena.py:340-357), so there
is a THIRD pinned-host consumer today.

That registry is what makes the joint budget general rather than a two-consumer
special case, and it is the door sgl-project#706's canonical host/disk tier will arrive
through. It had ZERO tests -- register_pinned_post appears nowhere in the
corpus's tests.

These 7 pin it: posts accumulate rather than replace, unregister removes only
its own, an admitted post is registered so the next caller sees it, and an
unreadable host figure does not refuse (refusing to guess beats refusing a boot
on a fabricated number). The pair that matters is a can-fail: 20 GB is REFUSED
against 40 GB available once 30 GB is registered, and ADMITTED when it is the
only post -- so the refusal is demonstrably the sum, not the size.

Stated plainly: these are CHARACTERIZATION tests and were green on arrival.
There was no defect to fix, so nothing was red-first; the mechanism is already
correct. The value is that a later tier is now accounted by construction rather
than by the next author reading a docstring.

Deliberately not touched: whether sgl-project#706's store should register, which is their
spec and their branch.

mem_cache + the 547 suite: 810 passed, 0 failed. ruff clean.
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
…ambiguity, survive a full disk

STATE OF THE TICKET FIRST, because most of it is already in this tree.
Directory sharding EXISTS: page_shard spreads stems over 256 hex directories
with a 'zz' fallback for synthetic keys, every new write is sharded
(_sharded_path), pre-sharding files keep serving read-through (_existing_path),
and the shard directories are walked by _iter_existing_files. df monitoring
EXISTS too: the LRU evictor carries min_free_bytes, a TTL-throttled statvfs
watchdog (check_free_space) and a pre-write watermark enforcement, driven from
the storage worker loop via check_disk_space.

What was NOT covered is what the sgl-project#706 canonical store makes sharper, and that
is what this commit adds.

1. THE CANONICAL LAYOUT LANDS IN THE SAME SCHEME -- verified, not assumed.
   .part706 and .slots706 derive from the final path, so they inherit its shard
   and never accumulate in the store root (the root is exactly what the sgl-project#558
   incident filled with 11.7M entries), and the TTL sweeper walks the root as
   well as the shards, because a store that predates sharding holds flat
   orphans.

2. MIXED-LAYOUT AMBIGUITY IS NOW REFUSED. _existing_path prefers the sharded
   copy when a stem exists in BOTH layouts, silently -- and the two files can
   differ, because the flat one predates sharding and may predate the current
   key format entirely. That is one content-addressed key resolving to whichever
   file the lookup order finds first. audit_layout() detects it and attach
   raises MixedLayoutError naming the stems, so it is resolved deliberately
   (delete the legacy copies, or run the offline migration) instead of by
   lookup order. Cost: one scandir of a directory that normally holds only
   shard directories.

3. A FULL DISK IS THIS PROTOCOL'S WORST CASE, so it is handled explicitly.
   A page becomes visible by rename after its last byte lands, and the protocol
   ftruncates to FULL WIDTH on creation while writing only one rank's slice --
   so a store can be far closer to full than its file sizes suggest, and the
   failure lands mid-assembly after other stages already spent their IO.
   ensure_space() refuses at the door (cached statvfs, floor via
   SGLANG_HICACHE_CANONICAL_MIN_FREE_BYTES, 0 = today's behaviour). This is
   deliberately NOT the evictor's watermark: that one is disabled entirely
   unless a cap or min-free is configured, which is the DEFAULT, so on a
   default store nothing stood between this protocol and ENOSPC.

API gap found while testing and fixed: write_slice (the KV wrapper) did not
forward space_check to write_extents, so the KV path could not be protected at
all. Caught by the test, not by review.

Tests (hermetic, CUDA_VISIBLE_DEVICES=""), 13 new, 150 in the family:
* test_hicache_sharding_558.py -- sidecars land in the shard and the root stays
  empty; a completed page leaves only the sharded .bin; the sweeper reaps
  orphans in BOTH layouts; the synthetic-stem fallback; a pre-sharding page is
  still found and read byte-for-byte after a restart; a stem in both layouts is
  refused at attach; a clean store audits empty.
* ENOSPC injected at each syscall the protocol uses -- pwrite, the marker
  write, fsync -- because "the disk is full" is three events with different
  amounts of work already spent. In every case NO .bin appears, and after a
  failed marker write the coverage is not claimed, so the next writer treats
  the page as untouched rather than believing slots are present. The page
  completes normally once space returns: a failed write costs the write, not
  the key.
* The floor refuses before anything is created (nothing to reap, no other
  writer's work wasted) and is off by default.

Regression, same env, base c3e9487 vs this commit:
  unit/mem_cache   940 failed / 779 passed -> 940 failed / 907 passed (+128)
  unit/managers      4 failed / 2145 passed -> 4 failed / 2145 passed
One managers run reported 5 failed / 2144 passed; two further runs returned to
4/2145 with a failing-NAME set identical to baseline, so that observation is a
flake in that suite, not a regression from this change. Recorded rather than
dropped.

CAN-FAIL PROOF (mutation applied, suite re-run, reverted):
  R1  the mixed-layout audit never reports a duplicate
      -> test_a_stem_in_both_layouts_is_refused_at_attach, and ONLY that one
  R2  attach ignores the audit's finding
      -> test_a_stem_in_both_layouts_is_refused_at_attach
  R3  the space floor never refuses
      -> test_a_write_below_the_floor_is_refused_before_anything_is_created
  R4  the page is published BEFORE fsync (rename moved one step earlier)
      -> test_no_page_appears_when_fsync_fails,
         test_a_completed_page_leaves_only_the_sharded_bin,
         test_the_page_still_completes_after_the_disk_frees_up
         i.e. the durability ordering is pinned by three independent claims,
         not just by the ENOSPC test that targets it
  R5  the sweeper skips the flat layout
      -> test_the_sweeper_reaps_orphans_in_both_layouts
Restored tree re-verified green after every mutation (13 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
…gs-first)

Paused by user order (BUGS FIRST) part-way through sgl-project#411 slice 1. Committed as
WIP, deliberately unpolished, so the state is visible rather than sitting in a
dirty tree.

WHAT IS HERE: mem_cache/session_bundle.py -- the versioned container around
sgl-project#410's manifest (magic + length-prefixed deterministic JSON header + payloads
in header order), per-entry sha256, a CompatKey that checks ONLY what binds the
meaning of the bytes (model identity, canonical page spec, page_size, canonical
GDN blob layout) and deliberately NOT parallel geometry (tp/pp ranks and sizes,
token vectors, layer cuts, gdn units) -- geometry freedom being the entire point
of the sgl-project#706 format. Refusals: unknown bundle_version, truncation, digest
mismatch, trailing bytes, and a named incompatibility listing the fields.
Import is two-pass on purpose: verify the WHOLE bundle before writing a byte,
so a short bundle refuses having changed nothing.

WHAT IS NOT DONE, and must not be mistaken for done:
* NO TESTS AT ALL. None of this has been executed beyond an import check.
* verify_bundle re-opens the file to re-read the header length instead of
  seeking with the value it already has -- clumsy and worth fixing, left as-is
  under the no-polishing instruction.
* import_bundle's write path is not yet wired to the canonical store's
  invisible-until-complete protocol (it takes a write_payload callable; the
  whole-page window construction on the receiving side is unwritten).
* No pin registration (sgl-project#410 slice 2 machinery) on import.
* Round-trip export->import->branch seed_plan identity: unwritten.

Resume from the four unwritten items above; the red-first list from the task
still stands (truncated bundle without residue, dtype mismatch by name,
round-trip seed_plan identity).
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
…cket

Two docs, both prep: no branch pointer on a real line moves here.

MERGE_TRAIN_2_FOLLOWUP.md -- the follow-up train, measured against the head
train 1 projects (integration/r2 + 621 + 699 + 673-lockstep + 4c84637 +
67572ce + 677 = 6bab764c33), not against r2.

Order and trial-merge result: reconcile/cluster-b-seam-model clean;
fix/673-teardown-stack ONE conflict, docs/dev/MERGE_TRAIN_2026-08-17.md, doc
only, no source conflict anywhere in the train; fix/728-max-bytes-uniform
clean. Assembled head c5a4c1bca8.

Ancestry finding, which moves the kernel rebuild: 4512136 and a8b068b
are ancestors of reconcile/cluster-b-seam-model (YES) and of nothing else in
the train -- not of 6bab764c33, 887a6d4 or a66f5e2. So the separately
listed "sgl-project#441 kernel commits" step is a NO-OP and should be struck, the
sgl-kernel rebuild is triggered by step 1, and train 1 is unaffected (it
merges 67572ce, which carries neither). The rebuild step is named with the
runbook's wheel-pin discipline (arch list 86;120, MAX_JOBS=4, nvcc from the
venv cu13 toolkit) and its acceptance is boot-gated, not desk-gated.

Baselines on c5a4c1bca8, hermetic (CUDA_VISIBLE_DEVICES=""): mem_cache 1086
passed / 0 failed (1651 skipped); managers 19 failed / 2367 passed; planner 8
failed / 2842 passed (all test_webui/chess, missing optional dep);
distributed 27 failed / 2764 passed vs 21 on train 1;
test_scheduler_teardown_673.py 10 passed.

The +6 on distributed is attributed rather than asserted. On the three
implicated files: 887a6d4 9 failed, a66f5e2 9, feat/704 9, fix/602 9,
fix/701-ledger-wiring 15, reconcile 15, train-2 head 15. The extra failures
are pre-existing on fix/701-ledger-wiring and inherited unchanged; no merge
in this train creates one. Reported as "21 pre-existing + 6 inherited from
sgl-project#701", not as green.

DESIGN_706_BOOT.md -- the boot-side open items are closed as a decision, and
section 5 is a run-card F4-r4 can execute: preconditions, verbatim flag set,
ordered steps, pass/fail by greppable log string, abort conditions.

Boot WITHOUT the second host pool. The phase_flip_host_pools builder stays
unwritten deliberately: it does not fit (5.37 GB remainder, both pools need
~27 GB on rank 0's ratio) and the cross-phase path does not need it, since
sgl-project#706 made the disk tier geometry-neutral.

One code-verified correction to this doc's own earlier framing: with
--phase-flip-rebind-hicache OFF, rebind_for_cutover returns None on the flag
check BEFORE phase_pools_for is called, so the recommended boot logs no sgl-project#719
line AT ALL -- the previous text said the unarmed rebind refuses at every
cutover. Armed without a second pool it does refuse, exactly once per
cutover, logged-never-raised at ERROR level. Both expectations are stated,
because an expected ERROR line is what stops a boot for no reason.

Acceptance counts the prefill log line (#cached-token > 0), never
cache_hit_rate, which reports 0.0 despite real hits.
efschu added a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…cket

Two docs, both prep: no branch pointer on a real line moves here.

MERGE_TRAIN_2_FOLLOWUP.md -- the follow-up train, measured against the head
train 1 projects (integration/r2 + 621 + 699 + 673-lockstep + 4c84637 +
67572ce + 677 = 6bab764c33), not against r2.

Order and trial-merge result: reconcile/cluster-b-seam-model clean;
fix/673-teardown-stack ONE conflict, docs/dev/MERGE_TRAIN_2026-08-17.md, doc
only, no source conflict anywhere in the train; fix/728-max-bytes-uniform
clean. Assembled head c5a4c1bca8.

Ancestry finding, which moves the kernel rebuild: 4512136 and a8b068b
are ancestors of reconcile/cluster-b-seam-model (YES) and of nothing else in
the train -- not of 6bab764c33, 887a6d4 or a66f5e2. So the separately
listed "sgl-project#441 kernel commits" step is a NO-OP and should be struck, the
sgl-kernel rebuild is triggered by step 1, and train 1 is unaffected (it
merges 67572ce, which carries neither). The rebuild step is named with the
runbook's wheel-pin discipline (arch list 86;120, MAX_JOBS=4, nvcc from the
venv cu13 toolkit) and its acceptance is boot-gated, not desk-gated.

Baselines on c5a4c1bca8, hermetic (CUDA_VISIBLE_DEVICES=""): mem_cache 1086
passed / 0 failed (1651 skipped); managers 19 failed / 2367 passed; planner 8
failed / 2842 passed (all test_webui/chess, missing optional dep);
distributed 27 failed / 2764 passed vs 21 on train 1;
test_scheduler_teardown_673.py 10 passed.

The +6 on distributed is attributed rather than asserted. On the three
implicated files: 887a6d4 9 failed, a66f5e2 9, feat/704 9, fix/602 9,
fix/701-ledger-wiring 15, reconcile 15, train-2 head 15. The extra failures
are pre-existing on fix/701-ledger-wiring and inherited unchanged; no merge
in this train creates one. Reported as "21 pre-existing + 6 inherited from
sgl-project#701", not as green.

DESIGN_706_BOOT.md -- the boot-side open items are closed as a decision, and
section 5 is a run-card F4-r4 can execute: preconditions, verbatim flag set,
ordered steps, pass/fail by greppable log string, abort conditions.

Boot WITHOUT the second host pool. The phase_flip_host_pools builder stays
unwritten deliberately: it does not fit (5.37 GB remainder, both pools need
~27 GB on rank 0's ratio) and the cross-phase path does not need it, since
sgl-project#706 made the disk tier geometry-neutral.

One code-verified correction to this doc's own earlier framing: with
--phase-flip-rebind-hicache OFF, rebind_for_cutover returns None on the flag
check BEFORE phase_pools_for is called, so the recommended boot logs no sgl-project#719
line AT ALL -- the previous text said the unarmed rebind refuses at every
cutover. Armed without a second pool it does refuse, exactly once per
cutover, logged-never-raised at ERROR level. Both expectations are stated,
because an expected ERROR line is what stops a boot for no reason.

Acceptance counts the prefill log line (#cached-token > 0), never
cache_hit_rate, which reports 0.0 despite real hits.

(cherry picked from commit 60414e9)
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
The Flip+HiCache run-card boot refused on PP0 with "40.42 GB requested ... does
not fit in 33.97 GB available minus a 10.74 GB OS reserve = 23.23 GB usable".
35.18 GB of that demand was the three phase-flip weight images. They were
already allocated when the figure was read.

MEASURED BEFORE ANY DESIGN CHANGE WAS PRICED, because a cheaper answer outranks
a better one. Sampled against the live serving process, mid-flight and flipping
normally: MemAvailable 33.62 GB while the three schedulers held 86.51 GB
resident (PP0 39.85, PP1 22.27, PP2 24.40) on a 126.75 GB box. The images are in
RSS, therefore already absent from MemAvailable -- and the backstop added them
to the demand as well.

check_and_register_pinned_post summed every already-registered post plus the new
one and compared that total against LIVE, post-allocation availability. sgl-project#695
registers the weight images AFTER allocating them (weights_arena.py:428), so
from that point every later post in the process paid for them a second time.

joint_pinned_host_error is not at fault and is unchanged. It is exact where it
was designed to be used: once in the launcher, over CONFIGURED numbers, before
anything is pinned, where availability is untouched by any post. Reusing that
comparison as a runtime backstop is what introduced the error, because by then
the sum and the availability figure disagree about what has already happened.

Fixed by crediting the already-allocated posts back to availability. The true
marginal cost of that boot on PP0 is the 5.24 GB tier, which fits in 23.23 GB
with ~18 GB to spare. No dedup, no mmap, no freeing of host RAM is needed for
this ticket -- the blocker was arithmetic, not physics.

WHY CREDITING IS SOUND, and its one precondition: registration FOLLOWS
allocation for every producer of a post. check_and_register_pinned_post
registers after its own check, so the post being weighed is correctly NOT
credited to itself; the weight images register after _alloc_host_image returns.
A future producer that reserves ahead of allocating must not use this path, and
the comment says so. Other ranks' pins are still charged in full: they are
absent from availability and absent from this process's registry, so the
rank-divergence bound in the module docstring is unchanged.

TESTS  test/registered/unit/mem_cache/test_pinned_budget_double_count_706.py,
6 passed; mem_cache 940 failed / 999 passed, the 940 baseline unchanged and the
6 new passes are these. Mutation-proven: dropping the credit turns the specimen
test red. The suite pins the machine out of the measurement with the specimen's
own numbers -- read live, a roomy box would admit the tier without the fix and
the can-fail would prove nothing there.

Can-fails included: an impossible tier is still refused (crediting must not
disable a guard on non-swappable memory), the refusal still prices every post by
name and flag, the post under test is not credited to itself, and the first post
in a process is unaffected.

DOC  DESIGN_706_BOOT.md, three corrections found by executing section 5:
  * 5.2 said `--hicache-size 5G`, called itself verbatim, and is rejected by
    argparse (`invalid int value: '5G'`); the arg is an int in GB. Cost a boot.
  * new 1.2a: 1.2's measured figures are ONE rank's, and it is the smallest.
    PP2 reproduces them exactly (10.94/9.41/0.15); PP0 carries 18.06+17.12 =
    35.18 GB. So 1.3's 5.37 GB remainder does not hold on the binding stage,
    where it is -11.95 GB before any tier, and 5.5's "shrink --hicache-size"
    cannot rescue such a boot.
  * new 1.2b records the double-count and its fix, and precondition 1 now says
    which rank its 24.3 G floor is calibrated on.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…them dense

The Flip+HiCache boot died at readiness:

    CanonicalPageError: attention layers [51, 55, 59, 63] map to page slots
    [51, 55, 59, 63], which is not a contiguous run.

They should have been slots [12, 13, 14, 15]. The caller resolved the id list as
`full_attention_layer_ids or range(num_hidden_layers)` under the comment "a
model with no hybrid split" -- a guard that cannot tell NOT HYBRID from NOT
POPULATED. The deployed checkpoint is a GDN hybrid with 16 full-attention layers
at 3, 7, ... 63, so it took the dense branch and the page was cut against 64
slots instead of 16.

THE FIX IS AT THE CONSUMER, and deliberately not in get_hybrid_layer_ids.
Verified at code before writing anything: ModelConfig calls that helper ONLY
under `if self.is_hybrid_swa` (model_config.py:915). This checkpoint is
correctly not is_hybrid_swa -- it is a GDN/linear hybrid, layer_types are
full_attention/linear_attention with no sliding_attention -- so a generic branch
added there would either misroute GDN hybrids into SWA machinery or never run at
all behind that gate. An earlier proposal from this strand to widen it is
withdrawn: wrong tool, and it would have changed shared model-config semantics
for every model to fix one mapping.

THE AUTHORITY ALREADY EXISTED. Qwen3NextConfig.full_attention_layer_ids
(configs/qwen3_next.py:280) derives the list from layers_block_type, and
Qwen3_5TextConfig inherits it. Measured against the deployed checkpoint:
hf_text_config is Qwen3_5TextConfig, layers_block_type is populated, and the
property returns [3, 7, 11, ...] count 16 -- while
ModelConfig.full_attention_layer_ids is [] and is_hybrid_swa is False. Sibling
GDN configs differ, so this is a per-class attribute lookup, not an assumption
about all of them.

resolve_attn_layer_ids is a ladder with refuse-not-guess at the bottom:
  (a) ModelConfig.full_attention_layer_ids when populated -- the SWA path;
  (b) the checkpoint config's own full_attention_layer_ids property -- covers
      the GDN hybrids;
  (c) range(n) ONLY on a POSITIVE DENSE PROOF: no declared layer kinds AND
      neither hybrid flag. The old comment becomes an actual predicate;
  (d) kinds declared but nothing resolved them -> NAMED refusal carrying the
      architecture and the kinds seen.

TESTS  test/registered/unit/mem_cache/test_canonical_attn_layer_ids_706.py,
8 passed. The first two read the REAL deployed config off disk rather than a
fixture, so they cannot drift from the checkpoint being served: 16 ids, and
layers [51,55,59,63] -> slots [12,13,14,15], the exact failure. Mutation-proven:
restoring the guess-dense fallback turns 5 of the 8 red, including both
real-checkpoint tests and both refusal tests.

Can-fails: a declared-kinds config with no id list must RAISE and name the arch
(not silently go dense), and a hybrid flag with no kinds must raise too.

Regression: mem_cache 940 failed / 1007 passed (940 baseline unchanged, +8 are
these); managers 12 failed / 2295 passed, unchanged. Ruff clean on both new
files; cache_controller's 13 pre-existing lint errors are at HEAD too and are
untouched.

DOC  DESIGN_706_BOOT.md 5.2 gains `--hicache-mem-layout page_first_direct`, the
third defect found by executing the run-card: MambaPoolHost only supports that
layout on a hybrid checkpoint and the boot dies at pool construction without it.
Setting it also switches the io backend to `direct` automatically.
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
…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
…indow; audit finds it systemic

The residual filed in the train's T2: a post registered with nothing allocated,
where sgl-project#706's credit-back then under-charges the next admission.

WHY IT EXISTS, and the audit answer is bigger than the filing. Every producer
declares its post BEFORE allocating, deliberately -- "an over-commitment is
refused instead of discovered: the registry's whole job is to fail at the
declaration rather than at the allocation" (read_buffer_pool.py:70-72). Correct
for the check, and it necessarily opens a failure window: if the allocation
raises, the post describes bytes that never existed, and the credit-back
subtracts already-allocated posts from the next demand. A post that never
allocated is credited back anyway, so the next admission is charged too little
-- the registry waves through the exact over-commitment it exists to refuse.

AUDIT (brief item 3): the brief expected two siblings; ALL EIGHT producers have
this shape, none is clean.
  FIXED    model_executor/weights_arena.py:428  (alloc at :439-460)
  FIXED    mem_cache/read_buffer_pool.py:73     (alloc at :79)
  FILED    mem_cache/memory_pool_host.py:141, :770, :1147, :1680
  FILED    mem_cache/pool_host/mha.py:684
  FILED    mem_cache/pool_host/base.py:164
The six filed are on the KV-pool hot path and each wants its own
allocation-failure test; fixing eight at once on a train branch is a blast
radius this slice did not need. unregister_pinned_post already exists and both
fixes use it, so the rest are mechanical.

FIX SHAPE, constraint honoured: the success path is byte-identical -- same
allocator, same fallback, same return. Only the failure path is new, and it
obeys sgl-project#386: the post is taken back and the ORIGINAL exception is re-raised
untouched, so the operator still reads cudaHostRegister's own words instead of
a cleanup message. _register_image_post returns the name it registered so there
is something to take back; None means nothing was registered.

TESTS extended, not rebuilt (gate): 4 cases added to
test_pinned_post_registry_550.py, the sgl-project#548/sgl-project#550 characterization file --
the poisoned state, the sgl-project#386 no-masking property, a success-path guard so the
fix cannot pass by never registering, and the same window in read_buffer_pool.

CAN-FAIL, three mutations, each redding ONLY its own case:
  cleanup made a no-op            -> test_a_failed_pinned_image_leaves_no_post
  error re-wrapped in a new one   -> test_the_real_error_is_not_masked
  ring cleanup disabled           -> test_a_failed_read_buffer_ring_leaves_no_post

unit/mem_cache 1148 passed / 0 failed. unit/model_executor 15 failed / 660
passed, IDENTICAL to the pre-slice commit fac99d6 measured in a pristine
worktree -- those 15 are pre-existing and this slice adds none.

FEATURE_CATALOG gains the window, the two fixes and the six open sites by
file:line, so the next producer written does not repeat it.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…oject#550's audit

The comment on the credit-back said it was sound "because registration FOLLOWS
allocation for every producer of a post". That is FALSE, and it was a
misreading of weights_arena on my part: `_register_image_post` declares the post
BEFORE `_alloc_host_image` allocates (:458 vs :476), deliberately, so the
registry can refuse an over-commitment at the DECLARATION rather than discover
it at the allocation.

The fix itself stands; only its stated justification was wrong, and a future
reader would have verified the wrong property. What actually makes the credit
sound is weaker and sufficient: by the time a LATER post is weighed, the EARLIER
posts' allocations have COMPLETED, so their bytes are already absent from
`available` -- which is what was measured (MemAvailable 33.62 GB while the
schedulers held 86.51 GB resident on a 126.75 GB box).

The real hazard is a post registered whose allocation NEVER happens: credited
back without ever being resident, so the next admission is charged too little
and the registry waves through the over-commitment it exists to refuse. sgl-project#550
found that window independently and closed it (`_unregister_image_post` on the
raising path). The comment now names that as the standing obligation on any
future producer that can leave a post registered with nothing behind it.

TESTS  23 passed + 3 subtests across the sgl-project#706 double-count, sgl-project#550 registry,
sgl-project#630 rendezvous and guard suites together -- the two fixes compose.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…e pipeline's dependency chain

THE DEADLOCK. `_count_ready_acks` MIN-reduced a ready count across the group,
and that reduction sat inside `check_hicache_events` ->
`_get_new_batch_prefill_raw` -- the PER-MICROBATCH path of a pipeline, whose
stages are at DIFFERENT offsets by construction. Measured 2026-08-17: PP0/PP1
inside the drain while PP2 was blocked in `_pp_recv_proxy_tensors`, waiting for
data PP1 would only send after leaving the collective PP1 could not leave
without PP2. A circular wait between adjacent stages -- the sgl-project#633 shape one level
up, with a collective in place of a handler.

The bug was PLACEMENT, not participation: every stage calls the function, just
never on the same tick.

WHAT THE REDUCTION PROVIDED, and where each part went:
* OP-SEQUENCE UNIFORMITY -- concerned the TP all_reduce, which ran only on
  pp_rank 0. With no reduction there is no op left to keep in sequence.
* THE EMPTY-QUEUE SENTINEL (sgl-project#581: one idle rank froze the drain on ALL ranks and
  `protected` ratcheted until the state pool died). Rank-local counting removes
  that failure mode BY CONSTRUCTION -- an idle rank cannot freeze a peer that no
  longer waits on it.
* THE THROTTLE. Pacing, not correctness, and the one thing genuinely lost.

CORRECTNESS IS OWNED BY THE MARKER, NOT BY ACK LOCKSTEP. The cross-rank hazard
was publishing a shared content key incomplete on some stage. sgl-project#706's
`PageCompleteness` bounds that per page: production is layer-sharded while
storage is token-sharded, so slots arrive from several PP stages and
`is_complete()` gates use. Ranks arbitrarily far apart therefore yield an
INCOMPLETE page -- a MISS, never wrong bytes. The docstring now says this so
nobody resurrects the collective for a service the marker owns.

THE THROTTLE IS FILED, NOT GUESSED. No backpressure bound is shipped: one chosen
without an operating point is another shipped-number-without-evidence (#505c).
Instead a rate-limited drain-depth line (per-rank ready/pending at drain) makes
the first real fast-rank host-pressure specimen attributable when it appears.

TESTS  test_rank_local_ack_drain_737.py, 8 passed, both arms:
  (i)  deadlock -- ranks answer independently and may differ; an idle stage
       cannot freeze a busy one; and a CAN-FAIL that stubs torch.distributed to
       raise on ANY access, so a future edit that reintroduces a group op here
       fails loudly. Mutation-proven: adding one torch.distributed reference
       turns it red.
  (ii) divergence -- through the REAL `PageCompleteness`: worst-order arrival
       (PP2, PP1, then PP0) stays a miss until every slot is marked; order and
       tick are irrelevant, only completeness; a fast rank racing ahead cannot
       complete a page alone; double-writing a slot is refused.

THREE PRE-EXISTING TESTS CORRECTED, both causes recorded rather than absorbed:
* two sgl-project#734 fallouts I had missed -- the timeout stubs raised INSTANTLY, which
  the new dead-peer discriminator rightly reads as transport failure rather than
  expiry. A real timeout raises AT its deadline, so the stubs now sleep the
  bound. That keeps both the discriminator and the tests' original intent.
* the sgl-project#581 throttle test asserted exactly the property this change withdraws. It
  is rewritten to the new contract -- a slow rank no longer holds the others,
  which is what sgl-project#581 actually needed -- with the withdrawal stated in the
  docstring, not silently deleted.

Also: the sgl-project#580 comment at scheduler.py:6253 now states its ACTUAL guarantee --
uniform entry WITHIN the function once a rank calls it, which says nothing about
all ranks calling it on the same tick. The ack collective leaned on it and
deadlocked; anything added there needing GROUP agreement needs a
pipeline-aligned point, not that one.

REGRESSION  mem_cache + managers: 19 failed / 3696 passed against a captured
baseline of 19 -- ZERO new failures. Ruff: unified_radix_cache clean,
scheduler.py 96 before and after (pre-existing).
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 24, 2026
…t inventory

USER DECISION 2026-08-24, binding, verbatim: "das kv soll niemals vom layer
flip her stammen, einfach aus dem hicache laden fertig." Recorded BEFORE the
build so the build cannot quietly become something else, and so the ledger
that follows reads as validation rather than as a vote.

THE TREE ALREADY AGREED, which is the part worth landing on its own.
hicache_flip_writeback.py:21-23 states the premise in its own words: "a
prefix's only way across the flip is the geometry-free STORE (sgl-project#706): the disk
tier, whose keys carry content alone and whose pages are cut at read time for
whichever geometry asks." And it names exactly why a mover exists today:
"device rows survive the flip, because the live row set (radix tree values
UNION parked requests' rows) is relocated between the two phase pools BY ROW
ID." That relocation IS the wave mover.

THE BLOCKER THAT SHAPES THE BUILD, found before writing any code.
phase_flip_resident_carry.py:64-76 -- a carried Req keeps its req_pool_idx
across the swap "by construction", and the reason it stays valid is that "the
bytes behind those ids are what the KV and GDN movers relocate". So
PHASE-FLIP-CARRY is NOT a KV mover and NOT a retirement candidate, but its
correctness today DEPENDS on the mover. Retire the mover alone and a resident
request's req_pool_idx points at unwritten memory. The fence and the
retirement must therefore land together, and the cutover must leave the new
phase's device tier in a state where a lookup MISSES rather than returning
stale rows. That is the correctness core, and it is where the red-first tests
must bite hardest.

WHY THE PRIZE IS FUNDING, NOT LATENCY -- stated plainly because the opposite
is the natural assumption. The whole KV+GDN movement is 901 ms of an 11.6 s
seam (W25 epoch 11, 116502 live slots). Removing it leaves ~10.5 s. What it
DOES remove is wave_peak = incoming + max(outgoing, local) + one_layer_window
+ backing_slack (phase_flip_runtime.py:7314) -- every term a KV quantity --
which is the 2339.11 MiB tp_to_pp staging reserve behind W25's 33 refused
arms, 25 of them on the staging rate limit, and 17 FLIP ABANDONED.

RETIREMENT INVENTORY, scoped to the flip path, REPLACE/RETIRE/KEEP-WITH-REASON
with file:line, in the note. Rules held to: "hardened against corruption" does
not count as reconciled; no bulk deletion; shared machinery with a named other
consumer is KEPT (kv_reshard's sgl-project#297 domain, gdn_flip_preconditions -- whose
"no other consumer found" is recorded WITH the narrow search set that failed,
not as a licence to delete); anything merely deletable-later is a separate
section and marked un-re-verified.

EXISTING MACHINERY TO EXTEND, NOT REBUILD: hicache_flip_writeback.py already
IS the fence (stage + bounded ack drain, deadline 2.0 s); hicache_demotion.py
already covers evict-before-persist WITH counters and is merely off by
default; sgl-project#719 rebind + sgl-project#718 disarm already own the read-path switch;
mamba_ckpt_utils' anchor grid is already what anchor-resume needs.

NO FALLBACKS, per standing doctrine: every gap is fixed inside the HiCache
route. A flip enabled without hierarchical cache becomes a validate-early
launch refusal on the sgl-project#806 precedent (c0a6347, ServerArgs.__post_init__
after materialize_declarations) -- NOT a silent mover revival. That refusal is
deliberately NOT landed yet: it only becomes true once the flip carries no KV,
and shipping it early would reject launches that work correctly today. Forced
build order, recorded rather than discovered later.

VALIDATION METRIC CHANGED, and one half of it does not exist yet: cutover-
blocking time (fence + weights refill) can reuse the existing
seam_census.mark("flip_writeback") and the DONE stats dict, but there is NO
instrument for post-cutover warm-up cost as served-request latency -- searched
and named as a build item rather than assumed present.

OPEN GAPS ARE LISTED AS GAPS, with the search sets that failed: sgl-project#735's "sgl-project#706
rows on the full plan" could not be located (both greps resolve to a different
topic -- non-contiguous PP placement), fp8 kv_cache_dtype against the canonical
page format is unverified, and the worst-case un-hashed resident tail at the
quiescent-flip instant is reasoned from the quiescence predicate rather than
measured.

No code changes. Documentation only.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 24, 2026
…ath, and name where the leg's time goes

CLOSES A GAP I FILED AGAINST MYSELF. `_timed_arena_refill` discarded the
`RotationStats` it got back, so on metal `overlapped_steps` -- the duplex
falsifier this whole scheme rests on -- was NOT OBSERVABLE for a warm flip. W28
could therefore score it only as NO DATA. Both the stats line and a phase line
are now logged per flip leg.

THE SECOND HALF IS THE HONEST ONE. W28's leg reported

    LINK-BOUND (read 0.000s / h2d-wait 0.114s over 512 chunk(s), drain 0.001s)

on a 4.833 s rotation. Those terms are 2.4 % of it. The phrase named a bound
nobody had observed -- one number wearing several meanings, inside the dominant
term of the seam, which is the class sgl-project#851 exists to remove.

`RotationPhases` splits the leg into save / d2h-issue / h2d-issue / wait / ring
/ checksum / plan and, crucially, a NAMED `UNACCOUNTED` residual, so the
unexplained mass has to land somewhere instead of being distributed over the
parts that happen to be measured. `dominant()` lets the residual COMPETE with
the real phases: if the leftover is the biggest term, the instrument says it
does not know rather than crowning the largest thing it can see.
`phases_reconcile` refuses a leg leaving more than 10 % unexplained -- chosen,
not derived, and chosen so that W28's own 97.6 % could not have passed it.

HOST-SIDE PHASES ARE WHAT RECONCILE, and that follows from the measurement, not
from taste: `h2d_wait_s` was near zero, so the host was never blocked on the
device, so whatever consumed the wall clock was work the host thread did
itself. Device spans answer a different question and are deliberately excluded
from the sum -- adding a device span to a host total is how a reconciliation is
made to "pass" without meaning anything.

A CPU replay puts `d2h_issue` on top. That is a LEAD, not a finding, and it is
labelled as one: on CPU those copies are eager by construction.

DEFERRED BY USER DECISION (2026-08-24): ~4 s per flip is acceptable for now, so
the 4 s -> 1-2 s hunt is filed as W30 rather than chased here. What W30 still
needs is written into the ticket: CUDA-event device spans (staggered read after
the drain, never sync-in-loop) and the two can-fail mutants.

ALSO FIXED, and it was mine from the previous slice: the sgl-project#758 emitter test
replaced `rotation_executor.rotate_arena` and never restored it, so a green
file made the scheduler suite fail behind it. setUp/tearDown now restore it.
`Tuple` was used unimported (masked at runtime by `from __future__ import
annotations`, caught by ruff).

W29 IS TURNKEY, and the runnable path is the point of this slice:
  * /spinning/gpu-arb/w29_load.sh -- ALTERNATES concurrent large-prompt BURSTS
    with low-concurrency decode HOLDS. W28's driver was serial deep decode, which
    builds no prefill backlog at all, so the policy went TP-sticky after one
    flip; the user caught that from the outside. Bursts aim well above the bar.
  * /spinning/gpu-arb/boot_w29.sh -- the sgl-project#630 PP x disk-HiCache warmup wedge is
    AVOIDED with `--skip-server-warmup`, and the alternative is named and
    rejected: dropping `--hicache-storage-backend file` would delete the
    geometry-free disk STORE that is a prefix's only route across the flip
    (sgl-project#706), i.e. the premise of the no-KV design.
  * BREAK-EVEN REPRICED FROM THE MEASURED SEAM. N ~= 2188 tokens per second of
    seam (18614/8.50 = 2190 and 39500/18.06 = 2187 agree). The measured flip is
    6.410 s slowest rank, round trip 12.82 s -> N ~= 28,050, not ~39,500. The
    bar is ~29 % LOWER, so the policy should flip MORE readily. Derived by
    proportion from the two known pairs, said plainly so it is not mistaken for
    a first-principles repricing.

GATE (foreground, family-batched):
  model_executor    15 failed / 803 passed -- the same three pre-existing sgl-project#815
                    files, ZERO new
  managers (chunked) 3184 passed; 1 failure + 1 collect error, both identical
                    at HEAD
  mem_cache (chunked) 7f+474p / 24f+1192p -- byte-identical to HEAD
  scheduler test_phase_flip_boot 31 passed; rotation suites 95 passed combined
ruff F/E7/E9 clean on the changed files; format clean.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 27, 2026
…layer ids, or refuse

sgl-project#706 slice 2 (a38f39f, 2026-08-17) built the geometry-neutral {hash}.mamba
blob and build_mamba_window to cut it for either phase. It has never once been
built at runtime, on any model, on any boot.

THE HOP. HiCacheController._canonical_mamba_window opened with

    cache_params = getattr(model_config, "mamba2_cache_params", None)
    mamba_layer_ids = list(getattr(cache_params, "layers", None) or [])
    if not mamba_layer_ids:
        return None

and mamba2_cache_params is a property of the CHECKPOINT config
(Qwen3NextConfig, configs/qwen3_next.py:288, layers=self.linear_layer_ids),
never of sglang's ModelConfig: `grep -c mamba2_cache_params
configs/model_config.py` is 0. The getattr missed on every model, the list was
always empty, and the one silent branch fired every time. The correct hop is
hf_text_config -- the one gdn_flip_mover.py:929 already uses for GDN geometry.

MEASURED, boot 2g (boot_2f_698cd396ce_0827_0704.log). Format explicitly armed
(phase_flip_canonical_kv_page=True, phase_flip_writeback=True, backend 'file',
page_size 1, so the pairing guard at server_args.py:8716 held), and the log
carries "sgl-project#706 canonical KV page active" THREE times -- one per rank -- against
"sgl-project#706 canonical GDN blob active" ZERO times and zero refusals. Exactly the split
_canonical_mamba_window's own docstring calls fatal: "a canonical KV page beside
a phase-local GDN blob delivers ZERO usable prefix ... Silently running KV-only
would look like the feature was on while every cross-phase lookup missed."

THAT IS WHERE sgl-project#928 COMES FROM. KV crossed the flip geometry-neutrally while the
recurrent anchor stayed phase-local; sgl-project#856 then drops the tree at every cutover
trusting the canonical store ("Nothing is carried across"), and read-through
returned a correct KV prefix beside an anchor in the writing phase's layout. The
on-device fallback could not cover it either: the GDN mover runs AFTER the drop
and logged "moved 0 slot(s)" on all ten flips of that boot.

THE FIX IS THE SIBLING LADDER, NOT A SECOND BARE LOOKUP. resolve_attn_layer_ids
was given exactly this treatment on the same day, for the same reason ("RESOLVED,
not guessed" -- it could not tell NOT HYBRID from NOT POPULATED). The linear half
kept a raw getattr aimed at the wrong object. canonical_page_store gains
resolve_linear_layer_ids with the same four rungs: (a) ModelConfig's own list if
a future one populates it; (b) the checkpoint config's own properties through
hf_text_config, linear_layer_ids first and mamba2_cache_params.layers second;
(c) [] ONLY on a positive dense proof; (d) otherwise a NAMED REFUSAL. The
caller's `return None` is now sound rather than a hole: an empty list can only
mean a proven dense model.

BEHAVIOUR CHANGE THE NEXT BOOT WILL SHOW, stated rather than discovered. A
hybrid whose config class exposes neither property now REFUSES the boot instead
of silently running KV-only -- the conversion the caller's docstring demanded
("this must succeed or attach fails"), with the remedy in the error text. And
because the window is now actually built, derive_mamba_blob_spec is reached for
the first time; if this checkpoint's config lacks a GDN field it will say so
loudly. So the first boot on this commit yields either "sgl-project#706 canonical GDN blob
active" three times or a named refusal. Both are results. Neither is silent, and
silence was the defect.

TEST RESULTS (desk, CUDA_VISIBLE_DEVICES="", /spinning/htsglang-gpu/.venv):
 * test_canonical_gdn_blob_attaches_931.py -- 5 passed. Five arms: a
   Qwen3-Next-shaped hybrid resolves its 48 GDN layer ids; the wrapped source
   (mamba2_cache_params.layers) resolves too; a proven-dense model returns []
   (a ladder that refuses everything is an outage); an unresolvable hybrid
   RAISES; and _canonical_mamba_window gets PAST its early return -- the attach
   itself, probed by making the next call raise a sentinel, because a green
   resolver beside a caller still holding its own getattr looks identical from
   outside.
 * MUTATION, one per claim:
     M1 caller reverts to the bare getattr on ModelConfig   1 failed (the attach arm)
     M2 resolver aims at ModelConfig instead of hf_text_config  4 failed
     M3 the (d) refusal degrades back to a silent skip      1 failed (the refusal arm)
   restored: 5 passed.
 * REGRESSION: test/registered/unit/mem_cache/ -- 2822 passed, 927 skipped,
   471 subtests passed, 2 failed. Both are test_acceptance_emitters_758
   "RuntimeError: No CUDA GPUs are available" and fail identically on the
   parent; the desk has no GPU. The sgl-project#706 format suites
   (test_canonical_mamba_blob_706, test_canonical_page_store_706,
   test_mamba_phase_uniform_706, test_mamba_gates_the_hit_706) are inside that
   run and stay green.
 * ruff: canonical_page_store clean; cache_controller 13 errors before and 13
   after, all E402/F541 at lines 16-44 and 1414, none in the edited region.
   (First count of "0" was a broken extraction -- ANSI codes in the concise
   output defeated the per-file grep; recounted verbatim.)

NOT BUILT, AND NAMED RATHER THAN IMPLIED: the end-to-end content proof --
archive a PP-phase anchor through the fence, load it back in the TP phase,
compare against the reference state -- needs live pools and a storage backend
and is not hermetically cheap at the desk. It is a boot-proof item, and the
measurement window's coherence probe drives exactly that path.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 27, 2026
…store instead, by content key

WINDOW-946RF-0828 PROVED THE ROOT RATHER THAN SUGGESTING IT: reason=anchor_no_vote
5 of 5, and "[sgl-project#915 prefetch-gate] no observation" confirming from the other side
that the gate was never reached at all. The escape's precondition was

    locally_eligible = last_host_node.backuped or last_host_node is root_node

and `backuped` means "the full KV is ALREADY in THIS rank's host pool" -- local
residency demanded as the entry price for an operation whose whole purpose is to
obtain what is NOT resident. THE PRECONDITION IS ANTI-CORRELATED WITH THE
SITUATION THE ESCAPE EXISTS FOR. Five instances in this family were compensators
in the wrong PLACE; this is the first that was in the right place asking the
wrong QUESTION.

THE REPLACEMENT: presence by CONTENT KEY. `HiCacheController.store_presence_pages`
computes the page-hash chain with the SAME helper the real fetch uses
(`get_hash_str` -> `batch_exists`, the `_storage_hit_query` path) and asks the
backend once. A second spelling of a key chain would be a second installer of the
same payload -- the rule #949b was just fixed under, one layer up.

WHY THIS IS MORE THAN A BUG FIX. Under sgl-project#706 the store is geometry-neutral: a page
carries all attention layers for its tokens and the cut happens at READ time, so
the key is a function of CONTENT, not of any rank's layout or residency. A
content-key fetch therefore lands in the CURRENT layout and sidesteps the
layer-sharded seam problem of sgl-project#941 entirely -- the practical route to cached>0
after a flip, host store instead of device seam carry.

ONE GATE BLOCKED TWO COMPENSATORS. sgl-project#939/#943b's re-issue already had its
reachability half fixed (sgl-project#946 widened the candidate set to pp_request_locations,
scheduler.py:8354) and it still never fired, because the chosen rid is re-issued
through this same `_prefetch_kvcache` and died at this same anchor. That is why
PREFETCH RE-ISSUED read 0 for seven boots AFTER its candidate set was corrected.
One fix serves both.

COVERAGE CHECKS BEFORE BUILDING, two of which changed the design:
 * sgl-project#937/sgl-project#911 generation routing already sits on the insert path
   (unified_radix_cache.py:3192-3198), so this adds NO second completion path --
   the fetch completes through the ordinary route and inherits the refusal.
 * sgl-project#915's gate is TRAVERSED, not bypassed: only the ANCHOR term changes, so
   too_short and rate_limited can still speak. That keeps the capacity-asymmetry
   candidate measurable instead of assumed away.
 * sgl-project#706 IS landed (six production importers; --phase-flip-canonical-kv-page in
   the boot), contrary to a stale "when it lands" comment in disk_tier_control.py
   that would have had this design built on a false absence.
 * sgl-project#941's kv_reshard seam route is PRICED in the ticket as the alternative and
   deliberately not built -- it answers a different question.

GROUP UNIFORMITY: `prefetch_from_storage` is a collective under `symmetric`
(sgl-project#580), so the rank-local presence answer enters the EXISTING vote as
`locally_eligible`. Never a new early return, never a new collective -- a
rank-local answer that skipped the vote is the sgl-project#580 desync itself.

COST, bounded by construction: the whole key chain goes in ONE batch_exists, the
verdict is cached on the request per streak increment, and an anchored request
short-circuits before any probe -- so the default admission path pays nothing.

TESTS: 5 arms RED FIRST, all four failing with the metal reason
`declined:anchor_no_vote` verbatim before the fix. Delivery proven by the EFFECT
(rid in ongoing_prefetch), never by a return value. Counter-arm: an empty store
declines with `declined:store_absent` and never enters the fetch. Can-fail proven
by mutation. `anchor_no_vote` survives for tree caches with no controller to ask,
because calling that "store_absent" would claim a check never made.

Blast radius 44 modules, each alone in a fresh process, identical script both
sides vs 3303289: BEFORE 1167 passed / 9 failed, AFTER 1172 / 9. Exactly ONE
module differs (946: 42 -> 47). The 9 failures are pre-existing and identical
both sides (580: 7, 610: 2). Extraction count probe 9 == 9.

ruff (F401,F821,UP037) clean. cache_controller.py is NOT ruff-format-clean at
HEAD, so it was NOT formatted wholesale -- the diff is 61 insertions and ZERO
deletions; a wholesale run had touched two unrelated asserts and was reverted.
The two codespell hits in scheduler.py are pre-existing.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 28, 2026
…dow at flip) into merge/flip-window-0828

Terrains disjoint: sgl-project#971 (scheduler.py, scheduler_pp_mixin.py) x roundtrip
(cache_controller.py, hicache_phase_binding.py, hicache_storage.py,
canonical_page_store.py). Gate on the merge tip recorded in the register
before push.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 30, 2026
…ing it

Fork (B), per the sgl-project#939 order's own wording: on a stale refusal, re-issue the
READ under the current generation rather than recompute the prefix.

WHY NOT THE COPY: BOOT-MEASURED (boot_855_939rehome) all 15 host->host copies
raised `shape '[2,16,1,4,256]' is invalid for input of size 16384/8192` -- the
PP-phase and TP-phase host tiers shard differently under uneven DCP, so
carrying a span across a flip is a RESHARD, not a relocation.

WHY NOT A RESHARD MOVER: that would be a bespoke second mover for a payload
the canonical reader already moves correctly (`ein-job-ein-mover`). Instead
`HiCacheController.reread_pages_into` drives `page_get_func` -- the exact
dispatch `_page_transfer` uses -- so the layout-correct reader stays the only
thing that ever writes a page into a host tier. The store is geometry-neutral
by design (sgl-project#706, "cut only at read time"), and that premise was verified on
the same boot: a single key suffix across 666 KV + 171 mamba keys.

Behaviour now: same geometry -> byte copy (no store IO); differing geometry ->
re-read the same content keys into the fresh current-tier slots. A short or
zero re-read frees the slots and leaves the sgl-project#937 refusal standing, because
publishing a partial span would advertise pages that were never written.

COST PREMISE, measured rather than assumed: the store is on ZFS, not tmpfs
(1.2 GB under /tmp/hicache_*), so this is a real filesystem read -- though a
store that size should largely sit in ARC. Not free, not a disk seek either.

R19 remains the open question: admission never waits, so the re-read must
beat recompute to the readmit match. The latency is now on the RE-HOMED line
(via=copy|reread) so the next boot measures it instead of arguing it.

CHECKS: can-fail proof extended to 10 paths, all pass -- same-geometry copies
without touching the store, differing-geometry re-reads the right keys without
attempting a byte copy, and short/zero/no-keys/no-room/copy-raised/same-pool/
page-size/zero-length all decline and free. Mutation check still fires.
py_compile clean on both modules.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 10, 2026
…windows 2..n

DESIGN A (user ruling 2026-09-10 'A, und M auf den sn5w-Wert pinnen').
The X gate priced 'uncached' against the TREE only -- device rows plus
host-tier rows. Under the phase law group P prefills the whole backlog and
writes it through to L3, so on group D a long prompt's prefix is in NEITHER
tier and 'total - group_match' priced the WHOLE prompt as uncached work:
W50, re-route, P prefills a store-resident prompt AGAIN. L3 is the carrier,
so a token the carrier holds is CACHED, and uncached now means 'not in the
tree AND not in the store'.

The store depth rides a THIRD ARM of the packed MIN reduce that
_update_uniform_pool_budget already takes -- no new collective (verified:
2 all_reduce sites on branch and parent alike), same canonical head as the
ORDER and COMPLETION arms, MIN in the conservative direction. Its input is
store_presence_pages, which is legal as a group input for a stated reason:
it answers BY CONTENT KEY and under sgl-project#706 the key is a function of the
content, not of any rank's layout or residency.

THE PHASE LAW HOLDS, PROVEN NOT ASSUMED. The credited depth is
anchor-capped (#869b), so by the sgl-project#939 one-chunk law what survives as
genuinely uncached is at most one chunk C. And X >= C on every path:
derive_x_star returns max(int(floor_tokens), ...), the override path
applies max(floor_tokens, int(override)), and floor_tokens is
CHUNKED_PREFILL_TOKENS at the only call site. So D prefills at most a
chunk and never above X, with no launch refusal needed.

C4/C6, reachable ONLY because of A: before A the request was refused in
the waiting-queue pass and never became chunked_req, which is the ordering
refutation of the 0907 spec recorded in section 1bl. Now it is admitted, a
round exists, and the round seam issues the next window. The gate carries
no rank-local term (AST-checked on the executable body): admission
identity plus a mark armed from the GROUP-agreed 'issued:truncated_group'
verdict. No new offset field -- the re-matched tree IS the cursor. The
mark's lifecycle table names its two writers, its reader and the cutover as
the separating event.

--pin-ledger-arm-m pins the ledger arm's M. The pinned arm is still PRICED
by the same price() the ladder uses and REFUSED by name (W39) when it does
not fund at both moments: a pin selects among arms the ledger would fund,
never a way past its verdict. Verified: M=600 funds (launch +5.17, run
+14.19), M=2400 refuses.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…icache too

xsn31/7 second attempt reached READY cleanly (health 200, no exception)
then was torn down by an unconditional launcher-side post-ready check:
count_marker() greps each group's own log for "sgl-project#706 canonical KV page
active" / "canonical GDN blob active" x3 each and refuses (W7/W10) if
missing. Grep-verified: both lines are printed ONLY by
managers/cache_controller.py's HiCacheController (~1411/1608), which is
instantiated ONLY under enable_hierarchical_cache (mem_cache/registry.py's
create_tree_cache) -- this hybrid-SSM model falls through to a plain
MambaRadixCache otherwise, which never emits either marker. Same class as
the draft-KV-producer wall this file already fixed: a gate that never
learned the switch exists.

Both group P's and group D's copy of this check now SKIP (named line, not
silent) when hicache_disabled, mirroring the pre-existing "W10/W11
SKIPPED" pattern for draft_kv_on_p. Not unit-tested (this file's other
sgl-project#1386 tests are all hermetic dry-run/argv-level): the check reads a
spawned rank's own log file post-READY, the same "Metal only" class the
project's own doctrine already names for bytes/cushion/timing -- it can
only be exercised by an actual boot, which is exactly what caught it.

Dateigrenze unchanged: launcher.py + host_ledger.py only.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…her than a second scanner

Prior-art gate first (per order): sgl-project#1328's own file
(test_weg2_xchg_refusal_reachability_1328.py) already answers "can
production reach this raise/verdict at all" via a name-based AST
reference graph (_Index/build_index/reachable), with an empty-allowlist
ratchet plus a frozen, classified UNWIRED_DEBT for the exceptions, and a
synthetic-tree plant-proof (TestTheRatchetCanFail) that RED/GREENs its
own failure mode. sgl-project#1306 (test_weg2_wcode_uniqueness_1263.py) answers a
different question (is one W-code used twice) and isn't the right host.
Extended sgl-project#1328's file rather than building a second walker.

THE NEW QUESTION sgl-project#1389 ASKS, different from sgl-project#1328's: does the code that
READS a producer's log-line marker run under the SAME precondition the
producer's own construction requires? Five real instances from one
night (2026-09-13/14):

1-3. W7/W10 (P and D) and W9: count_marker() gates in launcher.py read
   markers ('sgl-project#706 canonical KV page active', 'canonical GDN blob
   active', 'sgl-project#1233 HICACHE BIGRAM KEYS FORCED') that only
   managers/cache_controller.py's HiCacheController ever prints, built
   only inside mem_cache/registry.py:192's `if
   ctx.enable_hierarchical_cache:` -- the gates ran unconditionally.
   ALREADY FIXED (sgl-project#1386 follow-ups 2/3, commits 683ccc5/2ef1a0979d).
4. W45: launcher.py's carrier census reads 'sgl-project#915 PREFETCH LIMIT', whose
   producer (mem_cache/prefetch_budget.py's log_prefetch_limit) is a
   no-op whenever its caller passes no cache_controller. ALREADY FIXED
   (sgl-project#1386 follow-up 4, d6c3d19).
5. The W100 guard bound to _weg2_xchg_inject_from_peer, which runs zero
   times on the metal (the real call site is _weg2_xchg_bounce_leg) --
   DESK10's own test passed because it checks the same wrong function.
   UNFIXED, in files locked to DESK10 (weight_updater.py) -- reported as
   a finding, not fixed here.
6. A wait-loop entry-vs-condition race (P enters 03:19:28Z, the
   condition it waits for exists at 03:19:32Z) -- no expressible static
   form found.

THE MECHANISM (ThePresenceRatchet): for each registered (gate anchor,
guard names, producer anchor, producer guard names) tuple,
_guard_chain_by_line walks the file's AST once and maps every line to
the source text of every enclosing `if` test (presence, not polarity --
an `if X: skip / else: gate` shape records X for lines in EITHER
branch, since both fix shapes in the corpus are exactly that). Two
per-entry checks (gate side guarded, producer side guarded) plus a
DEBT_SIZE_ON_THE_LINE-style pinned corpus size (4) so a removed entry
cannot silently pass -- the corpus itself is the required "does the
scan find the known corpus" probe (sgl-project#1341/sgl-project#1306's own lesson: a scan
that finds nothing reads green).

Instances 5 and 6 are DECLARED BOUNDARIES (PRESENCE_RATCHET_BOUNDARIES),
not invented rules: sgl-project#1328's own RESOLUTION docstring already states the
honest bound this ratchet shares (name-based resolution can call an
unwired path wired, never the reverse; no ordering/timing semantics).
Instance 5 gets one structural fact this file CAN verify without
touching the locked source -- the exact AST call-site count and line of
the wrapper _weg2_xchg_inject_from_peer (1, at weight_updater.py:1045)
-- pinned so a future desk can diff DESK10's rewire against it.

Tests: ThePresenceRatchet (4 corpus checks + shape/naming pins),
TestThePresenceRatchetCanFail (synthetic plant-proof: unguarded shape
RED, guarded shape GREEN, ambiguous/absent anchors reported not
silently misread), TestTheBoundariesAreDeclaredNotInvented (boundary
entries carry real reasons; the W100 wrapper's call-site count is
pinned). 10 new tests, all green; full file 27/27 green (17 pre-existing
+ 10 new).

Manually verified both required danger-direction mutants: (1) removed
one entry from PRESENCE_GATES -- exactly
test_the_corpus_cannot_shrink_or_grow_silently goes red, the two
per-entry scans stay green over what remains (proving the corpus-size
pin, not the per-entry logic, is what catches a silent removal);
restored, diff empty. (2) reverted the REAL launcher.py's W7/W10 group P
guard to its historical, unconditional pre-fix shape -- the ratchet goes
red against the ACTUAL file, not just a synthetic one, naming the exact
entry; restored, diff empty (git diff confirmed clean before
re-committing).
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 21, 2026
…ands in for both markers (fnFL2 v18 D READY refused 'kv x1 blob x1, need 3 each')

canonical_marker_counts counts the worker line (no attention layer, no page
window, null storage tier) once into the KV-page and the GDN-blob tally. F10
anchors re-pinned (7379/7383). Tests: launcher profile 7 + seam registry.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 23, 2026
…lots-Metadaten (fnFL2x48b, fnFL2x47)

x48b (HiCache-A/B für den ersten Graph-Verify eines neuen Requests auf D)
wurde vom Launcher abgebaut, NACHDEM D bereit war: W10
Weg2DrafterIdentityMismatch P=None D=None. Ohne HiCache existiert kein
Träger, also druckt keine Gruppe eine "HiCache draft KV registered"- oder
"sgl-project#706 canonical DRAFT page"-Zeile -- das Gate verglich zwei Abwesenheiten
und lehnte eine Route ab, die in diesem Arm per Konstruktion fehlt. W7, W9
und W45 werden unter --weg2-disable-hicache bereits mit benannter Zeile
übersprungen; W10/W11 jetzt ebenso, vor dem --draft-kv-on-p-off-Zweig.

Zensus: x47 druckte für die QSA-Forward-Metadaten keine einzige Zeile --
das Objekt hat kein __dict__ (Struct/Slots) und _walk übersprang es still;
einziges Indiz war "done tensors=15". _fields liest jetzt __dict__,
__struct_fields__ oder __slots__.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 27, 2026
…stay off) -- P's store read of an NF session is no longer clamped to told=0 by a unigram anchor probe

NF rc12t (dkrnfh91dprbar1dauer09271756, e1eb275, profile nf-h91-dpr): 0 of 41 P legs cached. P's PP0 read
the store (weg2-1-9 18:05:34 "HiCache prefetch success ... loaded=54208", WEG2-LOAD-DEVICE 54336 tokens),
then "sgl-project#1416 STORE-TOLD ANCHOR-CLAMP rid=weg2-1-9 completed=54336 anchored=0" -- told 0, the followers
registered nothing (their STORE WITNESS unprobed), every rank prefilled from 0 (SERVED group=P
prompt_tokens=54388 cached_tokens=0). Every P read with loaded>0 in that boot clamped to anchored=0. Root:
with TOLD_PROBE_TREE_KEY off, weg2_store_told._anchor_clamp hashes origin_input_ids as UNIGRAM keys while
the fetch keys the span as the tree does (RadixKey is_bigram=tree.is_eagle, bigram on NF's MTP group) and
through the sgl-project#1442 hand-off chain -- the probe asked for keys nobody writes: the 27B #1416d class, fixed by
TK, which the nextflash row kept off.

The row now carries told_probe_tree_key, told_paced and p_twin_defer = True (TK brings TOLD_ABSOLUTE along).
TK never without PACED: sgl-project#211 (rc11b, -15 % PP0 prefill) was TK's single-phase follower busy-wait in
admission(). With PACED the only remaining wait is admission()'s bounded residual loop when a follower's
read outlasts PP0's pacing window (max(1.25 x PP0's read, told x 1 s/100k), cap 10 s). On the NF P cut PP0
carries the heaviest store share (sgl-project#706 lines: KV slots 7/12 on PP0 vs 3 and 2; GDN blob 35.95 of 58.83 MB
vs 13.07 and 9.81), so a follower's read ends inside the window; 27B metal 09271525: PACED-ADMIT 24, WAITED
0. PF (group fallback) stays off, MZ and front span inflight stay off (not released by the NF seat). An
explicitly set env still wins; profiles/nf-h91-dpr-tk.env states the same values.

Metal (NF seat, rc12u with nf-h91-dpr-tk, 19:09-19:16Z): P legs 10, 8 with a hit (the 2 cold ones first
turns), walls 2.6-8.3 s instead of ~25 s; STORE-TOLD WAITED 0, waited_max 0.62 s, ANCHOR-CLAMP 0.

Tests: test_unify_prefix_switches_profile.py updated to the new row (NF3 = TK, PACED, TW: registry,
state per profile, published form, publish writes exactly the trio, build_env differs by exactly the trio,
profile_docker facts, rank readers incl. TOLD_ABSOLUTE). Fix vs base dbeb9ff, 26 files one by one
through test27b.sh (the prefix-switch/profile suites and every weg2_store_told / p_twin_defer /
told_fallback suite): no new failure.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 28, 2026
…-09-27: "der l3 hicache wird jedesmal verworfen, oder? der soll natürlich persistent sein" / "aber natürlich zwischen 27b und nf verschiedene L3 caches. sonst knallts")

Defect: plan_store named the store directory after the BOOT TAG and sweep_store_residue rmtree'd every
other directory under the root at the next boot, so every boot started with an empty L3 (the NF docker
mount held only dkrnfh91dprbar1dauer09271632). Hidden second half: the shared L3 stem index (sgl-project#1459) answers
"not on disk" for any stem it does not know, and a freshly created index knows none -- a kept directory
would still read as all misses.

Fix (switch SGLANG_WEG2_L3_PERSIST, default on; 0 = the per-boot store as before):
- launcher: the store is <root>/l3-<profile>-<model>-<identity10>; identity = model realpath, sha1 of the
  model config, profile, form_kv, kv_cache_dtype, on-disk generation (706). The directory carries
  L3_IDENTITY.json, checked BEFORE the boot touches a file: a mismatch is a named W57 refusal, never a
  shared store. The sweep spares every l3-* directory (this model's and the other's) and removes only
  per-boot tag directories. l3_persist_attach walks once before any rank starts: counts the pages
  ("L3-PERSIST reuse|fresh dir=... files=... bytes=... staging_removed=...") and unlinks crash-left
  .tmp.<uuid> staging files (no writer is alive yet); canonical partials stay with HiCacheFile's marker
  sweep. The disk check credits the reused directory's own bytes (walked only when the plain check would
  refuse), so a full store does not refuse its own reboot.
- hicache_storage: the process that CREATES the L3 index seeds it from _iter_existing_files
  ("L3-PERSIST index_seeded=N"); joiners querying before the seed completes see misses only.
Facts checked: page keys already carry compute_model_identity_hash; Mamba/GDN state is in L3 as the sgl-project#706
canonical mamba blob; clear_storage_backend runs only on the /clear_hicache_storage_backend API, not on
reset or flip; the evictor's attach census adopts the previous boot's pages (own_known=None), so the cap
holds across boots; the docker arm mounts $ACC/store per line (27b / nf), so the volume already persists.
Cap: per model = --store-max-gb of that model's boot; the disk check counts the other model's store as
used space, so the sum cannot exceed the disk minus min_free.
W8b on the warm store (closed, not left for metal): the evictor's census only indexes its own group's
suffixes, so the sibling group's private-suffix pages a previous boot left would count as seen-but-unindexed
and could drop coverage under the 50 % floor. In a persistent store the launcher proved (L3_IDENTITY.json
present, switch on) such unindexed files OLDER than the evictor are counted as inherited_bytes/entries,
logged ("L3-PERSIST W8b graded without N inherited file(s)") and left out of the gate's denominator; files
written after the evictor was born still count, so a blind scan filter on this boot's own writes is still
refused at the wake re-scan.
Disk sum (user "L3, jeder 150gb"): each store records L3_CAP.json {max_size_bytes, bytes_at_attach}; at attach
"L3-PERSIST DISK-SUM ok|WARN" checks sum over all l3-* stores of (cap - bytes at their last attach) + min_free
against free space, a named warning with the numbers when short, never a silent cap. Measured: /mnt/nvfast
(XFS, bind-mounted as $ACC/store for both lines) 1.8 TB, 1.4 TB free -> 2 x 150 GB + 32 GiB min_free fits.

Tests: test_weg2_l3_persist_0927.py 23 passed (W8b: 60 % sibling-private pages inherited, no refusal; without
identity file / switch off / files newer than the owner the refusal stands; disk sum fits, short = named WARN,
no-record stores named) (switch; 27B/NF two named directories, stable name,
kv format / generation / re-quantised config -> new directory; identity written, matched, foreign refused;
dry run writes nothing; sweep keeps both models' l3-* dirs and removes the tag dir; attach counts pages and
drops staging, dry run removes nothing; disk check credits own bytes, no walk when roomy, tag dir without
a name; index seed in 4096 batches, switch off, creator only; wiring order sweep < identity < attach <
prepare). Comparison fix vs base e1eb275, 31 neighbouring files (incl. every LRUFileEvictor suite) one by one via test27b.sh: identical
pass/fail on every file (pre-existing reds in test_fence_store_decider_1063, test_hicache_era_purge,
test_weg2_s5_store_carrier, test_weg2_dormant_vram_1y, test_hicache_file_lru_unit on both sides).
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 28, 2026
…boot's write window out -- pages written in a revoked window are moved aside at the next attach; P and D with different rope overrides are refused

rc12z17 (103bfdf) wiped D-TP0's live expert bank at its first S1 wake (10:51:24Z, n=4, rows +33 -> +23) and served garbage until the stop at 10:56Z. Every page it wrote into the persistent store in that window carries the store's own identity: the identity (L3_IDENTITY.json + L3_RANK_IDENTITY.<group>.json) separates what was CONFIGURED -- checkpoint, config, weight-file stat, KV dtype, both groups' --json-model-override-args, vision, generation -- not what a running boot COMPUTED. No identity field can exclude it; the next boot would have reused those pages as hits. The operator's only lever was to put the whole store in quarantine.

Measured in the quarantined store (read-only audit, l3-...-fe3b0e1fce.quarantaene-0928-1057): 21764 pages = 13164 KV (9.6 GiB) + 8084 QSA index (0.4 GiB) + 516 mamba (28.3 GiB); 3103 pages (3.4 GiB) written 10:51:24..10:57:19Z. No other boot today ever entered a KV stage above S0 (every D log of 0928 grepped for stage=S1/S2: only rc12z17, first line 10:51:24), so the window is the whole of the damage.

Fix:
* L3_REVOKED.json names windows {from_unix, to_unix, reason}. l3_persist_attach -- the one walk before any rank starts -- MOVES every .bin whose mtime falls in a window into the sibling <store>.revoked (same relative path, os.replace on the same filesystem): moved, never deleted. Marker: "L3-PERSIST ... revoked=N (x GiB, moved to ...; windows [...])". A page is written once, whole, via tmp+rename, so its mtime is its write; a page computed before the window but written inside it is revoked too (conservative).
* An unreadable or malformed record is refused by name (W57 L3-REVOKE), never read as "no windows".
* l3_revoke_window() appends a window (atomic replace); pages move at the next attach, a store in use is never walked from outside.
* python -m sglang.srt.weg2.l3_store_audit audit <store> (read-only: records, pages by kind, KV pages without their QSA sibling, write-time histogram, pages per revoked window) and ... revoke <store> --from/--to/--reason.
* The disk sum names a .revoked sibling instead of reading it as a store without cap record; the residue sweep keeps it (l3- prefix).
* sgl-project#259 identity: l3_persist_check_rope(extra_p, extra_d) before the identity check -- P and D read each other's pages (one L2, one L3, key = token ids), so a rope/position override on one group alone (YaRN x2 on D only) is refused by name. Differences outside rope_scaling/rope_parameters/max_position_embeddings pass. Everything else the WIP listed is already in the identity or the key: KV dtype (argv always carries the constant, EXTRA overrides are recorded), page size (changes the key: clean miss), YaRN via --json-model-override-args (launcher override_p/d + rank override_sha), abliteration (a different checkpoint path), the sgl-project#706 canonical page (geometry-neutral: form and cut are not in the bytes). Today's store name fe3b0e1fce is pinned by a test.

H106 (b28315d) cross-check, no change: the Form-A worker's storage tier is FormAWorkerNullStorage (cache_controller: claims every page, reads and writes nothing), so no worker writes L3 and the QSA index page on disk comes whole from D-TP0 and the P stages. "every rank runs the replicated indexer" (qsa_kv_pool.py) is the classic uneven-DCP layout of fn1u (09-16); under Form A the worker runs no dense chain. The skip is correct and loses no sidecar page.

Tests test_weg2_l3_revoke_0928 (13): on ff7a9cb the file does not import (no l3_store_audit); with the audit module alone 11 red (no revocation, no rope refusal); with the fix 13 green. Neighbours (l3_persist 0927, l3_teardown_keep 0928, l3_reuse_after_restart 0928, probe_hold_257, store_max_gb_user_order, store_on_disk_1236): 89 passed on the base, 89 with the fix.

Metal marker: the attach line "L3-PERSIST reuse ... revoked=" (absent without a record); "L3-PERSIST P and D rotate differently" only on an asymmetric rope override.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 28, 2026
…nter dem Token-Schnitt

rc12z29d -st-cut (bd238e5) kam bis D READY (Karte, Pin, W170,
Store-Geometrie korrekt) und wurde vom Launcher selbst abgebrochen,
launcher.log 20:34:28Z:
  W7/W10 launcher half, group D log: 'sgl-project#706 canonical KV page active' x1,
  'canonical GDN blob active' x1
  REFUSED: W7/W10 (launcher half): D logged kv x1 blob x1, need 3 each

Wurzel: Unter dem Schnitt (--uneven-token-vector 0,48,16, Form A
--rank-tp-ratio 1,0,0) bauen die Worker, die Token-Zeilen besitzen, ein
KV-Seitenfenster (cache_controller F14-Zweig) und melden
'sgl-project#239 F14 KV-WORKER-WINDOW: Form A worker owns token rows ...' (D-Log
Z. 10146/10148, TP1/TP2) statt der alten Zeile 'this rank is a Form A
expert worker (no attention layer) -- no page window'.
canonical_marker_counts kannte nur die alte Zeile -> kv 1, blob 1 (nur
TP0, Z. 10160/10161). 3446b7f (S3h) oeffnete den Riegel fuer F14, die
Launcher-Haelfte von W7/W10 wurde nicht nachgezogen; kein Schnitt-Boot kam
vorher bis READY.

Fix (der Riegel bleibt):
- canonical_marker_counts zaehlt die F14-Zeile als KV-Fenster des Workers;
  den GDN-Blob haelt der Attention-Host, die Zeile steht dafuer ein wie die
  alte Worker-Zeile.
- Zusaetzlich: d_kv_worker_ranks(extra_d) nennt die Worker, die unter dem
  Schnitt Zeilen besitzen ([1, 2] bei 0,48,16); logt davon einer kein
  F14-Fenster, verweigert W7/W10 benannt -- genau der Fall 'Rang haelt KV
  ohne kanonische Seite', den der Riegel schuetzt.
- Ohne Schnitt / ausserhalb Form A: byte-gleich.

Andere Launcher-Haelften mit Zaehlung je Rang geprueft: W7/W10 P (PP3, keine
Worker), W9 (>= 1), BAR1 window clip (nur Log), gate_w10/w11 (Draft-
Identitaeten, im Schnitt unveraendert TP0) -- keine setzt 3 Raenge mit
Kanon-Zeile voraus.

Test test_weg2_w7w10_kv_worker_window_239 (6, Metallzeilen woertlich):
5 rot auf bd238e5, gruen mit Fix; Nachbarn 22 Altlasten identisch, 0 neu.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 28, 2026
…nter dem Token-Schnitt

rc12z29d -st-cut (bd238e5) kam bis D READY (Karte, Pin, W170,
Store-Geometrie korrekt) und wurde vom Launcher selbst abgebrochen,
launcher.log 20:34:28Z:
  W7/W10 launcher half, group D log: 'sgl-project#706 canonical KV page active' x1,
  'canonical GDN blob active' x1
  REFUSED: W7/W10 (launcher half): D logged kv x1 blob x1, need 3 each

Wurzel: Unter dem Schnitt (--uneven-token-vector 0,48,16, Form A
--rank-tp-ratio 1,0,0) bauen die Worker, die Token-Zeilen besitzen, ein
KV-Seitenfenster (cache_controller F14-Zweig) und melden
'sgl-project#239 F14 KV-WORKER-WINDOW: Form A worker owns token rows ...' (D-Log
Z. 10146/10148, TP1/TP2) statt der alten Zeile 'this rank is a Form A
expert worker (no attention layer) -- no page window'.
canonical_marker_counts kannte nur die alte Zeile -> kv 1, blob 1 (nur
TP0, Z. 10160/10161). 3446b7f (S3h) oeffnete den Riegel fuer F14, die
Launcher-Haelfte von W7/W10 wurde nicht nachgezogen; kein Schnitt-Boot kam
vorher bis READY.

Fix (der Riegel bleibt):
- canonical_marker_counts zaehlt die F14-Zeile als KV-Fenster des Workers;
  den GDN-Blob haelt der Attention-Host, die Zeile steht dafuer ein wie die
  alte Worker-Zeile.
- Zusaetzlich: d_kv_worker_ranks(extra_d) nennt die Worker, die unter dem
  Schnitt Zeilen besitzen ([1, 2] bei 0,48,16); logt davon einer kein
  F14-Fenster, verweigert W7/W10 benannt -- genau der Fall 'Rang haelt KV
  ohne kanonische Seite', den der Riegel schuetzt.
- Ohne Schnitt / ausserhalb Form A: byte-gleich.

Andere Launcher-Haelften mit Zaehlung je Rang geprueft: W7/W10 P (PP3, keine
Worker), W9 (>= 1), BAR1 window clip (nur Log), gate_w10/w11 (Draft-
Identitaeten, im Schnitt unveraendert TP0) -- keine setzt 3 Raenge mit
Kanon-Zeile voraus.

Test test_weg2_w7w10_kv_worker_window_239 (6, Metallzeilen woertlich):
5 rot auf bd238e5, gruen mit Fix; Nachbarn 22 Altlasten identisch, 0 neu.
efschu pushed a commit to efschu/htsglang that referenced this pull request Oct 1, 2026
…told=0, not the z30y14 group death

z30y14 (image 02adfaa, 01.10. 03:15:38Z): PP1 raised sgl-project#1400 STORE-TOLD
MISMATCH rid=weg2-64-273 told=97631 own_prefix=own_loaded=93858.

Root cause (P log): the three P ranks reach three store depths for one told.
PP0 WEG2-READ-STAGES pages=97631 l3fill_pages=1888; PP1 pages=95684
l3fill_pages=88; PP2 pages=95716 l3fill_pages=88. PP0's L3 view is the
shared sgl-project#706 canonical store (WEG2-STORE-RESCAN: SIBLING GROUP bytes > 0 on
every PP0 wake, 71.6 GB at 03:15:33), PP1/PP2 index a fixed 1497788-file
store with 0 B sibling pages on all 33 wakes; PP0 also evicted ~1800 slots
of the shared arena to disk during its own read (ARENA-EVICT n=7..11,
03:15:34-35) and pulled the tail back through its own L3 view. The
followers' reads TERMINATED short (sgl-project#1157 PREFETCH REAPED elapsed=2.09s of
budget 97.34s), so no admission wait closes the gap. PP1's tail_release=1826
is sgl-project#257 PREFETCH BELOW-ANCHOR (read 95684, deepest mamba anchor 93858,
#1028B FETCH CAP lost=1826). The L3 write-behind (8287104, YIELD_MS=2000)
is not the cause: it logs on PP0 only, written_total=512 for the boot.

With TOLD_PACED on and PF off (registry row qwen27b), PP0 admitted the
paced told on its window/idle path without knowing the followers' depths.
PF (weg2_told_fallback, in the tree since ff1087f) is the existing
rank-agreed answer: followers ack their own prefix, PP0 answers own != told
with Admit(0, fallback) for EVERY rank (re-prefill; the mismatch refusal
itself stays in place for any path that bypasses PF). This commit turns
the qwen27b registry row's told_group_fallback on; nextflash stays off.
Not yet seen on metal: the next boot must show PF TOLD-OPEN lines.

Tests (CUDA_VISIBLE_DEVICES="", worktree python on path):
- new test_weg2_told_pf_27b_z30y14.py: red on ea95ea4 (2 failed: PF off
  by profile; specimen raises "told=97631 own_prefix=93858" on PP1), green
  here (4 passed: rank-agreed Admit(0) on the acks, no raise, no leaked
  read; PF=0 still dies by name; equal depths still admit told).
- changed area: PF, registry, told family, shortread, dual, form profile
  suites: 167 passed; registry-dependent neighbours: 219 passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant