Skip to content

enhance latency test - part 2 - #915

Merged
Ying1123 merged 1 commit into
sgl-project:mainfrom
etched-ai:benchy
Aug 4, 2024
Merged

Ying1123 merged 1 commit into
sgl-project:mainfrom
etched-ai:benchy

Conversation

@min-xu-et

@min-xu-et min-xu-et commented Aug 4, 2024 •

Copy link
Copy Markdown
Contributor

Pure refactoring the function. No logical change.

After this, it will be easier to make this into a loop to general multiple measurement points.


CI States

Latest PR Test (Base): ❌ Missing run-ci label -- add it to run CI tests.
Latest PR Test (Extra): ❌ Blocked -- run-ci is required first.

@Ying1123
Ying1123 merged commit afd411d into sgl-project:main Aug 4, 2024
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 26, 2026
…, so 411 declines have no verdict

Routing from the write-side agent (sgl-project#872) narrowed Posten 0 correctly: the store
is healthy, 24277 canonical pages live during the R7 window, and the historic
"store is empty" readings probed a path this boot does not use. So the 671
refused walks are a MATCH problem, not a content problem. The question that
follows immediately is the one nobody could answer: a walk that matches nothing
should fall through to an L3 prefetch, and prefetch was attempted on only 264
of 675 sampled walks.

THE OBVIOUS ANSWER IS WRONG, and the code says why. It is tempting to read the
411 as the same MambaComponent refusal declining twice -- one root, two numbers.
It is not:

  * The prefetch anchor IS mamba-gated, but by an aliasing the base contract
    does not describe. base_prefix_cache.py:201-210 separates `last_host_node`
    (the L3 prefetch anchor) from `best_match_node` (the validator-consensus L2
    anchor) -- two fields, two purposes. UnifiedRadixCache sets them equal under
    HiCache (unified_radix_cache.py:1443-1449). Deliberate and commented, but it
    contradicts the field's own documentation, and two fields that are
    documented different and implemented identical are a drift source (sgl-project#747's
    shape). Named, not changed here.
  * Even so, the refusal does NOT decline the prefetch. Total refusal leaves
    best_match_node at the root, and the caller admits the root on purpose:
    `locally_eligible = last_host_node.backuped or last_host_node is
    self.tree_cache.root_node` (scheduler.py:4933-4935). A cold request with no
    match is supposed to prefetch. The first term holds.
  * The second term (>= 256 new tokens) holds for agent prompts of thousands.

That leaves the rate limiter -- AND THERE THE EVIDENCE STOPS, which is the
actual finding. None of the three terms is counted or logged. The 411 declines
are silent. Nobody can attribute them from this boot, and no amount of
re-reading the log will change that.

    eligible = (locally_eligible
                and prefetch_length >= self.prefetch_threshold
                and not self.cache_controller.prefetch_rate_limited())

Three unrelated verdicts wearing one boolean, remedies in three different
files. The sgl-project#914 shape one module over: blame without a defect.

So this is an instrument and NOT a policy change. The three terms are the same
three, evaluated in the same order, with the same outcome; `eligible` is now
`reason is None`, one expression, so the predicate and its explanation cannot
drift apart the way sgl-project#747 records these very lineages drifting. The first
failing term is named rather than all of them -- a request can trip several,
and summing them would double-count exactly as
`refused_tokens_by_component` is documented to.

Not env-gated, unlike the sgl-project#904 match census. That one builds an object and
walks validators a second time, so it pays for itself only when armed. This is
one integer increment on a path that already builds a RadixKey and takes a host
lock -- and a counter you must remember to arm cannot answer "was it ever
tried", which is the whole question. `attempted` is counted alongside the
refusals so the denominator is local (sgl-project#873: a denominator reconstructed from
another log is how a narrowed candidate set reads as a decomposition), and an
unrecorded gate says "no observation" rather than a silent zero (sgl-project#829).

HYPOTHESIS, RECORDED AS ONE. prefetch_capacity_limit is `0.5 *
mem_pool_host.size` (cache_controller.py:729), and that size is not constant
across a phase flip: sgl-project#905 measured the two host tiers at 703472 rows (PP) and
30518 (TP), 23x apart, putting the TP-phase budget near 15259 tokens -- under
four prefetches of the 4096 this window actually completed, against 5
concurrent requests per flip. The order of magnitude fits 411/675, and I am
deliberately not fitting it exactly: the PP phase has ample budget, so the
number cannot come from there alone. If it holds, the same host-tier asymmetry
behind sgl-project#905's double-free is also starving the TP-phase prefetch budget -- one
defect, two effects, to be checked rather than assumed. The counter decides it
on the next boot instead of re-arguing it.

RED-FIRST, four mutants, each red, restored green (14 tests):
  revert to the shipped conjunction (no counter) ......... 4 failed
  eligible computed twice instead of derived from reason . 2 failed
  attempts not counted (denominator lost) ................ 2 failed
  no-observation reported as attempted=0 ................. 1 failed

ONE SELF-INFLICTED DEFECT, found and fixed in the same pass, recorded because
the form is evidently easy to commit. My first version of
test_the_rate_limit_check_is_still_called_at_most_once counted occurrences in
the function's RAW source and went red because a PRE-EXISTING comment at :2674
mentions `prefetch_rate_limited()`. That is the sgl-project#908 substring defect -- prose
used to reach a verdict about code -- in a test of mine, an hour after I
rejected the same form in someone else's patch. Comment lines are now stripped
before counting.

GATE test/registered/unit/mem_cache serial, CVD="": 3 failed, 1950 passed,
1658 skipped. Both axes agree (summary 3, ANSI-stripped extraction 3). Two are
test_acceptance_emitters_758::RefillTiming, baseline-proven pre-existing
earlier in this branch; the third is test_pool_invariant_double_owned_912, a
concurrently-developed test belonging to sgl-project#912 and untouched by this commit.
The sgl-project#904 census suite is green against this change (62 passed together with
the sgl-project#913/sgl-project#914/sgl-project#915 suites), which is the regression that matters: note_refused
gained an optional third argument and its existing callers must not care.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 26, 2026
…project#914 mamba refusal component, sgl-project#915 prefetch decline instrument, sgl-project#912 invariant checker available_size vs read_free_rows) into the flip train
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 27, 2026
…ke the verdict an observation

WINDOW-946FIX-0828 MEASURED A COMPENSATOR THAT WAS, FOR THE FIRST TIME IN THIS
FAMILY, PROVABLY ON THE DEFECT'S PATH AND STILL DID NOTHING. The sgl-project#946 escape
fired 8885 times (act_rid_hit) while PREFETCH RE-ISSUED stayed 0, cached>0
stayed 0, and the rid stayed frozen at told=8192. Root: `_prefetch_kvcache`
returned None on every one of its paths and the escape read that as success --
`prefetch(req); return "refetch"`.

ITS SUCCESS VALUE WAS NOT EVIDENCE THAT IT ACTED. Five earlier instances were
compensators placed off the path the failure takes; this one is a compensator
whose own report cannot distinguish acting from not acting.

SAME CLASS, NAMED SIBLINGS: sgl-project#872 (silent falsy paths), sgl-project#501 (the contract
promises what the code does not deliver), sgl-project#685 ("a silent precondition is
indistinguishable from dead code"), sgl-project#656/HANDOFF_678 4.0 (four early ABSTAIN
returns above the trace), sgl-project#767 (name the eaten branch).

THE VERDICT IS AN OBSERVATION, NOT A PROMISE. There are SIX silent exits
between the escape and registration -- two in `_prefetch_kvcache`, four inside
`prefetch_from_storage`. Enumerating them one at a time is how this family has
failed five times: a seventh added later would be silent again. So the verdict
is taken from the EFFECT -- did the operation appear in `ongoing_prefetch`
(unified_radix_cache.py:2996)? -- which covers every exit at once, including
ones nobody has written yet. Deep reasons come from the sgl-project#915 gate counters as a
per-call DELTA (anchor / too_short / rate_limited).

CONSEQUENCE, and it is where the old code leaked: the mark was cleared BEFORE
the attempt, so a DECLINED re-fetch spent it and the request never saw the
escape again -- invisible while every decline reported success. Now an OUTCOME
spends the mark, an attempt does not: issued clears it, a decline keeps it and
retries, bounded by REFETCH_DECLINE_CAP=3, then the terminator. Kein-Doppel-
Prefill unchanged: re-fetch preferred, told=0 the bounded last resort that
still names its discard.

sgl-project#915 WIRED AT LAST. `note_prefetch_gate` has recorded the decline reason on
every attempt since sgl-project#915 landed; `format_prefetch_gate` had ZERO callers, so it
was never reported -- PRESENT-BUT-UNWIRED for twelve days, printed by every boot
script and read as a note. Now logged on the census cadence.

CANDIDATE (iii) REFUTED BY MEASUREMENT, not by argument. The suspicion was the
sgl-project#915 host-tier capacity asymmetry (prefetch_capacity_limit = 0.5 *
mem_pool_host.size, cache_controller.py:841 -- NOT :729, a stale pointer in
sgl-project#915's own comment). The gate line is byte-identical across both stages of the
window (attempted=6, anchor/too_short/rate_limited ABSENT), so the escape never
reaches the gate at all: it returns at the ANCHOR exit above it. The escape's
precondition (`last_host_node.backuped`) is anti-correlated with the situation
the escape exists for.

TESTS, each module alone in a fresh process, 33-module blast radius derived from
the touched symbols, identical script both sides vs the 707f234 baseline:
  BEFORE  1017-11 = 1006 passed, 9 failed
  AFTER   1017 passed, 9 failed
Exactly ONE module differs: test_chunked_continuation_clamp_946.py 28 -> 39
(+11 new arms). Every other module matches its baseline EXACTLY, including
test_unified_radix_cache_unittest.py (642 passed / 860 skipped / 44 subtests,
both sides). The 9 failures are PRE-EXISTING at the pin and identical on both
sides: test_prefetch_progress_symmetry_580.py (7) and
test_collective_family_siblings_610.py (2). Extraction count probe: 9 == 9.

CAN-FAIL PROVEN IN BOTH DIRECTIONS, not asserted: a mutant returning "issued"
unconditionally is caught by the delivery arm; restoring the old consume-
before-attempt is caught by the mark arms. Four contract inversions recorded at
their sites -- stubs that returned None used to read as successful re-fetches,
which is the defect itself encoded as a test.

ruff (F401,F821,UP037) and ruff format clean. The two codespell hits in
scheduler.py are pre-existing at the pin.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 27, 2026
…at already had a canonical fix

WINDOW-946RF-0828 KILLED ALL THREE RANKS the first time a boot ever REACHED the
dead-premise terminator:

    RuntimeError: Boolean value of Tensor with more than one value is ambiguous
      scheduler_pp_mixin.py:1523
      discarded = len(getattr(req, "prefix_indices", None) or ())

THE LINE IS PRE-EXISTING (sgl-project#946) AND WAS UNREACHABLE UNTIL sgl-project#949. The escape
always took the silent `return "refetch"` above it, so the terminator had never
run in production. Making it deliverable is what exposed the bug -- the defect
and its discovery have the same cause, and that is the honest reading of the
window rather than "the fix broke it".

IT IS THE THIRD COPY OF A SPELLING THAT ALREADY HAD ONE CANONICAL DEFINITION.
`phase_flip_draft_bootstrap.prefix_len` exists precisely because this crash
already happened (W37-B, 2026-08-25, same message, same expression) and its
docstring opens "ONE DEFINITION, because two of them is what put the boot on the
floor". `scheduler.py:8108` carries the same warning as a comment: "sgl-project#796: NO
`or []` HERE. `prefix_indices` is a tensor". sgl-project#946 wrote a third spelling anyway.
So the fix USES the canonical helper rather than adding a fourth -- the
one-job-one-mover rule, applied to a two-line expression.

SIBLING SWEEP over the whole tree for the same `getattr(...) or ()/[]` shape on
a field that can be a tensor: only this site was live. `phase_flip_output_trace`
and `phase_flip_draft_bootstrap` touch `output_ids` / `origin_input_ids`, which
are lists; `schedule_batch.py:2856` uses a bare `len()`, which is correct.

TESTS: 3 arms, RED FIRST against the real crash (multi-element tensor, the 0-d
tensor where `len()` raises but `numel()` answers 1, and a ratchet asserting the
canonical helper is used rather than a fifth spelling). Can-fail proven by
reverting the fix: all 3 go red, the multi-element arm with the metal error
message verbatim. Module 39 -> 42.

One of my own arms was wrong first and is recorded: it grepped raw source for
`or ()` and went red on the FIX'S OWN COMMENT, which quotes the landmine to
explain it. An assertion about code must not be satisfiable or breakable by
prose -- the sgl-project#915 guard-comment lesson, applied to a test. It now strips
comments before asserting.

Blast radius re-run, each module alone in a fresh process, all matching baseline:
796 9/9, 797 31/31, 798 12/12, 791 11/11, 630 5/5.
ruff (F401,F821,UP037), ruff format and codespell clean on both touched files.
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 Sep 8, 2026
…t just redact

THE REGRESSION IS MINE AND THE COMMENT THAT WARNED ME WAS ONE LINE ABOVE THE
EDIT. Fix 3 replaced `**dataclasses.asdict(server_args)` with
`**server_args.redacted_dict()`, and `redacted_dict` built its dict with
`dict(vars(self))`. Those are not the same shape:

    vars(ServerArgs)   662 keys  -- every instance attribute
    asdict(ServerArgs) 661 keys  -- the DECLARED FIELDS only

The one extra is `model_config`, set in `__post_init__`. The line directly
above the one I changed says it outright:

    # server_args.model_config is not serializable but should be excluded by asdict.

So `/get_server_info` and `/server_info` began handing a live ModelConfig to the
encoder and 500'd:
    TypeError: 'torch.dtype' object is not iterable
    TypeError: vars() argument must have __dict__ attribute
Per boot: sb4 0, sb5b 0, sb5c 468 (masked, 40 requests), sb5d 7196. The front's
sgl-project#915 D-pool read rides that endpoint, so it took serving with it --
d_pool_read_failed 1130, leg2_failures 1116, 637 SERVED against 1142 NOT-SERVED
http=503 -- while group D was healthy the whole time.

THE COERCION WAS NEVER MINE TO DO. `asdict` leaves a `torch.dtype` a
`torch.dtype`; the CALLERS wrap the dict in `msgspec_to_builtins`, and that is
what renders it. Reproducing that coercion inside `redacted_dict` would be a
second encoder drifting from the first. The fix is to hand the callers exactly
the shape they had before -- `dataclasses.asdict`, with only the classified
VALUES replaced. One line, and the field set is now asdict's by construction.

SIBLINGS CHECKED. `/set_internal_state` already popped `model_config` and is
correct either way; the pop stays as free insurance and a test pins it. The
grpc `get_server_info` path uses the same helper and inherits the fix.

WHY FIX 3'S TESTS STAYED GREEN THROUGH ALL OF THIS -- the part worth keeping.
They asserted the redaction (`redacted_dict()["admin_api_key"] == REDACTED`)
and the call site (`"redacted_dict()" in source`). Both questions were about
the SECRET. Nobody asked whether the result still SERIALISED, so a suite of 15
green tests covered a route that could not answer a request. A test that
asserts a substitution happened is not a test that the thing still works.

RED-FIRST, through the REAL FastAPI route (TestClient, no GPU), with a
ServerArgs carrying both shapes that blew up on sb5d -- a declared `dtype`
field holding `torch.bfloat16` and a non-field `model_config`:
  * 200 not 500
  * admin key absent from the body, `admin_api_key == "<redacted>"`
  * `model_config` absent, exactly as asdict had it
  * `dtype` renders as `str(torch.bfloat16)`, as before
  * field-for-field parity with `dataclasses.fields(ServerArgs)`
Plus a CAN-FAIL GUARD that encodes every value the endpoint would return and
NAMES any unencodable one, so the next unserialisable field type reds a test
instead of 500ing a live route -- with a proof the guard itself can fail.

UNPROVEN: not on metal. The 500 is reproduced through TestClient against the
real app, not against a running D.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 9, 2026
…e: F3 made executable, the gap pinned

PART (C) IS NOT BUILT, AND THIS COMMIT SAYS WHY AT file:line INSTEAD OF
GUESSING. The briefing's premise -- "hang the deferral mark on the
group-agreed truncation outcome, the A12.2 path already exists" -- does not
survive reading the two ends of that path.

BLOCKER 1, the truncation never reaches the deferral. A read the pool CUT
still REGISTERS (unified_radix_cache.py:3614 non-symmetric, :3833 the sgl-project#1290
group trim), so `_prefetch_kvcache`'s effect-based verdict is `issued`,
byte-identical to a read that landed whole. `_apply_prefetch_deferral`
(scheduler.py:5990) is entered ONLY by `declined:rate_limited`. Measured on
the sb5h D log: `host_pool_truncated=37` per rank with no `rate_limited`, no
`deferred`, no `defer_refused` key present in the sgl-project#915 census at all.

BLOCKER 2, and it is the one that matters. Even a verdict that DID reach the
machine leaves no mark on group D: `_prefetch_deferral_refusal_reason()`
(scheduler.py:5932) returns `symmetric_vote` whenever the tree votes, and
group D votes -- 660 genuine `reason=vote_negative` lines on the sb5h D log,
a branch that exists only inside `if symmetric:`. The refusal's own stated
reason (scheduler.py:570-574) is the exact hazard the briefing forbids
creating: "a rank-divergent deferred set would enter that vote unevenly."

WHY "IT IS ONLY A VOTE, THE MIN REDUCE MAKES IT UNIFORM" DOES NOT RESCUE IT.
That argument holds for the X gate, which consumes
`_weg2_store_read_is_pending` through a MIN reduce and says so. It does not
hold for the OTHER consumer: `_retry_deferred_prefetches` (scheduler.py:6208)
re-enters `prefetch_from_storage` and therefore the sgl-project#580 participation
all_reduce (unified_radix_cache.py:3780). A mark set on a rank-local term
makes the RETRY SET rank-local and the ranks enter different collectives --
a desync crash, not a mispricing.

AND THE TERM IS RANK-LOCAL BY CONSTRUCTION. `group_len` is group-agreed (MIN
reduce plus the desync raise at :3796). The trim CONDITION is `group_len <
len(prefetch_key)`, and that second half derives from `_matched_len =
len(req.prefix_indices) + req.host_hit_length` (scheduler.py:5137),
documented rank-local at :5115-5117. Measured rank-unanimous 37/37 on sb5h --
empirically uniform, NOT uniform by construction, which is the standard the
briefing set.

WHAT SHIPS

* F3 RUNS NOW. Fix 2 wrote the acceptance and it was never executed as a
  pytest node (skipped remotely, no local pytest under a boot window), so its
  34/37 had only ever been computed by hand. The lines it reads are cut into
  fixtures/sb5h_D_truncation_terminals_1298.log (129 lines from 109,471) and
  the test reads the fixture everywhere. `test_f3_fixture_is_faithful`
  re-runs the identical walk over the full 23 MB log wherever the evidence
  tree exists and asserts both the truncated set AND the orphan set match, so
  the cut cannot drift into a friendlier subject. It also now filters
  `over_bound=true` as the acceptance specifies (111/111 on sb5h -- the
  filter removes nothing, and the denominator is stated rather than assumed)
  and asserts a population floor so a green cannot come from an empty walk.

* THE GAP IS PINNED WHERE THE HARNESS ALREADY LIVES
  (test_prefetch_deferral_1068.py, characterisation and labelled as such --
  these pass on the parent): an `issued` verdict is not the deferral's
  business, and the rate verdict is the only door in, enumerated over every
  other verdict `_prefetch_kvcache` can return. A future part (C) must add
  its door there, and this is what will notice. Blocker 2 is NOT duplicated
  -- `TestTheMarkDoesNotSurviveTheCutover` already pins it.

No new W-code (the census in test_weg2_wcode_uniqueness_1263.py is untouched
and none was needed). No source file changed: the fix shape is named in the
record, not half-built.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 9, 2026
…ect#1290 MIN payload, so a group-cut read defers instead of being priced whole

S1 the span rides the vote (unified_radix_cache.py): slots 3/4 carry this
rank's pre-vote span and its negation, so one MIN yields both ends. The
truncation condition group_len < span is then computed from two REDUCED
values and is identical on every rank. A span split is W55
Weg2PrefetchSpanSplit, a named STOP in the same class as the two raises
above it, placed BELOW the threshold return because an ineligible rank
enters the vote carrying an empty span.

Why a span and not a shortfall bit: group_len is a MIN, so ONE short rank
cuts every rank's registered span. The group fact is the OR, which
group_len < span already computes; MIN over a raw bit is the AND, i.e.
inverted, and redundant besides.

S2 published on the census the scheduler already samples per call, under a
key only the post-consensus group trim bumps -- the non-symmetric site's cut
is rank-local and must not reach the deferral.

S3 verdict issued:truncated_group (not a decline: the read registered).
X-DEFER now names its reason so a shortfall defer is never read as
rate_limited.

S4 the symmetric_vote refusal is SCOPED, not deleted: its own text says it is
about a rank-local mark entering the sgl-project#580 vote unevenly, which cannot
describe a mark built from MIN-reduced values. rate_limited keeps every
refusal it had; unpriced_timeout and symmetric_probe_failed still refuse
both. The retry evaluates the refusal per mark reason, so the retry set is
rank-identical by construction.

S5 every exit already existed: carrier-exceeds is the undeferrable exit
(its limit IS the carrier bound, 27466 on the boot's own sgl-project#915 line) taken on
the FIRST mark so it cannot loop; the repeat case re-defers under
_deferred_prefetch_bound_s and leaves by DEFER EXPIRED.

Ruff added 0 (the 2 findings are pre-existing at HEAD, same lines).
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 10, 2026
…e; strip the dead front flag

HALF 2 of 2. D already carried the CARRIER-EXCEEDS exemption and its comment
states the rule this obeys: "derived here rather than carried on the request
... no marker has to survive an HTTP hop to get here."

THE GAP the existing arm left. It fires on `uncached > carry` (the RAW host
pool size, 30518) -- which is why boot weg2sn5n served 50732 tokens DIRECT
(`prompt_tokens=50732 cached_tokens=0`, `freed_by=leg2_finished`, no W50). But
the front's bound is `carrier_max = 0.9 x pool` = 27466, so a band exists where
the front can prove NO carrier route while `uncached` is still BELOW `carry`
and the arm stays silent. Measured on weg2sn5t, every one 413'd:

    uncached=11116 total=32549 | 17493 / 47549 | 19741 / 52549
    carry=30518   carrier_max=27466

Each side was individually consistent; the two were jointly wrong.

FIX: a second arm, `verdict=exempt_no_carrier_route`, exempting when
`total_prompt > carrier_limit and uncached > x`. The limit is READ from
`cache_controller.prefetch_capacity_limit` -- the same live property the
`sgl-project#915 PREFETCH LIMIT` line prints and the launcher reads to set the front's
`--carrier-max-tokens` -- so the two sides agree BY CONSTRUCTION. Retyping the
0.9 here would be a second bookkeeping of the fraction, and the band between
two copies is exactly this defect again. `total_prompt` is the same term
`weg2_uncached_extent` calls `total`. Resolved defensively: no helper or no
host tier -> 0 -> the arm is DISABLED and the pre-sgl-project#1317 verdict stands, the
safe direction.

FRONT, same commit: the dead payload flag is STRIPPED. It could never have
worked -- `AnthropicMessagesRequest` and `ChatCompletionRequest` set no
`model_config`, so pydantic's `extra="ignore"` silently drops an undeclared
field, the hazard `anthropic/protocol.py:456` warns about in its own words
("SILENTLY DROPPED ... and nothing says so"). Making it work would have meant
declaring it across both protocol models plus four more hops through upstream
code, to carry information D can derive locally. The front's W68 line stays as
a COUNT, not a channel.

W68 Weg2ForcedDirectPrefill is used on BOTH sides deliberately: one code for
one deviation, countable end to end from a single census key, so the user can
veto it. The TTFT estimate stays on the front's line, which owns `r_D`; a
second copy of that rate on D would be the very thing these comments are about.

DEVIATION, NAMED: soft-rule exception to law 4 (operator 2026-09-10, `Regeln
WEICH, abweichen mit Grund`). Unchanged for everything the carrier can serve.

Tests: 8 D cases + 13 front cases. RED-first on D (3 band cases refused where
they must not, plus the absent helper); 53 pass with the pre-existing X-gate
suite. 4 mutants killed with an unmutated control: band -> 'none' again; cap
ignored; new arm disabled; gate always exempts (law 4 broken). ruff unchanged
against baseline.

FIFTH EDIT CAUGHT BY READING BACK: `total_prompt` was referenced twice and
defined nowhere (NameError inside the gate), and the first fix broke an
existing X-gate test whose stub binds only the methods the gate used to need.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 10, 2026
…ed read, and the anchor ask was never capped

Boot weg2sn6n confirmed #1317k's root and fix on metal -- `W=4096` wired, 39x
`got=4096` with `available=26422`, `available=0` on **0 of 138** `sgl-project#915` lines,
`reason=vote_negative` down from 26,985 to **90**, `closed_total` off zero for
the first time -- and then failed on four things that the same boot named.

(1) A DECLINE IS NOT A FINISHED READ. `still_owed = verdict ==
"issued:truncated_group"` closed the chain on `declined:anchor_pool_exhausted`
after window 1 of ~27, so the request was priced at the 4,096 tokens it
happened to hold out of 109,130 and there was never a window 2 for C1 to
release for. Three outcomes where there were two: a truncated group still owes
one; ANY `declined:*` leaves the window OWED (nothing landed and nothing was
decided -- a busy anchor pool is not a statement about the prompt); only a
whole `issued` closes the chain. Safe ONLY because the standstill exit exists:
a decline that recurs while nothing moves reaches
`_weg2_prefetch_stall_passes()` and is answered W88 by name, so the progress
witness is this change's precondition rather than an addition to it.

(2) THE ANCHOR ASK WAS NEVER CAPPED -- #1317k capped one of two pools. The KV
alloc is bounded, but the component loop still asked every component for
`len(prefetch_key)`, the WHOLE remaining prompt, because prefetch_key is
trimmed only AFTER the group vote. So a 109,128-token remainder asked the mamba
component for ~27 anchors against a 13-slot pool
(`host_anchor_avail=0 host_anchor_size=13` on 93 lines,
`anchor_pool_exhausted=19/29`) while the KV pool sat at `available=26422` --
two pools, one of them asked for 26x what the read could hold. Now built for
`len(host_indices)`, the span actually allocated: 2 anchors per window against
13 slots. PRE-EXISTING and only made binding by #1317k, which is the honest
framing -- before the cap the KV span was the whole pool and the component ask
was still 109,128.

(3) THE CENSUS GAP THE BOOT NAMED. #1317k promised "a bare WINDOW-RELEASE=0 is
now impossible" and it held only for a chain that DIES: the sn6n chain CLOSED,
took the success path, and printed no census anywhere. The vector now rides
EVERY re-issue line, close included, through one accessor that names its own
absence (`unnamed:no_census_on_this_tree`) rather than returning blank -- a
missing census and an all-zero census read the same to a grep.

(4) THE EXEMPTION DIED ON ITS OWN TERMS. `exempt_carrier_exceeds` fired 15x on
sn6n and prefilled the whole 109k prompt on D over X=11,101 **while the client
was refused anyway** -- worst of both, and the barrier that used to feed it was
already gone (`CARRIER-EXCEEDS after leg 1` = 0). Its own comment set the
sunset: "the exemption dies in the same commit as the wall, when the carrier
build gives this group an unbounded windowed store read." This is that commit.
Retired on the windowed path only; over-X now takes the ordinary named
W31/W50 exit, which `is_x_refusal` matches, so the front re-routes once (W35
bounds the second), while W88/W89 deliberately do NOT match and reach the
client.

THE GUARD IS A MODULE FUNCTION, THIRD FORM AND THE FIRST THAT WORKS. Direct
`self._weg2_windowed_store_read_active()` raised on five SimpleNamespace
harnesses (one gate run). A defensive METHOD failed identically, one level out,
because those harnesses bind a CURATED list of real methods and a NEW method is
missing from them exactly as the predicate was (a second gate run). A module
function resolves in globals, never on the receiver, so no stand-in can be
missing it -- immune by construction instead of by curation, which is what
sgl-project#1298's lesson actually demands.

Tests: 27 in test_weg2_window_liveness_1317k (both directions of (1): a decline
keeps the window owed AND only a whole read closes it AND the standstill exit
stays inside the owed arm), the anchor arithmetic (2 needed vs 13 held vs the
~27 that fired), the census's named absence, and the exemption's gating.
229 passed / 1 skipped across all twelve affected files, hermetic.
Confirming gate of the previous SHA came back GREEN at bab0c0f: 6349/49
against base 6334/49, NEW=0.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 10, 2026
…d two pins that outlived their premise

All eight NEW-only failures of the 7191379 gate, re-extracted per name WITH
messages from the artefact itself (`897d9968ac` and `06d3ed02ad` give the
identical eight; NEW-only 8, disappeared 0).

THE THREE LEDGER FAILURES ARE **TEXT, NOT PRICE** -- classified, not assumed,
which was the one thing that could have been the cycle's serious finding.
The ARM line had gained `S_D` BETWEEN `S` and `M`, and three suites match the
literal substring `ARM S=<s> M=<m>` (two by `in`, one by a list comprehension
that then indexes `[0]` and raised IndexError). `S_D` now goes AFTER `M`, so
the old reading is byte-identical and the new term is purely additive -- which
is also the honest shape: nothing about S or M changed, D simply gained its own
budget. All three pass with no pricing change.
And the pricing was never wrong: `charge_terms(s_gb_d=None)` is byte-identical
to the single-budget form (asserted), while the reclaimable term cannot book
pinned host pools as reclaimable by construction --
`cg_reclaimable_bytes` is `(file - shmem) + slab_reclaimable` and its own
docstring states "anon and unevictable are never subtracted: both are exactly
what the reaper kills to recover". cudaHostAlloc rows are unevictable, so the
12.86 GiB of rings is a CHARGE, never a reclaimable credit. No ledger defect.

THE GUARD IS OUT OF `main()`. `_derive_d_l2_budget` now carries the derivation
and BOTH refusals. `main()` has a pinned law of zero try/except (the single
funnel is `cli()`, sgl-project#1248) and a pinned inline-raise count; the first draft
broke both (`[<ast.Try>] != []` and `6 != 4`). This is the class sgl-project#1248 exists
to stop, and it cost a red gate.

TWO PINS OUTLIVED THEIR PREMISE AND ARE REWRITTEN, NOT DELETED. Both asserted
that `exempt_carrier_exceeds` must EXIST as D's cold-store fallback, with the
reason that an above-carrier prompt whose write-through had not landed would
otherwise have no route. That was true at a fixed 1 GB (30,518 rows, sgl-project#915
limit 27,466). With L2 derived from `--max-kv-per-request` the carrier is at
or above the cap, so there are exactly two cases and both have a route:
* ABOVE the cap -> the front refuses at admission. The cap is the law and 413
  is the answer, not a hole.
* BELOW the cap with an unlanded read -> the X-DEFER arm (sgl-project#1238 fix 7) holds
  it while the read is pending, so it is never priced at its whole extent.

THAT ROUTE IS VERIFIED RATHER THAN ASSERTED IN PROSE, which the operator's
ruling required before any pin was flipped: the new
`test_t9b2_a_pending_store_read_DEFERS_it_never_refuses_it` pins
`_weg2_store_read_is_pending` on BOTH pending shapes (an `ongoing_prefetch`
record and the sgl-project#1068 A12.2 mark) plus the negative case, so the defer arm
demonstrably covers the population the exemption used to. No replacement route
was built and no bypass was added.

AND THE FIFTH INSTANCE TODAY OF A SOURCE ASSERTION MATCHING PROSE, this one in
a test I wrote after naming the class four times: my own absence check tripped
on the `front.py` COMMENT that DOCUMENTS the deletion. The comment is right and
stays; the check now strips comments AND string literals via `tokenize` (a
deleted emitter's log text is a string literal, and keeping one would be the
same false positive wearing quotes) -- and it carries a PLANT-PROOF, because a
stripper that removes too much turns the suite into a rubber stamp: every name
is planted as real code and must be caught, while the same token in a comment
or docstring must not be.

One process note, since both seats got the count right and the names wrong in
different ways: the boot agent's reconciliation listed five of these as green
and quoted messages that belong to BASE failures. Re-extracting name+message
pairs from the junit settles it -- `extraktions-zaehlprobe` applied to a
handover, in both directions. Neither list was dishonest; a name recalled from
code reads exactly like a name read from a result.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
xsn31/7 fourth attempt got past W7/W10/W9 (all three skips confirmed
firing in the boot log) then hit W45 Weg2CarrierCensusRefused: group D's
log carries no 'sgl-project#915 PREFETCH LIMIT ... site=(init_hicache|hiradix_init)'
line, so carrier_census.py's census could not measure the KV carrier host
pool's budget. Its own COMPONENT string names the source directly:
"group D KV carrier host pool (cache_controller.mem_pool_host via
prefetch_budget.host_pool_anchor)" -- the fourth consequence of the same
root fact as the three fixes above: HiCacheController never builds under
hicache_disabled, so there is no host-staged carrier pool to overflow and
therefore nothing for the front's CARRIER-EXCEEDS route to protect
against in the first place.

Skipped (named line) under hicache_disabled: carrier_max_tokens falls
back to CONTEXT_LENGTH_TOKENS, which front.py's own routing reads as
"never take the CARRIER-EXCEEDS branch" (no accepted prompt exceeds the
model's own context length) -- correct for the zero-request Minimalform
regardless, and every non-Minimalform boot still runs the real census
untouched. carrier_census.py itself is unmodified; only launcher.py's
call site is gated, same as the three prior fixes.

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 15, 2026
… Prefetch-Verdikt TOLD auf der Request-Leitung

Befund (Boot xsn116, 2026-09-15 17:32:17, rid e10588ca, zweite Anfrage mit
identischem Praefix, D hatte ihn durchgeschrieben): jeder P-Rang registriert
seinen HiCache-Storage-Prefetch, keiner wartet darauf (sgl-project#973 PP0 PREFETCH WAIT
DISARMED / #969Z), der spaeter fertige Host-Treffer wird als sgl-project#1245
'undistributable' verworfen, damit die Raenge gleich bleiben -- P prefillt
einen im Store byte-vollstaendigen Praefix neu (STORE WITNESS state=unprobed
loaded=0, 'sgl-project#928 anchor REFUSING resume ... re-prefilling'). D leg 2 liest
denselben Store korrekt (cached_tokens=4314/4316), weil der TP-Pfad wartet
(Policy timeout) und MIN-reduziert.

Fix: der Traeger ist die Request-Leitung, die es schon gibt (recv_reqs wird
je Pass PP0->PP1->PP2 gepickelt weitergereicht; sgl-project#1268 fix 1c faehrt dort
schon Weg2IdleVoteReq). Protokoll je rid:
  1. Intake: PP0 registriert wie bisher und haelt; Folgestufe registriert
     NICHTS ('declined:weg2_held', neuer sgl-project#915-Partitionsterm).
  2. PP0 vor dem Forward: fuer jeden gehaltenen rid mit terminiertem
     Prefetch (check_prefetch_progress, kollektivfrei bei tp_size 1) wird
     die geladene Zahl ohne Pop gelesen, als told gespeichert und als
     Weg2StoreTold(rid, told) auf die Leitung gehaengt. PP0 admittet nur,
     was es auf die Leitung gelegt hat.
  3. Folgestufe nach dem Forward, vor dem Dispatch: nimmt die Objekte aus
     der Liste, speichert told, registriert den Prefetch fuer EXAKT told
     Token (_prefetch_kvcache(limit_tokens=told)) -- gleiche Seiten, gleiche
     Laenge, gleicher Store: Host-Baum und Load-Back-Extent sind inhaltlich
     uniform, keine Praefix-Truncation an einem Mamba-Anker noetig.
  4. Admission auf jedem Rang: ohne told -> Skip 'weg2_store_told_pending';
     mit told -> bounded Warten auf den eigenen Read, Pop, und benannte
     Verweigerung Weg2StoreToldMismatch bei own != told (Raenge nie uneins).
Der sgl-project#1245-Drop bleibt fuer die traegerlose Form ohne told; mit told ist der
Extent verteilbar. Arm nur bei pp_size>1, tp_size==1, Storage an, kein
Zeilentraeger; Kill-Switch SGLANG_WEG2_STORE_TOLD=0. pp_size<=1 (Gruppe D)
unveraendert.

Tests: test_weg2_store_told_1400.py 12 gruen; Mutant (Admission ohne Verdikt
+ Mismatch-Refusal aus) 3 rot. 16 Test-Dateien der beruehrten Symbole:
34 rot vor und nach der Aenderung identisch (Sockel: Doubles ohne ps /
_pp_post_send / _pp_send_admission_decision), 0 neu. Provider-Smoke 19/19.
Metall-Abnahme steht aus (arm_xsn117): zweite Anfrage gleicher Praefix ->
P leg 1 cached_tokens>0 und 0x 'sgl-project#928 anchor REFUSING'.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 15, 2026
…gl-project#915 line for anchor/too_short/rate_limited, PP0 intake verdict

Boot xsn117 (8d6be71): the told carrier works end to end (STORE-TOLD ARMED
on all three P ranks, PUBLISHED on PP0, ABSORBED on PP1/PP2), but PP0's own
prefetch registered nothing on both P requests (told=0, witness registered=0,
first request included, although the store holds the prompt from earlier
boots), and no line in the P log names why: `prefetch_from_storage`'s three
local terms (anchor / too_short / rate_limited) returned silently under
`not symmetric`, counted only in a census whose '[sgl-project#915 prefetch-gate]' line
never prints on group P (0 lines on P, 81 on D). Two instruments:
  * unified_radix_cache.prefetch_from_storage: the silent exit now emits the
    existing 'sgl-project#915 PREFETCH REFUSED reason=<term> ...' line (one per refused
    intake, like the other exits).
  * weg2_store_told.intake (PP0): 'sgl-project#1400 STORE-TOLD INTAKE rid verdict span
    matched' for the first 8 intakes and every 256th.
Tests: test_weg2_store_told_1400 + test_prefetch_gate_census_915: 40 passed.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 15, 2026
…tore read: partial hit = admit

Boot xsn121 (991e1ea), rid 06089842 (Q1 prefix + 6.8k appendix): the
told carrier now lands (PP0 told=4095, PP1 ABSORBED/WAITED, 'sgl-project#988 LOADBACK
prefix moved to 4095', no mismatch), but PP0 then went through the sgl-project#1324
'STORE READ INCOMPLETE delivered=4095 deliverable=11126 shortfall=7031'
arm (A12.2 store_prefix_short deferral), re-issued the 7031-token remainder
every pass ('sgl-project#1035 PREFETCH DROPPED host anchor pool exhausted avail=0
size=4', 'sgl-project#915 PREFETCH REFUSED alloc_failed_post_vote'), sat
'ADMISSION-WEDGE: 1 queued, 0 running' for 120 s and died on
'sgl-project#973 RING COMMIT TIMEOUT' -- while PP1 had admitted (extent 4095..8191).

The arm was built for the single-stage CONSUMER (group D, leg 2: P's
write-through still in flight, boot weg2sn6s). On a PP prefill group the
store has no producer to wait for -- the group itself prefills the rest --
so a read that terminated short is a partial hit to admit.
`_weg2_note_store_shortfall` returns None on `ps.pp_size > 1`; the
single-stage form is byte-identical (no ps on the harness doubles -> 1).
Tests: test_weg2_store_consistency_1324 (+1: PP group admits the partial
hit) + test_weg2_store_told_1400: 39 passed.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 16, 2026
…s satisfied, not mismatched

Boot xsn141 (01567d2, the first with the shared arena): PP0's device
tree had evicted part of a prefix its followers still held (PP0 carries
39 of 64 layers, so its 487k-token pool evicts first); PP0 read 686
tokens from the store to reach told=3615, the followers -- holding
>= 3616 locally -- had nothing to fetch: prefetch_length 0 < threshold,
"sgl-project#915 PREFETCH REFUSED reason=too_short", "sgl-project#1400 FOLLOWER REGISTRATION
DECLINED", and admission raised Weg2StoreToldMismatch on own_prefix=0.
P stopped (RAENGE-NIE-UNEINS), the front's W3 ended the boot.

_follower_register: a 'declined:too_short' verdict with local prefix
(prefix_indices + host_hit_length, the two terms _prefetch_kvcache
subtracts) >= told is "satisfied:local_prefix"; admission admits it at
told with no read to wait for. A follower holding LESS than told still
refuses by name.

Tests: test_weg2_store_told_1400 (+1: satisfied without a read; less
than told still raises): 16 passed.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 16, 2026
…to the card out of the store releases its host rows

Boot xsn152 (three ~80k prompts): two served from the store with
79126/79128 and 79806/79808 cached; the third got a 503 -- D's host pool
(109,863 slots) kept the first loaded 79k prefix (occupied 38,695) and
the next two 79k reads found available=0 ("sgl-project#915 PREFETCH REFUSED
reason=vote_negative ... host_pool_shortfall", W88 after 64 passes,
"W28 Weg2Leg2Unpriced").

The load-back ack (ack_load_queue drain) now releases the host rows of a
node marked l3_present (its pages came out of the store, sgl-project#1317 C2
writer 2) once it is on the card, under the same transit rule as the
write side: the arena is the L2, the host pool is the DMA transit for
both directions.

Tests: 937, 843, 1157, 869b, retired_966: 62 passed. Metal: xsn153.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 23, 2026
…in-Pool, sgl-project#1035 nennt 'arena_unbound' (fnFL2x25)

x25 (0f5294f): W45 weg, Flip D->P 14,6 s (x24-Wand weg), dann im P->D-Flip
ein Gloo-Abort 'op.preamble.length <= op.nbytes. 8 vs 4 ... collective
mismatch' -> W17. Davor auf D TP1/TP2: 'sgl-project#1035 PREFETCH DROPPED (host anchor
pool exhausted) ... host_anchor_avail=6 host_anchor_size=6' und
'sgl-project#915 PREFETCH REFUSED reason=alloc_failed_post_vote' -- die Worker stiegen
rang-lokal aus (D laeuft dcp_size=1, kein Token-Vektor, Teilnahme nicht
kollektiv), TP0 registrierte (DORMANT-HOLD, sgl-project#1455-Prefetch waehrend des
Flips) -> die naechsten Prefetch-Kollektive liefen auf ungleichen Mengen.

Wurzel: der 27B-Merge brachte den Arena-Anker-Pool (#1427b). x25 zeigt
'mambahost=ArenaMambaPoolHost' auf allen drei D-Raengen, x22 (ein Commit vor
dem Merge) 'MambaPoolHost'. Auf einem Form-A-Worker traegt der
FormAWorkerNullStorage weder Arena noch canonical_mamba_blob, ensure_bound
antwortet still False, build_hicache_transfers gibt [] -- mit 6 von 6 freien
Slots. Dritte Merge-Naht derselben Klasse (x23 Arena-KV bei page_size 64,
x24 Meta-Manifest, x25 Arena-Anker): ein Byte-loser Worker trifft einen
Mechanismus, der jedem Rang Bytes unterstellt.

- memory_pool_host.mamba_host_pool_cls(plain_cls): EIN Chooser fuer beide
  Konstruktionsstellen (Assembler, Phase-Flip-Rebind); Arena nur, wenn der
  Knopf an ist UND der Rang kein Form-A-Worker ist; die Arena-Klasse wird
  erst beim Wahl-Treffer importiert; der Aufrufer reicht seinen eigenen
  MambaPoolHost-Namen durch (die hermetischen Fixtures patchen ihn).
- sgl-project#1035 nennt die Ursache: 'exhausted' vs 'arena_unbound', plus Pool-Klasse.

Tests: test_mamba_host_pool_cls_form_a_x25 (3; Worker -> Plain rot auf
0f5294f), mem_cache 41 rot = Basis, weg2-Liste 18 = Basis,
test_unified_radix_cache_unittest 645/860 = HEAD.
Arm: NEEDLE_N Default 500 (~10k) statt 12800 (259k), SGLANG_LOAD_PROFILE=1
per Default auf P und D (Nutzer-Order 23.09.).
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 23, 2026
Boot fnFL2x61 (erster Boot der seitenfähigen Arena-Form, 550734d) wurde am
READY-Gate verweigert:

  W45 Weg2CarrierCensusRefused (disagree): the 3 TP ranks do not agree on
  'now': '157248' on TP [0]; '3686' on TP [1, 2]

Gruppe D ist unter Form A ein Attention-Host (TP0, 5090) und zwei Experten-
Worker (TP1/TP2: kein Attention-Layer, Null-Storage). TP0 meldet in sgl-project#915 die
Arena-Kapazität (0,9 x 174720 = 157248), die Worker synchronisieren ihren
Plain-Pool auf TP0s Pool-`size` (base.py "Sync fixed-size HiCache host token
capacity ... to 4069" = der 4096-Zeilen-Staging-Ring der Arena-Form) und
melden 0,9 x 4096. In x59 stimmten alle drei nur, weil TP0s Pool damals der
4-GB-Plain-Pool war (325568 Zeilen), dessen Größe die Worker übernahmen.

Ein Worker hält keinen Träger; seine Zahl ist keine Grenze für etwas, das die
Front routet. Er enthält sich jetzt, wie im Prefetch-Vote (Task sgl-project#89):
- carrier_census.form_a_worker_ranks(log): Ränge mit der Marker-Zeile
  "this rank is a Form A expert worker (no attention layer) -- no page window"
  (dieselbe, die W7/W10 zählt).
- census(..., abstain_ranks=...): Zeilen der Enthaltenden werden weder gezählt
  noch verglichen; Population = erwartete Ränge minus Enthaltende; leere
  Population = missing (kein Träger); CarrierCensus.abstained + Detail-Zusatz.
- Launcher übergibt die Worker-Ränge und protokolliert sie in CARRIER BOUND.

Test test_weg2_carrier_census_form_a_abstain_x61 (6): Marker-Lesung, das
x61-Log als aufgezeichnete Verweigerung ohne Abstention, mit Abstention
bound=157248 aus TP0 allein, alle enthalten sich = missing, fehlender Host
bleibt missing, Log ohne Marker enthält niemanden. 1246/1317d/1294: 85 passed.

Host-RAM x61 (hostram_fnFL2x61.log, Stand bei READY, KEIN Betriebswert --
der Boot fuhr weder Request noch Flip): nonreclaim 71,8 GiB; Pools P
0,05/0,02/0,01 GB, D TP0 0,05 GB statt 4,0/1,71/0,57+1,14 und 4,0 GB.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 24, 2026
…l below the threshold, and a standstill within X recomputes instead of W88 503

Metal weg2xsn437 (P_TRIM=1): two leg-2 requests answered 503 (front W28).
  (a) rid weg2-6-2, N=4316: D delivered=4095 deliverable=4314 shortfall=219;
      the re-read refused 'sgl-project#915 PREFETCH REFUSED reason=vote_negative
      need=219 threshold=256' at 21:09:30 and 21:09:50; W88; 503 at 21:10:38.
  (b) rid weg2-20-37, N=2050: delivered=2047 deliverable=2048 shortfall=1;
      'sgl-project#1456 HOLD-REFETCH ... verdict=declined:too_short'; after the wake
      'W88 Weg2StoreLoadNotProgressing ... no_progress_passes=64 -- terminal,
      answered 503'.

CAUSE, AT THE CODE. The trimmed chain was published WHOLE: P's own lines
'WEG2 END-ANCHOR ... units=4314/4314 ok=True trim=1' and 'units=2048/2048',
'sgl-project#1442 HANDOFF ids=4316 page_keys=4314' = D's 'HANDOFF-KEYS USE pages=4314
covered=4314' -- the bigram units match D's deliverable exactly; no unit is
short. What moved is WHEN the last node goes out: without the trim the N-1
node leaves through the chunk publish (_weg2_publish_at_chunk) one forward
before the finish; trimmed, it is the finish insert and leaves through the
retain publish ('RETAIN-PUBLISH ... issued: 1, pending: 1') at the moment P
answers leg 1. D's first read therefore landed before it: 4095 = the chunk-
published prefix up to the 4096 interval anchor (weg2_anchor_step
'interval'), 2047 = the chunk-published prefix up to the boundary 2048,
which is the trimmed request's own N'-1 'end' step. A race the sgl-project#1324
deferral exists for -- and the deferral could not finish it: the owed
re-read of a tail below prefetch_threshold (256) is refused at the gate
(prefetch_from_storage: 'elif prefetch_length < self.prefetch_threshold:
reason = "too_short"', the group vote then negative), so the chain can only
stand still, and _apply_group_shortfall_deferral's standstill exit on the
windowed path answers W88 503 whatever the remainder -- 221 and 3 tokens
here, against X=4096.

REPAIR (one switch, SGLANG_WEG2_STORE_SHORT_TAIL, default on; 0 = both old
forms for A/B):
  * prefetch_from_storage(min_tokens=...): the smallest read worth issuing;
    None = prefetch_threshold (unchanged). _prefetch_kvcache passes 1 when the
    request carries the short-read stamp (_weg2_store_delivered, written by
    _weg2_note_store_shortfall from the group-synced record, so every rank
    of the group asks the same and the sgl-project#580 vote stays uniform); the call is
    byte-identical otherwise.
  * _weg2_store_short_recompute: a STORE-SHORT read that stands still with
    a remainder (prompt - materialised prefix) within X is admitted -- the
    mark cleared, 'expired', the X gate prices it with the group's match
    and D prefills it (store-short must recompute). Over X it stays the
    named W88: the user's veto against a prefill over X is untouched (the
    sn6s form still ends in W88).
Both helpers are module functions (the file's own rule: stand-ins bind a
curated method list). No P change: the anchor needs no sync on P's path
('Anker bremsen nie'); D now completes the read as soon as P's write lands
(the hold refetch every 2 s during a flip, the retry every pass awake).
Side note, not changed: for a trimmed prompt whose last chunk boundary is
N'-1 (N=2050) G's 'end' step donates one extra anchor there -- harmless.

Tests (hermetic, CPU, each file alone through test27b.sh / incg cap):
  test/registered/unit/weg2/test_weg2_store_short_tail_xsn437.py  11 passed
    -- the two metal forms: P on a real tree (512 chunks, interval 4096,
    bigram): the trimmed chain = D's deliverable (4314, 2048; and 2047 for
    N=2049), the prefix published before the finish = the metal first reads
    (4095, 2047), short by 219 and 1; D: the completion read of 219 and of 1
    token is issued (a fresh one keeps the threshold); a standstill with
    remainder 221 / 3 within X=4096 is recomputed, not W88; sn6s over X stays
    W88; the switch off restores W88.
    RED first on 67b6352 (git-archive, PYTHONPATH): 6 failed -- the
    completion read (219, 1), the stamp helper, the call wiring, the
    standstills 221 and 3 answered 'failed' (W88); the P-side and over-X /
    switch-off cases pass there too (they pin what did not change).
    Mutants, each KILLED: the completion read keeps the threshold; the tree
    ignores min_tokens; the standstill never recomputes; the standstill
    recomputes over X.
  affected: store_consistency_1324 25, prefetch_deferral_1068 42,
    prefetch_gate_census_915 28 (its source pin now names `_min_len`, which
    is prefetch_threshold unless min_tokens is given), participation_desync
    _580 8, hold_refetch_1456 5, hold_refetch_uniform_xsn296 3,
    revoke_reissue_1479 10, prefetch_reissue_retire_939 16,
    leg2_store_probe_1290 9, store_told_1400 19, dormant_hold_1445 9,
    p_trim_end_anchor 18 -- passed. Red on 67b6352 already, identically:
    prefetch_progress_symmetry_580 (8, stale fakes), wcode_uniqueness_1263
    (3, W68 collision). unified_radix_cache_unittest: the full file is
    SIGKILLed by the 3 GiB cap; its prefetch subset (-k prefetch) is equal on
    both trees (1 passed, 57 skipped).
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 27, 2026
…of it -- a follower that already holds the told span is satisfied locally, not "cannot load what PP0 admitted"

NF rc12u (dkrnfh91dprtkbar1dauer09271905, dbeb9ff, TK+PACED+TW), weg2-4-7 19:11:06, PP1 and PP2:
"sgl-project#1442 HANDOFF-KEYS REG matched=39232 new=1 span=0", "sgl-project#915 PREFETCH REFUSED reason=too_short ... need=0",
"sgl-project#1400 FOLLOWER REGISTRATION DECLINED told=39232 verdict=declined:too_short: this rank cannot load what PP0
admitted" -- 6x in the boot (weg2-4-7, 9-1x, 12-1x), each time on a rank that HELD the told span. The legs
still hit because those tolds were twins ("#TW TWIN-TOLD head=39232 span=0"), whose admission adds the
registered head; 27B 09271525: 24 DECLINED, 0 "FOLLOWER SATISFIED LOCALLY" ever.

Root: weg2_store_told._local_prefix computed len(getattr(req, "prefix_indices", []) or []) -- bool() of
the live match's torch tensor raises for more than one element (RuntimeError, verified), and the except
turned it into 0 on every real request. So the xsn141/xsn155 "satisfied locally" branch of
_follower_register was dead on metal: a plain (non-twin) told on the shape it exists for -- PP0 re-read what
its followers still hold -- would reach admission with own_prefix 0 and raise the named STORE-TOLD
MISMATCH (a rank exit under load). Fix: len() of the object itself, None -> 0; the same idiom in
weight_updater's WEG2-PRELOAD log line (inside the per-request try: it skipped the request) likewise.

Tests: test_weg2_store_told_local_prefix_sl_0927.py 4 (tensor, tensor+host, None and absent fields; the
rc12u shape: holding told=39232 -> satisfied:local_prefix, limit told+1 unchanged; short of told still
declines; admission admits a satisfied rid at told without waiting). 3 of 4 red on the base, green here.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 27, 2026
…ol ist nie die Schranke der Gruppe -- seine Zeilen wachsen als 0-B-Platzhalter statt abzulehnen; sgl-project#915 nennt den kürzenden Rang, W88 min_rank

rc12t: 8 W88 in 11 min. Befund Fork A, tmp/r989/befund_w88_host_pool.md.
- Die KV-Host-Pools der Expert-Worker sind byteless: 0 kv-heads, 0 B je Zeile.
- Unter R12 behalten sie jede Zeile bis zum Reset (SHADOW-OWN-EVICT-REFUSED).
- Die synchronisierten 353573 Zeilen liefen voll, während TP0s Arena die Spanne noch hatte.
- Im sgl-project#580-Vote (prefetch_participation_vote) enthalten sich die Worker seit H99 nur bei der Spanne. Ihre Länge in Slot 2 ist ihr allokiertes Stück, und das setzte das Gruppen-MIN.
- Folge: sgl-project#915 PREFETCH TRUNCATED need=54336 got=49216 auf allen Rängen, 64 Requeues, W88 arm=host_pool_shortfall.

Fix, Form-A-only:
- HostKVCache.alloc: ein byteless Pool (JG, element 0 B) wächst um ganze Seiten statt None zu liefern (_grow_byteless). Die Buchhaltung (mem_state, slot_used, free_slots, page_num) wächst mit.
- MHATokenToKVPoolHost._regrow_byteless_buffer formt den 0-Byte-kv_buffer auf die neue Id-Zahl um, damit kein Index des gewachsenen Bereichs je außerhalb liegt. Nichts wird gepinnt oder kopiert.
- clear() (Reset) stellt die synchronisierte Größe wieder her.
- Kein größerer Pool, keine Reserve: Die Zeile trägt 0 Byte, sie ist ein Platzhalter.
- Folge: Die Längenstimme eines Workers ist wieder seine Spanne. Die Gruppe hat den Platz, den TP0 hat.
- Ein Pool mit Bytes (TP0, 27B, jede klassische Form) lehnt unverändert ab. Test: nicht-byteless → None, Größe gleich.

Abweichung von der Order ("Worker enthalten sich auch in Slot 2"), mit main abgestimmt:
- Die Längenstimme des Workers bleibt, denn sie ist eine echte Schranke, wenn der Schlüssel des Workers kürzer ist. Das ist der H99-Fall: Der Schatten-Anker des Workers liegt TIEFER als der Anker des Hosts.
- Ein Rang kann nicht mehr Tokens registrieren, als sein Schlüssel hat. Mit einer Enthaltung in Slot 2 wäre group_len > local_len auf dem Worker, und der Desync-Stopp würde feuern.
- Das Wachstum entfernt genau die falsche Schranke, die Kapazität eines 0-B-Pools, und lässt die richtige stehen, die Länge des Schlüssels.

Instrument (3):
- Im gruppeneinheitlichen Trim-Zweig (group_len < span_lo, beides reduzierte Werte) läuft EIN MIN: "mein Rang, falls meine eigene Länge die Gruppenlänge ist". Es nennt den kürzenden Rang.
- sgl-project#915 PREFETCH TRUNCATED trägt cut_rank= und local=. Die Zeile der Einzel-Rang-Kürzung trägt cut_rank=local.
- prefetch_cut_terms(rid) hält den letzten Trim je rid (Deckel 4096).
- Die W88-Zeile (_weg2_store_load_terminal) trägt min_rank=R group_len=G need=N, oder min_rank=-.
- sgl-project#249 Punkt 2 (STATE-Freigabe an die Worker) steckt in sgl-project#248 (release_loaded_host).

Tests test_forma_byteless_len_vote_249 (7), durch die echte prefetch_from_storage auf drei simulierten Rängen (H99-Harness) mit echter MHATokenToKVPoolHost-Buchhaltung:
- rc12t-Form (Worker-Pools voll, available=0, TP0 hat die Spanne): alle Ränge registrieren die volle Spanne.
- Worker halb voll: keine Kürzung.
- TP0 knapp: die Kürzung bleibt, cut_rank=0 in allen drei sgl-project#915-Zeilen, min_rank=0.
- H99-Fall (Worker tiefer): die Gruppe kürzt einheitlich auf den Worker-Schlüssel, min_rank=1, kein Desync.
- Pool wächst um Seiten, clear() stellt her.
- Pool mit Bytes unverändert.
- W88 nennt min_rank.
Rot auf e39b37d: 6 von 7. Der Pool mit Bytes ist auf beiden Seiten grün, das ist der Unverändert-Beweis.

(cherry picked from commit 79435c635d686f95046e1be90c217a699a94cd89)
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 27, 2026
…cht läuft, hält über den Flip keine Arena-Referenz -- Ordnung statt Pin, L3-Kopie im Hintergrund, Referenz erst beim Wake, Host-Zeilen nach dem Load-back zurück (Worker-Spiegel per R12 STATE)

rc12s dkrnfh91dprbar1dauer09271719, D-TP0 17:32:40 (tmp/r989/befund_248_park_l2_pinnt.md): ARENA-REF-HOLDERS n=7 tree=1231 tree_in_use=3982 sum=5213 own_held=5213 -- ein SCHLAFENDES D hielt 5213 von 5461 KV-Arena-Slots per Referenz: die Schlaf-Vorabholung (sgl-project#1443/sgl-project#1455) von 2 Geparkten (1292 Seiten) und 3 im Schlaf eingetroffenen Wartenden (3921). P fand "no free slot" (17:32:21-58, 17:35:18-25), BACKUP-REFUSED arena_claim, parent_unbacked-Kaskade, 4 leere 200 (W50 re-route impossible). Einen Weg "gehalten -> L3 -> frei" gab es nicht (Arena-Eviction nimmt nur Unreferenzierte, der Claim gibt ohne I/O frei, L3 hielt 96 MiB). Nach dem Wake hielt D die geladenen Spannen weiter als tree=5213 bis zum nächsten Reset; auf den Form-A-Workern wuchs derselbe Bestand als byteless Spiegelzeilen im festen 353573-Zeilen-Pool bis zum Reset (sgl-project#249: R12 SHADOW-OWN-EVICT-REFUSED n=1->592, Vote-MIN -> sgl-project#915 TRUNCATED -> W88).

Fix (Form, keine Reserve, keine größere Arena; Schalter SGLANG_WEG2_ENABLE_PARK_L3, Default an, nur Gruppe D; aus = alter Pfad):
1. Referenz erst beim Wake (weg2.park_l3): der Dormant-Hold-Intake schlägt nur nach (P-Kette auf den Request), keine Store-Lesung, keine Referenz, kein Pin im Schlaf. Die Lesung läuft bei sgl-project#1443 DORMANT-RELEASE in Hold-Reihenfolge auf jedem Rang (issue_deferred_reads), das sgl-project#1471-Settle gibt frei, wenn komplett.
2. Park als Ordnung: park_running markiert jeden Geparkten (handoff_pending Rolle "park", Kette in der Marke, mark_park); keep_for liest pending + park, Parks zuerst.
3. L3-Kopie im Hintergrund: Thread weg2-park-demote (D, attn-Rang 0, nie Scheduler-Thread) kopiert gehaltene Seiten per HiCacheFile.arena_copy_to_disk nach L3 OHNE Freigabe -- über den bestehenden Evictor (reserve/commit/abort, 150-GB-Kappe), kein eigener Größen-, Sweep- oder Verzeichnispfad.
4. Claim in drei Stufen, weiter ohne I/O (arena_pool._evict_for_claim): (i) unreferenziert+ungehalten, (ii) gehalten MIT L3-Kopie (frei, arena_fill_from_disk liest zurück), (iii) gehalten ohne Kopie -> benannt HANDOFF-LOST / PARK-LOST. sgl-project#1427 ARENA-DROP nennt stages=i:,ii:,iii:.
5. Nach dem Load-back gibt TP0 die KV-Host-Zeilen des geladenen Pfads zurück (park_l3.release_loaded_host aus loading_check; Seite bleibt COMPLETE in der Arena, Mamba-Anker bleibt), mit R12 STATE je Knoten -> die Worker-Spiegelzeilen gehen beim nächsten Broadcast mit. form_a_host_shadow._reconcile lässt dabei den Anker stehen, wenn TP0 ihn hält (vorher riss ein KV-Verdikt den Anker mit -> SHADOW-SHORT im nächsten Zyklus).
6. PA-Naht (TEILPARKEN_notiz_0927.md §5): handoff_pending.keep_role(rid, "park", page_range=(a,b), page_keys=, page_size=) -> Zahl der Seiten aus [a,b), die zuerst in die Demotion gehen (rang-gleich); keep_role(rid, None) idempotent; keep_state(rid, tree=None) -> {device, l2, l3, pages}; register_pool. Wirft nie.
Instrument: sgl-project#248 HOLD-LOOKUP, WAKE-READ, PARK-MARK, PARK-DEMOTE, KEEP-ROLE, LOADED-HOST-RELEASE; HOLDERS park_kept/handoff_kept.

Tests: test_weg2_park_l3_248 (17: Hold ohne Referenz, Wake-Lesung + Settle, Park-Marke, Claim-Stufen, L3 bytegleich zurück, Demotion ohne Freigabe, 3 Ränge gleiche Keep-Liste, keep_role/keep_state/Teilpark), test_park_l3_loaded_host_r12_248 (5: Metall-Form Load-back -> TP0 und Worker (0,1), Worker-Pool ohne Ratsche über 5 Park/Resume-Zyklen, Worker gibt nie selbst frei, Host-Lock/Host-Blatt bleiben, Schalter aus/Gruppe P = alt). Rot auf 27e1d90738, grün mit Fix. Nachbarsuiten: siehe Bericht, 0 neue Rote.

Metall-Abnahme: own_held(D) im Schlaf ~0; 0x no free slot / BACKUP-REFUSED arena_claim über >=3 Park-Zyklen bei Stau >=5; PARK-DEMOTE vorhanden, Rückkehr per sgl-project#1433 L3->L2 fill digest=match; W50 re-route impossible = 0; LOADED-HOST-RELEASE nach Load-back; R12 SHADOW-OWN-EVICT-REFUSED ohne Ratsche; Flipzeit gegen rc12t prüfen (Wake-Lesung statt Schlaf-Lesung).
(cherry picked from commit 3a339b714dc8b3ba6079ce149cf0442995fd4977)
(cherry picked from commit b606ec3b7283ea679b5f06aa01bec1789b9aed59)
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 28, 2026
…anz nicht mehr in die Host-Release-Queue -- TP0 sammelte ~1,26 Mio. Seiten-Eintraege, der Flush-Reset lief sie einzeln ab

Befund (D-Log boot_weg2_dkrnfh91dprsavisnoadopts0bar1dauer09281111_103bfdf29a_0928_111148.D.log):
- TP0 stand 11:22:57 -> 11:23:14 im Flush vor dem Schlaf ('sgl-project#1476 DISPATCH kind=FlushCacheReqInput dispatch_ms=16372'), zwischen 'R12 HOST-VERDICT reset drops' und 'sgl-project#1068 RESET JOIN ... joined_s=0.00'. TP1/TP2 resetteten 11:22:57.
- Das ist kein Warten auf Store-Ops/Backup-Acks, nicht der sgl-project#1068-Join (0,00 s) und nicht die W88-Schleife selbst. Es ist der Reset-Gang ueber die Host-Release-Queue (_weg2_release_queued_refs_before_reset, ein torch-Aufruf je Eintrag). Er gab nichts zurueck und schrieb deshalb keine Zeile.
- Gefuellt hat die Queue der W88-Retry-Sturm von weg2-10-50: 1299x 'sgl-project#915 PREFETCH TRUNCATED need=69952 got=5760 lost=64192' nur auf TP0 (Worker lost=0).
- Der Gruppen-Trim legte den abgeschnittenen Schwanz jedes Mal in die Queue, je 64-Id-Seite ein Eintrag, also ~1000 je Pass. Das sind Lese-Platzhalter aus alloc_read (kein Slot, keine Referenz); der Drain verwirft sie ohnehin (ARENA-QUEUE-REFS placeholders=64 je Aufruf, kumulativ 2,4 Mio.).
- Der Drain einigt sich auf das Gruppen-MIN der Queue-Groessen. Einen Ueberschuss, den nur TP0 hat, erreicht er nie.
- Derselbe Queue-Gang im Zensus-Thread: ARENA-REF-HOLDERS n=7 faellig 11:22:40, gedruckt 11:23:03 (snapshot=torn); HOST-ANON-STACK 11:22:53 zeigt ihn in unified_radix_cache.py:1639 (queue-Summe).

Fix:
- Der Schwanz eines Gruppen-Trims wird nur noch gequeued, wenn host_indices echte Zeilen sind (alloc). Platzhalter aus alloc_read werden gezaehlt (_weg2_trim_placeholders_dropped), nicht gequeued.
- Der Reset-Gang misst sich. '#1424g ARENA-REF RESET-QUEUE' traegt jetzt ms= und erscheint auch ohne Rueckgabe, sobald der Gang >= 100 ms dauert.
- Kein Schalter.

Test test_weg2_trim_placeholder_tail_rc12z17 (4), ueber das echte prefetch_from_storage:
- rc12z17-Form (need 69952, Gruppe 5760): 0 Ids gequeued.
- 64 Retry-Paesse: Queue bleibt leer.
- Staging-Schwanz (alloc): weiter freigegeben.
- Ohne Trim: keine Freigabe.
- Die ersten beiden sind rot auf 1bab093 und gruen mit Fix; die beiden Waechter sind auf beiden Seiten gruen.

Gate: 35 Testdateien, die prefetch_from_storage, _reset_full oder den Reset-Gang beruehren (ohne test_unified_radix_cache_unittest, OOM in der Cgroup).
- Fix: 33 failed / 396 passed.
- Basis 1bab093: 35 failed / 394 passed.
- Die 33 Altlasten sind identisch, 0 neue Rote.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 30, 2026
… -- sgl-project#915 too_short gilt nicht fuer eine told-begrenzte Registrierung (NF fbca82c, y4a-Tod 03:36:24)

Port von NF fbca82c auf die 27B-Linie: gleiche Naht (weg2_store_told,
sgl-project#1400-Follower, sgl-project#915-Schwelle 256). told-begrenzte Lesung bekommt min_tokens=1
(weg2_store_told.told_read_min_tokens), 3 Zeilen in Scheduler._prefetch_kvcache.

Tests: test_weg2_told_shortread_0930 3 passed (neu, Funktion fehlt auf der Basis).
49 Nachbardateien (weg2_store_told/_prefetch_kvcache): 658 passed, 22 failed --
dieselben 22 scheitern auf der Basis 51b6aa3 (Altlasten, Liste identisch).

(cherry picked from commit fbca82c)
efschu pushed a commit to efschu/htsglang that referenced this pull request Oct 1, 2026
…chedule decides it (sgl-project#1180-W), hand-backs read below the sgl-project#915 threshold

Metal gmps4 (dual1m ...10011614, 6ff17a0) died 16:19:25Z on P PP1:
PpRowDeferCapExceeded sgl-project#1180 -- slot 0 held PP0's frame naming weg2-0-9, which
PP1 could not locate. Sequence: PP0 admitted weg2-0-9 into slot 0 (fwd 118),
then the client's AbortReq reached all P ranks in the same pass. PP0 took it
as a chunked abort (xsn324: two more chunks, slots 1-2); PP1 still held the
request in its WAITING queue (told/paced-admit absorbed, frame not yet
consumed) and popped it at receipt -- PP0's slot-0 frame then named a rid PP1
no longer had.
sgl-project#1180-W: a PP follower under row authority (True/unknown; never the
pass-aligned form, PP0, non-PP, abort_all) holds a waiting-queue abort
(WEG2-PP-WAITING-ABORT held) and follows PP0's forwarded schedule each pass
(weg2.pp_abort.follower_waiting_abort_verdict): named -> keep (admitted this
pass), admitted -> the chunked abort path, pp_size frames naming others -> pop,
PP0 idle (sgl-project#1268) -> pop, no frame -> keep.

Same boot, weg2-0-7 N=25: P published its N-1 anchor (END-ANCHOR units=24/24
ok), but D's store read was refused by the sgl-project#915 threshold (vote_negative
need=24 threshold=256), D matched 0, uncached 25 -> W31/W50 -> re-route
through P -> the same refusal. In the dual layout every D request is a P
hand-back: dual_handback_min_tokens() = 1 on group D (min_tokens of the read).
The anchor fix itself held: 16x DUAL-HANDBACK d_uncached=1 admit, END-ANCHOR
units = N-1, HANDOFF-KEYS offset=1.

Tests: test_weg2_dual_abort_handback_1001 7/7 (verdict table; the gmps4
sequence on the real scheduler methods: not popped at receipt, kept while
PP0's frame names it, handed to the chunked path once admitted; PP0-popped ->
pop after pp_size frames; no frame keeps, PP0 idle releases; immediate on PP0
/ non-PP / abort_all / pass-aligned; hand-back min tokens; wiring) + the
anchor file 6/6; red on 6ff17a0 (import). Gate: 84 test files touching
aborts / PP abort / prefetch min tokens, 643 run: 4 failed / 12 errors, the
identical set on 6ff17a0.
efschu pushed a commit to efschu/htsglang that referenced this pull request Oct 1, 2026
…chedule decides it (sgl-project#1180-W), hand-backs read below the sgl-project#915 threshold

Metal gmps4 (dual1m ...10011614, 6ff17a0) died 16:19:25Z on P PP1:
PpRowDeferCapExceeded sgl-project#1180 -- slot 0 held PP0's frame naming weg2-0-9, which
PP1 could not locate. Sequence: PP0 admitted weg2-0-9 into slot 0 (fwd 118),
then the client's AbortReq reached all P ranks in the same pass. PP0 took it
as a chunked abort (xsn324: two more chunks, slots 1-2); PP1 still held the
request in its WAITING queue (told/paced-admit absorbed, frame not yet
consumed) and popped it at receipt -- PP0's slot-0 frame then named a rid PP1
no longer had.
sgl-project#1180-W: a PP follower under row authority (True/unknown; never the
pass-aligned form, PP0, non-PP, abort_all) holds a waiting-queue abort
(WEG2-PP-WAITING-ABORT held) and follows PP0's forwarded schedule each pass
(weg2.pp_abort.follower_waiting_abort_verdict): named -> keep (admitted this
pass), admitted -> the chunked abort path, pp_size frames naming others -> pop,
PP0 idle (sgl-project#1268) -> pop, no frame -> keep.

Same boot, weg2-0-7 N=25: P published its N-1 anchor (END-ANCHOR units=24/24
ok), but D's store read was refused by the sgl-project#915 threshold (vote_negative
need=24 threshold=256), D matched 0, uncached 25 -> W31/W50 -> re-route
through P -> the same refusal. In the dual layout every D request is a P
hand-back: dual_handback_min_tokens() = 1 on group D (min_tokens of the read).
The anchor fix itself held: 16x DUAL-HANDBACK d_uncached=1 admit, END-ANCHOR
units = N-1, HANDOFF-KEYS offset=1.

Tests: test_weg2_dual_abort_handback_1001 7/7 (verdict table; the gmps4
sequence on the real scheduler methods: not popped at receipt, kept while
PP0's frame names it, handed to the chunked path once admitted; PP0-popped ->
pop after pp_size frames; no frame keeps, PP0 idle releases; immediate on PP0
/ non-PP / abort_all / pass-aligned; hand-back min tokens; wiring) + the
anchor file 6/6; red on 6ff17a0 (import). Gate: 84 test files touching
aborts / PP abort / prefetch min tokens, 643 run: 4 failed / 12 errors, the
identical set on 6ff17a0.
efschu pushed a commit to efschu/htsglang that referenced this pull request Oct 1, 2026
…_tokens, not the bare threshold

prefetch_from_storage honoured the caller's min_tokens in the LOCAL gate
(_min_len) but the group vote of a symmetric (TP-decided) tree compared
group_len with self.prefetch_threshold (256). Every P hand-back read whose
span beyond D's match was below 256 tokens was refused vote_negative although
all ranks probed it present -- metal gmps7 dkr27bnvfp4dual1mbar1fs10011748,
D TP=3: weg2-0-6 need=24, weg2-0-10 need=40 (H108 present=True on TP0/1/2)
-> W31 -> W50 -> P ran leg 1 twice -> W53/503. The flip's TP=3 D reads its
hand-backs through the same vote (handback_min_tokens), so N2's "hand-back
reads below sgl-project#915" did not reach a TP group either.

The vote now uses _min_len (rank-uniform: a pure function of the request and
the group's env). The span-agreement argument after it still holds:
group_len >= _min_len >= 1 proves every rank eligible and allocated.

Test test_prefetch_vote_min_tokens_1001.py: short hand-back span (24/40) with
every rank present registers through the group vote (red before), the default
(no min_tokens) still refuses below 256, mutant (vote bound back to the
threshold, exec'd from the real source) is red in-suite.
Gate (nice, -n 2, the 31 mem_cache/weg2 files touching prefetch_from_storage /
the vote / min_tokens, fix vs a3da496): 237 vs 235 failed; the two extra
are an xdist-order flake (test_weg2_scheduling_slice_a_0907 passes serially on
both, 43/43) and a log line counted as ERROR. New file: 5 passed.
efschu pushed a commit to efschu/htsglang that referenced this pull request Oct 2, 2026
… line at once, D decodes on (no wait for an idle D)

Coordinator 02.10. on the user rule ~19:12Z ("prefillt er in D die kleine menge
angefallene token"): on route=D at the 7.5 s D-check (or the window's end) the
SHORTs held on the seat path took their seats, but a queued entry <= X that was
not SHORT-routed -- a SHORT D's sgl-project#915 budget refused (d_eligible False), a
CARRIER entry -- stayed queued until D went idle (X-IDLE-REGRANT / D-SHORT-DRAIN
need an idle D; ARRIVAL-SEAT's QUEUED-SHORT takes d_eligible only).

_dc_hand_to_d: the release records the set's rids (rel_rids); route D moves every
one of them still queued -- in arrival order, each and the sum <= X, never
p_only / intake_stalled / leg1_done / rerouted / re-queued -- to _ready_for_d as
d_direct (USAGE x_short for an x_deferred one), on both D decision sites (27B
_immediate_park_due, ARRIVAL-SEAT step). A band request (x_deferred: over X_busy,
the X in force while D decodes) stays P-bound by needs_p (PK2) and makes the set
route P, unchanged.
Marker: WEG2 DECODE-COLLECT to-d n= tokens= X= rids= epoch=. Counter
decode_collect_to_d. Window 0: never reached (byte for byte the old path).

Tests: test_weg2_decode_collect_27b_1002 14 (3 new/extended red on a7bcf2c:
the small set and a budget-refused SHORT reach _ready_for_d while D decodes, an
intake-stalled entry stays), NF's 11 green; neighbours (23 park/seat/arrival/
early-flip files) 280 passed, the one red manual_flip_park _ipc_dp_clock as on
the base.
efschu pushed a commit to efschu/htsglang that referenced this pull request Oct 2, 2026
… line at once, D decodes on (no wait for an idle D)

Coordinator 02.10. on the user rule ~19:12Z ("prefillt er in D die kleine menge
angefallene token"): on route=D at the 7.5 s D-check (or the window's end) the
SHORTs held on the seat path took their seats, but a queued entry <= X that was
not SHORT-routed -- a SHORT D's sgl-project#915 budget refused (d_eligible False), a
CARRIER entry -- stayed queued until D went idle (X-IDLE-REGRANT / D-SHORT-DRAIN
need an idle D; ARRIVAL-SEAT's QUEUED-SHORT takes d_eligible only).

_dc_hand_to_d: the release records the set's rids (rel_rids); route D moves every
one of them still queued -- in arrival order, each and the sum <= X, never
p_only / intake_stalled / leg1_done / rerouted / re-queued -- to _ready_for_d as
d_direct (USAGE x_short for an x_deferred one), on both D decision sites (27B
_immediate_park_due, ARRIVAL-SEAT step). A band request (x_deferred: over X_busy,
the X in force while D decodes) stays P-bound by needs_p (PK2) and makes the set
route P, unchanged.
Marker: WEG2 DECODE-COLLECT to-d n= tokens= X= rids= epoch=. Counter
decode_collect_to_d. Window 0: never reached (byte for byte the old path).

Tests: test_weg2_decode_collect_27b_1002 14 (3 new/extended red on a7bcf2c:
the small set and a budget-refused SHORT reach _ready_for_d while D decodes, an
intake-stalled entry stays), NF's 11 green; neighbours (23 park/seat/arrival/
early-flip files) 280 passed, the one red manual_flip_park _ipc_dp_clock as on
the base.
efschu pushed a commit to efschu/htsglang that referenced this pull request Oct 20, 2026
…a follower's told read is prescribed: the speculative-span budget (sgl-project#915 rate_limited) does not refuse it; scheduler.py, unified_radix_cache.py, pdflip_store_told.py merged without conflict
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