Skip to content

docs: update README - #1336

Merged
zhyncs merged 1 commit into
mainfrom
bench
Sep 5, 2024
Merged

zhyncs merged 1 commit into
mainfrom
bench

Conversation

@zhyncs

@zhyncs zhyncs commented Sep 5, 2024

Copy link
Copy Markdown
Contributor

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.

@zhyncs
zhyncs merged commit 3494b32 into main Sep 5, 2024
@zhyncs
zhyncs deleted the bench branch September 5, 2024 13: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 11, 2026
…ble, with no fallback

Boot weg2xsn11 refuted sgl-project#1335's SOURCE on metal while confirming its shape. The
producer refused correctly on every agreed leg (39 of them) because it read
CUDA_VISIBLE_DEVICES, and /proc/<pid>/environ of the live ranks showed why:

    launch_server (P)        CVD = GPU-31d7ef41,GPU-5c648f96,GPU-62dbbae1
    sglang::sched (P rank 0) CVD = GPU-31d7ef41          (one card)
    sglang::sched (P rank 1) CVD = GPU-5c648f96
    sglang::sched (P rank 2) CVD = GPU-62dbbae1          (D identical)

Every scheduler process -- the one that runs the flip leg -- has CVD narrowed
to its OWN SINGLE CARD, which is this repo's documented preferred isolation.
weight_updater.py:1494-1498 describes the process the launcher SPAWNS, not the
child that runs the leg, and one /proc read before writing the producer would
have caught it.

Operator ruling: the launcher publishes SGLANG_WEG2_XCHG_CARD_UUIDS -- the card
uuids in LAUNCHER CARD ORDER, index == the card ordinal the region and pair
tables address -- beside the other xchg variables. One producer, no region
handshake, no second producer of card order. This is the READER half:

* xr.ENV_CARD_UUIDS, published beside CROSS_PAIRS, read once. The launcher
  publishes what this module reads; a retyped literal is how two ends drift.
* uuid_of_card() reads THAT variable and only that. Five named reasons now:
  unset / count (== N_CARDS exactly, never "at least") / blank / duplicate
  (two ordinals naming one card would turn a CROSS pair into an on-card one
  behind the pair tables' back, with the diagonal carrier unused) -- plus
  `disagrees` at the door in require_card_uuid_map.

AND NO FALLBACK, which is a decision with a measurement behind it. On that same
boot the launcher's card order was 5090,3080,3080 and NVML's was 3080,5090,3080
-- the orders DIFFER. A fallback to NVML or CUDA enumeration would return the
right uuids under the WRONG ORDINALS: a silently wrong PairStats label and a
wrong identity check that refuses correct ranks. A refusal is strictly better
than a plausible map, so the no-fallback rule is a test (by call shape, over
the function AND the module), not a comment.

Two stale tests found while moving the source, both recorded rather than
quietly fixed: one asserted CUDA_VISIBLE_DEVICES appeared exactly once in the
producer and after the move its single hit was a DOCSTRING MENTION explaining
why that variable is NOT read -- a count over prose passing as a count over
code; and the first no-fallback test forbade the WORD "NVML", which forbade the
explanation. Both now pin code shapes.

Waits on seat 4's publisher (weg2/xchg-card-order-1336-0911); this half rebases
onto that SHA, not merges.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 11, 2026
…der vector

The first ruling had the launcher publish a new SGLANG_WEG2_XCHG_CARD_UUIDS.
Its premise -- "no publisher exists" -- is falsified by measured code, so that
variable is gone from this module and nothing replaces it here.

WHAT ALREADY EXISTS (sgl-project#407 cut 2, running on our boots):
  RANK_CARD_UUIDS_ENV = "SGLANG_RANK_CARD_UUIDS"        registry/rank_cards.py:82
  publish_rank_card_uuids(server_args)                  entrypoints/engine.py:671
    -- in the PARENT, BEFORE the spawn loop, and that file's own comment states
       our inheritance premise verbatim: "the channel is the environment, and a
       spawned scheduler inherits it only if it is set by now"
  resolve_rank_card_vector -> uuids[rank] = by_cuda_ordinal(ordinals[rank]),
    source "launcher placement (gpu_id_for_rank -> sgl-project#331 IdentityMap)", i.e.
    launcher placement order and explicitly NOT NVML enumeration
  readers rank_card_vector / rank_card_uuids, which own the parse
  weg2/launcher.py already passes --rank-gpu-id 0,1,2, so the publisher's
    CUDA-side gate is satisfied on every weg2 boot

MEASURED, XSN11, both runs, BOTH groups:
  rank->card vector (launcher placement ...): rank0=GPU-31d7ef41 [0A:00.0]
    rank1=GPU-5c648f96 [05:00.0] rank2=GPU-62dbbae1
byte-identical to the parent's CUDA_VISIBLE_DEVICES order, same on P and D,
`no CUDA context` 0. A second publisher would have been the one-job-one-mover
violation the ruling invoked, entered from the producer side.

So uuid_of_card() now takes one hop to the owner and nothing else: no env read
here (the parse stays with rank_cards), no variable named here, no injectable
string seam (every test drives the real reader).

AND THE COINCIDENCE IS ASSERTED, NOT USED. rank_cards indexes by WORLD RANK and
checks world_size; this module indexes by CARD and its invariant is N_CARDS.
They are equal on the Weg-2 form only because each group is three ranks and
"rank n of either group runs on cards[n]". A world of six -- a pipeline stage, a
MoE-TP subgroup -- separates them, and a six-entry vector re-indexed as a card
table would attribute one rank's card to another silently. The length is checked
here, by name, and the refusal SAYS that two different quantities were compared
so the next reader does not "fix" it by slicing to three. The vector is
deliberately fetched without world_size, so the owner's check and this one each
stay with the quantity they are about.

Reasons now: unset (the owner's own reason forwarded verbatim) / count (wrong
length, and where a dropped blank lands) / blank (a ratchet: unreachable while
the owner's parser drops empty fields) / duplicate -- plus `disagrees` at the
door. The no-fallback rule is unchanged and still a test by call shape: on this
rig the launcher's order is 5090-first and NVML's is 3080-first, so a fallback
returns right uuids under WRONG ordinals, which is worse than absence.

Instrument note, recorded because it is the second instance this cycle: one
bulk test edit did not match and failed SILENTLY, leaving a test asserting the
retired variable name. Same shape as the mutant whose edit raised SyntaxError
and scored "survived". Every scripted replacement in this commit asserts its
anchor, and the mutant harness now verifies the file actually changed.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 11, 2026
… gets executed

TWO TEST DEFECTS, one found by the mutant sweep and one by seat 4's reading.

(1) MUTANT SURVIVED: "absent vector loses the owner reason". The test asserted
`reason=unset` and the variable name -- and BOTH survive a mutant that replaces
the forwarded owner reason with a constant. So the test could not catch the
defect it was written for: a refusal that swallows the producer's reason, which
is what cost XSN9 and XSN10 a window each. It now reads the owner's wording
from the owner at test time and asserts that text appears, so it tracks a
rephrasing there instead of hard-coding one, and it fails the moment the
forwarding is dropped. 17/17 mutants red with this.

(2) THE BLANK RATCHET IS NOW EXERCISED. Seat 4 asked the right question: the
mapping "a,,c -> count" is a statement about ANOTHER module's parse, and such
statements rot silently. Measured answer: the `count` test DRIVES the owner's
real parse (it sets the real variable and calls the real producer), so the day
rank_cards preserves empty fields that test FAILS -- and that is precisely the
day the `blank` branch becomes reachable. That day is now simulated in a test
by substituting the owner's reader once, so `reason=blank` has been executed
rather than shipped as dead code, and the docstring says what to do when the
`count` assertion fails: update the mapping and expect `blank`, never relax the
assertion.

rank_cards is the canonical owner and this slice does not touch its parse;
substituting its reader for one test is how a consumer proves it is ready for a
change it does not control.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 11, 2026
…position

A gate finding worth keeping regardless of which card-order source wins.
`test_the_launcher_publishes_the_ceiling_to_both_groups_and_pops_it` greps the
launcher source for `ENV_ONCARD_SLOT_MIB):` -- the slot name followed by the
pop tuple's CLOSING PAREN. Appending any name to that tuple moves the paren and
breaks the guard while the property it exists for (the slot IS popped) still
holds. The parked sgl-project#1336 publisher hit exactly that on the local pair gate.

It now asserts membership, which is the property, and is indifferent to which
name happens to end the tuple.
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 13, 2026
…he inject field stops vanishing

Checked against the CURRENT train tip (c67f767) under the new standing rule,
not against my own older base -- the tip had moved 20 commits.

sgl-project#1334 -- THE GATE IS ON THE RIGHT AXIS, and this is measured rather than read:

  ring      bounce_lane_armed=False  shadow_armed=False
  shadow    bounce_lane_armed=True   shadow_armed=True
  exchange  bounce_lane_armed=True   shadow_armed=False

Both production gates (weight_exchange_shadow.py:4080, weight_updater.py:2611)
read `bounce_lane_armed()`, which is spelled `weight_source() != RING` rather
than `exchange_armed() or shadow_armed()` -- so it stays true for a fourth arm
the day one exists. A gate on `shadow_armed()` would read FALSE exactly when
the order arms `exchange`, which is the wrong-axis defect; no live call
remains (the three in weight_exchange_shadow.py are the definition and its two
re-exports). NO FIX NEEDED, and the probe above is the evidence.

sgl-project#1336 -- NO AUTHORITATIVE FALLBACK EXISTS. `inject_mode()` defaults to
INJECT_SHADOW (weight_exchange.py:2153), the leg line prints
`mode={self.mode or INJECT_MODE_UNSET}` with a sentinel rather than a guess,
and the verdict emitter is guarded by `if result.inject is not None` (:1282).
The reported fallback is closed.

WHAT WAS STILL OPEN is the same shape one field over: `inject=` was OMITTED
when there was no verdict, so a SHADOW leg that graded nothing printed exactly
like an AUTHORITATIVE leg, which has no comparison by construction
(`comparing = mode == INJECT_SHADOW`). weg2xsn25 already cost us that class
once, reading three legs' missing `phase` as proof they ran unsplit. The field
is now always present and says WHICH silence it is:

  inject=by-design-authoritative   no comparison exists under this mode
  inject=NOTHING-COMPARED          a shadow leg that graded nothing -- a
                                   finding, not a state

PRIOR ART, over the tip and every local branch before the first edit of the
symbols: `NOTHING-COMPARED` 0, `by-design-authoritative` 0 -- genuinely new.
(`shadow_nonce` 2 and `_weg2_xchg_deposit_before_sleep` 1 AT THE TIP, which is
the code-presence delivery proof for the earlier pair.)

test_the_bounce_leg_line_never_omits_the_inject_field_1330 asserts both
silences. 63 tests across the three files that build or assert this line.

(cherry picked from commit 32914ab)
efschu pushed a commit to efschu/htsglang that referenced this pull request Sep 13, 2026
… that says so

TWO HALVES OF ONE DEFECT, both measured on this rig, in ONE commit because
fixing either alone leaves the other able to produce the same wrong line.

(1) THE LAUNCHER AND THE RANKS READ DIFFERENT SOURCES. `prepare_xchg_env`
    publishes INJECT_ENV into the dict handed to the RANKS (launcher.py:3594)
    and never into the launcher's OWN environment, so every launcher-process
    caller of `inject_mode()` got the `shadow` default regardless of what the
    boot was armed with. S6 fix E fixed the IMPORT-TIME half of this and left
    the publication half standing.

    Measured consequence, sgl-project#1361 [23a]: a boot armed `authoritative` printed
    `bounce_slots=3` (computed as if shadow) beside `bounce_inject=authoritative`
    (from the argv) on the SAME line. Two fields contradicting each other about
    one arm, and the wrong one was the one describing what the ranks would do.

    `inject_mode(explicit=None)` is the one source: a caller that HAS the argv
    value passes it and gets an answer about the BOOT; the environment stays
    the source for the ranks, which have no argv. `inject_authoritative`
    threads it through. An `explicit` that is not one of the two real modes is
    IGNORED, not trusted -- a typo must never silently claim `authoritative`,
    which is exactly the direction INJECT_MODE_UNSET exists to guard: claiming
    ownership of 27 GiB of weights on evidence that did not parse.

(2) AN ABSENT MODE WAS READ AS A SHADOW FINDING. The bounce emitter's
    `inject=` field was a two-way branch on `== INJECT_AUTHORITATIVE`, so a
    record with NO mode fell into the `NOTHING-COMPARED` arm -- a claim that a
    SHADOW leg had graded nothing, invented out of missing evidence. The
    `mode=` field one column to its left already printed `unset`. Two fields on
    one line contradicting each other about the same absence.

    The branch is now three-way: `NOTHING-COMPARED` is reached only for a mode
    that IS shadow, and an absent mode prints `inject=unset`.

PRIOR ART, found by the gate BEFORE the first edit and the reason this commit
is small: `INJECT_MODE_UNSET` was ALREADY defined for this ticket in
`weight_exchange.py`, with a docstring that names this exact hazard and its
direction, and it was ALREADY used by the emitter's `mode=` field
(weight_exchange_bounce.py:677). Only the `inject=` field never learned it.
This finishes a constant that was built and half-wired rather than adding one --
the present-but-unwired family, this time as a consumer that skipped one of two
sibling fields.

TESTS (5, red-first on c73c361: 4 failed / 1 passed -- red in BOTH
directions as ordered):
  an authoritative boot must not read shadow (INJECT_ENV popped, which is the
    launcher's real state, not a contrived one);
  a typo is ignored rather than trusted, in both `inject_mode` and
    `inject_authoritative`;
  the ranks still read the environment -- the unchanged path stays unchanged;
  an absent mode prints `unset`, and NOTHING-COMPARED is reachable only from a
    mode that IS shadow;
  both fields name the same absence (the constant appears twice, once per
    field), so the two can no longer disagree.

Import smoke: all six weg2 modules import. ruff clean. The two reds in
test_weg2_xchg_bounce_1332 (`test_the_bound_is_the_widest_layer_never_the_mean`,
`test_this_rigs_instance_of_the_expression`) are PRE-EXISTING on the tip and
present in the base column's 11 -- they belong to the sgl-project#1335 slot change, not
to this commit.

(cherry picked from commit b1cb6bd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant