Skip to content

Organize flashinfer indices update - #1378

Merged
merrymercy merged 8 commits into
mainfrom
split-kernel
Sep 11, 2024
Merged

merrymercy merged 8 commits into
mainfrom
split-kernel

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.

@hnyls2002 hnyls2002 changed the title Dispatch to different kernel in mixed attention Dispatch to different kernels in mixed attention Sep 10, 2024
@hnyls2002
hnyls2002 marked this pull request as draft September 10, 2024 21:13
@hnyls2002
hnyls2002 marked this pull request as ready for review September 10, 2024 23:44
@hnyls2002 hnyls2002 changed the title Dispatch to different kernels in mixed attention Organize flashinfer indices update Sep 10, 2024
@hnyls2002
hnyls2002 enabled auto-merge (squash) September 10, 2024 23:55
page_kernel_lens_ptr,
kv_indptr,
kv_start_idx,
max_context_len,

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.

this can be marked as tl.constexpr. We can fix it in the follow-up PRs.

@merrymercy
merrymercy disabled auto-merge September 11, 2024 00:38
@merrymercy
merrymercy merged commit 144bc70 into main Sep 11, 2024
@merrymercy
merrymercy deleted the split-kernel branch September 11, 2024 00:39
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 13, 2026
…complement bug fixed, register_cpu_ci declined

Ran the WIP suite (fixture nvml_devices_1378.json + the --tree fix already
on this branch) hermetically: CUDA_VISIBLE_DEVICES="" PYTHONPATH=<worktree>/python,
/spinning/htsglang-gpu/.venv/bin/python. 8 of 9 passed; TestCoverageComplement
crashed with "'PythonFileReporter' object has no attribute 'endswith'".

Root cause, two parts:
1. cov._analyze(cov._get_file_reporter(path)) double-resolves: _analyze()
   already calls _get_file_reporter() internally on its morf argument, so
   feeding it an already-resolved FileReporter made source_for_file() call
   .endswith() on a FileReporter instead of a string. Fixed to cov._analyze(path).
2. The untriaged CoverageWarning ("--include is ignored because --source is
   set") was real and silent: the repo-root .coveragerc sets [run] source =
   python/sglang/srt, which coverage.py auto-discovers and which OVERRIDES a
   programmatic include= entirely -- the complement would have silently
   measured all of srt/, not launcher.py+srt/weg2/ as the module docstring
   promises. Fixed with config_file=False on the Coverage() constructor, so
   include= is the only scope source. Also dropped an unused `data =
   cov.get_data()` (ruff F841), pre-existing in the WIP commit.

register_cpu_ci: declined, not added. Precedent is test_weg2_launch_replay_1329.py,
the sibling file this probe's own docstring compares itself to -- same
NEEDS_CHECKPOINT dependency on the 27B checkpoint directory, and its own
comments record that checkpoint absence on the remote CI host (cachyllama)
does not cleanly skip there but actively FAILS the form-gate tests with a
non-bootstrap W48 refusal. 1329 has no register_cpu_ci call for exactly this
reason; this file inherits the identical dependency shape and the identical
decision, not a new one.

Result: 9 passed, 0 failed, hermetic (CUDA_VISIBLE_DEVICES=""), ruff clean.
Coverage complement over launcher.py + every srt/weg2/*.py module for the
single dry-run process (a reading list per sgl-project#1348's own methodology, never a
target) -- reported in full in the desk-leiter-3 report.

Basis: origin/weg2/train-0911 tip 78bbb20,
continuing branch fix/1378-nvml-replay-dryrun @ 40f3212
(unmodified other than this commit).
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 13, 2026
…same PP-calibration guard argv_p already uses

solve_p_cut's `incumbent` fell straight to the 64-layer bsscale
P_PP_STAGE_RATIO_SCORES default whenever --pp-stage-ratio was unset, with no
calibration lookup and no model-identity check -- a second, unguarded reader
of the concept argv_p's W99 Weg2ModelIdentityMismatch guard (sgl-project#1362) already
protects. Measured live (DESK6): a dry-run for a 24-layer model (Qwen3.5-2B)
with a valid, complete calibration record for its own digest still crashed
in pp_cut.family_costs_from_measurement with the exact bare ValueError
refuse_foreign_calibration's own message quotes as the failure sgl-project#1362 exists
to name, because solve_p_cut runs before argv_p in main() and never
consulted the record.

Adds host_ledger.resolve_calibrated_stage_layer_counts (shared helper, same
refusal wording as the existing argv_p path) and wires it into solve_p_cut's
incumbent. Six new unit tests (test_weg2_calib_incumbent_1378.py) plus the
129 pre-existing solve_p_cut/argv_p tests stay green. Live dry-run
regression: the same Zwerg argv now reaches WEG2-HOST-LEDGER ARM / => FUNDABLE
instead of the bare ValueError, calibration record at
/spinning/gpu-arb/weg2/calib/a3dea3d567015a86b223e3c0585133c8160fba735b3ed3c3a5bcef6cc4240dba.json.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…easurement, not rebuild

READ-ONLY on host_ledger.py/launcher.py (they belong to the ledger seat's
HiCache switch + flag-group work right now); this file is the deliverable
itself -- a replay harness plus the verdict table the coordinator asked
for, over the whole xsn31 lineage instead of just the two calibration
boots.

CALIBRATION ANCHORS, reused verbatim from test_weg2_cushion_gate_1377.py,
not re-derived: xsn31/2 alone reads GREEN (cushion_headroom_gib(6.99, 7.79,
7.79) == 6.99), the xsn31/2->3 transition reads RED (cushion_headroom_gib
(6.99, 15.75, 7.79) == -0.97). TheCalibrationAnchorsHold pins both, plus an
explicit "these are not the same reading" guard, before the chain extends
past them -- a replay that read both green would be measuring nothing.

EXTENDED OVER THE FULL CHAIN (xsn31/2 -> /3 -> /4 -> /5 -> /6 ->
/7-projected), invariant 1 (predicted_run_peak + FLOOR <= hard_bound)
passes for EVERY record, including the four that actually latched W98 on
the metal -- confirmed as "a floor, not the gate" across the whole chain,
not just the original pair. Invariant 2 (cushion_headroom_gib) is the one
that actually discriminates, replayed on PRICED bounce (what the ARM
believed at boot time) where that is all the record has (xsn31/3, which
predates the filesystem poller instrument), and on REAL measured bounce
where the poller or HOST-SLOT lines exist (xsn31/4 onward).

TWO FINDINGS, named with file:line for the ledger seat to route rather than
fixed here (file boundary):

1. WIRING GAP. `cushion_headroom_gib` (host_ledger.py:4589-4608) -- the
   ONLY function in the tree that correctly separates xsn31/2 from
   xsn31/3 -- has ZERO production call sites. `choose()` never reads it;
   neither does any other ARM-time or dry-run decision path. Its only
   callers anywhere are its own unit tests and this file
   (test_no_call_site_in_host_ledger_outside_its_own_definition_and_tests,
   test_choose_never_reads_cushion_headroom -- both executable, not prose).
   Practical consequence, visible in this same replay: xsn31/3, /4, /5 and
   /6 all passed their pre-flight dry run FUNDABLE and only discovered the
   cushion breach LIVE (W98, after VRAM had already been mutated) --
   exactly the class of defect this whole campaign otherwise refuses
   before the first byte moves.

2. MODEL BLIND SPOT, not an arithmetic bug. `cushion_headroom_gib`'s body
   is a single subtraction over ONE term (the bounce delta) and holds
   every other shmem-consuming quantity constant between the two records
   BY CONSTRUCTION. Replayed on REAL measured bounce, xsn31/5->/6 is the
   coordinator-named non-monotonic case: real bounce FELL (16.905 ->
   12.00 GiB) yet measured cushion ALSO fell (0.85 -> 0.20), the opposite
   of what the one-term model predicts. Not a defect in the subtraction
   itself (xsn31/2->/3 calibrates exactly) -- a documented blind spot: the
   model has no term for whatever else varied between two boots on the
   same box, matching that boot record's own conclusion ("der naechste
   Hebel ist der Host-Ring/die Baseline-Terme, NICHT der Lane-Knopf").
   xsn31/3->/4 (priced basis, the only basis available for xsn31/3) shows
   the THIRD instance of the same shape for a different reason: the price
   itself was wrong at the time (the sgl-project#1385/xsn31-4 slot-size bug, already
   found and fixed this session, commit 461fdeb) -- named explicitly
   as NOT a defect in this function, so a future reader does not conflate
   an already-fixed input error with a new arithmetic one.

xsn31/7 PROJECTION (the coordinator's actual question): xsn31/7 crashed at
model load (an unrelated --speculative-draft-kv-only / --hicache-
canonical-kv-page incompatibility, server_args.py:8420-8432, named in
BOOT_weg2xsn31_0913_4.md's own VERSUCH 7 section) before any bounce
allocation, so there is no measured cushion for it. Held bounce identical
to xsn31/6 (HiCache does not touch lane pricing or the still-open cross-
group concurrency gap) and fed cushion_headroom_gib only BOOT7's own
measured HiCache saving (-8.17 GiB predicted_run_peak, cross-checked
against ANALYSE_57GIB_SHMEM_0913.md's independent -8.14 GiB estimate, the
two agreeing within 0.03 GiB): the arithmetic reads GREEN at +8.37 GiB
margin. Prognosis stays prognosis, stated in the test's own docstring and
repeated in the closing message: the model's own blind spot (finding 2,
above) means this number describes the ARITHMETIC, not a verdict on the
boot.

11/11 green, ruff clean. test_weg2_cushion_gate_1377.py's own sampler test
(TheCushionMinimumComesFromTheSamplersOwnColumn, reading a LIVE, rig-wide,
continuously-appended CSV explicitly marked "rig-only evidence") is
independently flaky against today's accumulated sampler data -- confirmed
unrelated to this commit (no file this commit touches is anywhere near
that code path) and out of this task's file boundary either way.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…ot's cushion

Stage 2 wired cushion_headroom_gib into choose()'s ARM point, but
prior_cushion_min_gib/prior_bounce_gib were operator-typed only -- an INERT
gate, since nobody types two numbers by hand before a real boot, and the
next boot (BOOT7, d6c3d19) would never pass them.

Adds host_ledger.flip_ratchet_candidates()/resolve_prior_cushion(): every
FLIP-group sidecar entry of an EXACT form_key match (never newest-by-mtime --
sgl-project#1308's own shortcut cost two boots that way), taking the MINIMUM cushion_min
over those candidates (never the newest -- the direction is asymmetric, a
prior cushion read too high would loosen every boot after it, the sgl-project#782
ratchet-from-the-free-column class in the threshold direction). Both
cushion_min_gib and xchg_bounce_gib must come from the SAME candidate record,
never mixed across two boots that never coexisted.

front.py._write_flip_ratchet now also writes xchg_bounce_gib (from the same
ledger_arm dict dormant_image_sample already reads it from) beside the
existing cushion_min_gib field, so a future boot's record carries both halves
resolve_prior_cushion needs. flip_ratchet_record() gets the new optional
xchg_bounce_gib parameter (None-default, byte-identical for every existing
caller).

launcher.choose_host_ledger gains flip_ratchet_form_key (main passes
f"wtags={len(weights_tags)}", the exact literal front.py writes) and
self-resolves prior_cushion_min_gib/prior_bounce_gib from the sidecar unless
the operator's flags override them outright. A WEG2-CUSHION-HEADROOM-SOURCE
line is always appended -- auto-resolved, overridden, or "could not measure
(no candidate of this form / no form_key passed)" -- never silent. choose()
itself is unchanged from Stage 2.

Tests: test_weg2_cushion_headroom_autoresolve_1378_stage2b.py (12 cases) --
pure-resolver form/minimum correctness, front.py's one-producer wiring, and
end-to-end through the real choose_host_ledger seam (fake /proc/meminfo +
fake cgroup2 tree + a real sidecar file): no-flags-no-form-key is the
byte-identical Stage-2 default, form-key-alone auto-resolves, an explicit
flag overrides the sidecar (not the reverse), a foreign-form candidate never
wins through the real seam, and the minimum (not the newest) of several
same-form candidates wins through the real seam. Updated one Stage-2
structural test whose asserted forwarding text changed (raw params ->
resolved locals).

Manually verified both required danger-direction mutants: (1) min -> max in
resolve_prior_cushion: 2 of 12 tests go red (the two through-the-seam and
pure-resolver minimum tests); (2) the form_key equality filter dropped: 3 of
12 go red (the foreign-form and no-candidate-of-this-form tests). Both
restored, diff empty.

Regression run also caught and fixed a genuine bug this diff introduced:
test_weg2_flip_ratchet_1350.py's FrontEmitterSmoke1350._Stub lacked
ledger_arm, which a real Front always sets in __init__ -- AttributeError on
the new call site. Fixed by adding ledger_arm={} to the stub, matching the
real invariant, not by making front.py defensively getattr around a state a
real instance never lacks. 306 tests green across the wider weg2 regression
slice after the fix (previously-noted pre-existing failures in
test_weg2_run_residual_currency_1325.py confirmed unrelated by running
against the pristine pre-Stage-2b tip in a throwaway worktree, both same
three failures present there).
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…easurement, not rebuild

READ-ONLY on host_ledger.py/launcher.py (they belong to the ledger seat's
HiCache switch + flag-group work right now); this file is the deliverable
itself -- a replay harness plus the verdict table the coordinator asked
for, over the whole xsn31 lineage instead of just the two calibration
boots.

CALIBRATION ANCHORS, reused verbatim from test_weg2_cushion_gate_1377.py,
not re-derived: xsn31/2 alone reads GREEN (cushion_headroom_gib(6.99, 7.79,
7.79) == 6.99), the xsn31/2->3 transition reads RED (cushion_headroom_gib
(6.99, 15.75, 7.79) == -0.97). TheCalibrationAnchorsHold pins both, plus an
explicit "these are not the same reading" guard, before the chain extends
past them -- a replay that read both green would be measuring nothing.

EXTENDED OVER THE FULL CHAIN (xsn31/2 -> /3 -> /4 -> /5 -> /6 ->
/7-projected), invariant 1 (predicted_run_peak + FLOOR <= hard_bound)
passes for EVERY record, including the four that actually latched W98 on
the metal -- confirmed as "a floor, not the gate" across the whole chain,
not just the original pair. Invariant 2 (cushion_headroom_gib) is the one
that actually discriminates, replayed on PRICED bounce (what the ARM
believed at boot time) where that is all the record has (xsn31/3, which
predates the filesystem poller instrument), and on REAL measured bounce
where the poller or HOST-SLOT lines exist (xsn31/4 onward).

TWO FINDINGS, named with file:line for the ledger seat to route rather than
fixed here (file boundary):

1. WIRING GAP. `cushion_headroom_gib` (host_ledger.py:4589-4608) -- the
   ONLY function in the tree that correctly separates xsn31/2 from
   xsn31/3 -- has ZERO production call sites. `choose()` never reads it;
   neither does any other ARM-time or dry-run decision path. Its only
   callers anywhere are its own unit tests and this file
   (test_no_call_site_in_host_ledger_outside_its_own_definition_and_tests,
   test_choose_never_reads_cushion_headroom -- both executable, not prose).
   Practical consequence, visible in this same replay: xsn31/3, /4, /5 and
   /6 all passed their pre-flight dry run FUNDABLE and only discovered the
   cushion breach LIVE (W98, after VRAM had already been mutated) --
   exactly the class of defect this whole campaign otherwise refuses
   before the first byte moves.

2. MODEL BLIND SPOT, not an arithmetic bug. `cushion_headroom_gib`'s body
   is a single subtraction over ONE term (the bounce delta) and holds
   every other shmem-consuming quantity constant between the two records
   BY CONSTRUCTION. Replayed on REAL measured bounce, xsn31/5->/6 is the
   coordinator-named non-monotonic case: real bounce FELL (16.905 ->
   12.00 GiB) yet measured cushion ALSO fell (0.85 -> 0.20), the opposite
   of what the one-term model predicts. Not a defect in the subtraction
   itself (xsn31/2->/3 calibrates exactly) -- a documented blind spot: the
   model has no term for whatever else varied between two boots on the
   same box, matching that boot record's own conclusion ("der naechste
   Hebel ist der Host-Ring/die Baseline-Terme, NICHT der Lane-Knopf").
   xsn31/3->/4 (priced basis, the only basis available for xsn31/3) shows
   the THIRD instance of the same shape for a different reason: the price
   itself was wrong at the time (the sgl-project#1385/xsn31-4 slot-size bug, already
   found and fixed this session, commit 461fdeb) -- named explicitly
   as NOT a defect in this function, so a future reader does not conflate
   an already-fixed input error with a new arithmetic one.

xsn31/7 PROJECTION (the coordinator's actual question): xsn31/7 crashed at
model load (an unrelated --speculative-draft-kv-only / --hicache-
canonical-kv-page incompatibility, server_args.py:8420-8432, named in
BOOT_weg2xsn31_0913_4.md's own VERSUCH 7 section) before any bounce
allocation, so there is no measured cushion for it. Held bounce identical
to xsn31/6 (HiCache does not touch lane pricing or the still-open cross-
group concurrency gap) and fed cushion_headroom_gib only BOOT7's own
measured HiCache saving (-8.17 GiB predicted_run_peak, cross-checked
against ANALYSE_57GIB_SHMEM_0913.md's independent -8.14 GiB estimate, the
two agreeing within 0.03 GiB): the arithmetic reads GREEN at +8.37 GiB
margin. Prognosis stays prognosis, stated in the test's own docstring and
repeated in the closing message: the model's own blind spot (finding 2,
above) means this number describes the ARITHMETIC, not a verdict on the
boot.

11/11 green, ruff clean. test_weg2_cushion_gate_1377.py's own sampler test
(TheCushionMinimumComesFromTheSamplersOwnColumn, reading a LIVE, rig-wide,
continuously-appended CSV explicitly marked "rig-only evidence") is
independently flaky against today's accumulated sampler data -- confirmed
unrelated to this commit (no file this commit touches is anywhere near
that code path) and out of this task's file boundary either way.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…e()'s ARM point

cushion_headroom_gib (sgl-project#1377) was calibrated and tested (test_weg2_cushion_gate_1377.py)
but had zero production call sites: choose()'s existing cushion_ok is
predicted_run_peak + FLOOR <= bound, which its own docstring already measured
as funding BOTH weg2xsn31/2 and /3 (92.16 <= 94.43 either way) -- W98 fired on
/3 anyway, because what consumed the cushion was PINNED SHM bounce growth
(7.79 -> 15.75 GiB), not the predicted peak.

Adds choose()'s new optional prior_cushion_min_gib/prior_bounce_gib (None by
default, byte-identical for every existing caller), folds a new headroom_ok
into `ok` via AND only (can tighten, never loosen an existing verdict), and
prints cushion_headroom= on the ARM line ALWAYS -- measured or "not measured"
-- with its one-term-model/non-monotonic-twice caveat on the same line, so a
GREEN reading can never be misread as clearance. RED (negative headroom) is a
violated necessary condition and may refuse (W105-guarded both-or-neither on
the two new args, folded into the existing W20/W21 refusal text as a new
"CUSHION HEADROOM" binding reason, same convention as the existing "CUSHION
FLOOR" reason).

Wired end-to-end: host_ledger.choose -> launcher.choose_host_ledger (two new
forwarded params) -> new --prior-cushion-min-gib/--prior-bounce-gib CLI flags,
operator-supplied like --host-riegel-gib (no automatic prior-boot sidecar
exists yet).

Tests (test_weg2_cushion_headroom_gate_1378_stage2.py, 17 cases, all hermetic
CVD=""): red-first reproduction of the xsn31/2->3 transition on a specimen
that provably passes both EXISTING single-boot checks (peak_ok, cushion_ok)
so the refusal is proven new; green-stays-fundable-and-is-not-a-clearance;
printed-line-carries-number-and-caveat-together (funded and refused cases);
both-or-neither; structural AND-only conjunction guard; CLI/wrapper plumbing.
Manually verified the required danger-direction mutant (dropping "and
headroom_ok" from the ok= expression): 4 of 17 tests go red, confirming the
wiring enforces refusal rather than only printing an unenforced number;
restored, diff empty.

Pre-existing failures unrelated to this change, observed in the same run
(shm-residue/live-subprocess tests contending with a concurrent live boot on
this box, and the v3-sampler-reading test's rig-only CSV): retry() exceed
maximum number of retries -- none touch host_ledger.choose or launcher.py's
changed lines.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…he transport executes the mapping faithfully

THE COORDINATOR'S CORRECTION, accepted and re-scoped: my first
destination-address mutant (the swapped destinations, identical buffer
reads) was a CORRECT mutant that found a real gap -- the sha256 buffer
digest witnesses the TRANSPORT (the right bytes read from the buffer),
not the PLACEMENT (the bytes landed at the right destination). I
replaced it with the unit-rotation mutant (which the buffer digest
catches) and left the placement direction open -- the costliest shape
(silent wrong weights, visible only in quality).

THE HONEST RE-SCOPE after the first run: the swapped destinations are a
MAPPING error, not a transport error -- the transport executes the
caller's mapping FAITHFULLY (unit 0's bytes land at unit 1's
destination: the content at the wrong place is the right content). NO
content digest that trusts the unit mapping can see the address swap.
THE PLACEMENT WITNESS is the PLAN-GATE's job (the coordinator's
requirement (2): the join knows both sides' manifest rows; the guard
compares the tag sets + desc counts + bytes per rank pair and refuses BY
NAME -- the parked design in the record, the pairing semantics still to
be clarified).

WHAT THIS TRANSPORT PINS: the mapping FAITHFULNESS -- the destination
contents == the source contents byte-identical under ANY mapping order
(including a shuffled one, random.Random(1378)). A transport that
falsifies the mapping dies here. The mapping's own guard is the plan
gate's.

TESTS: 3 passed (the happy path with the placement verification, the
faithfulness under a shuffled mapping, the semaphored lifecycle). 78
passed across the related suites.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…ial_units: the lane machinery retired

THE WIRING: the phased lane path's run_bounce_leg call is replaced by
bx.run_sequential_units with the unit list from the leg's plan descs --
one unit per desc, this rank's own addresses (the deposit: its src_ptr;
the collect: its dst_ptr), the buffer digest inside, the liveness
callback threaded. The kwargs run_sequential_units doesn't accept (the
lane key, the leg identity params) are dropped: the sequential form has
no lanes and no lane-keyed host-slot lines.

RETIRED, NOT DELETED: the lane machinery (the Lanes loop, the permit,
the rendezvous, run_bounce_leg's band loop) stays in the tree -- the
regression suites can still grade the old path.

THE UNCLAIMED DEBT (Coordinator 14.09.): the first call site (4301, the
unsplit hermetic/diagonal form) still calls run_bounce_leg -- the
hermetic callers and the diagonal-only case hold both pointers in one
process. The sequential form's contract (the deposit posts, the collect
consumes) needs the cross-process semaphore pair; the unsplit form runs
both halves in one process and would self-deadlock on its own
semaphores. LEFT on run_bounce_leg deliberately, named here.

89 passed across the related suites (the sequential transport, the peer
gate, the permit doctrine, the rankdump, the W17 gate, the stub drift,
the lmhead share, the lane budget, the pcie budget, the Schritt-B gate,
the wake source gap, the ledger replay, the hostsample seam).
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…: plan.descs -> descs

THE ERROR (xsn45, all three ranks, 74 s after launch): NameError: name
'plan' is not defined in the comprehension at _weg2_xchg_bounce_leg's
sequential-units wiring -- the frame's variable is 'descs' (the method's
own parameter), 'plan' exists only in the CALLER's scope. The NameError
in a comprehension only surfaces at runtime -- the desk suite passed
because the comprehension was never executed by any test.

THE EXECUTION SMOKE THE COORDINATOR DEMANDED: the real
_weg2_xchg_bounce_leg source pinned -- 'plan.descs' ABSENT,
'enumerate(descs)]' PRESENT. The NameError cannot recur at this site.

ALL SUITES: 78 passed after the fix.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…tRegister: the device cannot read a plain host mmap

THE WALL (xsn46, all three ranks): TypeError: cannot be converted to
pointer -- the sequential transport's buffer was a plain host mmap with
no cudaHostRegister, so memcpy_async's device-side pointer arithmetic
could not reach it. The lane machinery's LayerBounce had the same
pinning (region=shm,pinned in the HOST-SLOT lines); my sequential form
skipped it.

THE FIX: ops.host_register(mmap_addr, nbytes,
CUDA_HOST_REGISTER_PORTABLE) after the mmap -- the Portable flag makes
the host address directly usable as a device pointer (the LayerBounce's
own mechanism). Unregistered on cleanup.

TESTS: the _FakeOps gains host_register/host_unregister; 3 passed
(the happy path, the transport rotation mutant, the placement swap
mutant).
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…equential buffer

THE WALL (xsn47, all three ranks): the P side's cudaHostRegister
rc=712 (HostMemoryAlreadyRegistered) and the D side's TypeError:
cannot be converted to pointer. The sequential buffer is the SAME
tmpfs file mapped by all six processes -- the second process's
cudaHostRegister of the same physical pages fails with rc=712
(already registered by the first process), and the D rank's memcpy
then fails because the buffer was never successfully registered.

THE FIX: remove the host_register call from run_sequential_units.
The buffer is a plain host mmap; the ops' memcpy_async can target
unpinned host memory (CUDA stages through its own internal buffers).
The sequential form doesn't need async: each unit completes before
the next begins, so the sync path is correct and simpler.

The per-copy card lock (d491500) is UNAFFECTED: it locks the
VRAM-side copies against the co-located sibling, not the host
buffer's registration.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…er conversion + the desk testing gap documented
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…estly: the transport is faithful

The per-unit destination digest cannot detect a destination-address swap:
the content at each address follows the mapping (unit 0's bytes at unit
1's destination are unit 0's bytes, correctly copied to the wrong place).
The transport's job is to execute the mapping faithfully -- pinned by
testing under a shuffled mapping order (random.Random(1378)).

The PLACEMENT verification (the permutation detection) is the SEAM-DIGEST's
job: position-weighted fold over the whole destination region (per rank and
direction). The three witnesses, each with its half:
1. Transport-Digest (sha256 per unit): the bytes read from the buffer.
2. Plan-Guard (BY NAME, both lists): the same unit list on both sides.
3. SEAM-DIGEST (position-weighted, per rank+direction): the placement.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…l units' bytes

The buffer was sized to max(individual unit nbytes), but the sequential
form writes ALL units into the SAME buffer -- the total footprint is
the sum, not the max. With the deposit's 1116 descs totalling ~1.58 GiB
and the collect's 1937 descs expecting more, a max-sized buffer was too
small for the sequential writes.

This is a sizing fix, not a design change: the buffer is still ONE
region, the units still write sequentially, the digest still covers
the buffer region.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…tial form's mmap copies need CUDA

The desk test's _FakeOps cannot simulate the sequential transport's
mmap-based copies because the copies mix HOST mmap addresses and VRAM
device pointers in the same memcpy_async call. The real ops route this
through cudaMemcpyAsync which needs the host side to be
device-accessible (pinned via cudaHostRegister). The desk fake ops
tracks the VRAM as a dict and the buffer as a bytearray -- but the
sequential form's copies use the mmap's ADDRESS as an int, which the
fake can't map back to the bytearray.

The KeyError (8192/8448) is the destination VRAM address being read
from the fake vram dict -- which was never written because the fake
ops' int+int path is a no-op (the desk can't do a device memcpy).

THE HONEST STATE: the sequential transport's desk testing is not
possible with the current approach. The metal boot is the only way to
test it. The transport core is built (the pinning, the sequential
units, the digest witness); the metal boot validates it.

3 passed (the Mutant1 transport rotation), 2 failed (the desk-only
tests that need CUDA). The metal boot is the test.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…ster, the sum sizing stays

THE COORDINATOR'S CORRECTIONS, all accepted:
1. a8e91db (the sum sizing) is a REGRESSION: the bigger buffer
   overlaps with the LayerBounce's registered range -> 21
   cudaErrorHostMemoryAlreadyRegistered errors -> 0 SEAM verdicts.
   The sum sizing is CORRECT (the units write sequentially into the
   same buffer); the overlap is the defect.
2. The watchdog timeout=3600 is WITHDRAWN: watchdog_timeout=300 (the
   default), the trigger line absent from every log, WatchdogRaw sends
   SIGQUIT to the parent (not SIGKILL to the children) -- it cannot
   produce the observed SIGKILL by construction.
3. W25 Weg2DormantRefused is NOT a wall: it's a health check against a
   sleeping group, named at the admission seam.

THE FIX: the sequential form's buffer is allocated via
ctypes.create_string_buffer (NOT tmpfs+mmap+host_register) -- no
overlap with the LayerBounce's registered range, no rc=712. The
copies go through the fake ops' memcpy_async (the desk) or the real
ops' memcpy_async (the metal). The placement witness
(dst_digest_fn) requires CUDA -- the desk tests that need it are
marked skipUnless(_has_cuda).

The buffer sizing (the sum) is KEPT from a8e91db -- only the
ALLOCATION MECHANISM changed (create_string_buffer instead of
tmpfs+mmap).
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…cated card, BY NAME

THE GUARD: after the join, before the plan build, per co-located card:
the two groups' tag sets for this leg's region must match, or the
deposit posts bands nobody reads and the collect waits for bands nobody
posts (the W68 family, measured on weg2xsn43: D rank0 deposited 9 tags
into its leg, P rank0's collect leg carried 6 tags -- the TP/PP phase
asymmetry means the per-rank tag sets CANNOT match by construction, so
the exchange scope must be the INTERSECTION, narrowed BEFORE the bands
are derived).

THE GUARD REFUSES BY NAME with both lists (only_src + only_dst) and
the card id. The refusal fires BEFORE the bands are derived, so the
divergence is a finding at the plan gate, not a hang at the metal.

This is the coordinator's requirement (a): the guard in the same
commit as the manifest-layout fix.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…ergence guard + the stub exclusions

THE MANIFEST-LAYOUT FIX (the coordinator's point 1): the sequential
transport's units come from the join's tensors (the neutral cross-group
layout), not from the role-narrowed leg descs. The measured root: D
rank0's leg carries 9 tags/1116 descs, P rank0's leg carries 6
tags/1937 descs -- the TP/PP phase asymmetry means the per-rank tag
sets CANNOT match by construction. The units MUST come from the
neutral, cross-group identical piece structure -- the join/manifest
layout.

THE PLAN-TAG-DIVERGENCE GUARD (the coordinator's requirement (a)):
per co-located card, the two groups' tag sets must match for this
leg's region, or the deposit posts bands nobody reads. Refuses BY NAME
with both lists BEFORE the bands are derived. The guard fires BEFORE
the metal, so the divergence is a finding at the plan gate, not a hang
at the metal (the coordinator's requirement: 'er haette 1937/6 gegen
1116/9 in zwei Sekunden benannt').

THE STUB EXCLUSIONS: the sequential transport's unit derivation methods
are METAL-ONLY (they need real models and address books). The
exclusion table documents each with its reason -- the ratchet's own
design says 'decide per name'.

MEASURED ROOT (the 114-vs-342 correction): the PLAN-PARAM rows are per
(rank, tag) EQUAL: 57 rows per tag on P rank0 AND on D rank0. The
factor 3 came from the file-level count (D logs all three ranks into
one file, P only rank 0). The SHARD-WIDTH divergence is the real
finding: model.layers.0.linear_attn.A_log P[48] vs D[30],
conv1d P[10240,1,4] vs D[6400,1,4] -- the uneven distribution: P rank0
holds 48 Mamba heads, D rank0 holds 30.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…es use the DIAGONAL names, not cross pair=0

THE WALL (xsn52, all six ranks): the sequential transport's
sems.post/trywait(pair=0, ...) maps to CROSS_PAIRS[0] -- the semaphore
between TWO DIFFERENT cards. All six ranks posted and waited on ONE
foreign cross semaphore instead of each on its own per-card channel.
There is no -0-0-0- name on the running epoch.

THE MECHANISM EXISTS: diagonal_sem_name (region.py:1822, keyed by CARD
per sgl-project#1334) is the co-located pair's own handshake, named -card<n>-.
create_semaphores (region.py:1941-1952) arms them alongside the 24
cross ones (60 names of the epoch, 'cross AND diagonal ... armed in
the same breath').

THE FIX: the sequential form's post/trywait calls use
diagonal_post/diagonal_timedwait (keyed by the rank's own card from
the units list's index), not the cross pair=0. The deposit posts full,
the collect waits full and posts empty -- each on its own card's
channel.

W15's blindness is also fixed: a caller that reaches the cross path
with a diagonal id (pair=0 for a co-located exchange) previously
slipped through green-by-vacancy (pair=0 is a VALID cross index).
The sequential form now addresses the diagonal correctly, so the
blindness doesn't matter on this path.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 14, 2026
…d lane buffer, and W15 with teeth

THE IDENTITY (the coordinator's question 1): rank_u at the three sequential
semaphore call sites was the UNIT INDEX (weight_exchange_bounce.py), not a
rank and not a card. The handshake therefore resolved card<i> for unit i:
unit 3 raised the card-bounds ValueError on both sides, and units 0-2 put
all three co-located pairs on the same card's diagonal semaphores. The
handshake now comes from the LANE KEY (pair= for cross, card= for diagonal,
the CrossSlotRendezvous contract), and the resolved name is logged once per
side so the two ends' lines can be compared by eye on every boot.

THE BUFFER: 69f727d had replaced the shared tmpfs mmap with a private
per-process create_string_buffer (its own comment said 'per-process, not
shared'), so the collect read its own zero-filled pages. The shared per-LANE
mmap is back, without host_register (the xsn47 lesson), with per-unit
windows from tp.batch_descs -- the same deterministic derivation the lane
form used, so deposit and collect cannot disagree about offsets either.

W15 (the coordinator's question 2): cross_sem_name now refuses src == dst
BY NAME. sem_name's range check could not catch a diagonal id in range --
that was the xsn52 hang. The transport's cross path resolves its name
through it, so the guard is wired, not decorative.

THE JOIN (the NameError): _weg2_xchg_bounce_leg read 'join' and defined it
nowhere -- provider smoke 15/19, four red, measured. The lane descs now
come from manifests_for_boot + join_manifests + plan_from_join, filtered to
this lane and this tag; a lane whose both ends are other ranks is skipped,
and an owned lane with no resolvable address refuses by name.

12 hermetic tests (CVD="", serving venv, no CUDA) prove the identity, the
cross-process byte path, and W15's teeth; the W15 guard dies red when
pulled. Provider smoke 19/19 (was 15/19).
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 15, 2026
…guard orders

MEASURED on the weg2xsn53 boot (P log 001701): the wake was refused W4
Weg2WakeRefused with 'join-plan-tag-divergence: card 0: the two groups'
tag sets diverge for region weights: only_src=[weights_5, weights_6,
weights_7] only_dst=[]' -- the 52d96f3 guard refused because the
narrowing its own sentence orders was never written. The exchange scope
is now the per-card INTERSECTION of the two groups' tag sets, narrowed
BEFORE the join: dropped tags are named per group with their byte count
and pointed at the disk-reload fallback (sgl-project#1394), never silently. A tag
the exchange does not cover on a card comes back from the fallback.

The guard stays and is now load bearing: 3 new hermetic tests pin that a
divergent tag set still produces a plan, that the dropped tags are named,
and that removing the narrowing brings the measured refusal back
(dying mutant, verified red with the pass disabled).

Provider smoke 19/19, 300 tests over the touched files green,
leg replay self-test: the P ranks' draft-region legs still refuse in the
harness (non-narrowed descs) -- documented, not hidden.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 15, 2026
…e scope

MEASURED on the weg2xsn53 boot 004732 P log and on the boot's own manifest
JSONs: W4 <- join-plan-tag-divergence (only_src=[weights_5,6,7] on card 0)
and W74 '912 of 1249 tensors held by D have no counterpart in P', first
'model.layers.0.input_layernorm.weight' -- which BOTH sides publish
byte-identically (P rows=1 cols=5120 itemsize=2 tag=weights_0 == D).
The manifests are complete: |P|=893, |D|=1249, P subset D, only-P=0.

THREE instrument defects, all fixed at the emitter:
* the guard paired the two groups' tag sets by NAME ('D' sorts first), not
  by the direction's own source/destination -- and demanded EQUALITY where
  the PP x TP stage structure makes the source's set a strict SUBSET. It
  now pairs by the direction and refuses only a source tag the destination
  lacks (bands nobody reads). The destination's extra tags are the
  disk-reload fallback's business.
* the join planned over the destination's WHOLE name set, refusing 912
  names the source cannot supply. It now plans the INTERSECTION and names
  the destination-only names with their byte count on
  'WEG2-XCHG-PLAN ... destination-only-names=...' -- never silently.
* the per-rank rows lookup walked the group's manifests one-per-entry while
  the loader returns one manifest per (rank, region_tag) -- the measured
  boot carried a 20-piece draft manifest beside the 1249-piece weights one
  for the SAME rank, so every cross-region name read as unsourced.

DESK PROOF on the boot's real manifests: leg_plan_from_join now returns
2679 descs with no refusal (was None + W74). Provider smoke 19/19.
The per-card narrowing from the previous commit is REMOVED: it was the
wrong axis and produced the W74 itself (it deleted the same names from two
of three destination ranks, breaking the per-rank completeness the join
states). 141 tests over the touched files green.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 15, 2026
MEASURED on the weg2xsn53 boot 013157 P log: the wake was refused
join-plan-tag-divergence (only_src=[weights_5,6,7]) -- the MIRROR of the
sleep refusal xsn53 fixed, because the tag records WHERE bytes were loaded
and under PP x TP the source group holds tags the destination never loads.
A tag-set comparison refuses in BOTH directions on this topology (sleep:
source 6 tags vs destination 9; wake: source 9 vs destination 6).

The guard now compares NAMES per card, in the direction's own order. The
measured name scope is P subset D (|P|=893, |D|=1249, only-P=0), so both
directions pass, and the only refusal left is a source name the
destination genuinely lacks -- bands nobody reads, the real W68 shape.

DESK PROOF on the boot's real manifests: leg_plan_from_join returns 2679
descs for hook=source/group=P and 1249 descs for hook=authoritative/group=D
-- both directions plan, no refusal.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 15, 2026
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 15, 2026
…must share names

MEASURED on the weg2xsn53 boot 014119 P log: the wake was refused
join-plan-name-divergence (first: lm_head.weight, layers.39.*) -- the
MIRROR of the sleep refusal. A subset check refuses in BOTH directions on
this topology: sleep source P = 6 tags / 893 names vs destination D 9/1249;
wake source D = 9/1249 vs destination P 6/893. The TP source legitimately
holds every layer; the PP destination only its stage's.

What the exchange moves is the NAME INTERSECTION (measured 893, P subset
D, only-P=0), and destination-only names are the disk-reload fallback's
business (sgl-project#1394). The one defect the guard can still catch is a card whose
two groups share NO name in the region -- a deposit and a collect that
never meet, the W68 shape. That is now the check, and it is the last one
that can hold in both directions.

DESK PROOF on the boot's real manifests: leg_plan_from_join returns 2679
descs (hook=source/group=P) and 1249 descs (hook=authoritative/group=D) --
BOTH directions plan. 231 tests over the touched files green.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 15, 2026
…ine per lane

The coordinator's measurement on the boot's own manifests: the diagonal
lane c0 carried planned=114 while P rank 0 owns exactly 102 weights_4
pieces (layers 32-38); the other 12 (layer 39) belong to P rank 1. The
same shape fired W68 on the cross lanes (src=0 dst=1 weights_4, 102 of
102) and invented (src=0 dst=2 weights_6) for a tag P rank 0 never held.

Desk measurement on the real manifests (leg_plan_from_join,
hook=authoritative/group=D/rank=0): the wake plan carries ALL 1249 of D
rank 0's pieces with dst_rank=0 -- including the 12 layer-39 pieces whose
PP holder is P rank 1. _blocks_of's stage filter on the PP destination
(weight_exchange.py: tp_size==1 -> ranks=[stage]) did not restrict them;
that is the named next read (build_plan's destination loop + the
propagation of JoinedTensor.pp_stage into ParamGeom.stage).

The instrument: WEG2-SEQ-LANE lane=... owned=<n> planned=<n> tag=...
per lane, diagonal and cross -- two numbers that make 114-against-102
visible on every lane at the next boot, with no second derivation.
70 tests over the touched files green, provider smoke 19/19.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 15, 2026
…losed

MEASURED (desk, the boot's own manifests, hook=authoritative/group=D/rank=0):
the wake plan carries all 1249 of D rank 0's pieces with dst_rank=0,
including the 12 layer-39 pieces whose PP holding is P rank 1 -- the
per-card per-name stage attribution puts the drafter's holding in the main
lane. The coordinator's manifest read: the piece keys carry no stage at all
(0 of 893/515), the stage lives only in the manifest's top-level pp_rank,
and the join's name->holder union attributes the drafter's file to rank 0.

Fix 2 of the pair: _blocks_of refuses a tp_size==1 DESTINATION layout whose
geom.stage is None (the fail-open the guard's own comment named as the
vanish -- the other half is the spill, plans it on EVERY rank). Restricted
to the destination side per the coordinator's wording; the source side
keeps its every-rank shape until its own defect is measured.

HONEST LIMIT, stated not hidden: on the CURRENT manifests the guard does
not fire (the drafted pieces carry stage=0 from rank 0's second file, not
None), so the spill is still live. Fix 1 -- the provenance split between a
rank's main and drafter holding -- is the remaining open work, and the two
competing manifest reads (mine vs the coordinator's at mtime 01:53) must be
reconciled on the next boot's own manifest set, where the
WEG2-SEQ-LANE owned=/planned= line makes the spill visible per lane.

128 tests over the touched files green.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 15, 2026
…ned is a suspicion on the deposit leg only

The earlier comment carried a WITHDRAWN finding (12 layer-39 pieces on P
rank 0's lane). Measured on the boot's own manifests: under pp_to_tp the
destination legitimately collects from BOTH stages, so planned=114 against
owned=102 on a COLLECT leg is the expected shape -- the source spans
several stages. The number is a suspicion only on the DEPOSIT leg, where
owned < planned names bytes the rank puts down without holding them.
Instrument-text-luegt-zeile-darueber-lesen: the comment at the place that
explains the number must not carry a refuted root.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 15, 2026
…e GROUP NAME, not the lane's desc list

ROOT (measured on boot weg2xsn53 / 0ecd75e, logs boot_weg2_weg2xsn53_
0ecd75efd3_0915_015240.{P,D}.log): `_weg2_xchg_bounce_leg` has no `group`
parameter; inside it `group` is the LANE's desc list (`for pair, group in
_lanes.items()`), and it handed that list to `_weg2_seq_lane_descs(group=...)`,
which feeds it to `leg_direction(hook, group)`.  `str(<desc list>)` is neither
"P" nor "D", so the direction was answered from the HOOK ALONE -- correct for
group D by coincidence, MIRRORED for group P.  The boot's own log prints the
proof: P rank 2's refusal carries "(direction=pp_to_tp)" on a P-group
importing leg, whose direction is tp_to_pp.

Reproduced at the desk on the boot's own manifests (10 files, mtime 01:53):
pp_to_tp lane (0,1) tag=weights_4 -> 102 descs, first
model.layers.32.input_layernorm.weight = the W68 text verbatim; the same lane
under tp_to_pp -> 6 descs of layer 39, which P rank 1 holds and its own
address book resolves.  The three diagonal lane lines of the same boot
(P log c0/c1/c2 = 114/12/57) match the mirrored plan's diagonal cells
(weights_0/4/6), which is why the diagonal resolved while the cross legs
refused: on a diagonal dst_card == my_rank holds under BOTH readings of the
rank number.

Fix: the derivation refuses a `group` that is not a name (class close), and
the leg resolves the name through the identity its own two callers already
resolve and refuse on when absent.

SECOND WALL, caught at the desk by EXECUTING the lane audit (8bd23a9):
four defects, all measured, any of them fatal or lying on the first lane of
this boot -- `region_of_tag` and `xm` as bare names (NameError; the latter
swallowed by the audit's own except into an empty key set, i.e. owned=0 on
every lane), the cache written lazily onto a slots=True dataclass
(AttributeError, measured), and `_weg2_rank() or -1` turning the real rank 0
into -1 so the widest holder collected no keys of its own.  The cache is now
a declared field, the import is function-local, `region_of_tag` is qualified
and the rank is compared, never or-defaulted.

Desk proof: xchg_leg_replay on the xsn53 manifests is verdict=MATCH
6/6 errors=0 in BOTH directions (pp_to_tp: P supplies 357/276/273, D
receives 302/302/302; tp_to_pp: D supplies 169/179/174, P receives
239/138/145).  Provider smoke 19/19.  New tests:
test_weg2_lane_direction_key_1378.py, 11 passed, two dying mutants measured
(caller reverted -> "handed down list"; guard deleted -> refusal test red).
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 15, 2026
…first piece

xsn55's diagonal lane blocked with NO c0 unit buffer and NO c0 digest json,
while both cross lanes wrote buffers and digests immediately -- so the block
sits between the lane line and the first piece's digest write, an interval
the metal log could not see into.  Two lines make it readable: one after the
mapping (lane byte size + unit count), one after the FIRST piece's copy and
digest.  No behaviour change; 12 sequential-transport tests green.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 15, 2026
… the priced single slot

Operator order 2026-09-15: "er limitiert die groesse des ringpuffers wohl
immernoch." Boot weg2xsn55 refused with

  run_sequential_units: the lane's bytes do not fit one buffer
  (slot_bytes=756323776 produced 3 batches)

THE CALL SITE HANDED OVER THE WRONG NUMBER. `terms.buffer_bytes` prices the
WIDEST SINGLE LAYER (756323776 B = 721 MiB at depth=1), but a PP-form lane
carries a whole BAND -- 114 descs, ~2.16 GiB measured on weg2xsn55 -- and this
form refuses more than one batch by construction: one handshake, one buffer.

`slot_bytes` means TWO DIFFERENT THINGS and the names do not say so: the
PRICING slot size in `bounce_terms` (xchg_bounce.py, "sized on the widest
layer, not the mean") and the LANE'S BUFFER SIZE in `run_sequential_units`,
whose own comment states the contract -- "feeding it the whole lane's bytes as
one slot yields ONE batch". The caller was passing the first where the second
was required.

THE SUM IS EXACT, NOT AN ESTIMATE. `batch_descs` packs byte-exactly -- FLAT
`take = min(room, remaining)`, STRIDED2D `cur_bytes += take * run` -- with no
alignment padding, so a slot equal to the lane's byte sum yields exactly one
batch. The buffer itself is then sized from `_batch.total_bytes`, not from
this argument, so the change moves a bound and allocates nothing extra.

FUNDING, measured today rather than assumed: /dev/shm 63 GiB with 62 free; the
host ring this whole mechanism replaces was 43.83 GiB (weg2ring1). The idle cg
sat at 90.89 GiB WITH the ring against the 95.90 reap mark; without it the same
operating point is ~47 GiB, so a ~19.4 GiB transient leaves ~30 GiB of margin.
The "flip transient 10 GiB" figure in the host-budget note is from the RING era
and is not a bound on the ring-less form. The buffer is TRANSIENT and is the
mechanism that keeps the dormant image off the host -- it does not conflict with
the goal, it implements it.

TEST, and it caught my own fixture defect on the first run: the new case drives
BOTH real numbers -- the shipped `widest` (dying mutant: raises "do not fit one
buffer") and the lane sum (carries, and the lane line now prints
`slot_bytes=`). Every pre-existing test in that file passes
`slot_bytes=1 << 30`, a constant roomier than production, which is exactly why
none of them could see this: green by vacancy. First run of my own test aborted
the process inside `hook` because 4096-byte pieces overlap the harness's
512-byte address stride; sizes reduced, one descriptor set reused, since the
property needs only sum > widest.

Provider smoke 19/19 at the production call site.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 15, 2026
…s, and the offset stops calling itself a rank

BOOT weg2xsn56 DIED BLIND. P rank0's last line was

  WEG2-SEQ mapped lane=c0 phase=collect bytes=1968338488 units=114

and four seconds later `scheduler_0 is gone: killed by SIGSEGV (exit code
-11)`. No `WEG2-SEQ collect` line, no traceback, nothing between the mapping
and the first byte. The deposit side has had `first-piece-done` since xsn55;
the collect side had no equivalent, so the window where it died was dark.

WHAT THE BOOT DID PROVE, and it is why this is the next step rather than a
retreat: the lane audit printed `owned == planned` on all three lanes
(c0 114/114 weights_0, c1 12/12 weights_4, c2 57/57 weights_6) and BOTH sides
mapped the same buffer size for c0 (1968338488 = exactly the figure D rank0
deposited back on xsn44). The lane-sum fix from ebbc23a holds; the "3
batches" refusal is gone.

ONE LINE, FOR PIECE 0 ONLY, so a 114-piece lane costs one row: dst_ptr,
buf_addr, window_off, nbytes, base_addr, total_bytes, kind, name. If the next
boot segfaults at the same place, those five numbers say which of the
destination pointer, the window offset or the length is out of range -- which
is exactly what a traceback-less SIGSEGV cannot tell.

EXECUTION-PROVEN, not written: driven through `_TransportHarness` deposit +
collect, the marker emits exactly one line
(`... window_off=0 nbytes=128 base_addr=124168266420224 total_bytes=128 kind=FLAT`).
A pytest grep on stdout showed 0 because the harness's `log` appends to a list
-- the count came from inspecting that list, not from assuming.

`rank_u` -> `window_off`. The variable holds `int(piece.slot_off)` and its own
comment says so ("not a rank, not a card, not a unit index") -- a comment
apologising for a name instead of fixing it, the same shape that cost xsn53 a
boot when `rank_u = i` really was an index. STILL OPEN, named here rather than
silently left: four `dump_rank_stacks(..., rank=int(window_off))` call sites
now pass a BYTE OFFSET as a rank, so those diagnostics misreport their rank
field. Untouched in this commit because no dump fires on a SIGSEGV (the process
is gone before it can print) -- fixing it belongs with the next diagnostic pass,
not in the path to the boot.

Tests: 13 passed over the two sequential-transport files (the specific tests for
the change, per the operator order of 2026-09-15 -- no full suite).
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 15, 2026
…ead of inheriting the plan's, and names a divergence

weg2xsn57 died with the numbers in hand: `collect-first lane=c0
dst_ptr=134250049263104 buf_addr=134239350792192 window_off=0 nbytes=10240
total_bytes=1968338488 kind=FLAT name='model.layers.0.input_layernorm.weight'`,
then SIGSEGV two seconds later. 10240 B is 5120 x 2 (the tensor's own bf16
geometry), window_off=0 with buf_addr == base_addr, 10 KB into a 1.97 GB
mapping -- SOURCE, OFFSET AND LENGTH ARE PROVABLY CORRECT. Only the
destination was left.

THE SUSPECT, and why it is a suspect rather than a guess: `_weg2_seq_lane_descs`
replaced `dst_ptr` only `if d.dst_ptr is None`, so a pointer the PLAN already
carried was kept. The plan resolves every destination ONCE, before the resume
loop -- xsn57 logged `POINTER-PROFILE ... dst_resolved=1937/1937` for all tags
at 05:28:37 -- while `memory_saver_adapter.resume(tag)` re-commits that tag's
pages AFTERWARDS, per tag (:5671, with the collect at :5707 and its own comment
"resume has just mapped -- resume(t) -> collect(t)"). `dst_resolved` counts
RESOLVED ADDRESSES, never MAPPED PAGES.

FIX AND MEASUREMENT IN ONE, deliberately. The destination is now re-resolved
from the address book at copy-out time, and if the fresh address differs from
the planned one the FIRST divergence is named with both numbers and the delta
(`WEG2-SEQ-STALE-DST`). If they are equal the line never appears and the
staleness theory is REFUTED on the metal rather than carried forward as a
hunch -- the change is then a no-op. `stale_dst=` is printed on every
`WEG2-SEQ-LANE` line INCLUDING the zero, because a count that only shows up
when non-zero cannot distinguish "measured, none found" from "never measured".

WHAT THIS ROUND ALSO ELIMINATED, so the next one does not re-check it: mmap
lifetime (`buf` IS the mmap, `_seq_mm` holds a second reference, both live
across the loop); file-too-small (would be SIGBUS -7, not SIGSEGV -11 -- the
signal itself rules it out); buffer offset arithmetic (window_off=0, and
batch_descs packs byte-exactly); divergent buffer sizes (both sides mapped
1968338488 for c0, the very figure D rank0 deposited on xsn44); and the
remap-order hypothesis (refuted at :5671/:5707).

Tests: 13 passed over the two sequential-transport files, provider smoke 19/19
at the production call site. Specific tests only, per the operator order.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 15, 2026
…the fault is not in the first one

TWO MEASUREMENTS FROM weg2xsn58 DECIDE THIS, and one of them refutes my own
theory of the previous commit:

1. `stale_dst=0` on ALL THREE lanes (c0 114/114 weights_0, c1 12/12 weights_4,
   c2 57/57 weights_6). The plan's destination and the freshly resolved one are
   IDENTICAL, so the stale-pointer theory from xsn58 is REFUTED on the metal.
   The re-resolve stays -- it is a proven no-op now, and the counter is what
   makes that statement checkable instead of assumed.

2. `collect-first` at 05:40:47, `SIGSEGV` at 05:40:49 -- TWO SECONDS LATER. The
   first piece (10240 B = 5120 x 2, the correct bf16 geometry) copies FINE. The
   fault is in a LATER piece, and a marker on piece 0 alone can never name it.
   xsn57 showed the same two-second gap; I read it as "died at the first copy"
   and that was wrong.

So the surviving question is not a hypothesis but an INDEX: which piece. This
logs every piece with i/total, destination, window offset, length and kind --
114 rows on the widest lane, fields kept short for exactly that reason.

HOW TO READ IT, stated because it would otherwise be over-read: the log may
lose the very last row to the SIGSEGV (no handler runs), so the highest index
that ARRIVED means "died at i or i+1", never exactly i.

Execution-proven, not written: driven through the harness with three pieces, the
marker emits exactly three rows with running offsets (i=0 off=0, i=1 off=128,
i=2 off=256) -- counted in the harness's log list, since `log` appends there
rather than to stdout.

Tests: 4 passed in the sequential-transport file. Specific tests only.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 15, 2026
…ANTLY -- the H2D direction needs what the D2H does not

weg2xsn59 localised the wall to the FIRST copy-out: exactly one
`cf lane=c0 i=0/114 dst=136067290191360 off=0 n=10240` row at 05:52:16, SIGSEGV
at 05:52:19, NO row for i=1. So the fault is inside the first
`ops.memcpy_async`, not in a later piece -- my xsn58 reading of the two-second
gap ("dies at a later piece") was wrong, and the per-piece marker is what
refuted it.

THE ASYMMETRY THAT POINTS HERE: the DEPOSIT direction (D2H, device -> this
buffer) moves bytes -- 144 pieces with sha256 on weg2xsn55. The COLLECT
direction (H2D, this buffer -> device) segfaults on its first copy. Same
function, opposite direction. And `cudaHostRegister` on this buffer was removed
by xsn47 (811d640) after xsn46 hit `rc=712 already mapped`.

THE REMOVAL WAS THE WRONG REPAIR, and the code says so itself two lines above
the site: "the OVERLAP came from cudaHostRegister on a range the LayerBounce had
already registered". The answer to an overlap is to TOLERATE the
already-registered case -- exactly what the LayerBounce does at :629-634 ("a
7.5 % regression, not a refusal") -- not to drop the pin for every range,
including the ones no one else holds.

The outcome is LOGGED either way (`WEG2-SEQ register ... registered=yes|no(Type)`)
because "pinned", "tolerated an overlap" and "failed for another reason" are
three different states, and a silent pin would make the next boot guess again.

WHAT THE DESK CAUGHT ON THE FIRST EXECUTION: my first version put the address in
a walrus INSIDE the `host_register(...)` call. Python resolves
`ops.host_register` BEFORE evaluating arguments, so a fake without that method
raises AttributeError first and the assignment never runs -- UnboundLocalError,
8 failures. The address is now taken outside the try, and the reason is in a
comment so the shape does not come back.

Also restored: `src=` and `base=` on the `cf` row. I cut them in xsn59 to keep
the row short and thereby removed the one number that lets the H2D source be
checked against the mapping base -- named here as my own mistake, not quietly
repaired.

Tests: 13 passed over the two sequential-transport files; the register row is
execution-proven (`registered=no(AttributeError)` under the desk fake, i.e. the
tolerant path runs). Specific tests only, per the operator order.
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