Skip to content

docs: update comment - #721

Merged
zhyncs merged 1 commit into
sgl-project:mainfrom
zhyncs:405
Jul 25, 2024
Merged

zhyncs merged 1 commit into
sgl-project:mainfrom
zhyncs:405

Conversation

@zhyncs

@zhyncs zhyncs commented Jul 25, 2024

Copy link
Copy Markdown
Contributor

Thank you for your contribution, we really appreciate it. The following instructions will help improve your pull request and make it easier to receive feedback. If there are any items you don't understand, don't worry. Just submit the pull request and ask the maintainers for help.

Motivation

Please explain the motivation behind this PR and the goal you aim to achieve with it.

Modification

Briefly describe the changes made in this PR.

Checklist

  1. Ensure pre-commit pre-commit run --all-files or other linting tools are used to fix potential lint issues.
  2. Confirm that modifications are covered by complete unit tests. If not, please add more unit tests for correctness.
  3. Modify documentation as needed, such as docstrings or example tutorials.

@zhyncs
zhyncs requested a review from Ying1123 July 25, 2024 00:22
@zhyncs
zhyncs merged commit 97e0f7d into sgl-project:main Jul 25, 2024
@zhyncs
zhyncs deleted the 405 branch July 25, 2024 00:51
timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
cherryblo added a commit to cherryblo/sglang-project that referenced this pull request Jul 2, 2026
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…er a conservative floor

THE MEASUREMENT IS THE POINT AND THE GATE IS SECONDARY -- that way round, on
purpose, and it is a change from the shape I was asked for.

Three external-kill crashes now, all flip-proximate:
    03:22:17 death, flip 03:21:05 -> rank0 lost ~7 s after the flip
    03:31:17 death, flip 03:31:06 -> 11 s
    03:38:53 death, flip 03:38:07 -> 46 s
Two of the three killed RANK0 ALONE (rank0 contributes 2 log lines while the
peers contribute 60-134 each -- the absent rank is the one that died), and
rank0 is PP0, the 35 G RSS process, the largest on the box. The third took the
whole tree symmetrically. A 21:24 kill is ledger-confirmed as the kernel OOM
killer.

BUT STEADY-STATE HOST HEADROOM IS ~38 G. So a floor small enough to be safe
would never have fired on any of these, and a floor large enough to fire would
defer constantly. I have NO measured projected host transient for the flip, and
I will not invent one to make a gate look decisive -- that is the hand-fitted
input mistake I already made once on sgl-project#702.

So the guard LOGS host availability at every flip, which nobody currently
records, and defers only under a deliberately conservative floor:
  * availability collapses at flips -> transient candidate confirmed, and the
    floor can then be set FROM DATA rather than from a guess;
  * availability stays flat while kills continue -> the flip is exonerated and
    lane RSS spikes gain.
The discriminator works whichever way it points, which is the property that
justified shipping ahead of attribution.

FLOOR = 4 GiB, justified from this box, not chosen round: ~10% of the measured
38 G steady headroom -- enough to absorb the lane RSS jitter sharing this
container (pytest/git spikes run under 2 G) without deferring on noise.
Deliberately NOT the 10 G PINNED_HOST_RESERVE_BYTES: that reserve protects
PERMANENT pins; a staging transient is by definition returned.

BOUNDED DEFER, 3 then escalate-and-proceed. A permanent hold is WORSE than the
hazard: the flip is how this instance alternates prefill and decode, so holding
forever converts a POSSIBLE process kill into a CERTAIN half-service outage --
and the kill is recoverable by a restore while the outage is not self-clearing.
The escalation says PROCEEDING WITH EYES OPEN and prints every term.

UNREADABLE HOST RAM STANDS THE GUARD DOWN. pinned_host_memory_bytes returns
(None, None) when there is no honest number, and refusing a flip on a
fabricated figure is worse than not checking -- the refusal is the thing with a
service cost.

sgl-project#696 INTERACTION, NAMED NOT ABSORBED: the defer reason is the shared constant
DEFERRED-HOST-RAM, so SLO / ARM-UNFUNDED accounting sees a host-RAM defer as
its own fact. A flip that did not arm because the HOST was tight is not the
same event as one that could not fund its VRAM seam, and merging them would
hide exactly the signal sgl-project#721 is collecting. It is a named defer reason, not a
new policy: the defer rides the existing unanimous too_small ballot.

Tests, hermetic (CUDA_VISIBLE_DEVICES=""):
  healthy allows and does NOT name a defer ..... CAN-FAIL: a guard that
      deferred on healthy state would pass every firing test and be useless
  low headroom defers; boundary is exactly transient+floor
  unreadable stands the guard DOWN
  defer is bounded, then ESCALATED and proceeds
  every term quoted; defer reason is the shared constant; degenerate inputs
  -> 8 passed + 6 subtests; 82 passed + 19 subtests with flip-runtime and 703.
     ruff clean in both changed regions.
CAN-FAIL PROVEN BY MUTATION: a never-defer mutant fails 5 of 8; reverted green.

The guard is wrapped so it can never break a flip: on any exception the flip
proceeds UNGUARDED and says so, rather than being refused on an unknown.
efschu added a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…em at the package root

THE ROOT TICKET I FILED LAST PASS. sglang/__init__.py called apply_all() on the
transformers compatibility patches at import time, which imported transformers
in EVERY process -- and transformers reaches torch._dynamo
(transformers/masking_utils.py), which imports triton. So a process that merely
imported sglang loaded a graph compiler and a GPU kernel compiler. On a
swapless box that is host RAM (sgl-project#721 family), not cosmetics.

THE FIX. The root now ARMS the patches: a post-import hook runs apply_all()
inside transformers' own import. The ordering guarantee is unchanged and if
anything stronger -- a caller must import transformers to use it, and the
patches land before that import returns -- while a process that never imports
transformers never pays, and never needed the patches, since they only touch
transformers internals. apply_all() had exactly ONE caller (the root), so
nothing else changes.

MECHANISM SHARED, NOT DUPLICATED. utils/post_import_hook.py is the generic
"run a callback when module X finishes importing, without importing X"
primitive, extracted from sgl-project#673's triton hook; triton_patch.py now delegates to
it and keeps its public API. The extraction was safe to do because that hook
already carried 12 tests and 5 mutation proofs.

MEASURED, fresh subprocesses, before -> after (modules / max RSS):

  import sglang        4320 / 783 MB  ->  1897 / 611 MB   (-2423 mod, -172 MB)
  server_args          5114 / 826     ->  5115 / 825
  tokenizer_manager    6760 / 962     ->  6761 / 953
  detokenizer_manager  6764 / 953     ->  6765 / 953
  http_server          7325 / 986     ->  7326 / 982
  scheduler            6991 / 965     ->  6992 / 965

HONEST SCOPE, INCLUDING THE ZEROS. The win lands on processes that import
sglang WITHOUT touching a tokenizer. The tokenizer and detokenizer managers are
UNCHANGED -- and that is not a shortfall of the fix: both import
hf_transformers_utils themselves, because tokenising is what they do, so
transformers is a genuine dependency there rather than a root artefact. The
ticket's premise (that these two process types would get lighter) was wrong,
established by inspection before building and confirmed by measurement after.
Everything else is +1 module (the hook) and flat RSS, which is exactly the
requirement for model processes: byte-identical behaviour, and the scheduler
still imports triton eagerly, deliberately unoptimised.

Tests (8 new, hermetic, fresh subprocesses): a bare `import sglang` pulls
neither transformers nor triton; the root arms the hook; importing transformers
applies the patches, including via a SUBMODULE import (a consumer cannot slip
in through transformers.utils); the can-fail (with the hook uninstalled the
patches do NOT apply, so the ordering tests prove something); and the scope
pins -- the text managers still import transformers themselves, and a frontend
process stays under 3000 modules.

LADDER RUNG CLIMBED, as designed: the previous rung asserted that a bare
`import sglang` pulled BOTH torch and triton (the honest state then). Triton is
now gone, so the rung asserts ['torch'] -- torch remains structural in
utils/common.py. The rung failing is what told me to climb it.

Two of my own tests needed repair after the shared-hook extraction, both
recorded: the idempotence pin counted _PostImportFinder objects and now had to
filter by target name (the transformers hook is armed too), and the isolated
ordering probes had to load post_import_hook by file path rather than
triton_patch, which is no longer stdlib-only now that it delegates. The
guarantee lives in the generic hook, so proving it there is the more correct
place anyway.

Regression, same env: unit/server_args 1 failed / 655 passed -> 1 failed / 663
passed (+8); unit/managers 4 failed / 2155 passed unchanged; unit/mem_cache 940
failed / 938 passed unchanged. Frontend smoke: sglang.function/gen/user/
assistant intact, version resolves, patches applied after transformers import.

CAN-FAIL PROOF (mutation applied, suite re-run, reverted):
  X1  the root applies eagerly again (the defect itself)
      -> test_a_bare_import_sglang_pulls_neither_transformers_nor_triton,
         test_a_frontend_process_stays_light, test_the_root_arms_the_hook
  X2  arm() is a no-op (patches never land)
      -> the three ordering pins + test_the_root_arms_the_hook
  X3  the hook callback is dropped (import runs, patch does not)
      -> test_importing_transformers_applies_the_patches,
         test_the_patches_land_before_the_import_statement_returns,
         test_a_submodule_import_also_triggers_the_patches
  X4  an already-imported module is not patched on install
      -> caught by test_triton_imported_first_is_patched_retroactively in
         test_triton_patch_ordering_673.py, NOT by this file. Recorded rather
         than papered over: the retroactive path of the SHARED hook is covered
         once, on the triton side, and the transformers side has no equivalent
         pin because arming happens at the package root before transformers can
         already be imported.
Restored tree re-verified green after every mutation (8 passed here, 12 there).
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 pushed a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…ter-load

The help said "Call posix_fadvise(DONTNEED) on each safetensors shard", which
is the PRE-sgl-project#408 mechanism and a NO-OP on ZFS: DONTNEED does not free mapped
pages there, not even after unmap. On this rig the checkpoint lives on ZFS, so
an operator reading only the help would conclude the flag is inert and skip the
one lever that removes the weights-load page-cache spike -- the spike that
OOM-killed the container on 2026-08-17 at a 111.3G peak.

The implementation is already the sgl-project#408 ladder: MADV_PAGEOUT walks the page
table of the live mapping, and plain fadvise survives only as the
no-mapping/no-madvise fallback (weight_utils._drop_file_cache_after_load). The
text was stale over a fixed implementation.

No behaviour change. Ruff: 357 errors before and after, all pre-existing.
efschu added a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
…ip named

Pass 2's state was unverified after the process-exit waves, so this pass began
by CHECKING every worklist item against the tip rather than by merging. Five of
eight were already on the train, verified with merge-base --is-ancestor rather
than assumed:

  feat/407-registry-reconcile (ahead=0) + docs/407 + VERDICT_407 present
  the two DESIGN_407 corrections filed under sgl-project#732 -- both committed
  fix/485-gdn-family-report (ahead=0)
  feat/363-remainder (ahead=0)  <- the worklist flagged this MISSING. STALE.
  fix/602-fill-side (ahead=0)
  the sgl-project#710 adapter item -- the named site carries the repair, from sgl-project#540

Merged (all clean, zero conflicts):
  origin/train/0817-desk  -- sgl-project#737 ack drain, sgl-project#734 dead-peer discriminator,
                             sgl-project#721 help text, and sgl-project#738 direct-io which F4-r4
                             pushed during the pass, resolving that item
  feat/516-miss-slot-budget
  feat/553-remainder
  fix/739-prefill-progress-signal

Plus sgl-project#748 shipped ON the train before the freeze: my sgl-project#744 armed-only gate
strangled the flip's own funder (35 refused tp_to_pp, IDLE-LOCK at 407,622
tokens pending), and the review boot must not carry the unrefined gate.

TEST EVIDENCE, per-suite and compared by FAILED/ERROR line rather than total:
  baseline before any merge        57 failed, 4 errors, 5510 passed
  after the three main merges      57 failed, 4 errors, 5575 passed
  new failures ZERO, disappeared ZERO
Pinned suites after sgl-project#748: 142 passed + 87 subtests.

ONE FINDING RECORDED RATHER THAN RE-RUN AWAY. Three later full-scope runs
showed ~50 extra failures in the distributed/ collective-floor family, and the
obvious suspect was the last merge. sgl-project#739 is EXONERATED by a same-commit
contradiction: commit 3c49cbc, the tree BEFORE sgl-project#739, was run twice on the
identical scope -- once ZERO new, once FIFTY. Same commit, same command,
opposite results. Corroborated: the suites pass in isolation, pairing each new
suite with a victim stays green, and distributed/ alone gives 27 rather than
27+50. So the combined run is order-dependent at ~50 tests on this lineage:
a test-infrastructure defect worth its own ticket, not a property of this
train. A suite that gives fifty different answers on one commit cannot gate
anything, and the tempting move -- re-running until it looked green -- would
have buried that.

NOT on the train: Slot-2's sgl-project#747, which arrived after the freeze. Nothing else
was withheld; every worklist item is merged or verified present.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 24, 2026
…all three falsifiers

First slice of the user's flip-image design: RAM holds ONE layout image plus a
small overshoot, and at the flip the incoming layout streams RAM -> VRAM while
the outgoing one streams VRAM -> RAM into the pages just freed. PCIe is full
duplex, so the copy-back rides the idle return direction.

THE COPY-BACK IS NOT WRITE-BACK. The weights are immutable and nothing is
saved; it is residency PLACEMENT for the next flip, which is what a
single-layout RAM budget requires. Written into the module docstring because a
later reader who mistakes it for a write-back will optimise it away and break
the following flip.

WHY THIS AND NOT THE PARTIAL PIN: W26 proved the dual pin impossible here --
both pin arms OOM-killed in the LAUNCH phase, before any flip. One layout plus
eps (~30 GiB vs ~68.7 GiB) fits AND takes the disk off the steady-state
critical path, which is what reaches the physics floor; a partial pin leaves a
disk share behind, and W26 measured the leg 99.8-100 % storage-bound.

THIS SLICE IS THE ARITHMETIC ONLY, deliberately. The overshoot sizing and the
interleaved schedule are pure functions over byte counts, so every invariant
the scheme rests on is falsifiable WITHOUT a GPU -- the same split sgl-project#852's
estimator and sgl-project#856(a)'s bound phrase use, and for the same reason.

OVERSHOOT = size asymmetry + in-flight window, sized from the LARGER
direction. The asymmetry is W26's measured one (PP0 15925.8/16362.7, PP1
8573.8/8961.3, PP2 8573.8/9481.6 MiB); a single fixed reservation has to cover
whichever direction the next flip takes, so a mean is the OOM. The in-flight
term is separate and pinned: an implementation returning only the asymmetry
gives 0 for equal layouts and stalls immediately.

ALL THREE NAMED FALSIFIERS ARE ASSERTED:
  * no actual overlap -- `rotation_totals` counts co-scheduled steps; a real
    rotation must have them and must have them as the DOMINANT shape (>90 %
    of steps), not as an accident of the tails. Its can-fail partner: a
    one-sided rotation must report zero overlap.
  * RAM leak across cycles -- three full A->B->A cycles must return host
    occupancy exactly to its start. Three, because W27-retry's leak fired on
    the THIRD cycle, not the first.
  * checksum -- verified against the real source: the image is
    `payload = image[:layout.total_bytes]` plus an int64 trailer, checked with
    `uint8_checksum(dst)` over the ARENA. That last part is what makes a D2H
    reproducible: bytes returned from VRAM verify exactly as bytes read from
    disk do, so only the 8-byte trailer is new.

A FINDING THE TESTS PRODUCED, and it is why the budget test first passed
vacuously: THE RAM BUDGET BINDS IN ONLY ONE DIRECTION. Pressure exists solely
when the OUTGOING layout is LARGER than the incoming one, because only then
does the copy-back need more RAM than the H2D frees -- PP0 copying back its
16362.7 MiB tp image while the smaller 15925.8 MiB pp image streams in leaves
436.9 MiB with nowhere to go. The opposite direction schedules cleanly at zero
overshoot. Both halves are now asserted so the asymmetry is recorded rather
than rediscovered.

Under-sizing STALLS LOUDLY rather than proceeding: a scheduler that kept going
would be holding both layouts, which is precisely the state that OOM-killed
W26's pin arms.

GATE (foreground, family-batched):
  managers core (45 PP files excluded)  3554 passed, 336 subtests, 0 failed
  model_executor                        777 passed / 15 failed (+14 new)
The 15 are the pre-existing sgl-project#815 family. ZERO new failures.

NOT YET BUILT, and not claimed: the device-side execution (streams, the pinned
ring registered once per sgl-project#720/sgl-project#729, the planner-priced host post per
sgl-project#721/sgl-project#770), and the separately-instrumented priming flip. This slice is the
plan those will execute.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 25, 2026
…roject#718 rebind can arm

MECHANISMUS VORHANDEN, AKTUATOR FEHLT. The whole sgl-project#718 rebind chain already
existed and was already wired: `rebind_for_cutover` is called at the cutover,
the sgl-project#719 generation stamp and `coherence_check` are built, and
`phase_pools_for` knows exactly what it wants. It wanted
`scheduler.phase_flip_host_pools[phase]` -- and across the entire tree that
name appeared ONLY in its own docstring and its own refusal message. Nothing
ever wrote it, so the rebind could never arm.

W32 measured the consequence end to end: no host pool -> RebindRefused ->
the rebind never arms -> bound_phase() stays "pp" ->
device_tier_disarmed("load") is True for the whole TP phase ->
HiCacheController.load() returns None -> ZERO tokens reach the device. The
one transport prefill logged `#cached-token: 0` on what should have been a
perfect disk hit, beside 6 `sgl-project#718 hicache-phase-guard` warnings.

`build_phase_flip_host_pools` runs in `init_model_worker`, right after
`build_phase_flip_tp_stack` -- the first point where BOTH device pools
exist, which is required because a host pool is allocated FROM its device
pool (DESIGN_706 C1) and cannot be derived after the fact.

FLAG-GATED: without --phase-flip-rebind-hicache it returns {} and allocates
nothing, so every other boot is byte-identical.

A STAGING PIN, NOT A MIRROR (sgl-project#810). `pp` maps to the tier the boot already
built; the rebind needs a HANDLE per phase, not a second pp pool. Only `tp`
is new and it is sized to the WORK, never to the pool: chunked_prefill_size
x max_running_requests x PHASE_FLIP_STAGING_CHUNKS tokens times the pool's
own measured per-token cell. `ratio=0` is passed explicitly, because a ratio
is the mirror-shaped answer sgl-project#810 forbids -- it would duplicate retention the
pp tier already provides and charge the pinned host budget for capacity
nothing reads. Pinned by a test: doubling the device pool changes the pin
not at all; doubling in-flight work doubles it.

HOST-LEDGER POST (sgl-project#721): the GB taken, the derived GiB, the token count it
came from and host free after, logged AT the allocation so the ledger
carries the number actually taken rather than an intention. The POST shrinks
if it does not fit; the FLOOR never does.

REFUSAL CONVERTED, NOT DELETED (sgl-project#847). `phase_pools_for` still raises for a
genuinely absent or mis-shaped pool, pinned against the REAL guard rather
than a restatement: no TP device pool -> no `tp` entry -> the cutover
refuses, exactly as in W32. A constructor that throws is caught, reported
loudly, and leaves the phase unbound rather than taking the boot down.

TESTS (13): default boot untouched; both phases registered; the pin comes
from the TP device pool; staging-not-mirror in both directions; and the
can-fail set -- no host tier, no TP pool, the real guard still raising, and
a throwing constructor.
Clean SERIAL gate (one suite at a time): 8 failed / 4071 passed / 2 skipped
-- the same pre-existing 8, +13 matching the tests added here.

METHOD CORRECTION: my earlier per-file "ruff delta vs HEAD" checks compared
a copy under /tmp, where ruff resolves a DIFFERENT config, so those readings
were invalid. Re-done in place: the single F401 in phase_flip_boot.py is
pre-existing and this change adds zero.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 26, 2026
…remise

POSTEN 1 -- MEASURED FIRST, AND THE PREMISE DOES NOT SURVIVE THE MEASUREMENT.

The instruction was: the guard is inert because there is no readable total, so
cap `memory.current` against a constant 111.3 GiB from sgl-project#721. Measured on this
box before touching anything:

    pinned_host_memory_bytes() -> total=118.05 GiB  available=112.95 GiB

so it does NOT land on the :245 "no honest number" branch. The guard is ACTIVE,
a total IS readable, and `PINNED_HOST_RESERVE_BYTES` = 10 GiB is therefore NOT
inert as a subtraction. The clamp binds too: MemAvailable 113.19 -> 112.95 GiB,
reduced by the cgroup's own resident accounting exactly as rule 2 of
`honest_host_memory_bytes` documents. `MemAvailable > MemTotal` is FALSE right
now, so the pathological lxcfs reading is not present either.

AND THE PROPOSED CAP WOULD NOT HAVE BOUND ANYTHING. Every level of the visible
hierarchy is unlimited -- root, system.slice and system.slice/claude.service
all read `memory.max = max`, and all three report `oom_kill 0` today (sgl-project#721's
17 kills predate this boot; `memory.peak` 101.98 GiB of 118.05). With no
enforcing cgroup anywhere, the physical machine IS the ceiling, which is what
MemTotal reports. A hand-carried 111.3 GiB constant would have been a third
floor with no enforcer behind it -- the rule this ticket already established,
applied to its own instruction. Not built.

THE REAL DEFECT IS ONE BUCKET OVER, AND IT IS THE sgl-project#695 CLASS AGAIN. Prior art
via the new index: commit c043235 measured that "CUDA pinned host memory is
accounted in the cgroup's `file` bucket, not `anon` ... the offload ledger
reported 20.78 + 14.44 + 14.44 = 49.66 GiB of pinned pool while `anon` sat
steady at 14.6 GiB." Confirmed live on this box: anon 2.12 GiB, file 19.06 GiB,
current 21.39 GiB -- the clamp charges ~2.4 GiB of a cgroup holding 21.4.
`honest_host_memory_bytes` charges anon + kernel + unreclaimable shmem and
NEVER charges `file`, correctly, because page cache is reclaimable. Pinned
bytes there are not. sgl-project#695 already fixed one member of this class (shmem hiding
in `file`); pinned host memory is the second and is still uncounted.

IT ALSO PUTS A DOCUMENTED PREMISE IN DOUBT, and the doubt is precise:
`pinned_host_budget.py:253` credits already-registered posts BACK to available
because "their bytes are therefore already missing from it". For a post whose
bytes land in `file`, they are NOT missing from it -- the clamp never
subtracted them -- so the credit-back would count them as free twice. The
2026-08-17 measurement quoted there is sound for the weight images it was taken
against; whether it holds for THIS pin depends on which bucket the pin's bytes
land in.

DELIBERATELY NOT FIXED HERE. That question is decidable only by watching `anon`
and `file` across an actual pin allocation, which is a boot. Changing admission
arithmetic on a shared path used by HiCache and kv-session-offload, on a guess
about which bucket, would be the "capping on a fabricated figure" the module
exists to prevent. So it is INSTRUMENTED instead -- the window script prints
the before/after pair and names the consequence -- and the arithmetic is left
alone until the boot answers it.

POSTEN 2 -- `chunk_blocks_quiescence` (phase_flip_runtime.py:144): SAME CLOCK
DIVERGENCE, and the determination is not a formality.

It is the same class as the retention gap: a consumer (the cutover) and a
writer (the chunk boundary that inserts into the tree) on different clocks.
Under STRICT the clocks are SYNCHRONISED -- the cutover waits for the prefill,
which is what "waiting for prefill to finish IS drain-and-flip" means in its
docstring -- and the residual is exactly the NON-STRICT case where they are
not.

THE DIFFERENCE THAT MATTERS, and why this is one root and not two: the chunk
case has a BOUNDED wait available (a prefill completes in finitely many
chunks), while a mid-decode resident does not. That is why STRICT can fix one
and nothing can fix the other by waiting. But the NON-STRICT chunk case cannot
be fixed by waiting either -- an unconditional block re-creates sgl-project#631 defect O,
the 32768-token prefill that ran in the slow layout and paid two cutovers for
nothing. So BOTH halves need the same missing capability: persisting PARTIAL
work at the seam. Neither is closable without it, and that capability is
`seam_copy_state` / `restore_seam_state` (schedule_batch.py:2054/:2089) --
sgl-project#875's active territory. Reported, not touched, per Posten 4. Unlike the
sgl-project#813/sgl-project#852/sgl-project#715 convergence I rejected last round, this one IS a shared root,
and I am saying so because the evidence supports it, not because it tidies.

POSTEN 3 -- `scripts/window_871a_verify.py`: one call, PASS/FAIL with numbers.

Decides all three open claims from a boot log plus the cgroup. Exit 0 all
passed, 1 a decided negative, 2 UNDECIDED -- and 2 is never a pass: "the
evidence was not there" is a different fact from "the claim is false", and it
sends the reader back to the boot. It boots nothing, claims no card, restores
no serving. It also prints the sgl-project#721 HOST-LEDGER pair (posts + memory.current /
peak / anon / file, before vs after) that Posten 1 needs.

IT SHIPPED A FALSE PASS AND I CAUGHT IT BEFORE THE WINDOW, which is the whole
argument for mock-smoking a window script. The first version summed `acked=`
over the WHOLE log and returned PASS on the W40 boot -- the very boot in which
all 21 fences reported `acked=0`. Seven lines there carry `acked=` from an
unrelated subsystem, three of them `acked=24`, so it credited 72
acknowledgements no fence ever made. A window script that reports a false PASS
is worse than none: it CLOSES an open claim. Now scoped to the fence's own
lines, with that exact log shape as a permanent self-test case.

The strongest desk check available is wired in: run against the real W40 log it
must reproduce that boot's known split -- tier armed PASS, store delivery FAIL,
exit 1 -- and it does.

TESTS (hermetic; no boot; no card touched).
CUDA_VISIBLE_DEVICES="" verified at the process and
`nvidia-smi --query-compute-apps` empty throughout; GPUs 0/0/0. Runner reported
its exclusions.
* the script's own --self-test decides SIX cases in the intended direction,
  both polarities, including the false-PASS regression.
* can-fail by mutation: un-scoping the acked regex reddens the real-boot
  reproduction and the self-test (2 red); restored green.
* A SECOND SELF-INFLICTED DEFECT FOUND AND FIXED: the test located the script
  by counting `dirname` calls, landed on `test/` instead of the repo root, and
  failed all six cases -- a green arm red for a reason unrelated to the thing
  under test. It now walks up to the root.
* partitioned tier-2 gate: 0 failing, 4421 passed (wide 3775 / narrow 292 /
  serial 354). Serial +6 over 348 is exactly the six tests added here.
  names=0 agrees with the summary on every lane.
* test/registered/unit/mem_cache: 2 failed / 1802 passed -- the known
  pre-existing test_acceptance_emitters_758 RefillTiming pair, unchanged.

POSTEN 4 -- boundary held. Nothing in schedule_batch.py, phase_flip_spill.py or
seam_kv_recover was read into or written. Both Posten 2's root and A's remedy
lead there; both are reported rather than resolved.

NOT ESTABLISHED. Which cgroup bucket the phase-flip pin's bytes land in -- the
question Posten 1 turns on -- needs the boot. Whether the admission ever
refuses on this box, likewise. And sgl-project#721's 17 oom_kills are from a previous
boot: today's counters are zero at every level, so nothing here re-measures
that incident, it only records that the enforcement it implies is absent.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 26, 2026
Measured here, three levels report three different `memory.current` values and
all three carry `memory.max = max`: root 23.5 GiB, system.slice 23.3 GiB,
system.slice/claude.service 22.3 GiB. sgl-project#721's "system.slice peak 111.3 GiB" was
taken at a different scope again. The script reads the container's ROOT view,
which is the right aggregate for a host-RAM question -- but which one it read
was inferable rather than stated, and I confused the two myself while rooting
this. The path now prints with the numbers.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 26, 2026
THE CLASS, CLOSED AT ITS ONE OWNER RATHER THAN AT ITS SYMPTOMS.

`turnkey/preflight.py:_real_mem_available` opened /proc/meminfo and returned
MemAvailable raw, with zero references to the sgl-project#407 owner. It feeds
`check_host_headroom`, which raises a HARD `REFUSE_HOST_HEADROOM` -- so this was
not a diagnostic reading a slightly wrong number, it was THE BOOT GATE deciding
whether an instance may start.

IT OVER-REPORTED TWICE OVER, and both halves were already written down in this
tree, one import away:

  * LXCFS SCOPE -- `honest_host_memory_bytes` states it: inside this container
    /proc/meminfo is synthesised, `MemAvailable` can EXCEED `MemTotal`
    (observed on this rig), and with `memory.max` unlimited it reports the
    HOST's figures on a box other containers are also spending.
  * CGROUP RESIDENT -- the owner additionally clamps by what this cgroup holds.
    Measured here: MemAvailable 113.19 GiB -> honest 112.95 GiB.

A gate that over-reports free RAM ADMITS a boot that should have been refused.
sgl-project#721 is that outcome on this box: a real container OOM, `oom_kill=17`.

BOTH COPIES, NOT ONE. `training/feasibility.py:read_meminfo` is the second
instance of the same reimplementation. It is only advisory -- nothing there
refuses a boot -- but a class with a known second instance does not get left
pending, because that is exactly how the first one survived long enough to
reach a gate. An EXPLICIT `path=` argument still reads that file directly:
callers that pass one are asking about a specific file, and silently ignoring
an argument would be worse than the reading it corrects.

THE SCOPE IS NOW IN THE MEASUREMENT, NOT IN A COMMENT. Measured on this box,
three cgroup levels report three different `memory.current` -- root 23.5,
system.slice 23.3, system.slice/claude.service 22.3 GiB -- and all three carry
`memory.max = max`. A refusal printing a bare "12.0 GiB" cannot be checked
against any of them, because the reader cannot tell which question was asked.
The refusal subject now carries the scope.

UNKNOWN STANDS THE GUARD DOWN, AND THE SENTINEL IS NEGATIVE SO THAT IS
REACHABLE. `MEM_AVAILABLE_UNKNOWN = -1`, never 0: read as a size, 0 is "less
than any want" and would refuse EVERY boot on a box whose cgroup files are
absent. The owner module states the rule and it applies here -- "a caller that
cannot get a number must say so, not invent one", and refusing a boot on a
fabricated figure is worse than not checking. The stand-down is logged with the
scope so it is never silent.

sgl-project#534 CARRIED AS A NAMED UNKNOWN, NOT GUESSED. CUDA pinned host memory is
accounted in the cgroup's `file` bucket, not `anon` -- commit c043235
measured "49.66 GiB of pinned pool while `anon` sat steady at 14.6 GiB", and it
is live on this box (anon 2.12, file 19.06, current 21.39 GiB). The owner
deliberately never charges `file` because page cache is reclaimable; pinned
bytes there are not. Whether that makes this gate over-report AGAIN, on top of
what is corrected here, is decidable only by watching anon/file across a real
pin allocation -- a boot. Guessing it would be the capping-on-a-fabricated-
figure this whole class is about, so it is a docstring unknown that
`scripts/window_871a_verify.py` answers on the next boot with pins.

TESTS (hermetic; no boot; no card touched). CUDA_VISIBLE_DEVICES="" verified at
the process, `nvidia-smi --query-compute-apps` empty throughout, cards 0/0/0.

* red-first: 6 of 9 failed against the unfixed pair, extracted names ==
  summary in both arms.
* CAN-FAIL IN THE DANGER DIRECTION, which is the one that matters here -- a fix
  that removes the over-reporting and loses the refusal is worse than the bug.
  Four mutants, each caught BY NAME, green restored after each:
    - gate loses its refusal          -> 2 red (incl. STILL_REFUSES)
    - unknown becomes a refusal       -> 1 red
    - scope dropped from the message  -> 1 red
    - sentinel made positive          -> 2 red
* A SECOND SELF-INFLICTED BLUNT ASSERTION FOUND AND FIXED: the probe test
  asserted `/proc/meminfo` absent from the function source, which caught the
  DOCSTRING explaining why reading it was wrong. It now strips the docstring
  and asserts on the code. Same mistake as #871a's floor-promise assertion --
  an assertion blunt enough to catch the explanation has to be deleted the
  first time someone documents the fix.
* whole `test/registered/unit/turnkey/`: 169 passed, 0 failed.
* partitioned tier-2 gate: wide 3775 / narrow 292 / serial 353 passed, 24
  exclusions reported by the runner, names=1 agrees with the summary on every
  lane. The single failure --
  test_pp_admission_wraparound_never_blocks::test_blocking_wraparound_wedges_the_ring
  -- is PRE-EXISTING and not mine: on the clean base 726f11e that module
  fails TWO tests, i.e. MORE than on this tree, and it touches nothing this
  commit changes.

NOT ESTABLISHED. Whether the `file`-bucket blindness makes this gate
over-report a second time -- boot-gated, named above. And this changes what the
preflight ADMITS on a box where the two readings differ; on this box the delta
is 0.24 GiB, so no currently-passing boot flips to refused here, but that is a
measurement of today's idle state, not a proof for a loaded one.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 26, 2026
THE QUESTION WAS "DOES sgl-project#721'S HOST-POSTEN-LEDGER EXIST", AND THE ANSWER IS (a)
WITH TWO NAMED HOLES -- NEITHER OF WHICH IS WHAT sgl-project#721 ASKED FOR.

IT EXISTS AND IT IS WIRED. `mem_cache/pinned_host_budget.py` is a named,
individually-priced posts ledger, and it IS a hard boot precondition: three
paths reach `joint_pinned_host_error` from `ServerArgs.__post_init__` and raise
`ValueError` --
  server_args.py:6937 -> _handle_kv_session_offload      -> :8173
  server_args.py:6962 -> _handle_phase_flip              -> :8416 -> :8961
  server_args.py:7019 -> _handle_hicache                 -> :8916 -> :9029
Four posts are priced there over CONFIGURED numbers (HiCache host tier, HiCache
staging host tier x ranks, phase-flip rotation staging ring x ranks,
kv-session-offload spill pool), and eight more register at runtime in the
workers (memory_pool_host x4, read_buffer_pool, weights_arena, and the two
halves of the phase-flip staging pin this branch added in db1b07e). So it is
not (b) "nobody calls it" and not (c) "an intention".

BUT sgl-project#721'S TWO PRESCRIPTIONS WERE BOTH DECLINED, AND BOTH DECLINES ARE RIGHT.
  * "16G floor against `free -g`" -- not implemented, and must not be:
    `free -g` is lxcfs-synthesised in this container. That was settled in
    #871b, which moved the boot gate onto the sgl-project#407 owner instead.
  * "sonst Posten schrumpfen" -- deliberately not implemented. The module's own
    charter: "The guard SUMS, it never caps. Nothing in this module shrinks a
    request. Silently capping a pinned pool moves the failure from a boot-time
    message that names both posts to a later allocation whose victim the OOM
    killer chooses." That is a better answer than the measure it declines, and
    it is the reason the ledger prices every post separately -- so an operator
    can shrink the right flag himself.

THE ONE REAL DEFECT, AND IT IS A COUNTER DESCRIBED AS AN ACTUATOR (sgl-project#464/sgl-project#578/
sgl-project#852). `check_and_register_pinned_post` carried this, about the largest
claimant in the system:

    "`_register_image_post` declares the post BEFORE `_alloc_host_image`
     allocates ... deliberately, so the registry refuses an over-commitment at
     the DECLARATION rather than discovering it at the allocation."

THE REGISTRY REFUSES NOTHING THERE. `register_pinned_post` is a bare dict write
with no comparison in it; `_register_image_post`'s own first line says "Never
raises"; and `grep -c check_and_register_pinned_post weights_arena.py` -> 0. So
the ~27 GiB of phase-flip host weight images are COUNTED, never ADMITTED.

THE BEHAVIOUR IS CORRECT AND STAYS. sgl-project#695 chose it at the call site and wrote
why: "Registered, not CHECKED: a new refusal path here could break a boot that
works today, and the diagnosis this is for is served by the number being
present, not by a veto." Registering early still makes those bytes visible to
every LATER admission, which is the half that matters. Only the comment was
wrong -- and a comment promising a veto that does not exist is worse than none,
because the next person sizing a pinned pool against this module would leave
exactly the headroom that post already spent.

WHY A TEST AND NOT JUST A RE-COMMENT. Prose cannot be regression-tested; the
CONTRACT can. The split is now pinned in both directions -- counting never
refuses however absurd the post, admitting refuses and names every post, a
refused post is not left in the registry, and weights_arena uses the counting
entry point only. If someone later wires the admitting one in there, that is a
real decision with a boot-refusal consequence and it surfaces here instead of
in a boot.

A RULE I PROVED ON MYSELF, THIRD INSTANCE IN ONE SESSION. The first version of
the prose test asserted the false sentence was ABSENT from the module -- and
failed against the FIXED file, because a correction has to QUOTE the claim it
corrects. Same shape as #871a's floor-promise assertion and #871b's
/proc/meminfo probe assertion. The general rule, now written into the test:
ABSENCE OF PROSE IS NOT TESTABLE where a correction must restate what it
corrects. Prose gets one positive marker; the behaviour tests carry the
contract.

THE WEIGHTS TRANSIENT, DECIDED WITH REASONS AS ASKED. It is a SPIKE, not a
standing post, and the existing treatment is already the right compromise: it
is registered at declaration (so concurrent posts see it), and taken back both
when the allocation raises (weights_arena.py:1044) and when the image is freed
(:1082). Booking it as a permanent resident would refuse too early; leaving it
invisible would be the sgl-project#721 outcome. What it is NOT is admitted -- and turning
that on is a behaviour change with a boot-refusal consequence that needs a
loaded box to justify, not a desk.

LOAD REMAINS UNMEASURED, AND THAT IS IN THE CODE, NOT ONLY HERE. #871b's 0.24
GiB delta between the raw and honest readings is an IDLE measurement. A
precondition gate bites under load. No load figure is asserted anywhere as a
threshold.

TESTS (hermetic; no boot; no card touched). CUDA_VISIBLE_DEVICES="" verified at
the process, `nvidia-smi --query-compute-apps` empty throughout, cards 0/0/0.
* red-first: 1 of 6 red against the uncorrected module, extracted == summary.
* can-fail in the danger direction: making the COUNTING entry point refuse
  (a counter grown into an actuator) reddens
  `test_counting_never_refuses_however_absurd_the_post`. Green restored.
* turnkey + this suite together: 175 passed, 0 failed.
* partitioned tier-2 gate: wide 3775 / narrow 292 / serial 353 passed, 24
  exclusions reported by the runner, names=1 agrees with the summary on every
  lane. The single failure --
  test_pp_admission_wraparound_never_blocks::test_blocking_wraparound_wedges_the_ring
  -- is PRE-EXISTING: on the clean base 726f11e that module fails TWO tests,
  i.e. MORE than here, and it touches nothing in this commit.
* test/registered/unit/mem_cache: 2 failed / 1808 passed. The two are the known
  test_acceptance_emitters_758 RefillTiming pair; +6 over 1802 is exactly this
  suite.

NOT ESTABLISHED. Whether the ~27 GiB image post SHOULD be admitted -- that needs
a box tight enough for the answer to differ, i.e. load. Whether the four
launcher posts plus eight runtime posts are the COMPLETE set of pinned
claimants: I enumerated every `PinnedHostPost(` and every register call in the
tree, but a pinned allocation that never posts at all is invisible to that
method by construction. And ZFS cache, named in sgl-project#721's list, is kernel-side and
cannot be a process post in this ledger at all.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 26, 2026
… my 18 commits: two claims withdrawn

The sweep I named and had not run. Every citation of a log string or a borrowed
measurement across all 18 commits on this branch, checked against THE source it
cites -- not against any source. 31 citations, four states.

BELEGT -- 27. Everything drawn from
/spinning/evidence-665-f1/boot_w40_857strict_0826_0516.log verifies literally in
that file: the three segment times, the 75 % worst-share, `save 4.342`,
`gpu-span d2h 0.000s / h2d 0.000s` (21x), `checksum 0.319`,
`gdn_state->refill_highwater` 0.2 and 7.0, `weights_refill->cutover` 113.5 and
972.1, the 498/268 aliasing counts, `REFILL pp_to_tp took 3.961 s for 8573.8
MiB`, `pp_attn_stage_ratio=[8, 4, 4]`, `disaggregation_mode='null'`,
`rank_tp_ratio=None`, `uneven_token_vector='29,19,16'`, and the W40 specimen
details I repeated from the briefing (05:20:50, the rid, the IndexError,
`SEAM RESTORE ATTEMPT`, `FLIP EXTENT PROBE`, `extent=13`,
`transfer_layer_num=32`). The log is present; source not missing.

NIE-GEDRUCKT, CLAIM ALSO FELL -- 1. "the boot line at :3228 prints
`get_total_num_kv_heads()`": zero occurrences. Already retracted in 19b8177;
the sentence it supported was false and the true one is restored.

NIE-GEDRUCKT, CLAIM SURVIVES -- 1. "24 s after health 200". The string
`health 200` never printed. The log says `"GET /health HTTP/1.1" 200 OK` at
05:20:26, and the crash is at 05:20:50: exactly 24 s. The claim is right to the
second; only my citation form was ungreppable, so anyone verifying it would have
found nothing. The two cases are kept apart because their consequences differ.

MISATTRIBUTED, AND MISREAD -- 1. I priced sgl-project#875's DO-NOT-BUILD verdict with
"43.9 KiB per crossing, 166 us enqueue, 1777-9201 us receive", attributed to
sgl-project#656. It is not in sgl-project#656. It is in 13c55d7 "[PP] sgl-project#201 slice 2: the stage
boundary across two rigs" -- CROSS-RIG, two nodes, a 40G line, a different model
(Qwen3.5-4B fp16), timing PP microbatch crossings and not an intra-node
collective. And its own text refuses my reading: "`recv` is BLOCKING, i.e. bubble
plus wire -- 9.2 ms on stage 1 is that stage waiting for stage 0, NOT the 40G
line". I used a pipeline bubble as transport latency, from the wrong ticket, for
the wrong link. WITHDRAWN, with no substitute: I have no measured local
collective figure.

QUELLE-FEHLT -- 1. "sgl-project#721's measured cgroup peak (111.3 of 118 GiB,
oom_kill=17)", used in sgl-project#877 and in sgl-project#878's headroom. `oom_kill=17` has NO in-tree
source, and the only `111.3` is `111.3%` in a benchmark table
(docs/dev/631/PROD_BRINGUP_BENCH.md) -- an unrelated percentage. It came from a
briefing and I repeated it as measured, twice. WITHDRAWN. This is the shape the
operator hit this morning with the retracted "1833/1833 records".

WHAT THE TWO WITHDRAWALS COST, stated rather than smoothed:
  * sgl-project#875's verdict loses its timing leg entirely. It now rests on two terms that
    need no transport number: the HEAD axis is LOSSY (PP 4 kv-heads per layer,
    TP 1), so PP->TP is not a remap until someone decides which heads survive
    and no such rule exists; and a new collective in the no-return region is the
    sgl-project#630 wedge shape, an unbounded risk. Point one alone is decisive. DO NOT
    BUILD stands, on better ground than it had.
  * sgl-project#878's headroom argument is re-grounded on a figure I took myself: this box
    reports 128711 MB total / 76971 MB free, so +96 MiB of pinned host image is
    negligible by four orders of magnitude, needing nobody's peak.
  * sgl-project#877's conclusion is untouched: N <= 72 rows of a per-LAYER temporary is
    kilobytes, and separately none of its six sites is constructed on this rig.

THE CLASS: a citation is evidence only for the claim it is attached to, in the
source it names. Three of the four defects here were true-sounding numbers from
the right neighbourhood -- a real measurement of a different link, a real
percentage read as gigabytes, a real code branch that never executes.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 31, 2026
…osts

THE OBJECTION THIS ANSWERS IS THIS MODULE'S OWN. `arm_process_trace` passes no
`max_entries` on purpose: sgl-project#602's capture came back exactly full at 100000,
holding its final 10.7 seconds, and a ring that wraps SILENTLY turns "this post
has no allocation event" into an untrue statement. That argument is about
SILENCE, not about caps, and it stops applying the moment the wrap is COUNTED.

A cap became necessary with sgl-project#1054's held-open window. The ring then grows for
the life of the process on a swapless box that has already host-OOM-killed
serving WITHOUT foreign load (sgl-project#1038: oom_kill 6->7 across one boot death), where
serving carries oom_score_adj=500 and is therefore the preferred victim -- so
the cgroup counter would name the victim and never the cause. A diagnostic boot
that kills the box measures nothing.

THE DROP COUNT IS DERIVED, NOT GUESSED, and this is the part that makes the cap
admissible. torch reports no drops, but
`memory_stats()["allocation.all.allocated"]` is a monotone count of every
allocation the process has made. Sampled at arm time and again at each dump, the
difference is how many events the ring was OFFERED; everything past the cap fell
out of it. `ring_loss_report()` prints that with every snapshot, beside the
artifact's path, so a reader opening the pickle six boots from now does not have
to reconstruct whether it wrapped. Three states, never two: a complete window, a
named number of dropped events, or UNKNOWN when torch's counter was unreadable
-- and UNKNOWN is never rendered as "none dropped", because an unmeasurable
loss is not an absent loss.

Scope kept honest in both directions:
* Uncapped remains the DEFAULT and is still called the better record. The cap is
  opt-in, for the one configuration that needs it.
* A malformed cap value falls back to UNCAPPED, never to a zero-entry ring --
  the failure mode of `int(raw)` on a typo would otherwise be a silently empty
  trace that looks like a boot which allocated nothing.
* The module docstring's "max_entries is therefore never capped here" is
  corrected in place rather than left to contradict the code.
* The ring is BYCATCH for this campaign anyway: the load-bearing artifacts are
  the snapshots at the corridor guard's first dip and in the crash handler,
  whose per-block stacks come from the live allocator's segments, not from the
  ring.

Launcher side (uncommitted, /spinning/gpu-arb): the diagnostic branch arms ONE
rank by default -- rank 0, the rank boot 24 died on -- rather than all three, so
one uncapped-by-default post does not become three; caps the ring at 3,000,000
entries; and runs `devtools/diag_host_preflight.sh` first, which prices the ring
against `free -g` and the sgl-project#721 16 GiB floor and REFUSES the launch rather than
discovering the shortfall by dying. Measured now: 109 GiB available, ring bound
1 GiB at that cap, 92 GiB headroom. The pre-flight states what it does NOT cover
-- it prices the ring only, not the serving posts and not the unmeasured
transient the boot exists to measure, so a PASS is not a promise that this boot
cannot host-OOM.

FUTURE CHECK: `devtools/check_1054_memory_truth.py` grew four assertions --
uncapped by default, cap read when set, malformed cap falls back to uncapped,
and UNKNOWN never rendered as zero drops. 15/15 green.

EVIDENCE TIER: DESK-PROVEN.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 4, 2026
…ee adversarial lenses found in the six cuts

WHAT WAS RED, and every finding was re-verified at the tree before it was
acted on. Two of the eleven reported were REFUTED and are named at the end.

1. sgl-project#1202 added `mbs` to the residency AUTHORITY and not to the retirer.
   `_live_reqs` walks `mbs`; `consume_retracted_from_live_universe` did not.
   That is the W30 asymmetry re-opened, and it is the W27 death: the release
   frees a request the authority then re-enumerates, and
   `resident_mamba_slots` (gdn_flip_mover.py:620) raises KvReshardError on a
   live request with no mamba slot -- inside the no-return region, where the
   only outcome is a dead rank. The mbs-only shape is ordinary, not exotic:
   under event_loop_pp a freshly planned prefill batch sits in `mbs[slot]`
   while `running_mbs[slot]` holds the decode set.
   RED: the property test "authority and retirer walk the same containers"
   reported authority-only = ['mbs']; the concrete test read
   "0 != 1 : the mbs route retired no reference".
   Pinned as a PROPERTY over the two walks, so the next route added cannot
   reintroduce it. The stale present-tense collateral at
   scheduler_pp_mixin.py:5121 ("_live_reqs does NOT enumerate mbs", dated
   2026-09-04) is rewritten as the dated fact it now is.

2. sgl-project#1203 A5 spent three ESCALATION budgets in the group's abandon currency.
   A5's premise is right and is kept: a rank-local counter that zeroes itself
   when this rank's own objection clears can never reach its limit while
   ranks take turns objecting. But `flip_host_headroom_verdict` and
   `flip_seam_budget_verdict` do not merely stop deferring at the limit --
   they return (allow=True, escalated=True), "PROCEEDING WITH EYES OPEN"
   under a failed sgl-project#721 host floor -- and the writeback arm proceeds with an
   incomplete sgl-project#703 fence. `_seam_abandons_in_a_row` is incremented on EVERY
   reduced-fit abandon or frame divergence, so three unrelated abandons
   disarmed all three guards and the next GENUINE shortfall escalated on its
   first firing, having deferred zero times. A bound may be widened to the
   group's currency; an escalation that permits the hazard may not.
   REPAIR: each guard is bounded by its own count again, and that count is
   refunded ONLY by a completed flip (beside the abandon book, whose own
   comment already states the rule) or by the guard's own escalation. The
   whole reset policy is `flip_defer_budget_after`, one pure function, so the
   three copies cannot drift again.
   RED: 8 of 10 A5 tests failed at the parent.
   Three instruments that named the wrong counter are corrected with it:
   "consecutive" becomes "in this abandon run", and the host-RAM defer is
   booked BEFORE its own log line instead of after.

3. sgl-project#1204's abstain discarded a term the rank had successfully read. Both
   reads shared one `try`, so a rank whose `backed_rows()` succeeded and whose
   `live_floor_rows()` then raised contributed `_UNBOUNDED_ROWS` in slot 0 --
   the MIN identity, i.e. "I am not the poorest". Slot 0's MIN becomes the
   level the peers cap to and the ceiling `book_deferred_grow` clamps to, so
   erasing a poor rank makes the group agree an id level it cannot map, which
   `backed_rows`' docstring calls a cudaErrorIllegalAddress that kills every
   rank. The hang the commit removed would have been traded for a wrong group
   answer -- the corrupting direction bought to avoid the refusing one.
   REPAIR: abstain PER SLOT. Each slot carries this rank's own measurement or
   that slot's neutral, unchanged for a wholly unreadable relief.
   RED: "30 != 1099511627776".

4. sgl-project#1205's `seam_refused` measured a population its label does not name --
   the sgl-project#1205 defect class, committed inside the sgl-project#1205 fix. The fence read
   `seam_refusals()` with NO direction, summing "load" refusals raised on the
   controller's own background threads while the fence runs, and printed the
   delta as "of refused_silently, the share the FLIP SEAM refused".
   REPAIR: `seam_refusals("write")`, and the log line and the field comment
   now say what it is: process-wide write-direction refusals during the fence,
   not a subset of `refused_silently` and not per-node (consume_gate refuses a
   whole queue and counts one).
   RED: "1 != 3" when the direction-less read is put back.

5. `assert_future_map_identity` was REACHED and CANNOT-FAIL. Measured: four
   combinations of (algo NONE|EAGLE) x (pool pp|tp), ZERO fires.
   `create_future_map` passes `self` as `spec_algo` and the scheduler's pool
   straight into `ConfidenceRelay`, so both stamp arms are construction
   invariants at a call site 57 lines after the rebuild; the two suite tests
   that are green hand-mutate a map no code path produces.
   REPAIR: the registry's obligation is "a probe proving the rebuild ran", so
   the probe now takes `previous` -- the map held BEFORE the rebuild -- and
   refuses when the rebuild did not replace it. A memoised build, a deleted
   assignment or a rebuild moved out of the cutover all land there and none of
   them are visible to the stamp arms. The tautology is pinned as a fact so
   the green is not read as coverage.

6. MambaRadixCache got the sgl-project#1201 assertion but not the sgl-project#1201 fix. It caches
   `req_to_token_pool` as a plain attribute and has no `bind_req_pool_owner`,
   so `_restamp_phase_handles`' hasattr guard skipped it and the handle stayed
   on the outgoing pool -- and `assert_req_pool_identity`, added to both
   classes, then raises ReqPoolRebindRefused at the END of every cutover.
   Reachable: registry.py hands back this class for a hybrid-SSM model WITHOUT
   hierarchical cache. The boot went from flipping wrongly to not flipping.
   REPAIR: the same owner property and bind hook UnifiedRadixCache got.

7. The sgl-project#1203 A1 group vote moved a non-pure function onto a new cadence.
   `seam_transport_premise_holds_locally` writes the edge-triggered
   `_seam_premise_refused_announced` latch and emits SEAM TRANSPORT REFUSED;
   the vote runs once per loop iteration while the consumer returns at
   `_active_phase != PHASE_TP` before it asks. The latch was therefore set in
   the PP phase, swallowing the gate's own first engagement in TP.
   REPAIR: `announce=False` for the vote; the gate's own read still announces.

Also: the anchor at overlap_utils.py:81-83 had drifted onto the line that
REFUTES its sentence -- scheduler.py:13174-13177 is now the overlap call
inside `if self.enable_overlap:`, while the non-overlap spec branch is the
sibling `elif not batch.spec_algorithm.is_none():` arm. The claim is true; the
number sent the next reader to the wrong branch. Named by branch, no number.

WHAT KILLED WHICH MUTANT (planted in place, restored by sha256):
  M1 retirer over-clears (frees a row a live req owns, the corrupting
     direction) -> test_an_mbs_only_resident_is_retired_by_the_retraction
  M2 host bound back on the group abandon book (disarms sgl-project#721)
     -> test_the_host_headroom_bound_reads_its_own_defer_count
  M3 a cleared vote refunds its own budget (the A5 wedge)
     -> test_this_rank_clearing_does_not_refund_the_budget
      + test_a_taking_turns_run_still_reaches_the_limit
  M4 refund moved back into the gate's cleared-vote branch
     -> test_a_completed_flip_returns_every_budget_beside_the_abandon_book
  M5 sgl-project#1204 discards a measured backing again (claims not-poorest, the
     fleet-death direction)
     -> test_a_readable_backing_reaches_the_group_min
  M6 MambaRadixCache loses the rebind hook
     -> test_both_classes_expose_the_rebind_hook
      + test_the_handle_follows_the_owner_and_falls_back_without_one
  M7 the seam stops handing the probe the outgoing map
     -> test_the_seam_hands_the_probe_the_outgoing_map
  M8 the A1 vote announces again
     -> test_the_vote_leaves_the_announcement_latch_alone
8 planted, 8 killed, 0 survived.

VERIFIED: 146 passed + 7 subtests over the six touched test files plus
test_1157_seam_witness.py and test_seam_census_double_905.py (the joint pin
over both sgl-project#1202 functions), hermetic, CUDA_VISIBLE_DEVICES="" with the serving
venv. Import smoke over all seven edited modules. ruff parity with the parent
on the touched files: 31 findings both sides, all pre-existing.

NOT VERIFIED: nothing on metal. No boot, no GPU claimed, no collective. The
sgl-project#1204 and A5 repairs are DESK-PROVEN only -- neither has run against a real
reduce or a real host-RAM shortfall.

REFUTED, and left untouched: (a) `assert_req_pool_identity`'s tree-cache arm
is not decorative -- it is a construction invariant for UnifiedRadixCache
BECAUSE the owner property is the fix there, and a live check for every other
holder class, which is exactly what caught finding 6; (b) `seam_refused` was
already read as a delta across the fence run (hicache_flip_writeback.py:700),
not as an absolute, so only its direction and its label were wrong.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 12, 2026
… instead of a constant

WHAT KILLED weg2xsn26b, measured (hostsample CSV + the /.lxc cgroup):
  * the kill was the GLOBAL host OOM killer, not a cgroup limit: memory.events
    `max 0 high 0`, oom_kill 1 -> 3, memory.max is `max`, and there is no
    separate serving cgroup -- ranks, front, sampler and the Claude CLIs all sit
    in /.lxc (sgl-project#721's nine `.lxc` kills, now confirmed for this boot);
  * the CURRENCY was right: shmem climbed 49.360 -> 60.008 GiB while anon FELL
    from its own peak, and `file - shmem` at the last sample was 0.008 GiB. The
    file-backed / checkpoint-mmap hypothesis (sgl-project#738) is refuted outright;
  * the guard at 93.0 never fired because ITS SERIES STOPPED: sampler gaps of
    19 / 25 / 18 s, last reading 82.28, memory.peak 95.86;
  * the last measured seconds climbed 50.157 -> 53.415 -> 55.847, i.e.
    2.4-3.3 GiB/s, covering the remaining 13.6 GiB in FOUR TO SIX SECONDS --
    entirely inside the 19 s blind window.
So the defect is CADENCE AND BLINDNESS, not the unit.

(1) `RateLatch`: fed on the caller's OWN cadence (200-500 ms), fires on
`nonreclaim + rate x lookahead` (5 s) against the reap mark, W98
Weg2HostRateLatched with `rate=` `projected=` `now=` `gaps_seen=` on the line.
Pure but for its clock: it returns a LINE, never tears anything down -- the
caller owns that, this owns the arithmetic and the words.

THE RATE IS THE WORST PAIR IN THE WINDOW, NOT THE ENDPOINT SLOPE, and that is
the whole latch: fitted end-to-end over 3 s, xsn26b's own ramp averages to
1.98 GiB/s, which projects 3.7 GiB BELOW the mark -- the new guard would have
watched the boot die exactly as the old one did. The worst pair of the same
window is 3.26 GiB/s and projects past it. Averaging smooths away the ONSET,
and the onset is the only part there is still time to act on. Same
MAX-over-samples rule the reap samples and the ring-era transient already use.
A FALLING reading projects to itself and never below: crediting a dip as future
headroom is how a guard talks itself out of firing.

BLINDNESS IS ITSELF A FINDING: a hole longer than 3 s emits its own
`WEG2-HOST RATE-GAP gap_s=` line. The guard that goes quiet must say so.

(2) `reap_model_line`: the mark DERIVED, the constant printed beside it as the
cross-check it has become. 95.90 is not a property of the box -- it is host RAM
minus whatever is outside this cgroup, and that term is real: ZFS ARC held
5.01 GiB (c_max 5.00) against this container's Cached 1.65 and the cgroup's
file 1.58. The ARC appears in NO container figure because it is charged to no
cgroup, so capping it moves the mark with nothing in our instruments changing.
AND THE MODEL REFUSES WHERE IT CANNOT SEPARATE: MemAvailable already counts
reclaimable pages the cgroup counts too, so on a quiet box the subtraction goes
negative (measured idle: 118.05 - 117.67 - 7.56 = -7.18). Clamping that to zero
would publish reap_mark = MemTotal = 118.05, i.e. 22 GiB above two recorded
kernel reaps and in the FUNDING direction. It prints `outside=OVERLAP` and
falls back to the constant instead.

Plus the PEAK BASELINE at launch, same shape as the cumulative oom_kill
baseline: `memory.peak` is a lifetime high-water mark with no reset anywhere in
this tree, and weg2xsn26b inherited ~95.1 GiB of it from weg2xsn25's death --
its record then read the inherited figure as its own peak. Baselined and
printed so the next record states a DELTA. No reset attempted: the file is
`nobody:nogroup` in this LXC and a failed write is a silent no-op.

Tests: 14 in the new file -- the real ramp latches on its ONSET sample (one
second of warning the level guard never had), the worst-pair-vs-average
contrast, flat and falling series never latch, latch-once, the three measured
gaps each reported, normal 200-500 ms jitter is not a gap, the mark derived
under load, OVERLAP on a quiet box, unreadable terms falling back by name, and
the ARC named. Launcher dry-run rc=0 with both new lines printed.
LOCAL: 145 passed / 0 failed across the touched weg2 suites, ruff clean.
No boot, no GPU, no /dev/shm.
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.

2 participants