Skip to content

Report median instead of mean in bench_latency.py - #1269

Merged
merrymercy merged 2 commits into
mainfrom
clean-up
Aug 30, 2024
Merged

merrymercy merged 2 commits into
mainfrom
clean-up

Conversation

@merrymercy

Copy link
Copy Markdown
Collaborator

No description provided.

@merrymercy merrymercy changed the title Clean up benchmark utilities Report median instead of mean in bench_latency.py Aug 30, 2024
@merrymercy
merrymercy merged commit 79ece2c into main Aug 30, 2024
@merrymercy
merrymercy deleted the clean-up branch August 30, 2024 13:05
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 8, 2026
…line

Boot weg2sb4 grew ~19.0 MiB/min of host anon across its six ranks while
completely idle, against an independently observed +21.3 MiB/min.  Measured
per rank over two /proc samples 140 s apart: P PP0 +5.4, PP1 +5.4, PP2 +0.0,
each D rank +2.8 MiB/min; everything else (front, detokenizers, launcher
parents, inductor workers) exactly 0.0.

WHERE IT IS.  64 MiB-aligned [anon] rw-p glibc malloc arenas, extended in
place plus new arenas appearing (PP1 7d51f4000000 63.7->64.0, 7d51e8000000
19.6->20.4, new 7d51ec000000 0->11.43 MiB).  It is NOT the host ring --
dShmem was 0.0 on every process -- NOT CUDA pinned memory (/dev/zero flat)
and NOT the store.

MALLOC_ARENA_MAX=4, chosen from this rig's measurement rather than folklore:
glibc defaults to 8 x ncores arenas and CPU affinity here is 0-31, so the
default ceiling is 256.  The allocating threads on the steady-state path are
the scheduler thread plus the three the reset path names by hand ("#N RESET
JOIN threads=['prefetch', 'backup', 'prefetch_io_aux']"), so 4 gives each one
its own arena without the default's fragmentation surface.  It is a CEILING,
published with setdefault so an operator experiment still wins.

malloc_trim runs at the idle point, BOUNDED: only when this rank actually
grew WEG2_TRIM_MIN_GROWTH_MIB since the last trim, because trim walks the
arena free lists and a flat rank must not pay for it.

WEG2-IDLE-CENSUS, per rank, once a minute while idle:
  rounds_per_s=<n> rss_anon_mib=<n> d_anon_mib_per_min=<n> threads=<n>
  arena_max=<s> trimmed=<n> group=<P|D> rank=<n>
from /proc/self/status only -- no smaps walk (these ranks carry ~3,300
mappings).  It exists because NEITHER fact was in the log: the round rate had
to be reconstructed by counting sgl-project#1028 lines with an external script, and the
growth was only visible because a desk agent read /proc minutes before a host
OOM killed the processes.  The next boot's acceptance can now gate on
rounds_per_s ~= 0 and d_anon_mib_per_min ~= 0 with no external tool.

`threads=` is in the line deliberately: the per-rank thread count was NOT
captured before the OOM, so the arena value is derived from the reset line's
thread names and the next boot confirms or corrects it.

EXPECTED EFFECT, stated as arithmetic and not as a measurement: the sgl-project#1276
ladder cap takes an idle origin from ~1,500 to ~20 rounds/s (75x), and the
growth is per-round allocator churn, so the arena bound plus the reduced
round rate should take +19.0 MiB/min toward ~0.  UNPROVEN until a boot.

WHAT REMAINS UNEXPLAINED: in the same 140 s window cgroup anon rose +815 MiB
while the tracked processes explain only +44.3.  That window was NOT idle --
a desk probe was reading the checkpoint inside it -- so the +815 is
confounded and must not be quoted as an sglang rate; the +19.0 MiB/min
per-process figure is the defensible one and it is the one that matches the
independent idle observation.  The full-system attribution of the remainder
was never taken: the scan was killed by the OOM before its second sample.

Tests hermetic, 11 passed, red-first proven (the launcher publication test
fails against the unpatched tree).  Ruff parity exact: launcher.py 0 -> 0,
scheduler.py 106 -> 106 (the census import is function-local, which also
keeps weg2 from reaching back into managers at module scope).

NOT BOOTED.  No GPU used; cards were free and nothing was booked.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 8, 2026
…th a named margin; a breach tears down, never runs on

User order 2026-09-08, verbatim, given AFTER the sb4 host OOM: "kein
uebertreten mehr der schwelle. fuehrt nur zum absturz."  The base stood green
while idling at 95.92 -> 96.36 -> 96.47 GiB against a 95.90 GiB reap mark,
growth entirely anon and entirely at idle.  "Accept the risk" had been offered
and taken.  It is not an option at this threshold any more.

THE MARGIN IS NAMED, NOT A CUSHION (resolve_margin -> Margin):
  transient  9.97 GiB  the flip transient this form actually spends,
                       floored at one ring granule so it can never be zero
  drift      1.67 GiB  19.0 MiB/min x 90 min, the measured idle anon grower
                       (sgl-project#1269) over the planned window
  total     11.64 GiB  hard bound = 95.90 - 11.64 = 84.26 GiB
Both terms are things that WILL happen during the window, so an arm that has
not left room for them is already lost.  The drift rate comes from a boot's
WEG2-IDLE-CENSUS line once one exists; until then the sb4 default.

WHICH WATERMARK SAMPLES COUNT.  A reap sample needs a KERNEL reap -- an
oom_kill delta in the same row.  weg2dk5 95.90 (oom_kill 18 -> 24) and weg2dk6
96.06 (same death) COUNT; weg2sb4 96.60 does NOT -- the operator killed it and
no kernel OOM occurred.  Counting a human's patience as a kernel threshold
would move the watermark UP on a boot that never reaped.  The bound is the
lowest kernel sample, so dk5 stays authoritative.  All three are printed:
  WEG2-HOST WATERMARK=<v> source=[<events>] margin=<v> (<terms>);
  hard bound = <v>; excluded=[<sample> EXCLUDED (<why>)]

(1) BOOT REFUSAL.  size_store_gib takes the margin and folds it into the reap
bound, so the STORE shrinks and the margin never does, and `bound=leftover`
can no longer exceed watermark - margin.  choose() gates the run peak on the
hard bound; W21 names the terms.

(2) RUNTIME.  front.host_watermark_sampler reads memory.current and on a
breach issues W22 Weg2HostWatermarkBreached and takes the SAME path a killer
takes (do_stop) -- never "accept", never a silent restart.  The verdict
function is pure, so it tests against a synthetic reading with no processes.
boot_deadman.sh tier 3 latches on the W22 line as it does on W4 (operator
tree, not in this commit).

SB4 ARITHMETIC.  Its chosen arm (S=1 M=2400, store 11) reported
"run_peak=91.44 GiB vs reap 95.90 GiB => FUNDABLE" and then idled 4.6-5.2 GiB
ABOVE its own prediction.  Against the hard bound 84.26 it is REFUSED by 7.18
GiB, and shrinking the store does not save it: the bound leaves room for 3 GiB
against an 8 GiB floor.  Its peak WITHOUT any store is 80.44, under the bound
-- so the refusal correctly names the store floor as the binding term.

THE ANON TERM WAS CHECKED, NOT CORRECTED: HEAP_AWAKE_GIB is already 3.385 GiB
of RssAnon and matches the live measurement (P 3395/3014/2346, D 3240/2959/
2896 MiB).  The ~6.5 GiB figure from the briefings is an INSTRUMENT ERROR --
CUDA pinned host memory maps /dev/zero MAP_SHARED and counts as RssShmem, not
RssAnon.  NO term double-counts: pinned is priced as rings + anchors and the
weights image as Sigma H, all shmem currency; this constant is anon currency.
Annotated in place so it is not "corrected" back to 6.5 later.

Tests hermetic, 14 new, 40 green across the branch.  The decisive one prints
both verdicts side by side: with margin 0 (the ledger as it stood) sb4's arm
is FUNDABLE with a store above the floor; with the named margin it is refused.
Ruff parity exact: host_ledger.py 0 -> 0, front.py 1 -> 1 (pre-existing E741).
The 5 failures in test_rotation_executor_809 / test_weg2_ring_ledger_1235 are
PRE-EXISTING -- verified by running them against HEAD, same 5, same names.

UNPROVEN: not booted.  The margin's transient term is the module constant, not
a fresh per-form maximum re-read from the measured records; the drift term is
the sb4 default until a boot carries WEG2-IDLE-CENSUS; and the 90-minute
window is the operator's rotation length, not a measured dwell.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 8, 2026
…ign-load terms in the watermark margin

Three corrections to fb37325. The previous bound was right for the wrong
reason: 9.97 GiB of pre-ring flip transient accidentally covered a gap that is
actually somewhere else, and the coincidence would have broken the day the
transient was measured properly.

(1) THE TRANSIENT IS RING-ERA. FLIP_HOST_TRANSIENT_GIB = 9.97 is the
PRE-RING, per-allocation value (a fresh cudaMallocHost per tag). With the
shared registered ring the legs copy THROUGH a preallocated region and the
transient collapses: weg2rg2 +1.10 GiB ("drops from +9.97 to +1.1"), weg2rg3
+2.88 GiB over 13 flips. The MAX binds (2.88), the pre-ring value is used only
when no ring-era sample exists, and the provenance line says which was used.
rg3's record calls its 10 s sampler a LOWER bound, so this term is itself a
lower bound on the true worst case.

(2) THE REAL GAP IS RUN-PEAK UNDER-PREDICTION. The estimator does not miss the
flip, it misses the STEADY STATE: dk5 +3.01, dk6 +4.83/+7.67, rg6 -0.11,
sb4 +5.16 (predicted 91.44, idled 96.03-96.60). Only the RING-ERA rows are
used -- the form is what the bound is for -- so the term is sb4's +5.16, and
it is now explicit instead of being smuggled in by an oversized transient.

THE RESIDUAL IS AN EMPIRICAL CATCH-ALL, and that governs what may be added on
top. It is (measured - predicted), so it ALREADY contains those boots' idle
drift, their foreign desk load, and the estimator's error. Two consequences,
both implemented: the drift term is charged ONLY on the window BEYOND the
~60 min the residual was measured over (0.56 GiB for a 90 min window, not
1.67), and the foreign term is not re-added at all --

(3) FOREIGN LOAD: MEASURED AND PRINTED, NOT DOUBLE-CHARGED. The cgroup that
reaps is shared with the Claude sessions (the boot agent counted 9 .lxc
oom_kills that were Claude CLIs; a single desk probe reading the checkpoint
added +815 MiB inside sb4's own idle window; pytest runs, worktrees and
dry-runs all land in the same memory.current). measure_foreign_anon() =
cgroup anon - sum(RssAnon of the boot's own pids); on the sb4 base that is
33.49 - 21.78 = 11.71 GiB foreign, which independently validates the 10 GiB
CLI_RESERVE_GIB the ledger already carried -- in the WRONG denominator,
against MemTotal instead of against the cgroup the reaper watches.

It is NOT added to the margin, and that is a finding rather than a shortcut:
run_origin_gib() returns a memory.current reading, and a cgroup reading counts
every process in the cgroup, Claude included. The arm-time foreign load is
therefore already in the origin; re-adding it would charge it twice. What is
NOT in the origin is desk work arriving LATER, and that is unbounded by
construction -- so it goes to the RUNTIME guard, which is what a guard is for.
W22 now carries `SPLIT sglang= foreign=` and names which side dominates, so a
breach the operator's own pytest run caused is named, not charged to the boot.

RECOMPUTED: margin 8.60 = transient 2.88 + residual 5.16 + drift 0.56 +
foreign 0.00; hard bound 95.90 - 8.60 = 87.30 GiB. sb4's arms:
  S=1 M=2400  peak 91.44  w/o store 80.44  store  6  REFUSED (floor 8)
  S=1 M=1200  peak 91.50  w/o store 75.50  store 11  FUNDABLE
  S=1 M=600   peak 92.04  w/o store 73.04  store 13  FUNDABLE

SO THE RING FORM DOES FIT, and the binding term is NOT the ring. Sigma H
(32.19-34.94 GiB) is inside all three peaks, so it cannot be what separates
them; what separates them is the mamba anchor pool M (9.49 / 4.75 / 2.37 GiB).
sb4 died on the arm the pre-margin bound let it pick. With the margin the
ladder refuses M=2400 and falls to an arm with an 11 GiB store and room to
spare. sgl-project#1273's VRAM exchange remains the lever for the ring itself, but it is
not required to get under the watermark.

Tests hermetic, 21 in this file, 47 green on the branch. Red-first: the four
assertions that encoded the OLD margin fail against the corrected terms
(margin total, drift window, Margin signature, sb4 shortfall) -- that is the
correction's own evidence. Ruff parity exact: host_ledger.py 0 -> 0, front.py
1 -> 1 (pre-existing E741).

UNPROVEN: not booted. rg3's transient is a 10 s-sampler lower bound; the
residual is one ring-era boot (sb4) since rg6's is negative; the 60 min
residual window is read off sb4's timeline, not instrumented; and the foreign
measurement is a single sample from a window that contained my own probe.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 8, 2026
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 8, 2026
…which was set and never named

build_env's own comment says the decision is "published explicitly so the boot
log names the decision" -- but it only called env.setdefault() and logged
nothing, so NO boot log ever carried MALLOC_ARENA_MAX or
SGLANG_IDLE_BLOCKING_POLL. Found while collecting the post-merge dry-run lines:
the provenance line the merge was expected to produce did not exist.

A knob that shapes host memory and is never named is the
instrument-that-does-not-report shape. The line now carries the value AND its
derivation, including the part that is weakest: 4 is a CEILING derived from the
reset path's thread names, not from a live thread count -- that census was
never captured before the host OOM took the base down -- and WEG2-IDLE-CENSUS
`threads=` is what confirms or corrects it.

Verified on the off-form dry-run (rc=0, no GPU):
  WEG2 MALLOC-ARENAS MALLOC_ARENA_MAX=4 SGLANG_IDLE_BLOCKING_POLL=1 (both groups) -- provenance: ...

Ruff parity 0 -> 0 on launcher.py.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 8, 2026
…d transient, split by baseline

W22 fired on its first real encounter (boot weg2sb5b, 47b0169) and did what
the standing order demands -- refused at startup instead of letting the box
crash. It also exposed three defects of its own, all fixed here.

(1) CURRENCY -- and this is the one that matters. memory.current counts
RECLAIMABLE page cache; the run-peak model is built from anon + shmem. The two
cannot be compared during a load. sb5b's memts at the peak 18:57:01Z:
memory.current 96.94 = anon 27.72 + shmem 40.50 (rings+store) + page cache
excl. shmem 28.08 + 0.64 slab/kernel -> NON-RECLAIMABLE 68.86, max over the
boot 78.26. Against the 87.30 bound the honest figure had 9.04 GiB of ROOM
while the raw reading breached by 9.64. Currency is now
`memory.current - inactive_file - active_file` (fallback
anon+shmem+slab_unreclaimable+unevictable, reported AS a fallback), both are
printed, and read_cgroup_pressure carries the memts column names verbatim so
the next boot's rows diff against the guard's line without a translation table.

THE WATERMARK CARRIES OVER UNCHANGED, as a derivation with its assumption: at a
real reap the kernel has ALREADY reclaimed the file cache -- that is what
reclaim IS and it runs before the OOM killer -- so memory.current at the kill is
already ~pure non-reclaimable. dk5's own reap row bears it out
(pagecache_ex_shmem 28,916 kB = 0.03 GiB). ASSUMPTION: dk6 behaved as dk5 did;
its memory.stat was not captured, so that half is inference from ONE row.

(2) THE "FOURTH UNDER-PREDICTION" DISSOLVES. It was the currency, not the
model: predicted 86.18 against a measured NON-RECLAIMABLE peak of 78.26 is a
+7.92 GiB OVER-prediction. No startup load-transient term is added, because the
evidence says there is nothing to add: the 28 GiB of cache was already resident
BEFORE the boot (pre-boot 28.53 -> peak 28.08, it FELL), the checkpoint load
added none, and the boot's own growth was 57.4 GiB entirely in anon+shmem. The
sb4 residual (+5.16) survives untouched because sb4's file cache at idle was
0.055 GiB -- there the two currencies agree. The family is: at IDLE they agree,
at STARTUP they do not.

(3) THE SPLIT WAS ARITHMETICALLY VOID. sb5b printed sglang=61.48
foreign=-30.91, because cgroup anon counts each page ONCE while sum(RssAnon)
counts a shared page once PER MAPPER over 111 pids. Replaced by the PRE-BOOT
baseline, which is subtractable because it is the same quantity at an earlier
time; sb5b measured 10.05 GiB in preflight and the guard did not use it. The
front now takes it as --anon-preboot-bytes (0 = unset -> no split printed,
never an invented one). Honest limit in the code: this attributes by TIME, not
by OWNER, which is the conservative direction for a guard that tears down.

THE FOREIGN CACHE THAT REFUSED sb5b WAS OUR OWN DESK WORK: 14.55 of the 17.33
GiB resident page cache are the safetensors of the served checkpoint, left
mmap-resident by MY OWN byte-identity probe (SECTION 1af deliverable 6). A desk
read on the shared box did not merely consume RAM -- it inflated the ledger's
currency and refused a boot. Second independent justification for the
shared-box rule, and the reason the currency fix outranks the margin arithmetic.

RECOMPUTED sb5b -- THE M=1200 ARM STARTS:
  startup peak   old 96.94  NEW 78.26
  advisory       86.18 <= 87.30, passes the gate
  verdict        old: BREACH by 9.64   NEW: no breach, 9.04 GiB of room

Tests hermetic, 52 green on the branch. Red-first for all three: a synthetic
memory.stat with 25 GiB inactive_file does not breach under the new currency
and DOES under the raw one; the sb5b numbers reproduce the refusal in the old
currency and the pass in the new; the split never prints a negative foreign
(including the anon-fell-below-baseline case). Ruff parity exact: host_ledger.py
0 -> 0, front.py 1 -> 1 (pre-existing E741). The 3 failures in
test_weg2_ring_ledger_1235 are PRE-EXISTING, same names as against HEAD.

UNPROVEN: not booted. The non-reclaimable peak comes from the launcher's memts
columns, not cgroup memory.stat per row (that sampler lands next boot). dk6's
reap-row composition is inferred from dk5's. WEG2-IDLE-CENSUS has still never
executed on metal, three boots running.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 8, 2026
…ark currency, startup load transient, split by baseline)

ONE CONFLICT, in front.py, and both sides are kept: the two branches appended
to the same `Front(...)` construction tail. Resolved as

  * `admin_key_file=args.admin_key_file` + the WEG2 ADMIN-KEY log line (sgl-project#1275
    fix 1/2, this branch), and
  * `front._anon_preboot_bytes = args.anon_preboot_bytes` (sgl-project#1269 fix 3, the
    pre-boot anon baseline the watermark's currency is split against).

Neither is a substitute for the other and nothing was dropped. Verified after
the merge: admin_key_mod 4 hits and the sgl-project#1279 est_uncached third-site fix 1 hit
in front.py; W22 5 hits in front.py and 23 currency/non-reclaimable hits in
host_ledger.py; the sgl-project#1275 fix-3 redaction untouched in server_args.py.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 8, 2026
…ried the PRE-ORDER expectation

REGRESSION I INTRODUCED AND PREVIOUSLY MIS-REPORTED. fb37325 (the hard
bound) broke four tests in test/registered/unit/weg2/test_weg2_store_reap_bound
_1233.py. I reported "no regression" after checking ONE file
(test_weg2_ring_ledger_1235.py); the full directory was never baselined. Bisect
over the branch, that file only:

  e4f1b9f (base)  14 passed
  bc57275         14 passed
  de7106a         14 passed
  fb37325          4 failed, 10 passed   <- the hard bound
  93aaaa9          4 failed
  d805103          4 failed

THE REFUSAL IS CORRECT; THE TESTS ENCODED THE OLD PREMISE. On that fixture's
readings the arithmetic is not close, and it is already in the honest currency
(choose() nets reclaimable_bytes, so 83.66 is non-reclaimable):

  peak without store          83.66 GiB
  hard bound 95.90 - 8.60  =  87.30 GiB
  room for a store             3.64 GiB against an 8.00 GiB floor

so no arm funds and the ladder refuses by name. That is the standing order
working as specified, not a bug in the bound -- a boot that has not left room
for the flip transient and the measured under-prediction is already lost.

The four are updated rather than relaxed, and the file keeps its subject:
* the two funding assertions become REFUSAL assertions that additionally
  require the refusal to name its terms (transient / residual / margin), which
  the old tests could not check because there was no margin to name;
* the per-arm table test now reads the table out of the W21 exception -- fix 8
  emits it on the refusal path on purpose, which is where a reader needs it;
* the funding path stays covered by a new `test_a_box_with_room_still_funds_an_
  arm` on a ring 6 GiB smaller. That lever is the one the W21 message itself
  names ("cut Sigma H"), and it is the ONLY one that moves this box: the origin
  cannot be lowered because run_origin_gib takes max(launch reading, run-moment
  residual floor) and the floor binds here. Verified by sweep: -4000 MiB funds
  M=600, -6000 MiB funds M=1200 at peak 85.80 < 87.30.

15 passed in that file. Ruff parity exact: 0 -> 0. Separately baselined and NOT
mine: test_weg2_ring_ledger_1235.py's 3 failures and test/registered/unit/
managers' 4 collection errors ('SchedulerPPMixin has no attribute pp_flip_dr...')
reproduce identically at e4f1b9f with my files reverted.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 8, 2026
…st the hard bound

The second pair of registered tests that carried the pre-order premise, found
by diffing the FULL registered/unit/weg2 failure set on the remote desk against
the branch base -- the baseline I should have taken before claiming parity the
first time.

  base b9273399a9 (production-identical to e4f1b9f): 26 failing
  branch 2168f97:                                    23 failing
  NEW on the branch: 2   FIXED by the branch: 5   common: 21

The 2 NEW are TestWeg2dk5WouldHaveBeenNamedBeforeItBooted's two ladder tests.
Both call _choose(), which under the hard bound now refuses outright.

THE CLASS'S CLAIM SURVIVES AND IS SHARPENED, which is why these are re-derived
rather than relaxed. Its docstring records that under fix 8 the ledger refused
dk5 OUTRIGHT, and that the ring then made every moment 16.41 GiB cheaper so the
ladder could fall to M=600 instead. The named margin puts the outright refusal
back: dk5's best arm predicts 92.19 GiB against a hard bound of 87.30. So
"weg2dk5 would have been named before it booted" is now true by a blanket
refusal rather than by a smaller arm -- the STRONGER form of the sentence the
class is named for.

Both halves are now asserted, and they are exactly what separates the raw
watermark from the bound the order enforces: every arm is still BELOW the raw
reap point (the ring's 16.41 GiB is real and this test keeps proving it), and
every arm is ABOVE watermark - margin, which is why the ladder refuses.
Asserting only the first would have hidden the change that matters. The price()
assertions are untouched -- price() carries no margin, so the launch-moment
term (-0.42 GiB at M=1200) still names the arm that actually died.

Ruff parity 0 -> 0. Verified on the remote desk (cachyllama), not on this box:
weg2sb5c is booting and the standing order forbids desk CPU here.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 8, 2026
…del-error term

Boot weg2sb5c came up fully -- READY 33/33/3 s, 4/4 round trips, 10 flips,
WEG2-IDLE-CENSUS running at 25-31 rounds/s against sb4's 1,499.8 and dAnon
falling to +0.5..+0.64 MiB/min -- and was then refused two minutes into load at
87.67 GiB non-reclaimable against the 87.30 boot bound, crossed by 0.37, with
the actual reap point 8.2 GiB away. That refusal was a DOUBLE-CHARGE, not danger.

THE CORRECTION IS A DESIGN ONE, NOT A RELAXATION. `residual` (5.16) is
(measured - predicted): it exists to cover how wrong a PREDICTION can be.
  W21 grades a PREDICTION  -> must carry it.
  W22 grades a MEASUREMENT -> must NOT: memory.current net of reclaimable cache
      IS the real number, and it has already realised whatever error the
      residual was reserving for. Charging it there subtracts the same error
      twice.
`transient` and `drift` stay on both bounds: neither has happened yet at the
moment of the reading, so both are still future spend the box must have room for.

  BOOT bound    = 95.90 - (2.88 + 5.16 + 0.56) = 87.30 GiB  (UNCHANGED)
  RUNTIME bound = 95.90 - (2.88 + 0.56)        = 92.46 GiB

sb5c re-graded: 87.72 measured -> 4.74 GiB of room under the runtime bound,
while still above the boot bound, which is exactly why it was refused before.

The W22 line now names which bound it grades, prints the other, and states the
omission ("residual DELIBERATELY NOT CHARGED here -- it is model error and this
bound grades a MEASUREMENT") so a reader cannot mistake it for a missing term.
The WATERMARK line prints both bounds with both margins' terms.

RESIDUAL PROVENANCE gains weg2sb5c: predicted 86.18 vs measured 87.72
non-reclaimable = +1.54, the FIRST ring-era sample whose two sides are in the
SAME currency (sb4's +5.16 compares a prediction against a raw memory.current
that carried ~0 file cache at idle -- true, but true by luck rather than by
construction). The rule is max-over-samples, so the term does NOT move: 5.16
still binds. The row is kept because a table that stores only its maximum
cannot show the estimator improving, and because the next in-currency sample is
what will eventually retire the sb4 row.

Red-first: sb5c's 87.72 passes the runtime bound and a synthetic 92.6 breaches;
four existing runtime-verdict tests had thresholds expressed against the BOOT
bound and are moved to the runtime bound (they would otherwise assert a breach
that no longer exists); W21 and the store sizing are untouched and the fix-3
sb4 arm table reproduces exactly. Ruff parity 0 -> 0.

Tests run on the remote desk (cachyllama) only -- weg2sb5c work continues on
this box and the standing order forbids desk CPU here.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 8, 2026
… two-bound line

My own test from fix 3 asserted the tokens 'margin=' and 'hard bound' in the
WEG2-HOST WATERMARK line. Fix 4 replaced that single bound with two -- 'BOOT
bound = ' and 'RUNTIME bound = ' -- so those tokens are gone by design, not by
accident. Caught by the remote run of aa26b79 (1 unit failure); the
registered set was unaffected (21 failures, NEW 0 vs base, FIXED 5).

Ruff parity 0 -> 0. Verified on the remote desk only.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 8, 2026
…unds: boot 87.30 keeps the residual, runtime 92.46 = watermark - transient - drift)
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 8, 2026
…aseline reaches the front

W22's `sglang=`/`foreign=` split subtracts a PRE-BOOT cgroup anon reading --
subtractable precisely because it is the same quantity at an earlier time,
before any group process exists. It replaced the old `sum(RssAnon)` split,
which printed `sglang=61.48 foreign=-30.91` because cgroup anon counts a shared
page ONCE while RssAnon counts it once per mapper over 111 pids.

THE MEASUREMENT WAS ALREADY BEING TAKEN AND THROWN AWAY. `choose_host_ledger`
returns the preflight cgroup snapshot, `main` already binds it as `cg`, and
`cg["anon"]` went nowhere. The front has accepted `--anon-preboot-bytes` since
the ledger's own fix 3 and was never given one -- so boot weg2sb5c's split had
to be reconstructed by hand afterwards. This wires the value the preflight
already has to the argument the front already parses.

ONE READ, CARRIED, and that is the whole design choice here: the baseline is
the PREFLIGHT's own reading, taken before any group process exists, NOT a
second `read_cgroup()` at front-launch time. By then the groups are up and the
number is no longer a baseline; two reads are two quantities. Same lesson as
sgl-project#1275 fix 2's single key source, applied to a measurement instead of a secret.
The test asserts `main` contains no `read_cgroup` call of its own.

0 MEANS UNSET. An unreadable cgroup ships no flag, and the front then prints NO
split rather than an invented one -- host_ledger is explicit that absent must
never be read as zero.

DRY-RUN (off form, rc=0, no GPU):
  WEG2-LAUNCH ANON-BASELINE preboot_anon=10.79 GiB (cgroup memory.stat anon at
    PREFLIGHT, before any group process exists; handed to the front as
    --anon-preboot-bytes so W22 can split its reading into sglang= and foreign=)
  front argv: --anon-preboot-bytes 11590135808        <- non-None baseline
  memory.current=18.58 | ARM M=2400 store=4 | M=1200 store=9 CHOSEN | M=600 store=12
  WEG2-LAUNCH RPC auth=bearer sites=2
  key 0 bytes: admin_api_key= 0 occurrences, '<redacted>' x2, 0 unredacted,
    no key file written by the dry run

RED-FIRST: before the wire no argv carried the flag at all, so
test_the_flag_carries_the_measured_bytes and
test_both_front_argv_call_sites_pass_it both fail on the parent.

UNPROVEN: nothing on metal. The split has never been printed by a running
front from a launcher-supplied baseline -- only the wire is proven here.
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