Repository navigation
Implement served_model_name to customize model id when use local mode… - #749
Merged
Merged
Conversation
Ying1123
requested changes
Jul 27, 2024
Ying1123
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the contribution! I left a few comments.
Contributor
There was a problem hiding this comment.
If served_model_name is given in a wrong format (not a list), self.served_model_name will be None. This could trigger errors in other parts of the changes. Could you check?
Contributor
Author
There was a problem hiding this comment.
Sure, I'll check it.
merrymercy
requested changes
Jul 27, 2024
Collaborator
There was a problem hiding this comment.
- Why do you allow it to be a list?
- Could you update it to the CLI args as well? https://github.com/sgl-project/sglang/blob/d360a4ea77f0af1f54e94575173f4fa964dc38fc/python/sglang/srt/server_args.py#L98
timethink
pushed a commit
to timethink/sglang
that referenced
this pull request
Mar 9, 2025
sgl-project#749) Co-authored-by: Ying Sheng <[email protected]>
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 18, 2026
…ded in (same resolution seam) Item 2. sgl-project#735 delivered the desk half -- crossing_schedule says which crossings exist, route_schedule binds each to a transport -- and moved no tensor. This is the forward wire that consumes both. WHY IT IS A MODULE AND NOT INLINE. The model's loop is boot-only territory: a wire written inside it can only be tested by booting, and F4-r5 owns the cards. pp_crossing_wire.py is the same logic as a small object with an injectable link, so the crossing algebra, the ordering, the counting and the byte-identity of the contiguous path are all hermetic. qwen3_5.py gains two call sites and no logic. BYTE-IDENTITY IS A NULL OBJECT, NOT A BRANCH. Without a layer set, or with the wire flag off, build_wire_for_model returns NoCrossingWire whose hooks return their arguments unchanged. The loop calls the same two methods either way, so the default path cannot drift from the wired one by acquiring a branch only one of them takes. ONE MECHANISM, NOT TWO INTERLEAVED. My first test asserted a contiguous set yields the null wire; that was wrong and the module was right. A contiguous 3-stage split still has 2 crossings -- the stage boundaries the old pp_proxy_tensors return carried. The wire takes ALL crossings rather than splitting the job with the old path: two mechanisms exchanging activations in the same loop is how they drift apart, and the boundary case is the one the old path already got right, which makes it the cheapest place to prove the wire equals it. Test corrected, module unchanged. THE OBSERVABLE. log_routing() had ZERO callers, so "31 crossings observed" was a claim no run could evidence. build_crossing_wire calls route_schedule + log_routing when given a peer map, and a test asserts the "31 crossings" line appears. HOST-STAGED BY THE RIG, NOT BY CHOICE. PpGroupLink rides the PP group's tensor-dict path; can_access_peer is false on all six directed pairs, so every crossing is GPU->host->GPU. That is the path sgl-project#735 priced at 24.68 ms/pass over 31 crossings, so wire and cost model agree by construction. sgl-project#754 FOLDED IN -- it is the SAME resolution seam, verified by reproducing it: get_pp_layer_set read the process-wide env regardless of pp_size, and the TP stack re-reads it during a phase flip with pp_size=1, where a 3-stage string is not merely inapplicable but invalid ("3 stage(s) given but pp_size is 1"). A flip with nothing to do with layer sets died on it. A single stage owns every layer, so the set form has nothing to express: pp_size <= 1 now answers None and hands the caller back to get_pp_indices -- the correct contiguous answer rather than a suppressed error. Pinned with a can-fail guard that the real pp_size still resolves AND that a genuinely wrong stage count (pp_size=2) is still refused, so the exit is not a blanket amnesty. TEST RESULTS test_pp_crossing_wire_753.py: 17 green. The load-bearing one is the BYTE GATE -- a full simulated forward driven through the wire must equal the same layers computed straight through, exactly, for BOTH the contiguous split and the user's gapped target layout. The layer function is order-sensitive on purpose (h = h*3 + id), so a skipped, duplicated or reordered crossing changes the number instead of looking close. A can-fail test drops one crossing and requires the result to diverge. Also pinned: crossing count == schedule length (31 for the target layout, the figure sgl-project#735 priced); per-rank sends/receives match the schedule; every failure path refuses BY NAME rather than continuing (a failed recv, a None payload, a failed send); the model entry point returns the null object without the flag. test_pp_layer_set_contiguity_753.py: 10 green (7 gate + 3 for sgl-project#754). Full distributed suite: 27 failed / 2983 passed, compared PER SUITE against the pre-753 baseline -- ZERO new failures. sgl-project#749 leak guard silent. One baseline failure absent (test_bar1_host_cleanup's pgrep self-match, environment sensitive) and NOT claimed as a fix. AST-verified that both hooks sit inside the owned_layer_ids loop rather than merely appearing in the file. Ruff: pp_crossing_wire.py clean. qwen3_5.py reports one F401 (triton), verified PRE-EXISTING against HEAD's blob. Codespell clean. Hermetic throughout, CUDA_VISIBLE_DEVICES=99; no cards touched, no boot.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 18, 2026
…gl-project#754 retires into the 753 fold, 13-step plan re-smoked clean The first map froze before today's second wave; new authority is F4-r5's harvest composite 59ce2d8 (declared COMPLETE, review tip still an ancestor). Pass 3 redefined: harvest tip = train base, unabsorbed branches cherry-pick on top, feat/753 lands FIRST by its owner (10 in-flight commits; carries sgl-project#749; folds sgl-project#754 at the same seam -- distributed/utils.py:1709, its own pp_size=1 handling). Sweep results, same git-cherry/merge-base rigor as the first map, outputs quoted in the ledger REFRESH section: - ABSORBED by ancestry: comp4 and its whole lineage, 915ce1b (F4-r5's own sgl-project#757), 57b04b2 (sgl-project#540 fix). - ABSORBED as different commits (desk-sgl-project#752 hazard class, never merge): fix/748-armed-gate-scope, fix/759-arming-economy, feat/755-slot-reorder. The sgl-project#758 emitters need no branch -- the harvest TIP ITSELF is a sgl-project#758 commit. - SUPERSEDED: my own fix/754 -- semantic-not-patch folded by 753 (git cherry vs 082293f shows '+'); merging it after 753 lands guarantees a get_pp_layer_set conflict with zero gain. Retired from the plan without regret. - REVIEW-never-merge: 9e56477 (independent sgl-project#757), per its reviewer's own in-composite note naming 915ce1b as the baseline. - fix/706-remainder not yet visible; slot reserved. Executor updated: HARVEST constant joins the lineage check, DEFAULT_TIP moves to the harvest tip, the sgl-project#754 step is replaced by the sgl-project#745 reachability pick, and the second-wave picks join (727 head-chain, sgl-project#738 verdict, sgl-project#535 tickets). Dry-run scratch smoke against the REAL harvest tip: all 13 steps complete with ZERO conflicts (exit 0) -- cleaner than the first wave; the sgl-project#740 pair ordering from the previous smoke holds. Plan-mirror test updated (12 passed). Gate unchanged: COMP4_ACCEPTED still required, nothing pushes, nothing booted.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 24, 2026
…ip deferred with its invariant named W27-retry leaked 152 rows per retract+drop cycle and died on the third. This is the root, derived from the tree code rather than from an API guess. `MambaRadixCache.reset` (mamba_radix_cache.py:555) installs a NEW `TreeNode()` as root and zeroes `full_evictable_size_` / `full_protected_size_`. It frees no device row -- the old tree is simply dereferenced, and the rows its nodes held are orphaned. It is a BOOKKEEPING reset: right for a teardown where the pool is reset too, wrong for a seam that keeps serving. That is why the detector saw `evictable=22` (the NEW tree) while 152 rows belonged to nobody, visible only as a total mismatch. The call that actually returns rows is `evict` -> `evict_full`, whose leaf path frees through `token_to_kv_pool_allocator.free`. So the drop is EVICT-THEN-RESET (`drop_prefix_tree_returning_rows`). THE EVICTION IS LEGITIMATE ONLY BECAUSE OF THE FENCE. sgl-project#703 has already persisted these prefixes to the canonical store and the new layout re-reads them; without that, this would be data loss. That is why the seam order is fence -> retract -> drop and not any permutation of it, and it is written into the function so a later reader cannot reorder it innocently. BOTH DANGER DIRECTIONS ARE PINNED, because only one of them is loud: * orphaning -- the metal defect, modelled with the accumulate-per-cycle shape it actually had (it fired on the THIRD cycle, not the first); * DOUBLE-RETURN -- silent where the leak was loud. The test allocator raises on a second free, so an evict-and-also-free implementation fails here rather than corrupting the pool quietly. A deliberate contract change: `build_cutover_release` no longer hands back the bare `tree_cache.reset`, and `test_seam_order_856` was updated to assert that it does NOT -- the bare reset is the tempting one-liner and it is exactly what leaked. THE EMPTY WAVE LOOP IS DEFERRED, WITH THE INVARIANT NAMED. W27-retry measured 16 empty waves costing ~314 ms plus 753.6 ms for retract+consume+drop. Skipping the loop looks like free seam time and is not safe yet: `finalize_wave` calls `dst.restore_backing(layers)`, which marks the destination layers RESIDENT independently of whether any KV moved. Skipping would leave the pool answering NO to `backing_is_resident`. The cheap successor is one `restore_backing(all layers)` outside the loop; it changes backing semantics and needs its own test, so it is a follow-up and not a line here. THE LOAD DRIVER IS FIXED, and its bug was a measurement trap worth recording. W27-retry's driver reported real token counts on requests that never connected: curl failed (dead-port smoke confirms code='000', rc=7, NO file written) and the parser then read `/tmp/w26_resp_<tag>.json` -- a LEFTOVER from the W26 window, same tag scheme, same prefix -- and reported W26's numbers as this run's. Two fixes: a unique prefix plus `rm -f` before the curl, so a failure can only ever yield a MISSING file and never someone else's numbers; and a health check that ABORTS after 3 consecutive failures. Mock-smoked against the dead server: exit 3 at round 4, instead of the 640 rounds in 45 s the broken one spun. GATE (foreground, family-batched, per the sgl-project#749 lesson; no background waiters): managers core (45 PP files excluded) 3554 passed, 18 skipped, 336 subtests, EXIT=0 PP family, one file per process 45/45, 0 failures mem_cache 1710 passed, 361 subtests, 0 failed server_args 776 passed, 191 subtests, 0 failed model_executor 763 passed / 15 failed The 15 are the pre-existing sgl-project#815 family, verified earlier against HEAD (identical 15/754 set). ZERO new failures.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 25, 2026
…o rules, one deleted premise `build_flip_quiescence_fn` carried two rules whose justifications both died with sgl-project#856 (2026-08-24, "the flip carries no KV"), and they pulled in opposite directions -- one let a flip through that must now be refused, the other refused one for a reason that no longer exists. Fixing either alone would leave the predicate half-governed by a deleted mechanism. SITE 1 -- the between-chunks allowance LET THROUGH what must now be refused. Written 2026-08-09 (sgl-project#631 defect O), justified verbatim in its own docstring as "exactly the state the carry moves". sgl-project#856 deleted the carry: the seam retracts residents and drops the tree, so that state is freed, not moved. The predicate was never revisited. A 6019-token prompt needs two chunks, the flip commits between them, and the re-admission restarts at prefix_lens=0 -- measured on W38-B ("prefill still chunked (allocated=4096, needs=6045)") and visible in W37-H arm A as 51 flips, 132 pp prefills, 57 tp prefills, ZERO decode rounds, zero completions. The block is added under STRICT ONLY, and that condition is the design rather than a hedge. Blocking every incomplete chunk re-creates defect O, where a flip armed FOR a prefill could not land until that prefill had finished (the 32768-token prefill that ran in the slow layout and paid two cutovers for nothing, 2026-08-09 04:23:35-54Z). Under strict batching the flip is armed for the DECODE after the drain, so waiting IS drain-and-flip. Landed in `chunk_blocks_quiescence`, NOT at the `ready_fn` call site: the helper's own docstring says its two callers must never disagree, and they drifted apart once already (2026-08-09 20:31:38Z). Both callers now pass the term -- `ready_fn` via `purity_of` behind a try/except (a purity read may never break a flip), the park site via the already-cached `self._phase_purity` (no new import, and no second purity read on the hot path). SITE 2 -- the orphan gate REFUSED for a mechanism that no longer exists. It blocked on requests "not yet merged into the resident set THE CARRY HARVESTS" (sgl-project#631 defect L). There is no harvest, and de4f541 gave `_live_reqs` the identical population (running_mbs, last_mbs, running_batch, last_batch). REMOVED, not narrowed: narrowing a gate whose entire purpose has been absorbed elsewhere leaves a third stale premise behind. RESIDUAL, WRITTEN DOWN RATHER THAN LEFT IMPLICIT (own posten). Post-sgl-project#856 there is no carry in EITHER mode, so a mid-chunk flip discards the prefill in non-strict too. We decline to block there because an unconditional block re-creates defect O. THE CORRECT NON-STRICT ANSWER IS UNKNOWN AND IS FILED, NOT SOLVED. `if strict` must not be read as evidence that the non-strict path was analysed and found sound -- it was not analysed. Three claims outlived their justifications on the night this was written; this one says what it rests on. TESTS test_quiescence_no_carry_858.py, 8 passed. Each mutation verified to kill exactly its own test and nothing else: drop the strict block -> test_strict_blocks_an_incomplete_... FAILS make the block unconditional -> test_non_strict_still_allows_... FAILS restore the orphan gate -> test_..._does_not_consult_the_carry_ FAILS Two assertions pass BEFORE and after (a completed prefill still permits the flip; non-strict unchanged) -- without them a block-everything predicate reads green, which is how three red-first files were nearly mis-reported this night. `test_live_reqs_still_covers_that_population` guards the removal's own premise: nothing else asserts that enumeration, so it is the belt rather than belt-and-braces, and it reddens if `_live_reqs` ever stops reading last_mbs/last_batch. SUITES -- all four arms hermetic (CUDA_VISIBLE_DEVICES=""), verified by `nvidia-smi --query-compute-apps` reading 0 during the runs, and run SEPARATELY per sgl-project#749 (the managers/ + distributed/ combination is order-dependent on ~50 tests and cannot gate anything). Pre-existing reds measured against the branch tip 322f331, not inherited. managers/ change 15 failed / 4334 passed / 18 skipped / 356 subtests base 15 failed / 4326 passed / 18 skipped / 356 subtests identical failure sets BY NAME, set-difference empty both ways; passed delta +8 = exactly the new tests, nothing else moved. The base arm reproduces R7's independent measurement of the same tip (4326/15) exactly. distributed/ change 95 failed / 3017 passed / 12 skipped / 1170 subtests base 95 failed / 3017 passed / 12 skipped / 1170 subtests identical BY NAME across all 95 -- 92 line-start FAILED plus 3 parametrized `FAILED(dcp_size=2/3/4)` subtest reports that a `^FAILED` pattern misses; both arms agree on all of them. No formatter was run on any file: this tree's black is older than whatever formatted it, and isort has moved a deliberately-late `# noqa: E402` import here before. The change is hand-written to the surrounding style. NOT PROVEN HERE: that sgl-project#857's acceptance follows. This removes the mechanism that made the livelock inevitable; whether a full A-B-A cycle now completes with COMPLETIONS>0 is a metal question and is not claimed.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 25, 2026
…plied it direction-blind sgl-project#858 traded the livelock for a deadlock, and the metal proved it in 12 minutes (boot_w40_857strict_0825_1931): 15 flips all with live_slots=0, 4 completions all inside ONE TP dwell after the last flip, none across a cycle, then 258 ADMISSION-WEDGE reports, 11 queued / 0 running, no first token for 535 s. 225 OF 228 QUIESCENCE HOLDS WERE tp_to_pp -- the direction sgl-project#858's premise does not cover. THE DEFECT IS IN MY OWN JUSTIFICATION, quoted from phase_flip_runtime.py: "Under STRICT batching the flip is not armed for the pending prefill: it is armed for the DECODE that follows the drain, so waiting for prefill to finish IS drain-and-flip rather than a stall." True for pp_to_tp. FALSE for tp_to_pp, which is armed FOR the prefill. Waiting there waits for work that strict forbids in the layout holding while we wait. A direction-specific argument, implemented direction-blind. AND IT HAD NO EXIT, which is why it presented as a wedge and not a slow flip. `validate_purity_policy_pair` already makes exactly this argument for PP -- a phase that "may not decode and cannot admit prefill ... has NO exit except the bounded window" -- and PP got `--phase-policy-pp-window-s`. TP got only `--phase-policy-tp-decode-floor-s`, a MINIMUM dwell that cannot end a hold. THE ASYMMETRY IS THE MISSING EXIT. FIX, three parts: 1. `prefill_runnable_in_current_layout(direction, purity)` -- the armed direction names the layout that currently holds; tp_to_pp consults `prefill_allowed_in_tp()`. `chunk_blocks_quiescence` gains `prefill_runnable_here` and blocks only when the work it waits for can actually progress. The predicate now asks "can what I am waiting for run right now", not "is waiting usually fine". Both callers pass it, resolved from the same local import block so they cannot drift. 2. `validate_tp_exit_pair` (phase_purity.py), mirroring the PP guard and wired beside it at boot. Refuses the checkable deadlocking triple: strict purity + strict drain mode + no bounded TP residency. Parse time, where refusing is free -- the same reason the PP guard exists instead of a runtime recovery. 3. Unit tests PARAMETRISED OVER BOTH DIRECTIONS. This is the check that would have caught sgl-project#858 at desk: a direction-blind predicate satisfies every single-direction test, and sgl-project#858's eight all passed. The decisive case asks ONE incomplete prefill in BOTH directions and requires the answers to differ under strict. TESTS test_quiescence_no_carry_858.py, 8 -> 17 passed. Mutation restoring the exact sgl-project#858 defect (dropping `prefill_runnable_here` from the condition) kills ONLY test_strict_does_not_block_tp_to_pp. Green-before-and-after controls kept, plus new ones: `off` purity is not refused by the boot guard, and a declared decode-stall SLO satisfies it. FILED, NOT FIXED HERE: the ADMISSION-WEDGE recovery gate fired 69 times with 69 x exit 'headroom-sufficient' -- a MEMORY-HEADROOM actuator answering a QUIESCENCE-HOLD wedge. It measured its own quantity truthfully; free headroom really was sufficient. INDIKATOR-GESETZ: it was never shown able to report the state it gates. Giving that path a wedge-cause discriminator is a different mechanism and would widen this commit past its evidence. SUITES -- all four arms hermetic (CUDA_VISIBLE_DEVICES=""), run SEPARATELY per sgl-project#749, measured against the branch tip c2e69c2, not inherited: managers/ change 15 failed / 4343 passed base 15 failed / 4334 passed identical failure sets BY NAME, set-difference empty both ways passed delta +9 = exactly the 8 -> 17 test growth distributed/ change 95 failed / 3017 passed base 95 failed / 3017 passed identical BY NAME, set-difference empty both ways EXTRACTION DISCIPLINE, because tonight produced three ways to misread these files and the third corrupts the comparison's own input: (1) ANSI escapes before the anchor -> `^FAILED` matched 0 of 15 (2) subtest failures with their own prefix -> `SUBFAILED(dcp_size=N)`, 3 of the 95, invisible to `^FAILED` and matched by a bare `FAILED` grep only because "SUBFAILED" contains it (3) UCX teardown warnings printed AFTER pytest's summary -> `tail -1` on a 2 MB file returns library noise, so the SUMMARY side reads empty and a count gate silently passes So: strip escapes, extract the summary BY PATTERN never by position, match `^(FAILED|SUBFAILED|ERROR)`, and gate on extracted-name-count == summary-count before any set-difference is allowed to mean anything. All four arms passed that gate: 15=15, 15=15, 95=95, 95=95. No formatter run on any file. NOT PROVEN HERE: that sgl-project#857's acceptance follows. sgl-project#858 removed the mechanism that made the livelock inevitable; this removes the deadlock that replaced it. Whether a full A-B-A cycle completes with COMPLETIONS>0 is the metal question.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 25, 2026
…both axes
THE SILENT HALF IS THE DEFECT. `-1` is simultaneously the classic stale-row
sentinel and valid torch indexing, so a stale id does not fault: it writes the
LAST row of the pool. Wrong KV -- or, on the mamba axis, wrong recurrent state
-- under a prefix the radix tree reports as RESTORED. No crash, no log line, on
a shipped path, refused nowhere until this commit. Two new tests pin it as a
fact about the code as it stood:
test_a_negative_row_does_NOT_fault_and_hits_the_last_row (MHA, dim 0)
test_a_negative_slot_does_NOT_fault_and_hits_the_last_slot (Mamba, dim 1)
Both PASS without the fix. That is the point of them.
The illegal memory access was the LOUD half, and it is the only reason we
looked. W40b, 2026-08-25 19:52:52, three PP ranks, instance down five seconds
later:
prepare_for_extend -> restore_seam_state (schedule_batch.py:2748, :2091)
-> Req.load_kv_cache (:1778) -> load_cpu_copy (memory_pool.py:3303)
-> current_platform.synchronize()
torch.AcceleratorError: CUDA error: an illegal memory access was encountered
ROOT. sgl-project#783's extent contract (25e7849) compares ONE SCALAR -- the row COUNT a
copy covers against the count the request now needs -- and then forwards
`req_to_token[req_pool_idx, :seqlen-1]` to the pools as ids that nothing
validates. EQUAL LENGTH IS NOT EQUAL VALIDITY. The pools index their buffers
directly and the only assert on the path (MHA :3298) compares the saved host
chunk's SHAPE against the chunk LENGTH -- a different axis, which that commit
already names: "per-chunk, on the wrong axis entirely. There is no backstop
below." This is that backstop. It sits BESIDE :3298, not in place of it: one
checks the saved payload lines up with the index count, the other checks the
index VALUES exist. Neither implies the other.
A MODULE FUNCTION, NOT A METHOD, AND THE BOUND IS AN ARGUMENT.
`check_cpu_copy_rows(indices, rows, direction, axis)`. The pools that need it do
not share a base -- `MHATokenToKVPool` and `MLATokenToKVPool` are `KVCache`
subclasses and `MambaPool` is not -- so a guard installed on one ancestor would
be silently inert on the other. The bound and axis are passed in because they
genuinely differ: MHA is bounded by KV buffer rows on dim 0, `MambaPool` by its
slot count on dim 1 (`conv[:, indices]`, layout [num_layers, num_slots, ...]).
An earlier draft of this guard read `k_buffer[0].shape[0]` off `self`; wiring
Mamba to it would have looked done and done nothing. A guard that cannot fire is
the failure mode this whole sweep exists to remove.
REFUSAL, NEVER A CLAMP -- the parent commit's rule for the parent commit's
reason: the ids and the pool describe different things, so dropping or wrapping
the offending id writes state into rows belonging to someone else. A refusal
costs a recompute, which is merely slow. Checked BEFORE the first store, with a
test asserting the pool is byte-identical after a refusal: a guard that fires
halfway through is a louder corruption, not a fix.
THE SWEEP -- 14 `get/load_cpu_copy` definitions in memory_pool.py alone, not
one. The first pass at this assumed a single site.
WIRED MHATokenToKVPool :3262/:3284 the W40b site, and what this rig's
HybridLinearKVPool delegates its KV half to (:4390, :4401)
WIRED MambaPool :1180/:1192 dim 1, bound mamba_cache.conv[0].shape[1];
reached here via HybridLinearKVPool -> mamba_pool.load_cpu_copy(
_mamba_translate(...)), and that translation is a second staleness
source
n/a HybridLinearKVPool :4389/:4399 pure delegator, covered by both above
n/a KVCache ABC :2319/:2322 NotImplementedError stubs
FILED PageMajorMHATokenToKVPool :4006/:4012, MLATokenToKVPool :4674/:4689,
DSATokenToKVPool :5023/:5048, dsa_cache_layer_split.py, and the
forwarders in allocator/{base,token,paged,swa}.py,
swa_memory_pool.py:285-330, unified_memory_pool.py:1223-1237
The 12 unwired sites are not on this rig's path. They are enumerated with their
file:line in docs/dev/NOTE_783b_cpu_copy_row_bounds.md rather than wired on
faith.
PRIOR EVIDENCE THAT THIS BELONGS AT THE POOL BOUNDARY, not per-caller: two
forwarders already filter their indices -- swa_memory_pool.py:295
(`swa_indices[swa_mask]`) and unified_memory_pool.py:1227 (`swa_phys[valid]`) --
the SWA half ONLY, with the unfiltered `full_phys` sitting directly beside them.
The need was seen once and not generalised. Putting the check where every caller
must pass through it is the answer to that, rather than trusting each caller to
remember.
OBSERVABILITY, because the emitter could not witness its own event.
`restore_seam_state`'s log line sat AFTER `req.load_kv_cache`, so a restore that
does not return is exactly what it cannot report: W40a logged 18 seam lines,
W40b crashed INSIDE the call and logged ZERO, which is why the traceback names
`synchronize()` and not the restore. An ATTEMPT line now goes before, rate
limited on the same cadence as the success line.
TESTS test_seam_row_bounds_783b, 17 passed. Hermetic, mocks only: the REAL pool
methods bound to CPU buffers, because a test that reimplemented the copy would
encode the defect's own assumption -- the shape 25e7849 corrected in three of
its own mocks. A/B against this tip (fc24204): 9 failed / 8 passed WITHOUT
the change, 17 passed WITH it. That A/B is the mutation proof; the 8 that pass
either way are controls, including the two silent-half pins above and the
over-refusal guards (valid rows still load, an empty index set is a no-op).
Hermetic suites, run SEPARATELY per sgl-project#749 against fc24204, count gate
(^FAILED + ^SUBFAILED + ^ERROR == summary) PASSED on all three before any
comparison:
mem_cache 2 failed / 1774 passed / 1658 skipped / 361 subtests
gate 2 == 2. Baseline on this tip was 1757 passed; +17 is exactly
this commit's tests. The 2 are the standing
test_acceptance_emitters_758 pair, "RuntimeError: No CUDA GPUs
are available" -- measured pre-existing earlier tonight by
reverting to the tip and re-running, not assumed.
managers 15 failed / 4343 passed / 356 subtests gate 15 == 15
IDENTICAL to the post-#858b baseline, by count and by name:
test_arena_high_water_631 (7), test_phase_flip_rotation_wiring_809
(4), test_restore_never_rebuild_677 (4), all hermetic-environment
CUDA failures.
distributed 95 failed / 3017 passed / 1170 subtests gate 92+3+0 == 95
IDENTICAL to baseline. The 3 SUBFAILED are the
dcp_size=2/3/4 subtests; summary extracted BY PATTERN because
these arms print UCX teardown warnings after pytest's summary.
Zero new failures on any arm. ruff: memory_pool.py 0 before and after,
schedule_batch.py 41 before and 41 after (untouched pre-existing), the new test
6 x E402 from the house `register_cpu_ci()`-between-imports convention, the same
class the existing test_seam_extent_contract_783.py carries (4). codespell
clean. black/isort deliberately NOT run over these files: the venv's black is
OLDER than the one this tree was formatted with and isort relocates a
deliberately-late `# noqa: E402` import in memory_pool_host.py -- every added
line was checked against the 88-column limit by hand instead.
STILL OPEN, AND NOT CLOSED BY GUESSING: why did W40a's nine restores succeed
while W40b's first one did not? Unknown. No trigger has been written into this
commit to make the story tidy. The guard lands anyway because it is the
INSTRUMENT that will answer it -- it converts an asynchronous IMA attributed to
an unrelated `synchronize()` into a deterministic host-side refusal naming the
id, the bound and the axis. CUDA_LAUNCH_BLOCKING=1 belongs in the sgl-project#857
acceptance arm so an IMA is attributed to its own kernel.
NOT PROVEN HERE: that a seam restore survives a flip on metal. This commit makes
the failure loud and specific instead of asynchronous or silent; making it WORK
is the acceptance boot.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 25, 2026
…urvive
`poll_status_words` caught every exception so the watchdog thread could not
die. That is right for a poll that hiccups and WRONG for a CUDA illegal memory
access: once a context takes one it is unusable, and every later CUDA call in
the process raises the SAME error at whatever site happens to run next.
Swallowing it did not keep serving alive. It only decided that the crash would
be reported somewhere innocent.
THE SPECIMEN. W40, boot_w40_857strict_0825_2113.log, the CUDA_LAUNCH_BLOCKING=1
arm. First CUDA fault in the whole log, 21:17:13, immediately after
"SEAM DRAIN tp_to_pp: device-tier streams quiesced in 0.0 ms at the no-return
point":
barlink_abort_gate.py:351 poll_status_words -> barlink_bar1.py:4937/4948
self._abort_poll_dst.copy_(self._ctl_dev[0:1], non_blocking=True)
torch.AcceleratorError: CUDA error: an illegal memory access was encountered
Logged as "barlink-BAR1 status poll failed" and continued past. Downstream, in
the same second, the scheduler died in `get_cpu_copy` inside the seam CAPTURE;
the boot before it (..._2107.log, no CLB) died in `load_cpu_copy` inside the
seam RESTORE. Three sites, one fault, two of them innocent -- and that cost this
shift two wrong roots before CUDA_LAUNCH_BLOCKING separated them.
THE CLASS: an exception handler that assumes its failure is survivable. It could
not tell a hiccup from a context kill because it caught bare `Exception`.
THIS MODULE ALREADY OWNED THE CLASS, which is why the fix belongs here. Its own
docstring opens on sgl-project#431: a run that tripped the cap on essentially every
collective produced an abort file with ZERO matching lines, so "nothing tripped"
and "everything tripped" were indistinguishable. The handler below it had made
"a poll hiccuped" and "the CUDA context is dead" indistinguishable in exactly
the same way, inside the module written to end that.
WHAT CHANGED
is_poison_error() classifies by MESSAGE, not by class, and that is the whole
point: torch raises AcceleratorError for a recoverable OOM and for an
illegal access alike, so isinstance would over-refuse. Markers are the
context-killing cudaErrors: illegal memory access, illegal instruction,
misaligned address, unspecified launch failure, device-side assert.
record_poison()/poison_record() FIRST wins, not latest. The record exists to
name the ORIGIN, and in a poisoned process every later call reports the same
error -- a record that tracked the newest would name the innocent site,
which is the defect itself.
poll_status_words on a poison-class fault: record, log ERROR saying in words
that the context is unusable and that THIS is the origin rather than the
traceback that lands next, and BREAK out of the round. The watchdog still
does not raise -- raising kills the thread and loses the record -- but it
stops reading devices, because every further read returns the same error and
multiplies the misattribution.
FOURTH INSTANCE OF ONE PATTERN, and the pattern is now worth more than any
single fix: WHERE IT SURFACED IS NOT WHERE IT ORIGINATED. (1) W40b blamed
restore_seam_state, actually the offload side. (2) the seam emitter sat AFTER
the dangerous call, so the one event it existed to explain was the one it could
not witness (#783b). (3) W40 arm 1 without CLB blamed the trailing
synchronize(). (4) this. CUDA_LAUNCH_BLOCKING=1 in one standing acceptance arm
is what separates them; without it every IMA is misattributed by construction.
PRIOR ART, CHECKED BEFORE BUILDING
pause_polling() (:309) EXISTS and excludes the watchdog's device reads for a
scoped window; one caller, parallel_state.graph_capture:2888, scoped by its
docstring to CUDA-graph capture. THE PHASE FLIP DOES NOT TAKE IT. Filed, not
used -- see below.
hicache_phase_binding's generation stamping (BindingState.advance,
host_pool_at, write_back_stamp_is_current:527) is the reusable shape for a
phase-generation stamp IF the mapping question resolves that way. NOT built
here: a stamp must not ship on a guess about which mapping moves.
poison-class handling: DOES NOT EXIST anywhere in
srt/distributed/device_communicators/. The only matches for "illegal memory
access" are four comments in pynccl.py:137,191,238,263 about avoiding one.
STILL OPEN, DELIBERATELY, and nothing here assumes an answer:
* WHICH POINTER IS FREED UNDERNEATH. `_ctl_dev` is allocated in `_build_up`
(barlink_bar1.py:2596) and nulled in `__init__` (:1765) and `close()`
(:5794), where vmm_free runs on _own/_own_flag BEFORE the null -- but
`poll_status_word` early-returns when `_ctl_dev is None`, so a COMPLETED
close() cannot produce this fault. Either a race inside close(), or a
different mapping entirely. Not established.
* WHETHER THE POLL IS THE ORIGIN OR MERELY THE FIRST REPORTER. Earliest in
time is evidence for origin, not proof. Falsifiable: if it is only
reporting, pausing polling across the cutover MOVES the crash rather than
removing it. That is the next arm, and it is exactly why pause_polling was
filed instead of applied -- applying it now would silence a messenger whose
guilt is unproven.
* W40a's nine successful restores versus W40b's first failing one. Narrowed,
not closed: with #783b's range check never firing (guard_refusals=0 on
metal) and the earliest fault in barlink, the restore was probably never the
origin in either boot. "Probably" is not a finding.
TESTS test_abort_gate_poison_867, 10 passed. Hermetic, no CUDA: the poison is a
real torch.AcceleratorError carrying the specimen's message, raised by a stub
transport. A/B on this tip: 5 failed / 5 passed WITHOUT the change, 10 passed
WITH it -- and the 5 that pass either way are the controls, deliberately routed
through getattr shims so they RUN on unpatched code instead of erroring. An
all-red file would have proved nothing about which behaviour this change owns.
Both directions of every judgement can fail: the classifier must match the
specimen text AND must NOT match a recoverable OOM; polling must stop after a
poison AND must continue after a hiccup.
Hermetic suites, run SEPARATELY per sgl-project#749 against fc24204 + 088d5d6, count
gate (^FAILED + ^SUBFAILED + ^ERROR == summary) PASSED on all three before any
comparison:
distributed 95 failed / 3027 passed / 1170 subtests gate 92+3+0 == 95
baseline 3017 passed; +10 is exactly this commit's tests.
Summary extracted BY PATTERN, not tail -1: these arms print UCX
teardown warnings after pytest's summary.
mem_cache 2 failed / 1774 passed / 361 subtests gate 2 == 2
managers 15 failed / 4343 passed / 356 subtests gate 15 == 15
Zero new failures on any arm; every failure identical to baseline by count and
by name (arena_high_water_631 x7, phase_flip_rotation_wiring_809 x4,
restore_never_rebuild_677 x4, acceptance_emitters_758 x2 -- all
"RuntimeError: No CUDA GPUs are available" in a hermetic run).
ruff: barlink_abort_gate.py 0 before and 0 after; the new test carries 4 x E402
from the house register_cpu_ci()-between-imports convention. codespell clean.
No line over 88 columns. black/isort deliberately NOT run over these files: the
venv's black is older than the one this tree was formatted with.
NOT PROVEN HERE: that this removes the W40 crash. It removes the MISATTRIBUTION.
The acceptance boot is what says whether the fault itself is still there, and
now its traceback will point at the origin instead of at the next innocent
caller.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 25, 2026
…for swallowed poison sgl-project#867 fixed ONE handler. This closes the CLASS, and it does it with a check rather than by reading 117 handlers -- which is the only way the gap actually shuts, because the sweep that found the class could not honestly claim to be exhaustive and said so. THE CLASS: a handler that catches BREADTH instead of KIND, making two states indistinguishable -- "the poll hiccuped" and "the CUDA context is dead". A CUDA illegal access poisons the context; every later CUDA call then raises the same error at whatever site runs next. Swallowing it does not keep the process alive, it only decides that the crash gets reported somewhere innocent. W40 produced THREE different innocent crash sites for one fault across three boots. (a) THE TRAP, REMOVED. barlink_liveness.py wrapped `probe_once()` and `poll_abort_words()` in `except Exception: logger.exception(...)` with the SAME "a watchdog must not die" comment -- and `poll_abort_words` calls straight into the handler sgl-project#867 just fixed. It did not mask that fix on the day it landed; it was a trap set for the next editor, who would have made the inner layer re-raise and had it swallowed one frame out. New `_stop_on_poison()` consults the classifier, records the origin (first wins) and LEAVES the ~10 ms loop: a poisoned context cannot be polled out of, and every further tick re-reads a dead device and buries the origin deeper. The thread still does not raise -- that part of the original comment was right. (c) THE WORST EXPRESSION, REMOVED. dual_group_lane.py:2244 is a DAEMON thread: on a step failure it dropped the active job and went straight back round. For a job-local failure that is correct; for a poisoned context it launches the NEXT job's kernels into a dead context, job after job, burying the origin under one identical traceback per job. It now stands down. (b) THE GUARD, and it is the actual deliverable. test_swallowed_poison_guard_867 walks the AST of srt/ and reports a handler when ALL THREE hold: the handler is broad; the guarded body reaches a device op; and it sits in a REPEATING context (a loop, or a poller/worker/tick function). Covered means it consults `is_poison_error` or re-raises. Result on this tree: 16 candidates, 12 still uncovered, listed in a shrink-only allowlist labelled DEFERRAL, NOT ABSOLUTION. PRIOR ART, EXTENDED NOT DUPLICATED: this tree already carries AST guards (~74 test files use `ast`), and test_instrument_reachability_861l.py is the shape -- a pure sweep function over a root plus synthetic-tree tests that drive it. This guard follows it exactly rather than standing a third mechanism beside it. THE GUARD FOUND THREE FILES THE SWEEP HAD LISTED AS UNREAD: barlink_bar1.py:4903 and barlink_ucx.py:1964/1972. That is the whole argument for doing (b) before (c) -- the unread-files gap closed mechanically, and it keeps closing as new handlers are written. AND IT CAUGHT A DEFECT IN ITSELF, on its first run against the tree: it reported barlink_liveness's two FIXED handlers as uncovered, because its COVERAGE test was one-hop-blind in exactly the way its DEVICE test is. Extracting the check into a named helper -- which is what a second handler in the same class should do -- read as "uncovered", so the guard would have pushed people toward copy-paste. Fixed symmetrically via `_poison_aware_names()` (functions whose own body consults the classifier), NOT by adding the helper to a maintenance list. A list would have lied within two weeks. BOTH CAN-FAIL DIRECTIONS, because a guard that cannot fire is what we have been finding all night, and one that fires on everything is switched off in a week: RED a planted broad handler around `dev.synchronize()` in a while-loop GREEN a handler that consults the classifier; one that re-raises GREEN a NARROW handler (catching a named error is the opposite of this defect) GREEN a broad handler with NO device op (the tree is full of these) GREEN a one-shot handler outside any loop (different judgement, not this class) Plus a sweep-found-something test, so the guard cannot pass by matching nothing. KNOWN LIMIT, STATED IN THE MODULE DOCSTRING RATHER THAN HIDDEN: the device test is ONE HOP by name. A handler whose body calls a helper that only reaches the device deeper down is invisible unless that name is in `_DEVICE_TOKENS`. This guard proves "these sites are uncovered", never "no others exist". TESTS test_swallowed_poison_guard_867: 8 passed. Hermetic suites, SEPARATELY per sgl-project#749, count gate before any comparison: distributed 95 failed / 3027 passed / 1170 subtests gate 92+3+0 == 95 PASS identical to baseline by count and by name. managers 17 failed / 4341 passed / 356 subtests gate 17 == 17 PASS 15 are the standing set (arena_high_water_631 x7, phase_flip_rotation_wiring_809 x4, restore_never_rebuild_677 x4). TWO ARE NEW AND ARE NOT SILENTLY DISMISSED: test_pp_admission_wraparound_never_blocks and test_pp_output_ring_retraction_wedge_791b. Both PASS IN ISOLATION on this exact tree (7 passed, re-run immediately after). Neither file touches barlink_liveness or dual_group_lane. The suite ran 1097 s against a 716 s baseline (+53%) because a serving instance (W41) was deliberately left running on the box throughout, so the most likely reading is timing sensitivity under host contention. NOT PROVEN: a contention-free full-suite re-run was not done -- it would have cost the live instance the successor needs. Flagged here so the next full run is compared against 15, not 17. mem_cache not re-run: no mem_cache file is touched by this commit. ruff: barlink_liveness.py 0, dual_group_lane.py 0; the new test carries 5 x E402 from the house register_cpu_ci()-between-imports convention. codespell clean. No added line over 88 columns. black/isort deliberately not run: the venv's black is older than the one this tree was formatted with. NOT CLOSED BY THIS COMMIT: the 12 allowlisted sites, and the one-hop limit above. Both are named where the next reader will hit them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Like vllm, user can load local model with model's id same as huggingface like: mistralai/Mistral-Large-Instruct-2407
Modification
Add an optional arg: served_model_name, change API: /v1/models
Checklist
pre-commit run --all-filesor other linting tools are used to fix potential lint issues.