Skip to content

Allow input_ids in the input of the /generate endpoint - #363

Merged
merrymercy merged 3 commits into
sgl-project:mainfrom
lolipopshock:shannons/allow-input-ids-in-generate
May 12, 2024
Merged

merrymercy merged 3 commits into
sgl-project:mainfrom
lolipopshock:shannons/allow-input-ids-in-generate

Conversation

@lolipopshock

Copy link
Copy Markdown
Contributor

As of now, GenerateReqInput only allows text in the input; this PR enables specifying either text or input_ids as the request input. Supplementing input_ids allows more precise token operations in the input; and hopefully this simple patch won't affect other functionality.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why this is needed?

@lolipopshock lolipopshock Jun 3, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sry I just saw your comment. I think this piece of code just tries to make sure the token output is aligned with text output. If I remember correctly, when I tested last time, if the last token is EOS, the text output does not include the <|endoftext|> token while the <|endoftext|> token id will be included in output_tokens without this code. But perhaps I am hallucinating on this since I did the test a while ago...

@merrymercy
merrymercy force-pushed the shannons/allow-input-ids-in-generate branch 2 times, most recently from bc6703a to 48a78a5 Compare May 12, 2024 22:12
@merrymercy
merrymercy merged commit 04c0b21 into sgl-project:main May 12, 2024
@merrymercy

Copy link
Copy Markdown
Collaborator

@lolipopshock Thanks for the contribution. It is merged. I do not understand this comment (#363 (comment)) so I reverted it. Feel free to reopen

timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
shiyu7 pushed a commit to shiyu7/sglang that referenced this pull request Dec 26, 2025
efschu added a commit to efschu/htsglang that referenced this pull request Jul 31, 2026
…plan flips, actuator reality and control-loop constraints
efschu added a commit to efschu/htsglang that referenced this pull request Jul 31, 2026
…) + status matrix against the cuttable/dynamic/spillable/graphs standing order
efschu added a commit to efschu/htsglang that referenced this pull request Aug 1, 2026
…split sensing, stage tuple subsumes the sgl-project#287 commit path; classifier built observe-only with F0/F1 green (sgl-project#363 phase 1)
efschu added a commit to efschu/htsglang that referenced this pull request Aug 1, 2026
…t the between-tick boundary — F2 self-conditioning trap confirmed real and guarded, F3 noise-floor 2x band, F5 desync counted never raised, off by default (sgl-project#363 phase 2)
efschu added a commit to efschu/htsglang that referenced this pull request Aug 2, 2026
…ed classifier and both PASS — 147105 verdicts (3 per-rank files), zero desyncs, 36 transitions, prefill_heavy regime present for the first time, prefill_share max 1.000 where the broken attribution recorded 0.000 over 34954 boundaries (early prefill%-check passed before spending R2/R3); gate 3 NOT PASSED with a method finding: the fix made the share signals near-binary at window_rounds=64, and a pointwise A-vs-A band on a binary burst signal is 1 whenever bursts land on different boundary indices (41 vs 56 active) — the alignment was designed against barely-moving shares and the fix invalidated the statistic chosen for them; distributional re-formulation is a seconds-cheap desk item on four archived traces; in-window fix: readout ranks_seen union not max (fifth instrument-newer-than-check instance); spread_veto_pct 25 vs measured max 0.68 recorded not retuned (sgl-project#363/sgl-project#388)
efschu added a commit to efschu/htsglang that referenced this pull request Aug 2, 2026
…ignals

sgl-project#388 made the share signals near-binary at window_rounds=64 -- a window is
essentially all-prefill or all-decode -- so a pointwise A-vs-A band on them
is 1 whenever the two boots' bursts land on different boundary indices, which
they must: the same workload produced 41 active boundaries in one arm and 56
in the other. The gate-3 re-record came back ARMS_DISSIMILAR on all five
signals. The alignment was designed against traces in which the shares barely
moved; the fix that made them move invalidated the statistic chosen for them.
This has blocked three windows.

The statistic is now chosen PER SIGNAL against one criterion -- is the value
at a given active boundary reproducible across boots, or only its rate?

  prefill_share, decode_share, occupancy, queued_prompt_tokens
      distributional. Per-run summaries and band = |summary_a - summary_b|:
      peak (what reachability reads, and the signal-level band), the duty
      cycle at each constant's own value, p50/p75/p90 for shape. A constant
      clears when mean(duty_a, duty_b) > 2 x |duty_a - duty_b| -- the direct
      form of the question the gate asks, "would this signal cross the
      threshold consistently across boots?".
  rank_ms_spread_pct
      pointwise, kept. A within-boundary ratio across ranks, continuous, not
      a burst counter. Not blanket-replaced.

Both guards survive. UNDERPOWERED is unchanged in meaning. ARMS_DISSIMILAR
keeps the within-arm rule on the pointwise path and gains a distributional
form: the two runs' duty cycles, at the constants' own thresholds, differing
by more than a two-proportion difference of 2.576 standard errors. Evaluated
at those thresholds and nowhere else -- a sup-over-all-thresholds (KS) form
calls two steady arms at slightly different levels totally separated, and
that offset is a real reproducible bias that IS the band.

Also: rank_ms_spread_pct is now restricted to ACTIVE boundaries like the rest.
It goes stale rather than absent through an idle stretch, which sgl-project#388 recorded
as an omission rather than a claim the signal was clean. Its pointwise band on
the sgl-project#388 pair drops 0.6815 (the full observed range, ARMS_DISSIMILAR) -> 0.5813
against a within-arm swing of 0.675.

FALSIFIER (bands.py --falsify, three cases, each can fail):
  (i)   same duty cycle 10/40, bursts shifted 0-9 -> 20-29:
        OLD pointwise band 1.0 ARMS_DISSIMILAR (the false alarm of record,
        reproduced against the path that is still live for rank_ms_spread_pct)
        NEW band 0, duty 0.25 vs 0.25, OK, enter_prefill CLEARS
  (ii)  genuinely different duty cycles 10/40 vs 30/40:
        NEW duty 0.25 vs 0.75, z=4.47 > 2.576, ARMS_DISSIMILAR -- guard survives
  (iii) barely-moving signal, flat 0.50 vs 0.53:
        OLD band 0.03 OK; NEW band 0.03 OK -- regression pin

RE-ANALYSIS of all four archived arms, desk only, no cards
(2026-08-01_363_gate3_{a,b} and _363_gate3_388_{a,b}, reports written to
bands-report-distributional.{txt,json} in each arm-A directory):

  constant                       pre-388 old  pre-388 new  post-388 old  post-388 new
  enter_prefill                  UNREACHED    UNREACHED    ARMS_DISSIM   CLEARS
  enter_decode                   CLEARS       CLEARS       ARMS_DISSIM   CLEARS
  kv_ascend_mark                 UNREACHED    UNREACHED    UNREACHED     UNREACHED
  spread_veto_pct                UNREACHED    UNREACHED    UNREACHED     UNREACHED
  PRESTAGE_SINGLE_PROMPT_TOKENS  NO_GAP       CLEARS       ARMS_DISSIM   CLEARS

The pre-sgl-project#388 pair's blocking list is UNCHANGED (the regression pin on real
data: that pair is the barely-moving regime the pointwise statistic was built
for). The post-sgl-project#388 pair's blocking list goes 5 -> 2, and both survivors are
reachability findings already on the record. Identical on all three per-rank
files. Gate 3 still NOT PASSED: kv_ascend_mark 0.85 vs 0.1649 peak occupancy
(sgl-project#287's mark, information only) and spread_veto_pct 25 vs 0.68 peak.

NO THRESHOLD CONSTANT CHANGED. spread_veto_pct=25 against an observed range of
0.0018..0.679 (sgl-project#388 pair) and 0.0027..0.614 (pre-sgl-project#388 pair) is recorded, not
re-tuned -- calibration is a separate decision with its own evidence rules.
The two passing distributional verdicts are thin and reported as such:
enter_prefill clears by 1.29x, PRESTAGE by 1.14x. A duty cycle from 41 active
windows has a standard error near 0.07, which is most of what had to be
cleared; the fix is a busier workload, not a constant.

TESTS
  bands.py --smoke        SMOKE OK
  bands.py --falsify      FALSIFIER OK
  pytest test/registered/unit/managers/test_regime_bands.py
         test/registered/unit/managers/test_regime_gate_tools.py
                          47 passed
  pytest test/registered/unit/managers/
                          426 passed, 11 failed, 18 skipped -- all 11 failures
                          pre-existing on the base commit (test_prefill_adder 7,
                          test_rank_prefill_log 1, test_scheduler_chunked_req_gate 3),
                          verified by re-running those three files with this
                          change removed: same 11.
  ruff check / format     clean
  codespell               clean
efschu added a commit to efschu/htsglang that referenced this pull request Aug 2, 2026
… against one criterion (is the VALUE at a boundary reproducible across boots, or only its RATE) — shares/occupancy/queued go distributional (peak + duty cycle at each constant's own threshold + shape quantiles; clear = mean duty > 2x |duty delta|), rank_ms_spread stays pointwise (continuous within-boundary ratio) and is now active-boundary-restricted (the sgl-project#388-recorded omission); sup-Wasserstein rejected with reason (measures the binariness, not the noise: 0.71 on the real pair); both guards retained, ARMS_DISSIMILAR gains a two-proportion form evaluated AT the constants' thresholds only (KS-style sup would call two steady arms at offset levels totally separated — that offset IS the band, pinned); falsifier reproduces the false alarm of record against live code; four-trace re-analysis: post-sgl-project#388 blocking list 5 -> 2 (only reachability: kv_ascend_mark and spread_veto_pct scale findings), pre-sgl-project#388 pair UNCHANGED (regression pin on real data); the two new passes honestly thin (1.29x/1.14x, SE-dominated at 41 windows — busier workload is the fix, no constant touched) (sgl-project#363)
efschu added a commit to efschu/htsglang that referenced this pull request Aug 2, 2026
… smoked at the desk

The posten's duty 4 as a one-boot recipe (scripts/dual_group/chunking/):
arms come ONLY from per-job overrides -- chunked and unchunked share one
boot, one capture set, one pool state -- so enqueue's whitelist now carries
prefill_chunk (pinned by test: a silently dropped field costs the boot) and
the result row carries prefill_chunks/prefill_chunk_ms (present only when
the prefill ran chunked; default row unchanged).

probe_arms.py keeps three verdicts apart because they fail for different
reasons: STRUCTURE is integer arithmetic over the row and always exits
non-zero (a red is a broken vehicle); COHERENCE is the graded three-state
gate -- trajectory vs a reference SET of --ref-draws single-forward runs,
the set's own spread is the band, VOID when the reference disagrees from
position 0 (sgl-project#328/sgl-project#363 discipline; GDN prefill is not reproducible past ~109
tokens, so byte identity alone is never the criterion) -- and a red there
is a finding, not an abort (r404 rule); PRICE is reported and never judged
(ms/chunk per size, prefill rate, solo floors re-collected because the
instrument's grain changed). Chunk sizes 512/1024/2048 sit on the lane's
prefill tier keep-list, so each chunk replays a rung.

Desk smoke through run() against fake_lane_server.py, clean plus four
dirty arms, each firing its own branch: tail -> coherence red (strict rc
1), chunks/sum -> structure red (rc 1), band -> VOID with rc 0 (VOID fails
the claim, never the run). The degenerate single-chunk arm stays green
under the chunks plant and is pinned exactly so. 16 harness tests + 15
chunking tests green (31 total); gates are pure functions so the hermetic
suite runs them without a server. DESIGN_121 §15 documents the build, the
can-fail proofs, the §13.11-3 closure and the card posten still owed.
ruff/codespell/black clean on the python delta (the German design doc
keeps its repo-wide codespell state).
efschu added a commit to efschu/htsglang that referenced this pull request Aug 3, 2026
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 5, 2026
…ing claimed otherwise

regime_stages.planner_candidates(server_args, *, solve_fn=None) is the
production feed of the sgl-project#363 stage table. Its docstring stated "Production binds
it to the key solver (planner.key_solver.solve through planner.solver_api)".
Nothing binds it, under any configuration: the one production caller,
regime_runtime.build_regime_stage_table, calls it as
planner_candidates(server_args) with the argument omitted, so the
`solve_fn is None` branch is the only branch production ever takes. The stage
table therefore permanently holds the booted stage alone and act mode has
nothing to select between -- not broken, UNFED.

Why it stayed invisible is the interesting half. The seam has three passing
tests, all injecting a stub -- the exact shape AUDIT_421 section 1 warns about
("the tests called the feature directly") -- and the runtime already reports
the absence honestly in its note ("no planner feed bound: the stage table holds
the booted stage only"). So the runtime told the truth while the docstring
asserted the opposite, and a reader who consulted either alone came away with a
consistent picture, wrong in the docstring's case.

This commit does not bind the seam, because binding is not a two-line call:
key_solver.solve takes plan_inputs, a base plan, per-rank budgets and RigRates
-- a card probe and a measured rate set -- and a binding must also map a
SolverAnswer back onto a Stage, which does not exist yet. Claiming it in a
docstring was free; building it is not, and pretending otherwise is what
produced this finding in the first place.

What this commit does:
- corrects the docstring to state the seam is UNBOUND, what binding requires,
  and that the runtime note is the honest report until then;
- adds a RATCHET test that reads the production call site with
  inspect.getsource AND the docstring, so the wiring and the prose cannot move
  apart again;
- records the finding and its general lesson in AUDIT_421_UNWIRED section B.9:
  a docstring describing its own production wiring is an unchecked assertion
  about a call site somewhere else, so test the call site instead -- and when a
  seam's default branch exists to report an absence, that branch being the only
  reachable one is the thing to detect.

Tests (CUDA_VISIBLE_DEVICES=99, hermetic, no GPU, no server):
  PYTHONPATH=python pytest test/registered/unit/managers/test_regime_act.py -q
  -> 60 passed, 2 warnings in 6.25s

CAN-FAIL PROVEN: restoring the "Production binds it" wording turns
test_the_seam_is_unbound_in_production red ("AssertionError: 'UNBOUND' not
found in ..."). Passing any solve_fn at the production call site turns it red
too, which is the ratchet's purpose: whoever binds the seam must update this
test and the docstring in the same commit.

Handoff: /spinning/spill-night-20260804/handoffs/TICKET_363_S8_stage_feed.md --
nothing to run in tonight's GPU window; it lists what binding requires, notes
that most of the input assembly already exists for the booted stage, and gives
a can-fail criterion that distinguishes "bound but the solver had nothing" from
"not actually bound".

ruff check: no new findings. ruff format: clean on all added lines.
codespell: clean.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 5, 2026
…and a five-cut list

Desk analysis only, no build, as scoped. docs/dev/ANALYSE_553_elastic_coresidence.md.

What the four named building blocks actually are, read from the code rather
than from their titles:

- sgl-project#330 VRAM dial: a REAL mechanism, and its decisive property for sgl-project#553 is that
  store_bound_rows is a LIFETIME bound baked into captured graphs. So the dial
  has a FREE BAND (shrink to any floor, re-grow to the boot bound) and a HARD
  WALL above it. The free band is exactly where CUDA-graph compatibility is
  preserved.
- sgl-project#364 GDN slot ladder: a real, executing hot/cold mover, and graph-neutral by
  construction (it moves state between slots, not geometry). It is the
  existence proof that a hot/cold event need not touch capture, and its
  inventory seam -- the owner enumerates its live set, consumers never read a
  container directly -- is the pattern the other consumers need (sgl-project#551).
- sgl-project#287 KV pressure ladder: PLANNER ONLY. Seventeen NotImplementedError sites;
  the docstring says so plainly. But the ordering invariants are already
  enforced in code and the relief rungs reference existing features BY NAME, so
  the relief half can be made to execute by delegation without new mechanism.
- sgl-project#286 register: the right vocabulary, but exactly one ledger exists and it is
  wired to the translator. There is no generic tenant to raise an event
  against.

The pattern across the event table: both directions are largely built, and
what is missing is ARBITRATION. Two registries exist (dial participants, sgl-project#286
asset classes) and neither can see the other, so "free 4 GiB for the video
tenant" has no addressee.

Cut list, ordered so each cut is provable alone and no cut before the last
touches capture: (1) one registry or an explicit bridge; (2) a generic tenant
mover factored out of AudioAssetLedger; (3) make sgl-project#287's RELIEF rungs execute by
delegation -- the largest block of stubs, and it never approaches the graph
wall because relief rungs are declared "no KV layout change"; (4) the
arbitration policy on top; (5) LAST and only with the rig, cross the graph wall
via the per-rung pre-captured graphs sgl-project#287 already specifies, with cold rungs
parked as register class graph_rungs.

Graph compatibility is treated as the target state throughout, per directive:
every cut states its effect on graph state, and cut 5 carries the explicit
route back to full coverage. Until cut 5 lands, sgl-project#553 must state its band --
"elastic within the boot capture bound" -- rather than implying unlimited
elasticity.

Instrumentation named honestly: SGLANG_KVSO_TICK_TRACE=1 (throttled per-session
regulator trace: effective interval, measured tick_cost, binding headroom
ratio, host-tail size; pure logging, no control effect). The analysis states
what it is NOT -- a regulator trace, not a per-phase breakdown of device time --
and proposes no measurement it has not checked exists.

One decision deliberately left open and named as such: whether sgl-project#553 owns the
arbitration policy or whether it belongs to sgl-project#363. That fork needs the sgl-project#363
stage feed bound first, since an arbitration policy fed by a table holding one
stage would have nothing to choose between -- the same failure sgl-project#363/S8
documents one level up.

codespell: clean.
efschu added a commit to efschu/htsglang that referenced this pull request Aug 5, 2026
… in-tree

C1 (results/RESULTS_C1_hibernate.md), the full park -> process exit -> restore
round trip on hardware, TP=3 uneven, GGUF Q3_K_M:

- POST /hibernate -> {"message":"hibernate: weights parked to disk."}
- 1202 params parked per rank on all 3 ranks, 15 GiB image, manifest written.
  Every per-rank artifact is keyed by the card's NVML UUID, which is the
  identity mechanism itself rather than a naming convention.
- Restore: "matching manifest found ... -> load_format='hibernate' (fast
  restore)", 1202 params restored per rank.
- Cold 249 s -> restore 193 s = 1.29x. Recorded as measured and deliberately
  NOT compared against the catalog's 50s->8-14s, which is a different case.
- Post-restore greedy smoke coherent.

C3 PASS with it: the fast-restore path was reached BY NAME, which is the sgl-project#499/
sgl-project#520 signal. Only the MATCH branch is exercised; a moved card is untested.

C2 NOT VERIFIED (no sparse-write clause observed, no dense-vs-sparse sha256).
Worth noting the image lands on ZFS, where DESIGN_456 already measured the byte
win as exactly zero because compression had taken it.

Also lands the window's combination matrix in docs/dev/ as the durable record.
Its final tally: 8 cells passed on hardware, 7 decided at the desk without a
GPU, and the rest carried as explicitly named open states rather than silence.

Three findings change what "it works" means for this feature family, and all
three are code-cited in the matrix:

1. The KV pressure ladder has NO actuator on the production flag set --
   wired_relief_features() returns empty unless --kv-reshard-vectors,
   --enable-kv-session-offload or --max-running-requests-ceiling is set, and
   production sets none. Flips are still logged; they move nothing, and the
   trailing field says "no actuator declared". Confirmed in both directions:
   with kvso wired, the same rung flips with "actuator WIRED: admission limit
   -> 1 (changed=True)".
2. Byte-equality of generated text is not a valid instrument on this rig: two
   IDENTICAL loads against one process, zero spills, already give
   identical=0 diverged=6. Correctness on the spill path needs decode-class
   bands, not byte identity.
3. sgl-project#363 act mode has zero flip targets by construction (planner_candidates is
   called without solve_fn), so it cannot actuate regardless of flags.

Serving restored afterwards: pgid 63368, health 200 after 90 s, completion
smoke correct, corridor 2260/4403/2778 MiB free. Locks released, holder handed
back to a SERVING line.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 5, 2026
Design only, no code. Records the mandate plus all three addenda as
requirements with falsifiers, and fixes the authority model: the planner
decides, the ledger is the denominator, every existing mechanism becomes a
sensor or an actuator. A slice that reimplements a carrier instead of driving
it has failed the mandate.

Addendum 3 becomes R6 and R7, both stated as error classes the design must be
structurally unable to commit rather than behaviours it should prefer:

R6 -- a state change re-SOLVES the cut (layer/TP split, draft placement,
KV/token vectors, phase layouts) under the new usage profile. Pool-only
squeezing is one candidate, not the search space. The planner may still choose
pool-only, but that must be its cost calculation under R5, never a structural
inability. F6 asserts on the CANDIDATE SET as well as the choice, because a
planner that picked correctly from a set of one is not implementing this; F6b
is the mirror, where pool-only wins on horizon and the planner must record
which re-cut it rejected and why.

R7 -- evacuation heat is PHASE-DEPENDENT, not static per item class. During
prefill everything decode-owned is cold and goes first; during decode the
ranking inverts. F7 is deliberately a PAIR (prefill-burst ranks decode graphs
below KV, decode-burst inverts) because a static ranking passes either case
alone. F7b adds imminence: at a prefill burst whose successor is decode, decode
graphs must NOT be evacuated -- separating 'phase-dependent' from 'reacts to
the instantaneous phase', which is a different and worse thing.

Carriers verified present in code before being built on: sgl-project#297 kv_ladder_auto,
sgl-project#485 uneven_perf, sgl-project#363 regime_act/regime_stages, sgl-project#261 scheduler:5063. Notably
regime_stages ALREADY classifies REGIME_PREFILL_HEAVY/REGIME_DECODE_HEAVY, so
R7 consumes that signal rather than adding a second phase detector -- a second
detector would be a new source of disagreement about what phase it is, the same
defect class as a second VRAM constant.

Slices 2-4 (enumeration, objective+movement cost, phase-dependent ranking) are
desk-provable in full; only slice 5 needs a card.

Open and named, not glossed: sgl-project#551 elastic co-residency has NO marker in
python/sglang/srt (only ANALYSE_553) and must be resolved before slice 5 plans
to drive it; R4's objective is marked CONFIRM because throughput and latency
can disagree and the design must not pick for the user; re-cut cost is not
measurable today and slice 3 must measure it or make it a fingerprinted
calibrated term, never a literal; the pressure ladder's autonomy overlaps the
planner's authority and slice 5 must resolve it or the two will fight over the
same pool under load.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 5, 2026
…ot per-flip

User correction, pinned hard because it is a repeat-forgotten class. The first
draft priced every graph-addressed knob at 3-6 s recapture and therefore put
all of them on the slow side of the tick/regime line. That is wrong: the stack
can pre-capture N stages and park the inactive ones FULL-CAPTURED in host RAM,
so a flip back to an already-captured stage rebuilds nothing and costs only the
graph-state RESTORE -- observed 40-85 ms, two orders of magnitude cheaper.

Carriers verified in tree rather than taken on report:
  * sgl-project#93 physical aliasing/remap keeps VAs stable across the park
    (offload_register.py, offload_movement.py, input_buffers.py,
    runtime_context.py) -- this is what leaves a parked capture valid;
  * sgl-project#286 offload register ALREADY lists graph_rungs as a parkable item class
    (offload_register.py:17 "cold capture rungs of the K-/algo ladder", class
    table at :114) -- confirmed, so this is drive-not-build;
  * sgl-project#89 hibernate for host-side staging;
  * sgl-project#464 has NO marker in python/sglang/srt -- it is a target, not a mechanism,
    so restore is priced at the observed band and any sgl-project#464 gain is upside the
    design must not assume.

R9's classification gains two middle classes: restore-flippable (graph-
addressed but target already captured and parked -- priced at restore, possibly
coarse-tick) and capture-bound (target never captured -- 3-6 s, one-time). The
criterion is unchanged in form; what changed is that "graph-addressed" no
longer implies "expensive", it implies "expensive ONCE".

R9(iii): the planner pre-captures its own sgl-project#363 stair at boot or lazily on first
entry, then parks. First entry is a priced one-time investment scheduled
deliberately (low load), never a tax paid at the moment a flip is wanted -- a
design that pays capture at flip time has turned a startup cost into a serving
cost.

R9(iv) + R1: holding N stages is nearly VRAM-free while parked (physical pages
returned via the sgl-project#330 VMM dial, VA reservation remains) but NOT free in host
RAM, so R1 now extends to host bytes and the ledger must carry the parked
stages' host footprint as a term. A stack parking eight stages without that
term runs exactly the unledgered-demand defect sgl-project#582 removed from VRAM, one tier
down. Falsifier R1b: parking N stages must move the host term by N x per-stage.

R5 splits its graph cost into two terms (capture one-time, restore per-flip); a
single "graph cost" line is wrong by ~2 orders of magnitude in one direction or
the other. F5b: a gain against a 60 ms restore must be accepted even at short
horizon; refusing it means a restore was priced as a capture.

F9d (runtime) asserts on the ABSENCE of a recapture rather than on elapsed
time, since a fast machine can hide a recapture inside a generous threshold.
F9e (modelling) is the more dangerous error and gets its own test: a model that
prices an already-captured flip at capture cost never misbehaves visibly, it
just silently refuses flips that were cheap, so the gain is never observed and
nothing surfaces the mistake.

FOUND IN TREE, same error, today: registry/rungs.py:93-95 prices the WARM rung
at "3-6 s / graph recapture" -- a blanket recapture tax on promotion. Correct
for a never-captured stage, wrong as a blanket price. Slice 4b must split it or
the planner inherits the very tax this correction removes.

Slice plan gains 4b (pricing split + WARM rung fix, desk-provable) and 4c
(pre-capture/park + host-RAM term). 4c is the one addition needing a card, and
it is cheap: capture two stages, park one, flip, time the restore.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 5, 2026
Seventh addendum, and the first requirement here carrying a MEASURED cost
rather than a hypothetical one: production showed all three ranks waiting 1.2 s+
on a 74k-cached prefill, with collective wait running 2-3x compute.

R12 is R6 applied to the one vector still frozen at boot.

(a) At LOW occupancy the planner selects the PERFORMANCE-optimal vector -- KV
concentrated so DCP prefix-gathers are minimal. Not a micro-optimisation: the
gather share grows with cached context, so at low fill the spread vector buys
capacity nobody is using and pays for it in a collective floor on every
prefill. sgl-project#588 decomposes the measurement; R12 is what the planner does with it.

(b) The shift is CONTINUOUS and BIDIRECTIONAL. This generalises sgl-project#287's pressure
ladder, and the generalisation IS the removal of its trigger-on-pressure-only
design: a ladder that fires only when memory gets tight can never take the
low-fill performance win, because low fill is not a pressure event. Refusing
the return leg is the "surplus sits idle" failure in vector form -- capacity
released, but the performance it was blocking never reclaimed.

(c) Carriers verified in tree: sgl-project#287 ladder stages; sgl-project#297 phase-boundary KV
resharding, delta move measured <1 s (DESIGN_297_kv_resharding.md:83, and the
TEIL_HOT rung in registry/rungs.py prices it "<1 s, one dial re-raise");
sgl-project#363/sgl-project#578 regime controller as actuator now that slice 0 binds its feed.
Priced movement-bound under R11's gates, and R11e is exactly the comparison
that matters here: a sub-second reshard removing a 1.2 s per-prefill floor pays
for itself in two prefills.

F12a (near-empty + long prefix -> concentrated, gather share must drop), F12b
(past the capacity knee -> spread), F12c (on drain -> move BACK). F12c is the
one a pressure-only design fails while passing F12b, which is why the falsifier
is again a pair, as with F4 and F7.

Slice plan gains 4e (both legs; hermetic F12a/b/c, GPU gate is the gather-share
drop under sgl-project#588).
efschu added a commit to efschu/htsglang that referenced this pull request Aug 9, 2026
…layout

Route A gave one instance two layouts but no policy, so a production
server rested in whatever layout the last manual POST /phase_flip left it
in -- serving long-prompt prefills from the TP layout indefinitely.
This adds the policy that chooses.

managers/phase_policy.py is the whole decision, as a pure function.
Rules: flip TP->PP when pending uncomputed prefill exceeds the break-even
N; flip PP->TP when the prefill queue drains to decode-only (speculation
and the decode CUDA graphs exist only in TP); return to the resting
layout after an idle dwell. N = C / (1/X - 1/P) from the measured flip
cost and the two prefill throughputs, and break_even_tokens REFUSES when
X >= P rather than emitting a negative threshold -- if PP is not the
faster prefill layout, Route A's premise is gone and that must be said,
not papered over. An independent minimum-dwell timer bounds thrash,
which N alone cannot do under bursty arrivals.

THE RESTING STATE IS PP. An idle flip is free; a flip inside a request's
TTFT is not, and every request begins with prefill. Resting in PP means a
long prompt hitting a quiet server gets PP-class prefill at zero flip
cost. HTSGLANG_PHASE_IDLE_STATE=prefill|decode makes it configurable;
TP-resting only wins for short-prompt/short-output traffic, whose
prefills are too small to repay a flip anyway and which therefore run in
whatever layout is current.

WHY THE POLICY EMITS A REQUEST INSTEAD OF ARMING. Arming is replicated:
the flip commits only where every rank is armed, and an unarmed rank
performs no collective at all, so a rank arming alone parks its requests
and blocks in a reduction its peers never enter -- bounded only by
barlink liveness, i.e. a tree kill. At pp_size=3/tp_size=1 nothing
establishes that agreement: the sgl-project#363 observer's cross-rank interlocks are
no-ops at tp_size=1 and the PP round counters are measured to diverge.
So only the request-origin rank decides, and its verdict travels as the
same control request the RPC path produces, through the same
distribution already proven on metal -- the P2P stage chain in the PP
phase, the TP broadcast in the TP phase (the cutover swaps ps, so rank 0
is the origin either way). One seam in recv_requests serves both.

Not routed through the sgl-project#363 regime controller, deliberately: its act
mode is refused at parse time without four-item gate evidence AND
requires a KV-reshard or VRAM-dial actuator (it does not count the phase
flip as one); its stage table has zero flip targets on every boot, so the
phase axis is never consulted; and under event_loop_pp the flip runtime
is built after the actuator, so that axis binds unwired. sgl-project#363 stays the
general answer; this actuates one axis and nothing else.

--phase-flip-policy defaults to manual, so every existing boot is
unchanged, and auto without --enable-phase-flip is refused rather than
ignored.

Tests: 312 passed in the sgl-project#631 flip family (274 before this change, +33
phase policy, +5 server-arg), CPU-only, CUDA_VISIBLE_DEVICES=99.
Can-fail proven for all four falsifiers by mutation: dropping the
threshold trips the thrash falsifier, disabling the dwell trips the
dwell test, disabling the drain rule trips the drain falsifier, and
disabling the injection trips the receiver test. GPU acceptance is the
next step and is NOT claimed here.
efschu added a commit to efschu/htsglang that referenced this pull request Aug 12, 2026
 integration line

Four add/add conflicts. The branch is an OLDER SNAPSHOT of the same audit, and
the governing fact for all four files is that its central claims have since
been overtaken: it asserts that several features are UNWIRED, and they are
wired now.

test/registered/unit/test_unwired_features_421.py -- the conflicted TEST file,
resolved so no coverage is lost. The branch carries four pin classes
(TestKvPressureLadderAutoIsUnreachable, TestOffloadRegisterProfileIsUnreachable,
TestColdTierShmIsUnreachable, TestMemTierRegistryHasNoConsumers) that the
integration line deliberately RETIRED, each replaced by a named positive test
that asserts the wiring and pins the call site. Resurrecting them would not
have added coverage, it would have re-asserted four absences that no longer
hold. Verified in the tree rather than taken on the retirement notes' word:
`cold_tier_fetch` is imported from production at
`layers/moe/fused_moe_triton/layer.py:1447` and `layers/moe/expert_offload.py:2711`,
and `memtier.registry`/`memtier.tiers` at
`model_executor/short_term_offload_register.py:113-114`. All five replacement
test files exist on disk. So the branch's 104 unique lines here are superseded
content, not dropped assertions.

Corrected while resolving: the F4 retirement note cited its replacement at
`test/registered/unit/moe/test_cold_tier_wiring_394.py`; the file is at
`test/registered/unit/layers/moe/test_cold_tier_wiring_394.py`.

docs/dev/AUDIT_421_UNWIRED.md (5 hunks), scripts/dev/audit_421/README.md (1)
and scripts/dev/audit_421/detC.py (6) -- resolved hunk by hunk, not by blanket
side-selection, and the branch side was found superseded in every one. detC.py
in particular: the integration side adds sys.path bootstrapping so the script
finds its sibling astlib.py, memoises four whole-tree derivations per Index,
and flushes progress to stderr. Same computed results, so no behavioural
divergence to adjudicate. The README's discarded sentence ("trust the STRONG
tier") is contradicted by later evidence the integration line records, and its
numeric claim survives verbatim at AUDIT_421_UNWIRED.md:317 -- checked before
discarding.

One stale citation corrected in the audit doc, section B.9: it claimed
present-tense that the sgl-project#363/S8 planner `solve_fn` seam is unbound and cited a
ratchet test `TestPlannerFeed::test_the_seam_is_unbound_in_production`. Task
sgl-project#578 BOUND that seam -- `managers/regime_runtime.py:912` now passes
`solve_fn=_planner_solve_fn(scheduler)` -- and the cited test does not exist;
it was inverted into
`test_regime_act.py::TestPlannerFeed::test_the_seam_is_bound_and_refuses_without_measurement`.
Both facts re-verified against this tree. The historical narration is kept and
a "Resolution (task sgl-project#578)" paragraph appended, matching how the same document
already handles F4 and F6.

Two inconsistencies noted and deliberately NOT edited, because neither is a
merge-side disagreement and neither number can be re-derived from the tree:
the memoisation speed-up is quoted as ~35 min in the audit and README but
~50 min in detC.py's own comment; and B.8 says "three of the eight pins are
retired" while naming four classes.

Tests: test_unwired_features_421.py 2 passed. sgl-project#631 flip family 1095 passed /
0 failed. detC.py py_compile OK, ruff clean.
efschu added a commit to efschu/htsglang that referenced this pull request Aug 12, 2026
…actuator (flag-gated OFF)

Merges feat/regime-stage-actuator-363 (b2f0a74) into the R6 batch.
New modules regime_ms_clock.py and regime_admission.py; --regime-stage-clock
defaults False, so the default path is unchanged.

Zero conflicts (path-overlap check returned empty against both other R6
branches before the merge).

Suite, same-environment baseline worktree /spinning/wt-merge-r6-base frozen
at 598f570, pytest --color=no, CUDA_VISIBLE_DEVICES=99:

  suite            base                          after step 2
  flip family      1116 passed                   1116 passed
  unit/managers    9F 1286P 18S                  9F 1357P 18S  (+71 new)
  unit/mem_ledger  1F 343P                       1F 359P
  unit/model_exec  15F 588P                      15F 594P
  unit/server_args 615P                          615P
  unit/turnkey     116P                          116P
  unit/utils       46F 331P 4S                   46F 331P 4S

Every failure count identical to baseline on both sides; the pass deltas are
exactly the new tests. Logs: /spinning/evidence-631/merge-r6/
efschu added a commit to efschu/htsglang that referenced this pull request Aug 12, 2026
…le-local-ref trap

Records the R6 batch: val/r5-residuals (21f0733), sgl-project#363 intra-phase stage
actuator (b2f0a74, flag-gated OFF), and chore/release-chain-prep
(ca15df7). All three merges conflict-free, as predicted by the pre-merge
path-overlap check (33 files, no file touched by two branches).

Suite against the frozen baseline worktree at 598f570, pytest --color=no,
CUDA_VISIBLE_DEVICES=99, every failure count identical at every step:

  flip family      1116 passed -> 1116 passed
  unit/managers    9F 1286P 18S -> 9F 1357P 18S
  unit/mem_ledger  1F 343P -> 1F 359P
  unit/model_exec  15F 588P -> 15F 594P
  unit/server_args 615P -> 615P
  unit/turnkey     116P -> 116P
  unit/utils       46F 331P 4S -> 46F 348P 4S
  unit/docker      (absent) -> 4 passed

+114 tests, 0 new failures. ruff 456 -> 456 (per-file identical, zero new);
codespell 4 hits, all four proven pre-existing on the baseline.

Register union verified: CONTRADICTIONS_REGISTER.md 0 deletions, 63 additions,
C-entries 7 -> 9 (C25, C26), pre-existing headings byte-identical.

Errors first in the document: the local feat/route-a-631 ref is two merge
rounds stale AND checked out elsewhere, so every merge source and push target
here was named as origin/... explicitly; R5's flip-family log was not captured
with --color=no; unit/turnkey's flat count is benign and proven so.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 14, 2026
…files rather than inferred

The preflight was pointed at both regime-gate-evidence.json files that exist on
this box. Both are CLOSED and both are missing the same two items,
f3_bands_measured and f4_card_comparison, while carrying gates 1 and 2 with
sources. So act would be refused right now on either file, which is what F1
predicted and is now a measurement rather than a reading of two runsheets.

Also recorded: /spinning/evidence-363/ does not exist, so the path in the
preflight example is a placeholder and the shift has to point it at the real
file. Leaving an invented path in a runsheet is how a copy-paste step fails at
2 a.m. against a file nobody ever created.
efschu added a commit to efschu/htsglang that referenced this pull request Aug 14, 2026
efschu added a commit to efschu/htsglang that referenced this pull request Aug 14, 2026
… two arms that do not sweep it

Docs-only, on measured code. barlink_matrix.py and registry/ledger.py already
use per-process staging, so the correct pattern was in the tree twice while
the census used the shared one. ~16 further sites unaudited: the question per
site is whether two PROCESSES can derive the same path, which degenerate
pp_rank under pure TP makes happen unintentionally.

Also records that unit/planner is not a canonical arm (the new regression test
does not run in the nine-arm sweep; run explicitly at 2366P 123S with 2
failures also present on the untouched R11 tree).
efschu added a commit to efschu/htsglang that referenced this pull request Aug 14, 2026
…te could not run

Q2 is decided on the ALLOCATED column as the analysis specified: across every
weights_refill stage, free drops and allocated moves 0 MiB -- max |d_alloc| = 0
over 594 seam-census flips on two different cuts. S1 and S2 both require
allocated to rise. S3 (the VMM commit in arena_carrier.set_active_prefix) is the
mechanism, and Q1 independently shows the arena IS such a reservation:
allocated exceeds the card's physical total on all three ranks, and
PYTORCH_CUDA_ALLOC_CONF is unset, so expandable-segments is not the explanation
the analysis offered.

P2 is the result that changes the ticket. --pp-solve-cut could not execute at
all -- three defects, two fixed here red-first, the third a card-rate
measurement pass that nothing in the tree produces (sgl-project#584's shape, the same root
that failed sgl-project#363). Fed borrowed measured rates it admits 37,14,13, not the
40,12,12 two windows were spent on, so the +25.5% is retired per section 6a.
Fed the M0 census instead it admits nothing at all -- the solve has a free
parameter (which boot's census calibrates it) that was not being reported.

W1 certified that cut CLEAN at +2560 MiB with 0 corridor samples below 1024
over 16473 ticks per card, and remains NOT CERTIFIED (C2): one window cannot
bound a variance. That is the pre-registered answer, not a shortfall.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 14, 2026
…erning answer is a refusal

First execution of --pp-solve-cut end-to-end through the wired handler on this
rig. The pass ran on all three cards and put measured rates on disk keyed by
UUID; the gate then answered, and under RUNSHEET 6b the answer is a REFUSAL,
which per 5.1b outcome (3) IS the result. No W2 window was owed and none ran.

MEASURED (m584/card_rates_by_uuid.json):
  5090 GPU-31d7ef41 0A:00.0  203.57 TFLOPS  1661.7 GB/s
  3080 GPU-5c648f96 05:00.0   51.14 TFLOPS   716.6 GB/s
  3080 GPU-62dbbae1 0B:00.0   50.81 TFLOPS   717.4 GB/s
All THROTTLED, correctly: this rig runs deliberate power caps (200/320 W,
400/600 W), so these ARE its operating rates.

THE BORROWED RATES WERE STALE. Against s50's numbers that R12 injected by hand,
bandwidth reproduces to the decimal (3080 717.4 vs 717.4) while GEMM does not
(5090 -12.2 %, 3080 -22.5 %) -- the direction and rough magnitude of the
2026-08-05 power-target reduction. The 37,14,13 admission rested on
pre-power-cap compute rates. A second, independent reason the old numbers do
not describe this rig, alongside 6a's change-of-cut retirement.

P2, pool 280000, budget 31400,19300,19300:
  M0 (most demanding)  REFUSED     M1  ADMITS 37,14,13     W1  ADMITS 37,14,13
The admitted cut is UNCHANGED at 37,14,13 despite the -12/-22 % rate move, so
on this shape the choice is driven by memory feasibility, not compute balance.
6b takes the most demanding census: REFUSAL. Independently, the M1/W1-admitted
cut fails C2' against the pooled-worst transient by -3643.3 MiB, so the refusal
does not depend on which route a reader prefers.

LEVER ARITHMETIC, swept against the REAL census rather than a fixture:
  L1 --rank-gpu-memory-mib   EXHAUSTED BY PHYSICS. Refuses at the 5090's entire
     NVML total (32607), and refuses even with every card at full nameplate
     (32607,20480,20480): 39968 MiB needed against 48684 usable. The aggregate
     FITS by 8716 MiB and the solve still fails -- it is a CONTIGUITY/PACKING
     result, which R12 suspected and this measures. There is no budget left.
  L3 --max-total-tokens      CONFIRMED NOT A LEVER, now on metal: 280000 ->
     20000, every one refused. 5.1a asserted this from a fixture proxy.
  L2 seam                    THE ONLY RECOVERING LEVER. Threshold ~515 MiB
     against the measured 1838 -- a 1323 MiB / 72 % reduction -- and it then
     selects a THIRD cut, 29,19,16. Independently close to 5.1a's fixture-
     derived "~500 MiB". Any throughput number would again be retired.

sgl-project#363 FLIP TARGETS, counted (bonus, not the protocol):
  card probe now visible to the planner's own lookup   YES, 3 cards with rates
  flip targets from planner candidates                 0
  ... with per-stage measurements present              2 stages, 1 flip target
The card-rate half CLEARS sgl-project#363's blocker-one precondition -- the
PlannerFeedUnavailable('no card probe on disk') every rank logged is gone -- and
does NOT produce flip targets, because build_stage_table refuses a
solved-but-unmeasured candidate (sgl-project#578/sgl-project#360). The sgl-project#363 verdict predicted this
hermetically; it is now confirmed with a real probe on disk. The remaining gap
is the OTHER half of sgl-project#584's pass: per-stage A-vs-A gain, band and instrumented
flip cost. Q2b proves the machinery works the moment those exist.

Evidence /spinning/evidence-631/m584/: card_rate_pass.log, card_library.json,
card_rates_by_uuid.json, nvml_identity.csv, p2_measured_rates.txt,
p2_levers_m0.txt, p2_levers_binding_fine.txt, p2_levers_ceiling.txt,
p2_seam_lever_m0.txt, p2_seam_threshold.txt, check_363_flip_targets.txt, and
the drivers that produced each.
efschu added a commit to efschu/htsglang that referenced this pull request Aug 14, 2026
…measurement canon and flip cost in the act rule
efschu added a commit to efschu/htsglang that referenced this pull request Aug 14, 2026
…forces it

spread_veto_pct = 25 blocked gate 3 for four consecutive recordings with the
verdict UNREACHED, and the reason is not that the rig is balanced. No runtime
code reads it: grep -rn 'spread_veto_pct' python/ returns nothing, and the only
act-mode interlock on that signal vetoes on rank_ms_spread_pct is None -- the
one-boundary-stale veto -- and never compares a magnitude to 25. A verdict that
cannot move with the workload is a finding about the gate, not about the rig.

Retired per operator mandate, structurally rather than by name: a Constant now
carries runtime_site ('module:SYMBOL'), and a bad verdict blocks only if that
symbol resolves. Retired constants are still judged and still reported -- new
'retired'/'retired_verdicts' report keys and an evidence-string clause -- so the
reachability history keeps accumulating for a shift that later wires the veto.

PRESTAGE_SINGLE_PROMPT_TOKENS = 8192 is a second orphan, found by the test
written for the first rather than asserted. It has been CLEARING, so it blocked
nothing today, but a quieter workload would have made it UNREACHED and blocked
the gate for the same non-reason. Retired on the same ground.

Red-first: the 9 pins failed before the change and pass after. Both detectors
are proven able to fail (bogus symbol, drifted value), the value check catches
gate-vs-runtime drift, and one test asserts a wired constant inside its own band
still blocks -- retiring the orphan must not become retiring the gate.

Evidence: docs/dev/363/TICKET_363_WINDOW_VERDICT.md section 3.
Tests: 9 passed (new file); test_regime_bands.py + test_regime_gate_tools.py
47 passed, unchanged.
efschu added a commit to efschu/htsglang that referenced this pull request Aug 14, 2026
…and here is why

Three defects, each found by EXECUTING the runsheet rather than reading it, and
none of them the one the window went looking for.

1. Rate freshness could not date two of three cards. Fixed on the line
   (42484da) and confirmed on metal.

2. THE ACTUATOR CRASHES THE SERVER AND BREAKS THE CORRIDOR WHEN IT FIRES.
   kv_reshard.py:746 _exchange allocates its receive buffer with no headroom
   check. Reproduced twice: 616 MiB against 550 MiB free under load, and
   758 MiB against 256 MiB free on a DRAINED pool -- so it is deterministic,
   not a load race, and draining makes it worse. Both times it drove two cards
   through the 1024 MiB corridor floor (gpu2 to 229 then 463 MiB) at the same
   instant, seven seconds before the OOM. Not fixed here on purpose: the guard
   has to join on_round's group-wide MIN reduction beside fit_ok, never the
   allocation site, or an OOM becomes the desync the module's own error text
   calls the sgl-project#94/sgl-project#194/sgl-project#259 hang.

3. NO RANK CAN FIND THE CARD PROBE. The sgl-project#513 keyed lookup matches on the full
   card inventory; every scheduler rank runs a narrowed device view. Proven in
   three commands: CVD=0,1,2 FOUND, CVD=1 NONE, CVD=0 NONE. So the planner feed
   is unavailable on ANY real multi-rank boot and the stage table is one stage
   with no targets. This, not the missing per-stage measurements, is why sgl-project#363's
   flip targets are 0 -- m584's prediction of '2 stages, 1 flip target' was
   made at the desk with an injected feed.

VERDICT, honestly: the decision rule was NOT evaluated. 0 of 42306 verdict rows
carry signal_pct, so this is not 'act correctly refused to flip' -- that would
need a signal below a threshold, and no signal was ever computed. A1 fails, A3
is unanswerable, A4 fails on B3/B3b (defect 2 firing), A5 passes, A2/A6 are
vacuous.

What the window did earn: gate 1 passes measured (70740 verdicts, 3 ranks,
desyncs 0); the A-vs-A floor is 1.48 %, below the 5 % watermark trigger, so
nothing was re-tuned; and gate 3's blocking list is down to ONE entry after
R13's retirement -- kv_ascend_mark, UNREACHED at peak 0.841765 against 0.85,
reproduced to four decimals on both arms. 1.0 % from reachable for the first
time.

Also recorded: the runsheet's own reserve breaches the corridor on this rig,
and its driver profile cannot feed its own analysis command. Both cost this
window a boot each.

Gate evidence returned to its single measured entry; no bootstrap left in
place. Serving restored and verified with a real generation (MERIDIAN41,
completion_tokens=6, finish=stop), not a health 200.

Suites: base ac0d1f3 -> tip 7b950dd -> tip2 2fe6ae0, eleven arms each,
all ten failure sets identical by name at every step. +99 then +11 tests, zero
new failures.
efschu added a commit to efschu/htsglang that referenced this pull request Aug 14, 2026
…empty canon

The STOP was not inferred from the crash. stage_measure_pass was run against
B3b's traces and refused on its own terms -- 'no summary line ... the trace
supports so far, not a measurement' -- and --show reports 0 record(s). The
window's durable output on this axis is zero records, stated by the store.
efschu pushed a commit to efschu/htsglang that referenced this pull request Aug 16, 2026
… arena ladder, and that reprices it

The actuator survey came back and it changes the design, so the design changes
rather than the finding being reinterpreted.

## R1: there is no runtime cross-rank weight mover, and the absence is deliberate

regime_stages.py:100 defines REACH_NO_WEIGHT_MOVER -- "no runtime actuator
moves weights, switching arms needs a restart (sgl-project#354/sgl-project#357)". StagePlan.reachable
(:156) excludes it, so such a stage cannot be selected, and regime_act.py:121-130
wires exactly kv/vram/phase. Corroborated at uneven_perf.py:7744-7751.

So sgl-project#363's "weight mover" is a REFUSAL CODE, not an actuator -- the opposite of
the counter-versus-actuator failure, and honest. It is not something to wire to.

What exists is weights_arena.py + phase_flip_boot.py:361: a fixed-address VRAM
arena refilled by a host->device memcpy from a boot-baked pinned image,
checksum-verified, with a rollback arm, and containing no dist.* call at all.
On this no-P2P rig that is the better primitive anyway -- a rank-to-rank
transfer would stage through host memory regardless -- and the fixed address
keeps captured CUDA graphs valid across a rung change.

## The consequence, which is not favourable

The arena is sized for the DEEPEST rung and resident at EVERY rung: a rank does
not get its weight bytes back when the ladder sits shallow. solve_arena_ladder()
models this, and two things fall out.

First, the shallow rungs get poorer. Over a rank0 span of [31,38] the top rung
drops from 518,433 to 390,700 live-equivalent -- below the incumbent's observed
434,878. The ladder costs ~10% pool at the top to buy up to 1.231x pipelined
prefill at the bottom. Standing alone that is a marginal trade, and this commit
says so in the design rather than shipping the flattering number.

Second, and structurally: with free memory pinned by the arena, a rung's pool
depends only on its ATTENTION count. Two rungs sharing an attention profile
price identically and the faster one strictly dominates. Under an arena the
ladder's real axis is the attention-count vector, not the raw layer cut.

That invalidates my own earlier Slice 1 pair. [33,15,16] <-> [35,14,15] was
chosen because it moves zero attention layers, which is exactly what makes it
useless AS A LADDER PAIR. It is retained only to prove the mover mechanically;
a pair that actually trades must cross an attention boundary, so Slice 1b uses
[35,14,15] <-> [38,13,13].

The alternative mover -- reallocate per rung, restoring the full per-rung pool
at the cost of a CUDA graph recapture -- is named and left open. Both solvers
are in the branch; Slice 2 measures the recapture cost and closes the fork.

## Part B repriced by its own survey

The cross-rank LSE merge is real, N-way and rank-order deterministic
(layers/dcp/comm.py:228-262, all_gather places rank i at index i), which RETIRES
the merge-order risk. But two blockers are confirmed: DCP groups are subsets of
one PP stage by construction (parallel_state.py:3142-3159) and under PP prefill
no DCP group is instantiated at all (dcp_group_guard.py:1-42); and the KV pool
is DIMENSIONED by weight ownership -- model_runner_kv_cache_mixin.py:2466-2470
filters attention layer ids to the rank's own [start_layer, end_layer) before
the pool is built, so a rank has no row-space for a layer it does not own.
Part B is construction, not assembly; slice 3 splits into 3a/3b/3c at 4-7
windows, with the pool allocation rework on the critical path.

layers/dcp/test_weightless_kv_math.py is confirmed test-only: it imports no
torch and reimplements the LSE formula locally. It is not evidence of a wired
path.

## Test results

60 passed, hermetic (CUDA_VISIBLE_DEVICES=""), ruff clean on all new files,
codespell clean.

- test_ladder_controller_704.py (10, new): oscillation falsifiers on adversarial
  fill traces. The anti-flap test carries a CAN-FAIL PROOF: with the hysteresis
  collapsed to a bare threshold the controller emits 400 moves under a 1-token
  jitter; with it intact, zero. An earlier version of that test probed an
  INACTIVE threshold and passed for both, i.e. it was vacuous -- fixed by
  exposing active_descend_threshold() and asserting a fixed point.
- test_layout_ladder_704.py (25, +5): arena sizing, the equal-attention-profile
  domination property, the deeper-ladder-costs-pool trade, and an unaffordable
  arena refused with its shortfall.
- test_pp_cut_family_pool_704.py (6) and the two sgl-project#702 suites (19): unchanged.

The controller is a DECISION FUNCTION and says so in its docstring: it moves no
bytes and nothing is wired to it yet. Stated because a decision function
mistaken for an actuator is the exact confusion this survey was run to avoid.
efschu added a commit to efschu/htsglang that referenced this pull request Aug 17, 2026
… stub under the bugs-first order

Neither verdict is finished; the absorption mapping both turn on is the
undone part. Parked rather than polished so the resume starts from the
evidence instead of from scratch.

Two findings worth not losing: sgl-project#363's own ACT verdict R3 postdates the
sgl-project#656/sgl-project#657/sgl-project#658 successors and still did not close, and the per-rank ms/round
ladder floated as its successor scope already exists and already answered
NEGATIVE (-3.16 % inside a 4.43 % band). For sgl-project#584, auto-measurement and a
mechanically enforced single authority look delivered; dynamic recalculation
is the unresolved pillar.

Both qwen sweeps were stopped by the same order before returning findings, so
this is desk evidence only.
Torches97 pushed a commit to Torches97/sglang-for-sail that referenced this pull request Dec 1, 2026
Backport t-head#363 to yuhe/v1.0.0. Use implicit packed
GDN decode offsets while forwarding the branch's QK normalization setting.
Reuse the prefill prefix mask and FlashKDA host offsets across eligible
layers and use indexed state for eligible eager batches.

Enable additional SAIL fused KDA decode head counts in both Kimi K3
weight preparation and decode dispatch under the PLA gate. Preserve the
existing CUDA head counts and SAIL layout checks.

Requires the PLA 1.1.0 interfaces used by sgl-project#363.
Refs t-head#362.

(cherry picked from commit f62f7c2)
1195343015 pushed a commit to 1195343015/sglang that referenced this pull request Dec 2, 2026
Backport t-head#363 to yuhe/v1.0.0. Use implicit packed
GDN decode offsets while forwarding the branch's QK normalization setting.
Reuse the prefill prefix mask and FlashKDA host offsets across eligible
layers and use indexed state for eligible eager batches.

Enable additional SAIL fused KDA decode head counts in both Kimi K3
weight preparation and decode dispatch under the PLA gate. Preserve the
existing CUDA head counts and SAIL layout checks.

Requires the PLA 1.1.0 interfaces used by sgl-project#363.
Refs t-head#362.

(cherry picked from commit f62f7c2)
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