Skip to content

Unify forward mode - #1360

Merged
merrymercy merged 2 commits into
mainfrom
unify-forward
Sep 9, 2024
Merged

merrymercy merged 2 commits into
mainfrom
unify-forward

Conversation

@hnyls2002

Copy link
Copy Markdown
Collaborator

Motivation

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.

@merrymercy
merrymercy merged commit 69b3bb9 into main Sep 9, 2024
@merrymercy
merrymercy deleted the unify-forward branch September 9, 2024 20:49
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 12, 2026
…comes measurable

THE GAP, measured on weg2xsn24 and weg2xsn25: the entire NEED tag census of both
boots reads `weights_0..weights_7`, `weights_draft`, `weights` and NOTHING else.
The leg guarded only the weights family -- correctly, because those are the tags
whose bytes the waking peer has to release -- so the "extra" population the ring
anchor needs (capture pool, workspace, static clones, everything else
`enable_cpu_backup` saves) was empty BY CONSTRUCTION. The question #1350c left
open by name -- "does weights + weights_draft cover what the saver puts away?"
-- could not be answered from a boot at all, and that is why the manifest anchor
(Sigma H 32.01 GiB against a 47.5 GiB census) stayed unflipped.

The leg now emits a line for every census tag, and the extra ones go through
`record()`, NEVER `guard_tag()`. That restriction is the whole safety of the
change: nothing waits, nothing refuses, no flip timing moves. A tag outside the
weights family is not ring-carried, so a `free` comparison would be meaningless
for it -- the line states its BYTES under its own name, which is exactly what
the anchor sums, and the five fixed fields stay on it so the series still
parses. `RingNeedGuard.free_mib_or_none` is the public reading the pass needs,
so it does not reach into the guard's private helper, and it returns None as an
ABSENCE rather than inventing a free number.

Tests (5): the call site exists between the census and the leg summary and its
CODE (not its prose) uses record and not guard_tag; an extra tag gets its own
named line with its bytes and its leg; the five fixed fields stay on every line;
free_mib_or_none is an absence and never a zero; and the extra population sums
to something, which is the set that was empty before this commit.

LOCAL: the two sgl-project#1360 files are 17 green. test_weg2_lane_coverage_1348 shows 23
failures -- reproduced UNCHANGED on a pristine checkout of the base 197795a
(23 failed / 21 passed there too), so none is new. ruff clean on both touched
files. No boot, no GPU, no /dev/shm.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 12, 2026
…lence is not

Boot weg2xsn26 was refused CORRECTLY (run_peak 95.12 vs hard bound 94.43,
source=SERIES binding weg2xsn25 8.697, W87 -> W20 "no arm of the ladder funds
both moments") and the launcher had NO named override at all: the boot seat
grepped the refusal text, the argparse and every SGLANG_*OVERRIDE/FORCE/ACCEPT
and found zero. The user's standing rule of 2026-09-12 is that the reap mark is
SOFT -- crossing it is allowed WITH a number and a runtime latch, and never
silently. The ledger had the "never" and not the "with".

`--host-ledger-deviation "<reason>"` + `--host-riegel-gib <float>`, BOTH OR
NEITHER (W97 Weg2HostDeviationRefused, census-checked, no collision). Flag only:
NO env twin, and a test pins that (sgl-project#781 fossil class -- one spelling, on the
command line, where it lands in the argv echo and the form key).

IT CONVERTS THE FUNDABILITY VERDICT AND NOTHING ELSE. The verdict is computed in
full first; the deviation then accepts it and appends

    WEG2-HOST-LEDGER DEVIATION reason="..." predicted_run_peak=<GiB>
      hard_bound=<GiB> reap=<GiB> excess=<GiB> riegel_gib=<float> source=<...>

with every number taken from the SAME arm arithmetic -- nothing is re-estimated.
`test_the_sizing_is_byte_identical_with_and_without_the_flag` is the ratchet on
that: every key and every value of `arm.terms` is compared against a plain
`price()` of the same arm, plus both leftovers.

TWO REFUSALS STAND, and they are what makes this a deviation rather than an
off-switch:
  * predicted run peak AT OR ABOVE the REAP WATERMARK (95.90) -- the bound is
    soft, the watermark is where the kernel reaped. weg2xsn25 died on a
    prediction 5 GiB below it; accepting one AT it is booting into the killer.
  * riegel AT OR ABOVE the hard bound -- a latch above the bound it is meant to
    catch a breach beneath can never fire in time. It is decoration, and the
    rule asks for a latch.
Sizing, ring dimensioning, the manifest guard (sgl-project#1359) and the runtime guard W22
are untouched; W22 still tears down at the latch.

DRY RUN, the boot seat's real xsn26 argv (shadow form, --pin-ledger-arm-m 150):

    WEG2-HOST-LEDGER DEVIATION reason="xsn26 Zielfrage: erster D2D-Flip, Riegel 93.0"
      predicted_run_peak=95.10 hard_bound=94.43 reap=95.90 excess=0.68
      riegel_gib=93.00 source=SERIES
    rc=0

Same argv WITHOUT the flags, as the control: rc=2, REFUSED W87 -- unchanged.

Tests (12 + 46 subtests): reason without latch, latch without reason, latch >=
bound, predicted >= reap, the happy-path line with its ordered fields and its
arithmetic (excess == predicted - hard_bound), the arm that comes back is the
one the ladder priced, byte-identical sizing, and no env twin. ruff clean.
No boot, no GPU, no /dev/shm.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 12, 2026
…comes measurable

THE GAP, measured on weg2xsn24 and weg2xsn25: the entire NEED tag census of both
boots reads `weights_0..weights_7`, `weights_draft`, `weights` and NOTHING else.
The leg guarded only the weights family -- correctly, because those are the tags
whose bytes the waking peer has to release -- so the "extra" population the ring
anchor needs (capture pool, workspace, static clones, everything else
`enable_cpu_backup` saves) was empty BY CONSTRUCTION. The question #1350c left
open by name -- "does weights + weights_draft cover what the saver puts away?"
-- could not be answered from a boot at all, and that is why the manifest anchor
(Sigma H 32.01 GiB against a 47.5 GiB census) stayed unflipped.

The leg now emits a line for every census tag, and the extra ones go through
`record()`, NEVER `guard_tag()`. That restriction is the whole safety of the
change: nothing waits, nothing refuses, no flip timing moves. A tag outside the
weights family is not ring-carried, so a `free` comparison would be meaningless
for it -- the line states its BYTES under its own name, which is exactly what
the anchor sums, and the five fixed fields stay on it so the series still
parses. `RingNeedGuard.free_mib_or_none` is the public reading the pass needs,
so it does not reach into the guard's private helper, and it returns None as an
ABSENCE rather than inventing a free number.

Tests (5): the call site exists between the census and the leg summary and its
CODE (not its prose) uses record and not guard_tag; an extra tag gets its own
named line with its bytes and its leg; the five fixed fields stay on every line;
free_mib_or_none is an absence and never a zero; and the extra population sums
to something, which is the set that was empty before this commit.

LOCAL: the two sgl-project#1360 files are 17 green. test_weg2_lane_coverage_1348 shows 23
failures -- reproduced UNCHANGED on a pristine checkout of the base 197795a
(23 failed / 21 passed there too), so none is new. ruff clean on both touched
files. No boot, no GPU, no /dev/shm.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 13, 2026
…and W102 gets the raise site its comment already claimed

Two halves of one defect class: a refusal that names its verdict and hides its
cause, and an intention written as a state.

(1) W97 Weg2HostDeviationRefused printed only `predicted 98.67 vs 95.90`
    (train dry run, arm_def.log:112). True and unreadable: nothing says WHICH
    term carried the peak, so an honest arm and a mispriced one look the same
    and the reader re-derives the ladder by hand. New `arm_terms_line(arm)` is
    the ONE producer of the ARM line's term fields; the refusal appends them
    under TERMS (S/M/S_D), so refusal and arm compare field by field. An
    unpriced term prints n/a, never 0.00 -- absent and zero are not the same
    state.

(2) Weg2XchgLanesUnmeasured (W102, host_ledger.py:1689) had NO raise site
    anywhere in the tree at 19c7502 -- `git grep` returned the class and one
    test reference -- while the comment at :1755 claimed the leg driver refused
    with it. The leg driver did refuse: with W68 Weg2XchgPlanDisagree, the code
    for a wrong phase or lane KEY, not for a lane COUNT priced too low. A
    W-code census reads such a comment as covered. The leg driver now raises
    W102 when the recorded cut contradicts what the leg itself enumerates, and
    the comment states it instead of intending it. The guard sits after the
    #1350e interleaved check and is documented as a NECESSARY, not sufficient,
    condition: the leg sees one rank, the ledger priced boot-wide.

Red-first: 7 of 8 red at 19c7502 in a detached worktree; the one green is
the pre-existing subclass invariant. The W97 half is an execution test on the
real refusal (reusing the sgl-project#1360 watermark specimen), not a source pin.
Neighbouring suites green (sgl-project#1358 per-lane, sgl-project#1360 deviation, lane-cut, arm
provenance, share guard: 49 passed). ruff unchanged: the same 7 pre-existing
findings at base and at tip, none added.

(cherry picked from commit 2f1db00)
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…her.main(), not just choose()

Prior-art gate first, per the order: sgl-project#1392 itself was already built and on
the train (commit 5a1c3f0 / rebased to de7f875's ancestor chain,
"the dry run says WHICH box state it funded against") -- the ARM line
already carries memavail/anon/shmem plus provenance, the PROVISIONAL text
above FOREIGN_LOAD_PROVISIONAL_THRESHOLD_GIB already exists with the
directional-asymmetry reasoning the order restates almost verbatim, and no
second refusal gate was ever added. This is NOT a rebuild of that feature.

THE ONE GAP the order actually named: "Nutze die Ruhig-Box-Fixture und
_HermeticMainBase aus sgl-project#1390... Prior-Art-Gate zuerst darauf, kein Zweitbau."
The existing test file's `TheLauncherThreadsTheThreeReadingsThrough` class
only inspects `launcher.choose_host_ledger`'s SOURCE TEXT (string/AST
checks) and calls `host_ledger.choose()` directly -- never `launcher.main()`
end to end, and never through sgl-project#1390's own `_HermeticMainBase` /
`_fake_quiet_host` fixture, which exist for exactly this seam.

Closes it by importing (not reimplementing) `_HermeticMainBase`,
`_fake_quiet_host`'s pinned readings, `_main_argv` and `_NEEDS_CHECKPOINT`
from test_weg2_hicache_disabled_1386.py, the same cross-test-file reuse
convention test_weg2_band_credit_1397.py already uses for its own sibling
fixture:

1. TheRealDryRunLineOnAQuietBox: `launcher.main(['--dry-run', ...])`, the
   REAL wiring, on the pinned quiet-box reading -- the printed line says
   "not stale-suspect", never PROVISIONAL, and carries memavail=/anon=/
   shmem=.
2. A new `_fake_loaded_host` (the quiet fixture's numbers, `memory.current`
   pushed exactly QUIET_BASELINE + THRESHOLD + 1 GiB) and a matching
   `_HermeticMainBaseLoaded` harness (own setUp/tearDown -- not a subclass
   of `_HermeticMainBase` overriding setUp, which would leave two live
   mock.patch layers active): TheRealDryRunLineOnALoadedBox proves the SAME
   real `main()` run, ONLY the host reading changed, now prints PROVISIONAL
   and a real foreign_load_now figure.
3. THE REQUIRED DANGER-DIRECTION MUTANT, against the real file, not a
   planted fixture (mirroring how sgl-project#1395's mutant ran against the real
   reader): `mock.patch.object(hl, "FOREIGN_LOAD_PROVISIONAL_THRESHOLD_GIB",
   float("inf"))` around a live `main()` run on the LOADED host -- the line
   still prints a real, honest `foreign_load_now=` figure (the box IS
   loaded) but PROVISIONAL never fires, because the axis that would have
   said so was neutralised. `test_the_real_printed_line_says_PROVISIONAL`
   (a DIFFERENT, non-mutant-specific test) independently catches the same
   defect when the axis is instead removed at the SOURCE (see below),
   which is the broader, more convincing proof.

MUTANT APPLIED LIVE TO host_ledger.py ITSELF AND REVERTED (diff empty
after), exactly as ordered ("fahr ihn gegen die echte Datei"): the
`_fl_now > FOREIGN_LOAD_PROVISIONAL_THRESHOLD_GIB` condition replaced with
`False` (the foreign-load axis silently removed from the line's effect,
never from its printed number). Re-ran TheRealDryRunLineOnALoadedBox: the
loaded box's `main()` run still completes, the line still claims a verdict,
`foreign_load_now=3.50 GiB` (real, above threshold) still prints, but
"PROVISIONAL" is gone -- `test_the_real_printed_line_says_PROVISIONAL`
(the plain, non-mutant test) goes red on its own, which is the strongest
form of this proof: the feature's OWN direct test catches the mutation
without needing a dedicated mutant assertion. Reverted, diff empty,
19/19 green again.

No second launch-time guard: sgl-project#1360/sgl-project#1361's own re-read at LAUNCH is
untouched, and nothing here duplicates it -- this is dry-run-time honesty
about the reading a verdict was measured against, not a second gate.

Regression: test_weg2_dry_run_box_state_1392.py (19/19),
test_weg2_hicache_disabled_1386.py + test_weg2_dry_run_order_probe_1378.py +
test_weg2_cushion_headroom_gate_1378_stage2.py (48/48, 2 subtests) all
green. pyright: host_ledger.py untouched net (mutant reverted); the new
test file's import-resolution noise is the same reportMissingImports class
already present for every sglang.* import in this desk-venv, not a real
type error.

File boundary: host_ledger.py (touched only transiently for the live
mutant, reverted) + launcher.py (untouched this round) + own test file, as
ordered.
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