Skip to content

fix: resolve fp8 for mixtral - #1290

Merged
zhyncs merged 2 commits into
mainfrom
fix
Sep 1, 2024
Merged

zhyncs merged 2 commits into
mainfrom
fix

Conversation

@zhyncs

@zhyncs zhyncs commented Sep 1, 2024

Copy link
Copy Markdown
Contributor

Motivation

python3 -m sglang.launch_server --model neuralmagic/Mixtral-8x22B-Instruct-v0.1-FP8 --quantization fp8 --kv-cache-dtype fp8_e5m2 --disable-radix --tp 8 --trust-remote-code

Modifications

Checklist

  • Format your code according to the Contributor Guide.
  • Add unit tests as outlined in the Contributor Guide.
  • Update documentation as needed, including docstrings or example tutorials.

@zhyncs
zhyncs merged commit 9b08052 into main Sep 1, 2024
@zhyncs
zhyncs deleted the fix branch September 1, 2024 14:29
@zhyncs

zhyncs commented Sep 1, 2024

Copy link
Copy Markdown
Contributor Author

ref

#1252
#1276

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 Sep 9, 2026
…terminal; sample r_D on concurrency

The two gates boot weg2sb5g (`80de2d31d1`, 07:06-07:27Z) failed. Both are on
the sgl-project#1289/sgl-project#1290 line and both are mine. The five that passed are recorded in
the boot record; sgl-project#1288's loopback trust (0 x 401), sgl-project#1290's route bases (53
LONG) and sgl-project#1289's flip_s sampler (`flip_s source=live n=1,2`) all held.

======================================================================
GATE 4 -- LEG 2 IS STILL A W50 CANDIDATE, AND THE REQUEUE LOOPS TO 503
======================================================================

53 LONG routes, **3 served** (natural 1/27, salad 2/26), 50 x 503 after 32-64
s. `W50_Weg2TpPrefillExceeded` 104, `W50_requeue` 54, `W35_Weg2XReQueueLoop`
50, and the sgl-project#1290 one-shot refusal was never reached: **0 anchored 413, 0
W52**. (Method note carried from the boot agent: a bare `grep 413` returns 11
hits on the front log, every one a digit coincidence inside
`queued_uncached=41356`; anchored on the HTTP status the count is 0 and the
driver's own census agrees, `{200: 3, 503: 50}`.)

ROOT, from D's own log, per request:

    W50 Weg2TpPrefillExceeded rid=a977bd8d87154067913632f1b8a81f09
        uncached=24657 X=8742
    PHASE-PURITY STORE WITNESS OBSERVATION (n=22) rid=a977bd8d...
        phase=None pp_rank=0 state=unprobed stamp

`uncached=24657` is the WHOLE prompt -- D priced it as if P had never run --
and the witness says the store was never probed for that rid. `WEG2 X-DEFER`,
the completion predicate that exists precisely to hold a request whose store
read is still in flight (`scheduler.py::_weg2_x_defers`), fired **ZERO** times
in the entire boot, so there was no pending read to wait for: the abstain
branch (`pending_ms is None` -> never defer) took every request. D's census:
X-GATE `verdict=W31` 312 / `admit` 84, `replicated_term=group` 396/396; store
witness `cold` 99 / `hit` 18 / `unprobed` 75.

So the P prefill's result never reached D -- and the front's answer was to run
the SAME P prefill again. The bet the requeue exists to place had already been
placed and lost on this exact request.

THE FIX IS THE RULE: **a completed P leg 1 makes the next W50 terminal.**
`_requeue_after_x_refusal` now refuses by name (W53 Weg2StoreHandbackFailed)
with HTTP 413 and the numbers, before any requeue bookkeeping. W53 is
deliberately NOT W52: W52 is "no route can serve this" (a sizing fact known at
admission), W53 is "the route ran and its result did not reach the group that
needed it" (a store/carrier fault found afterwards). Different faults, different
repairs, different names. W53 is free -- the used set is W50/W51/W52,
enumerated before choosing. The refusal names the evidence to collect next
(D's STORE WITNESS state for the rid, `unprobed` = no read was ever issued),
so the next boot does not re-derive this.

SECOND FINDING, STATED AND DELIBERATELY NOT FIXED HERE. `sgl-project#1236 Store >=
P-Pool` is violated on this form: P's pool is 304,655 tokens and its per-token
KV across the three PP ranks is 22528 + 4096 + 6144 = 32,768 B, so a full pool
is **9.30 GiB** against a store configured
`{"max_size":"5G","min_free_space":"1G"}` -- ~4 GiB usable. WHICH REPAIR: size
it, not refuse. A hard launch refusal would block every boot on this rig for a
fault that only bites the LONG route, which W53 now terminates honestly in one
shot instead of 32-64 s; and the arithmetic says sizing is not the proven
cause of THIS rid's `unprobed` anyway (one 24,657-token prompt is 771 MiB and
fits four times over). It is a real second fault at this arm's concurrency.
Sizing lives in `launcher.py`, which this branch does not touch and cannot
test on metal in this window, so it goes to that owner with the arithmetic
pinned in `TheSb5gArithmetic` rather than half-done here.

======================================================================
GATE 5 -- r_d IS NEVER SAMPLED, SO X CAN NEVER RE-SOLVE
======================================================================

`WEG2 X RE-SOLVE` 0 across 64 flips -- and sgl-project#1289's own instrument named the
starved term, which was the point of that ticket:

    WEG2 X NO-SOLVE: no r_d sample yet, so X stays at the carried-in 8742
      (flip_s source=live n=2; have r_d=0 r_p=1 flip_s=2)

ROOT, `front.py::leg2`:

    if verdict in ("single_prefill", "short_mispriced") and _unc > 0 and _w > 0:
        self.note_x_sample("r_d", _unc / _w)

Both admitted verdicts are EXCEPTIONAL -- `single_prefill` is route
CARRIER-EXCEEDS, `short_mispriced` is a SHORT the front UNDER-priced. The
ordinary well-priced SHORT returns `serve` (`_leg2_verdict`), and `serve` was
excluded. sb5g's front-log census: `verdict=serve` 24, `verdict=short` 20, and
ZERO of either admitted verdict against 84 admitted D prefills. The gate was
also incoherent: `short_mispriced` is a seated SHORT at exactly the same
concurrency as `serve`, so it admitted and excluded the same physical
situation depending only on how the front had priced it.

r_D is D's PREFILL rate -- tokens over the wall of a prefill D ran ALONE -- so
the qualifying property is CONCURRENCY. It is now measured directly and
EXACTLY: `_d_admissions` (every arrival at D) not moving across the window
rules out an arrival that came and went inside it, which two
`len(outstanding)` snapshots cannot. A rejected sample increments
`r_d_skipped_concurrent`, so an empty deque can be told from an emitter that
never ran -- the denominator law.

AND THE SAMPLE THAT COMPLETES THE TRIPLE NOW RESOLVES IMMEDIATELY. Without
that, an `r_d` arriving last (exactly sb5g's order) would wait for the next
flip or the eighth drain, so the term that was missing all boot buys nothing
on the pass that finally supplies it.

PROVENANCE: `r_d source=live|none n= src=` joins `flip_s source=` on all three
X decision lines and in `/weg2/state`. One word ("no r_d sample yet") located
this defect; r_D now carries the same.

TESTS, red-first by name: `test_weg2_handback_rd_1291.py`,
`ACompletedLegOneMakesTheRefusalTerminal::test_red_first_the_requeue_
terminates_after_a_completed_leg_one` and
`RdIsSampledOnConcurrencyNotOnAVerdict::test_red_first_the_ordinary_serve_
verdict_is_no_longer_excluded`. The sb5g numbers are the fixture.

MUTANTS, four on gate 4's danger direction (OVER-refusing, since this fix
adds a terminal verdict):
(1) a request with no leg 1 still gets its one requeue -- the bet has not been
    placed for a SHORT or CARRIER-EXCEEDS arrival and the re-offer is correct;
(2) `pending is not None` alone is NOT the condition: a CARRIER-EXCEEDS
    arrival carries a Pending with `skip_leg1=True` and `leg1_done` False, and
    gating on the Pending's presence would refuse it wrongly;
(3) the W52 estimate rule (sgl-project#1290 round 2) is not swallowed by W53;
(4) the terminal check must precede both the X-REQUEUE line and the W35
    branch, or the counters record a lap that never happened.
Three on gate 5's danger direction (admitting a CONCURRENT wall, i.e.
re-introducing sgl-project#1271 (a)'s latency-as-rate):
(5) a concurrent leg 2 is still refused AND counted;
(6) a snapshot-only witness is unsound -- the admissions counter must be in
    the conjunction;
(7) a zero/negative sample is still ignored.
Plus `test_the_counter_is_initialised_in_the_constructor`, because a
hand-built Front in a test is not proof that the real one has the field.

METAL PROOF OWED (UNPROVEN): `W53` > 0 with 413s replacing the 503 loop and
`W35_Weg2XReQueueLoop` = 0; `r_d source=live n>=1` by the second flip and
`WEG2 X RE-SOLVE` > 0; served fraction on the LONG arm above 3/53.

Author: efschu
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 9, 2026
REFUTER A MF-1. The W52/W53/W54 -> W57/W58/W59/W60 renumber moved every
form the census reads (emitter, counter key, concatenation) and left
SEVEN bare-number strings in shipped launcher prose, four of which now
name a LIVE DIFFERENT refusal: W52 is Weg2NoServiceableRoute (sgl-project#1290) and
W53 is Weg2StoreHandbackFailed (sgl-project#1291) at this tip, so a human grepping
either number in the source or a boot log lands on the wrong exception.

The census cannot see these by construction -- the pattern is
"W<nn> Weg2<Name>" and a docstring that opens "W52: the disk cannot
fund ..." carries no name -- which is exactly the channel
test_weg2_wcode_uniqueness_1263.py's own docstring says the guard is for.

Class docstrings of Weg2StoreDiskRefused and Weg2StoreArcRefused now open
with their real numbers and state the renumber and the holder that kept
the old one; the plan_store / arc_preflight_line / --store-* argparse
prose follows. Weg2ChunkCardMismatch W52 -> W59 and
Weg2CarrierFloorUnreachable W54 -> W60, same treatment.

Two siblings: the argparse help pinned "front.py:556's 'W52 is free'
comment" at a line that is now 560 -- the pin drops, the file stays; and
the teardown funnel test fabricated a third W53 holder
("W53 Weg2TpOperatingPointDisablesUnevenAxis") plus a bare "W53 fake
post-spawn refusal". Both now use W45 Weg2CarrierCensusRefused, a REAL
post-spawn refusal of this tree, which the test's own docstring already
enumerates.

Census unchanged: 51 codes, the five KNOWN collisions, no new one.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 9, 2026
…ck for all three exits

ROOT, measured on boot weg2sn5s @ fd92440 under a FLEET-SHAPE load (shared
~16k anchored prefix + growing tails), all three D ranks:

    22:27:51 #924D station=alloc_cow rid=664901103e55 mamba_slot=[7] site=finalize_match_result
    22:27:51 WEG2 X-GATE  rid=664901103e55 uncached=17236 X=8742 verdict=W31
    22:27:51 W50 Weg2TpPrefillExceeded rid=664901103e55 uncached=17236 X=8742
    on_idle  [mamba] total=30, available=4, evictable=25, leaked_mamba_pages={7}
             mamba_leak_owners=[slot=7 slot_used=True last_event=ALLOC@seq6158
                                releaser=none-recorded]

A prefix match drew a COW resume slot SPECULATIVELY
(`MambaComponent.finalize_match_result`, stamping
`mamba_slot_acquired_this_admission`). The X gate then refused the request by
name and `_weg2_answer_x_refusals` returned it to the front WITHOUT the slot.
That request has exactly ONE station line for its whole life: it never reaches
`alloc` or `cache_finished_req`, so the refusal exit is the ONLY owner of that
give-back. Zero `sgl-project#991` lines in the entire log confirms none ran.

WHY IT READ AS INTERMITTENT, and why four clean 41k prompts proved nothing:
BOTH conditions must hold -- `uncached > X` (long prompts only) AND a prefix
match carrying mamba state (so the COW acquire happens at all). Every earlier
repro put a unique nonce at the FRONT of the prompt to defeat prefix caching,
which satisfies the first condition and structurally excludes the second. The
fleet's real shape -- one shared system+tools prefix, growing tails -- leaked
within two passes.

THE CLASS: THREE admission-refusal exits, the give-back open-coded in two and
absent from the third.
  * `scheduler.py` admission revert (sgl-project#991)          -- FORK-OWN
  * `schedule_policy.py` PPScheduleRefused (sgl-project#791)   -- FORK-OWN
  * `scheduler.py` `_weg2_answer_x_refusals` (sgl-project#1290/law 4, W31/W50) -- FORK-OWN
All three are fork-own Weg-2 admission plumbing; the COW acquire they must
compensate is upstream (`e0b692600f`, PR sgl-project#27118). That is the
upstream-minimal statistic again: the defect sits in fork-own compensation
around an upstream mechanism, not in the mechanism.

FIX: lift the two open-coded bodies into ONE
`release_admission_acquired_mamba_slot` (`mem_cache/common.py`) and call it
from all three exits with identical guards (`mamba_slot_acquired_this_admission`
and not `req.session`) -- a third copy would have been the second-bookkeeping
answer. It also clears the match's other per-admission carry-overs
(`mamba_cow_src_index`, `mamba_needs_clear`, `mamba_loadback_anchor_adopted`)
so a refused request cannot carry a resume anchor into its next admission, and
emits `#924D station=give_back site=<exit>` so the exit is visible in the trail.
The wider partition on that exit needs nothing further: the request never
allocated KV rows or a req_pool row (no `station=alloc`), the match's
`inc_lock_ref` pairs are closed in-block at `mamba_component.py:488/:499`, and
the exit already calls `release_aborted_request` / `terminate_prefetch`.

Tests: `test_mamba_admission_giveback_q0.py`, 9 cases asserting the FULL
partition after every station -- `expected == free U tree U live` AND all three
pairwise intersections empty, i.e. the orphan direction AND the aliasing
direction that the earlier suite could not see. RED-first against fd92440:
5/5 red including the specimen simulated on the real allocator (slot orphaned
after the W50 exit); green on the fix. 3 mutants killed with an unmutated
control: acquired-guard removed (frees batch-owned slots, sgl-project#1051's direction),
session-guard removed, give-back made a no-op (the pre-fix exit). ruff: 127
findings across the three touched files, identical on the baseline tree.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 10, 2026
…tead of a 413 (W68)

HALF 1 of 2 (front only; D's X gate follows in its own commit so a
half-applied change can never reach a boot).

THE DEFECT, boot weg2sn5t under a fleet-shape load with a shared ~12.7k-token
agent prefix: 15 of 24 requests returned HTTP 413 `W52 Weg2NoServiceableRoute`,
and EVERY ONE carried `src=exact` -- not one `src=estimate`:

    verdict=none uncached=11116 src=exact chars=130197   x7
    verdict=none uncached=17493 src=exact chars=190197   x3
    verdict=none uncached=19741 src=exact chars=210197   x2
    verdict=none uncached=38839 src=exact chars=250197   x2
    verdict=none uncached=43304 src=exact chars=250197   x1

That is the `carrier_exact` gate: a FIRST-TIME prompt is routed
(`carrier_single`), and only the REPEAT -- after `_note_exact` learned the
exact count -- terminates. A cache hit therefore makes the request WORSE than
a cold one, which is a routing rule, not physics.

TWO PREMISES VERIFIED BEFORE THE EDIT (two earlier premises in this ticket
failed exactly by not being):
1. X IS THE ECONOMIC BREAK-EVEN, NOT A CAPACITY LIMIT -- the launcher's own
   provenance line: `X* = 2*flip_s/(1/r_D - 1/r_P)`, flip_s=2.90,
   r_D=1138 tok/s, r_P=4628 tok/s, floor=4096.
2. D DEMONSTRABLY PREFILLS FAR ABOVE X -- boot weg2sn5n rid weg2-6-9:
   `WEG2-SERVED group=D leg=2 status=200 prompt_tokens=50732 cached_tokens=0`
   with `freed_by=leg2_finished` (no requeue, no P leg 1). 50732 tokens
   direct, 5.8x above X=8742.
So sgl-project#1290's invariant ("never routed to a D single prefill") is about D
REFUSING at its gate and the requeue loop that followed, not about D being
unable. With no carrier route, the slow D-direct path beats a 413.

CHANGE (front): `serviceable_route` gains `per_request_cap` and returns the new
`forced_direct` where it used to return `none`; only a total above the
per-request cap stays terminal, because that is a real capacity wall. The
caller logs `W68 Weg2ForcedDirectPrefill` with total / carrier_max / X /
uncached / reason and an est_ttft derived from r_D (labelled an ESTIMATE), sets
`weg2_no_carrier_route` on the payload for D's gate, and then follows the
existing carrier_single path unchanged. W68 was chosen by ENUMERATING the used
set (`grep -ohE '\bW[0-9]{2} Weg2[A-Za-z]+'`); W59 and W65 came back non-zero.
`--max-kv-per-request` is plumbed front-side with default 0 = NON-terminal, so
an un-plumbed front is strictly more permissive rather than accidentally
terminal, and the launcher passes it at both call sites (dry-run and live).

DEVIATION, NAMED: a soft-rule exception to law 4 (operator 2026-09-10, `Regeln
WEICH, abweichen mit Grund`), counted under its own W-code so the user can veto
it from the census. Everything with a carrier route keeps today's behaviour.

Tests: 13 cases, RED-first (13 failed before the edit). The specimen and all
five 413 shapes of that boot now route; above the cap stays `none`; and the
first-time, carrier-exceeds-but-D-fits, short, long and disabled-bounds
directions are each pinned unchanged. 43 pass with the messages-pricing file.
ruff: unchanged against the baseline tree.

THREE EDITS CAUGHT BY READING BACK, recorded because the discipline is what
found them, not luck: `self.max_kv_per_request` did not exist on the Front;
`max_kv_per_request` was not a parameter of `front_argv_for` (NameError); and a
second `str.replace` matched the text the first one had just inserted, giving a
duplicated keyword argument and a SyntaxError, then left the LIVE call site
un-plumbed while the dry-run one was done twice.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 10, 2026
…, which MOVED by operator decision

Operator decision 2026-09-10, sgl-project#1317, law-4 NAMED DEVIATION, with sign-off to
re-point these guards rather than leave them asserting the old shape.

WHY THE RULE MOVED, and the arithmetic every edit is annotated with: sb5f
measured uncached 22200 > X 12944 AND total 28000 > carrier_max 27466. The
front now routes that carrier_single (counted W68 Weg2ForcedDirectPrefill) and
D's X gate answers `verdict=exempt_no_carrier_route`, so it is PREFILLED DIRECT
with no W50 and no requeue. The terminal moved to the per-request cap (262144),
which is a real capacity wall rather than an economic one.

sgl-project#1290's measured harm was never the 413 -- it was the CYCLE: front offers, D
refuses by name, front requeues, flip, store read refused, whole prompt
uncached, W50 again; 93 of 93 ending in HTTP 503 after a median 22.0 s with
ZERO tokens streamed. That loop stays closed, by a different mechanism, and the
guards now assert THAT rather than the 413 it used to be closed with.

  1. `test_red_first_the_sb5f_long_prompt_has_no_route` ->
     `test_the_sb5f_long_prompt_is_exempted_not_refused`, same numbers,
     verdict `forced_direct`.
  2. `test_a_no_route_request_gets_413_and_never_touches_the_queue` ->
     `test_only_above_the_per_request_cap_does_a_413_survive`: re-pointed at
     the surviving terminal, still pinning that the refusal RETURNS rather than
     parking and is counted exactly once.
  3. the three `test_mutant_*` keep their intent -- both bounds asked on their
     own base -- with the new verdict. Mutant 1's assertion is sharpened: the
     mutant's error is still caught, because it offers D a prefill D will
     REFUSE, while the fix offers the same prompt as a forced, EXEMPTED one.
  4. `test_a_long_request_is_queued_for_p_and_counted_as_long`: unchanged.
  5. `test_a_terminal_refusal_may_not_rest_on_an_estimate`: the round-2 rule
     STANDS and is now stronger -- neither figure terminates below the cap --
     and the two still differ, which is what the rule is about.
  6. NEW, the anti-loop guard, in two halves because the loop has two: the
     front asserts the band is ROUTED and never counted as a refusal
     (`test_the_band_is_routed_and_never_counted_as_a_refusal`), and the W50
     half is asserted where W50 lives, on D
     (`test_the_sb5f_band_is_exempt_so_no_w50_requeue_cycle_can_start`) -- the
     cycle can only START if D refuses, and it does not.

HARNESS GAP FOUND AND FIXED: `_front()` never set `max_kv_per_request`, so
`handle_generate` raised AttributeError inside the async body and surfaced as
"retry() exceed maximum number of retries" on all seven tests -- an
infrastructure symptom that looked nothing like a routing assertion. Set to 0
(= nothing terminal on that axis, the front's own default); the cap test sets
it explicitly. The front-side anti-loop guard is asserted at the verdict rather
than through `handle_generate`, because the forced path continues into the
D-seat machinery (`_batch_gate`) this harness deliberately does not build.

44 pass across the three touched files. ruff clean.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 10, 2026
USER VERBATIM 2026-09-10 ~04:4xZ: "das ist nicht akzeptabel und widerspricht
dem design." The forced route was an operator-sanctioned soft-rule deviation
from law 4; the user has vetoed it. Reverted in full.

EXACT REVERT, verified rather than asserted: `git diff 1c29ac3 --stat` over
the working tree is EMPTY, i.e. every file the three sgl-project#1317 commits touched is
byte-identical to the pre-sgl-project#1317 tip. Reverts:
  2154f9e  front: forced_direct + W68 + --max-kv-per-request plumbing
  bd451fa  D: exempt_no_carrier_route arm (and its strip of the dead flag,
              which had itself only existed inside this deviation)
  9b0430c  the sgl-project#1290 guards re-pointed at the moved rule

NET STATE, each property checked in the same commit rather than assumed:
  * front `serviceable_route` returns "none" for the band again -> 413 W52;
    no `forced_direct`, no W68, no `--max-kv-per-request` plumbing (its only
    purpose was that route's terminal, so it goes with it -- keeping it would
    have left an unreachable branch and a dead flag on the front and the
    launcher);
  * D's `exempt_no_carrier_route` arm and `_weg2_carrier_limit_tokens` are
    GONE;
  * D's PRE-EXISTING carrier-exceeds exemption (`uncached > carry`, sgl-project#1290
    R-3) is UNTOUCHED -- it is not part of this deviation, it fired 42x on
    boot weg2sn5u for the fleet's cold long prompts, and the user is being
    asked about it separately;
  * the Q0 give-back (`release_admission_acquired_mamba_slot`, 3 call sites)
    is UNTOUCHED -- a different ticket, still fixed;
  * `test_weg2_no_route_1290.py` is back to its ORIGINAL assertions and the
    band guard I added to it is deleted, so the suite guards the rule as
    written;
  * both sgl-project#1317 test files are deleted.

THE FLEET-FACING COST RETURNS, and it should be stated plainly rather than
discovered again: an exact-count REPEAT whose total exceeds carrier_max
(27466) and whose uncached extent exceeds X gets HTTP 413 `W52
Weg2NoServiceableRoute`. Measured on boot weg2sn5t, that was 15 of 24
fleet-shape requests -- a cache hit makes the request worse than a cold one.
That is now the expected, design-conformant verdict until the CARRIER itself
is fixed. The design-conformant fix is pending a user decision; the registered
direction is sgl-project#1236's staging knob after the VRAM exchange (unfundable today at
+10.24 GiB, because the host rings scale with s_gb).
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 10, 2026
USER RULING 2026-09-10. carrier_max was 'what can move through D's host
staging pool AS ONE PIECE'. The whole of sgl-project#1317 exists to end that: design A
prices D's uncached extent against STORE presence and the window loop
streams the store-backed span through the pool in W-sized windows, so the
pool is TRANSIT, not a ceiling. The carrier bound therefore no longer
terminates a route.

SPECIMEN, boot weg2sn6c, rid weg2-2-4: 'W52 Weg2NoServiceableRoute
uncached=18453 exceeds X=8742 ... carrier_est=48011 exceeds
carrier_max=27466' -- a 413 at admission for a prompt the rig can serve. W52
appeared 1x in the front log and 0x in D's, so design A, which lives on D's
X gate, could not possibly rescue it. That reachability coupling is what
this closes. The user's prompts are 50-100k tokens; that is the population.

ONE BRANCH, because the fallback needs no front plumbing: if the store
cannot vouch when D prices the prefix (a cold pass whose write-through has
not landed, a failed backup), D's extent stays large and D's OWN
exempt_carrier_exceeds arm -- deliberately untouched -- admits it as a
single prefill. Chain: store vouches -> A credits -> D decodes with a
remainder <= one chunk; store silent -> D's named exemption single-prefills
it. Never a 413 for a servable prompt, and no hand-priced guess at the
front: it stops deciding what D can do and lets D's own admission verdict
decide, which is what the ruling asked for.

PHASE LAW, stated rather than glossed: on the credited path D prefills at
most one chunk (anchor-capped store depth + the sgl-project#939 law, X >= C on every
path), so the law holds. On the FALLBACK path D prefills above X -- the
pre-existing exemption, the ONLY path on which it happens, retained by
explicit ruling. Not introduced here and not hidden here.

The invariant docstring is amended, not left standing: its 'no route exists'
half was true while the pool was a cap and is not any more. An instrument
text that outlives its behaviour is the class this function's own sgl-project#1290
comment is named for.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 10, 2026
…onger needs the carrier

Eight tests in test_weg2_no_route_1290.py failed on ONE shared invariant,
which is why they went red together: 'v in (short, long) implies
carrier_est <= carrier_max'. That implication was true while the carrier was
a CAP on what could move through D's host staging pool in one piece. Design
A + the window loop make the pool TRANSIT, so long is exactly the route an
ABOVE-carrier prompt now takes (user ruling 2026-09-10).

Narrowed to 'short', which still implies it -- that verdict means D serves
the request itself with no store read at all. THE FIRST HALF IS UNTOUCHED
and is the half that matters: no verdict may send an over-X prefill to D.
#1317d STRENGTHENS it, because the population that used to fall to
carrier_single or a 413 now goes to P instead.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 10, 2026
…naming the half it pinned

Per-test, docstring first: which sgl-project#1290 half did this test pin -- the RETIRED
'no route -> 413' half, or the SURVIVING 'no over-X prefill reaches D' half?
Nothing deleted, nothing loosened to a superset.

RETIRED half (3): red_first_the_sb5f_long_prompt (now asserts the P route
AND still asserts the request never reaches D); mutant_x_alone (the two
routers now legitimately AGREE on this input -- the test says so instead of
pretending a difference, and still asserts D is never offered it);
a_no_route_request_gets_413 -> an_above_carrier_request_now_parks_for_p
(parks like the sibling below-carrier long request; still asserts it is not
counted as a D route).

SURVIVING half, kept through the new route (4): a_terminal_refusal_may_not_
rest_on_an_estimate now holds A FORTIORI -- nothing terminates, so neither
estimate nor measured count can refuse; the_default_is_the_safe_one still
asserts the default is never the terminal verdict; mutant_carrier_alone
still asserts 'the fix must not send this to D at all', only the
destination moved.

mutant_swapping_the_two_bases: THE PROPERTY IS KEPT, THE WITNESS MOVED, and
the reason is stated rather than the assertion weakened. At the sb5f point
the carrier is no longer CONSULTED (over X -> P, whatever the carrier says),
so swapping bases there cannot change an answer that does not depend on one
of them -- that is one bound leaving the decision, not the bases becoming
interchangeable. New witness: uncached 9,000 (under X) with carrier_est
28,000 (over the bound) -> correct carrier_single, swapped long. Plus an
added assertion that over X the verdict does not depend on the carrier, so a
future reader cannot mistake the moved witness for a weakening.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 10, 2026
USER RULING 2026-09-10. carrier_max was 'what can move through D's host
staging pool AS ONE PIECE'. The whole of sgl-project#1317 exists to end that: design A
prices D's uncached extent against STORE presence and the window loop
streams the store-backed span through the pool in W-sized windows, so the
pool is TRANSIT, not a ceiling. The carrier bound therefore no longer
terminates a route.

SPECIMEN, boot weg2sn6c, rid weg2-2-4: 'W52 Weg2NoServiceableRoute
uncached=18453 exceeds X=8742 ... carrier_est=48011 exceeds
carrier_max=27466' -- a 413 at admission for a prompt the rig can serve. W52
appeared 1x in the front log and 0x in D's, so design A, which lives on D's
X gate, could not possibly rescue it. That reachability coupling is what
this closes. The user's prompts are 50-100k tokens; that is the population.

ONE BRANCH, because the fallback needs no front plumbing: if the store
cannot vouch when D prices the prefix (a cold pass whose write-through has
not landed, a failed backup), D's extent stays large and D's OWN
exempt_carrier_exceeds arm -- deliberately untouched -- admits it as a
single prefill. Chain: store vouches -> A credits -> D decodes with a
remainder <= one chunk; store silent -> D's named exemption single-prefills
it. Never a 413 for a servable prompt, and no hand-priced guess at the
front: it stops deciding what D can do and lets D's own admission verdict
decide, which is what the ruling asked for.

PHASE LAW, stated rather than glossed: on the credited path D prefills at
most one chunk (anchor-capped store depth + the sgl-project#939 law, X >= C on every
path), so the law holds. On the FALLBACK path D prefills above X -- the
pre-existing exemption, the ONLY path on which it happens, retained by
explicit ruling. Not introduced here and not hidden here.

The invariant docstring is amended, not left standing: its 'no route exists'
half was true while the pool was a cap and is not any more. An instrument
text that outlives its behaviour is the class this function's own sgl-project#1290
comment is named for.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 10, 2026
…onger needs the carrier

Eight tests in test_weg2_no_route_1290.py failed on ONE shared invariant,
which is why they went red together: 'v in (short, long) implies
carrier_est <= carrier_max'. That implication was true while the carrier was
a CAP on what could move through D's host staging pool in one piece. Design
A + the window loop make the pool TRANSIT, so long is exactly the route an
ABOVE-carrier prompt now takes (user ruling 2026-09-10).

Narrowed to 'short', which still implies it -- that verdict means D serves
the request itself with no store read at all. THE FIRST HALF IS UNTOUCHED
and is the half that matters: no verdict may send an over-X prefill to D.
#1317d STRENGTHENS it, because the population that used to fall to
carrier_single or a 413 now goes to P instead.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 10, 2026
…naming the half it pinned

Per-test, docstring first: which sgl-project#1290 half did this test pin -- the RETIRED
'no route -> 413' half, or the SURVIVING 'no over-X prefill reaches D' half?
Nothing deleted, nothing loosened to a superset.

RETIRED half (3): red_first_the_sb5f_long_prompt (now asserts the P route
AND still asserts the request never reaches D); mutant_x_alone (the two
routers now legitimately AGREE on this input -- the test says so instead of
pretending a difference, and still asserts D is never offered it);
a_no_route_request_gets_413 -> an_above_carrier_request_now_parks_for_p
(parks like the sibling below-carrier long request; still asserts it is not
counted as a D route).

SURVIVING half, kept through the new route (4): a_terminal_refusal_may_not_
rest_on_an_estimate now holds A FORTIORI -- nothing terminates, so neither
estimate nor measured count can refuse; the_default_is_the_safe_one still
asserts the default is never the terminal verdict; mutant_carrier_alone
still asserts 'the fix must not send this to D at all', only the
destination moved.

mutant_swapping_the_two_bases: THE PROPERTY IS KEPT, THE WITNESS MOVED, and
the reason is stated rather than the assertion weakened. At the sb5f point
the carrier is no longer CONSULTED (over X -> P, whatever the carrier says),
so swapping bases there cannot change an answer that does not depend on one
of them -- that is one bound leaving the decision, not the bases becoming
interchangeable. New witness: uncached 9,000 (under X) with carrier_est
28,000 (over the bound) -> correct carrier_single, swapped long. Plus an
added assertion that over X the verdict does not depend on the carrier, so a
future reader cannot mistake the moved witness for a weakening.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant