Repository navigation
fix the broken server args - #585
Merged
Merged
Conversation
timethink
pushed a commit
to timethink/sglang
that referenced
this pull request
Mar 9, 2025
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…faster A permanently-red suite hides every new regression (sgl-project#380/sgl-project#585 test-honesty class). Hermetic mem_cache stood at 944 failed / 777 passed / 707 skipped in 248 s. It now runs 777 passed / 1651 skipped / 0 failed in 32 s. CLASSIFICATION, and it is simpler than the count suggested: (a) GPU-required under CVD="" ...... 944 of 944 (100%) (b) stub-drift / sgl-project#624-class ........ 0 (c) genuinely broken code paths .... 0 (d) obsolete tests ................. 0 Every one of the 944 shared a single root: get_device() raising "No accelerator (CUDA, XPU, HPU, NPU, MUSA, MPS) or platform plugin is available". Red meant "no GPU here", never "broken". Verified by taking the non-GPU remainder of the FAILED lines, which is EMPTY. Two secondary findings, both of which made this worse than it had to be: * CustomTestCase._callTestMethod wraps every test in utils.common.retry, which re-raises a bare Exception("retry() exceed maximum number of retries.") WITHOUT chaining the cause (no `from e`). The real one-line reason was discarded, so 841 of 944 reported an opaque retry message. That is why a single environmental cause looked like a suite-wide catastrophe. * the same wrapper retried a DETERMINISTIC environment failure several times each, which was most of the runtime -- hence 248 s -> 32 s. FIX. retry() honours exactly one exception: SkipTest is re-raised immediately and never retried. So a directory conftest converts the environmental error into a skip AT ITS SOURCE, which fixes the masking and the retry storm together and needs no edit to any test. It patches get_device on both the defining module and the package namespace, because the tests bind the name at import time and conftest is imported first. Installed ONLY when there is genuinely no accelerator, so a GPU run is unchanged and any real failure stays red; it fires only for tests that actually call get_device, so the 777 that already pass keep running -- the passing count is identical before and after, which is the check that no green test was silenced into a skip. One test needed an individual marker: test_memory_allocated calls torch.cuda.memory_allocated() directly and never goes through get_device. Marked with skipUnless and the reason, rather than widening the patch to cover torch.cuda. PHANTOM MOCK removed (mine, from the sgl-project#701 harness): tc.mamba_recoverable_size was mocked and NO SUCH ACCESSOR EXISTS -- the real one is mamba_evictable_size (mamba_radix_cache.py:1177, unified_radix_cache.py:3189). Nothing read it, so it never produced a false green, but a mock of a non-existent API teaches the next reader an interface the tree does not have, which is the same sgl-project#380 shape. Both it and its unused `recoverable` parameter are gone, with a comment naming the real accessor. mem_cache + managers together: 2883 passed, 0 failed (baseline 945 failed / 2870 passed). ruff clean.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…r discarded again Ride-along from the sgl-project#585 mem_cache triage, and it benefits every suite rather than that one. CustomTestCase._callTestMethod wraps EVERY test in sglang.srt.utils.common.retry, which re-raised a bare Exception("retry() exceed maximum number of retries.") with no `from e`. The original error was thrown away, so 841 of 944 hermetic mem_cache failures reported an opaque retry count instead of their one-line reason ("No accelerator ... is available"), and the triage had to reconstruct the cause by hand. Any suite that hits a deterministic failure inherits the same blindfold. Both raise sites are chained -- the retries-exhausted path and the should_retry-refused path -- because a fix covering only the first would still discard the cause on the other. Tests: 4, red first. They assert the chained __cause__ on both paths, that a successful retry is unaffected, and -- the one that matters operationally -- that the reason appears in the RENDERED traceback text, since what an operator reads is the point. ruff clean (0 findings, same as HEAD).
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…riant, refuse both guard flips (a) ROOT, at file:line. transfer_item_warp moves bytes with 64-bit PTX -- ld.global.nc.b64 / st.global.cg.b64 (transfer.cu:29-30) -- which faults on a misaligned address. The only alignment guard in the path is TORCH_CHECK(item_size % 8 == 0) at transfer.cu:285. That guard is sufficient for the lf_pf sibling and NOT for lf_ph, and the difference is entirely in the offset arithmetic. I compared the two launcher calls line by line (:496-513 against :532-551): identical empty tensors, identical tables in identical slots, identical layout dims. But get_global_offset_pf builds offsets only as multiples of item_size and layout_dim, so alignment is inherited from the checked guard, while get_global_offset_ph (transfer.cu:106-119) SUBDIVIDES by head_num in three of its four terms and the page-head kernel copies head_size_bytes = item_size / head_num (transfer.cu:145). Nothing requires that quotient to be 8-byte aligned. MISSING INVARIANT: item_size % (8 * head_num) == 0. Smallest faulting shape head_num=2 head_dim=2 fp16 -- item_size=8 passes the guard, head_size=4 does not, 24 enumerated offsets misalign. SCOPE, STATED RATHER THAN STRETCHED: this does NOT explain the reported segfault. test_minimax_sparse_pool_host_unit's shapes (page_size=4, float32, head_num=1, head_dim=2) give head_size=8 and zero misaligned offsets, and so do this rig's serving shapes (head_num=4, head_dim=256, fp8 -> head_size=256). The defect is real and latent; no production shape here is exposed. Both facts are PINNED so the attribution cannot quietly widen. Three hypotheses checked and closed on the way: the layer pointer table is correctly a device uint64 tensor (mha.py:135-144); layout_dim is the right per-token all-layer stride for the ph formula (mha.py:182); the k-only pool cannot reach lf_ph, it raises for any non-page_first layout under the kernel backend (mha.py:1113-1118). Attribution needs metal, so the falsifier is FILED NOT RUN: tools/441/falsify_lf_ph_441.py, three arms (repro / alignment / bisect), one arm per invocation because each is expected to kill the process, to be run under a gpu-arb claim. (b) BOTH GUARDS: DO NOT FLIP. The brief's premise was that the sgl-project#436 rebuild made them obsolete. Checking them at the code says otherwise, for two reasons, neither of which is the ABI issue. test_kvcacheio.py:20-24 module skip claims "segfaults on CUDA 13.x". But the lf_ph segfault reproduces on BOTH wheels -- that is this ticket's own premise and why it is not sgl-project#436. So the reason is wrong or incomplete, and flipping would expose a live cu12 crash. It must stay until (a) is fixed; what should change now is the REASON STRING, because a wrong reason sends the next reader to the wrong wheel. _DIRECT_PF_BATCHCOPY_BROKEN_CUDA13 never guarded a wheel issue at all. Per the measured matrix above it, it guards a TEST-SHAPE violation of the cudaMemcpyBatchAsync contract: pageable+default stream fails, pinned+side stream is OK, and production pins (mha.py:97) and uses a side stream (cache_controller.py:276,:742-749). The file's own comment already says unskipping alone leaves it red. The rebuild landing does not change a contract the test violates by construction; the fix is a test-shape change, and verifying it is GPU work. PIN TESTS NOT WRITTEN, deliberately: a pin that "goes red if the breakage returns" presupposes the breakage is gone, and for both guards it is not. Writing them now would encode a green state that does not exist. NOT DELIVERED: the sgl-project#261-Gate short-run script. Preparing it turnkey needs the gate's shim details verified at the code, which I have not done, and shipping a script I cannot stand behind would be worse than saying so. Tests, hermetic (CUDA_VISIBLE_DEVICES="", no CUDA context, no launch, no GPU): test_page_head_offset_alignment_441.py 6 passed + 6 subtests in 0.07 s pure arithmetic transcription of get_global_offset_ph; states the proposed guard positively and fails if that predicate is not the right one test/registered/unit/mem_cache/ 940 failed / 796 passed -- the 940 are PRE-EXISTING ON THIS BASE (b786858 lacks the sgl-project#585 conftest that turns no-accelerator errors into skips). Proven by re-running with my file ignored: 940 failed / 790 passed, i.e. identical failures and exactly my 6 passes added. ruff clean; falsifier byte-compiles without executing.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…ason strings, file the host-tier gate 1. THE GUARD. check_page_head_alignment in csrc/kvcacheio/transfer.cu, requiring item_size % (8 * head_num) == 0, called from BOTH page-head entries: transfer_kv_all_layer_lf_ph and transfer_kv_per_layer_ph_lf. Guarding only the reported one would have left the same asymmetry sgl-project#717 was reverted for -- a defect that looks fixed from one side. The message names the two facts that EXPLAIN the rule, not just the rule: the .b64 PTX width (ld.global.nc.b64 / st.global.cg.b64 fault on a misaligned address) and the subdividing offset formula (get_global_offset_ph divides three of its four terms by head_num). A reader who learns only the rule works around it by changing head_num. Pinned: the predicate refuses the faulting shape (head_num=2 head_dim=2 fp16, item_size=8 passes the OLD guard, head_size=4 does not), does NOT falsely refuse the reported-crash shapes or this rig's shapes, and AGREES WITH ACTUAL OFFSET ALIGNMENT on every shape -- so a future edit cannot keep the tests green by tuning the constant. A source pin holds it wired at both entries. MUTATION PROOF: unguarding one entry and weakening the predicate back to % 8 turns 2 pins red. 2. BOTH REASON STRINGS. test_kvcacheio.py's skip said "segfaults on CUDA 13.x". It now states the evidence: reproduces on BOTH wheels, root NOT yet attributed, the alignment defect found here is real but is NOT this crash's cause (these shapes are aligned), and the metal falsifier is at tools/441/. The >= 13 condition is deliberately left as-is with the reason recorded -- widening it would hide the cu12 signal the falsifier needs, removing it would hand CI a known segfault. test_minimax_sparse_pool_host_unit.py's batchcopy comment now LEADS with the reading it previously only implied: the flag guards a CONTRACT VIOLATION COMMITTED BY THE TEST, not a wheel, ABI or CUDA-13 bug, and the measured matrix proves it because pinned+side-stream passes on the same wheel that fails the other three. It says explicitly that the sgl-project#436 rebuild cannot make it obsolete, since a rebuild cannot change a contract the test breaks by construction. 3. sgl-project#261 GATE: THE "SHIM" IS LOAD-BEARING. Verified at the code, which is what was owed. Step 4 is `python -m sglang.srt.mem_cache.hicache_migrate` with --target-tp-size / --target-ratios / GDN layout arguments. The live gate runs source A at TP=1 and destination B at TP=N (live_handover_gate.sh:37), and stored KV pages and GDN state blobs carry the SOURCE's shard geometry. Without the conversion B is not reading the host tier the hard way -- it is handed bytes in a layout it cannot interpret, and the run fails for a reason unrelated to the host tier. So a no-shim 1->N run is structurally meaningless, which is the stop condition the brief named; the cross-geometry handover IS the umsharder. What IS meaningful is holding the geometry EQUAL and dropping the migration: no conversion is needed by construction and the host tier is what remains under test -- write-through, park/export, prefetch, resume from cache, byte-identical continuation. Weaker than the 1->N gate, and real. Filed as scripts/handover/hostier_gate_noshim.sh, syntax-checked and refusing cleanly on missing env, NOT RUN. Its preflight REFUSES when the two servers' geometry/checkpoint differ rather than producing a red a reader could mistake for a host-tier finding -- that refusal is the script's safety property. It keeps the original gate's two load-bearing pieces: the A-vs-A floor FIRST (a cross-server byte claim on a rig whose own repeat is not byte-identical is not a claim about handover) and --expect-cached (without it a destination that re-prefilled reproduces the same greedy tokens and the comparison passes while proving nothing -- observed for real on the sgl-project#261 gate before it was added). Tests, hermetic (CUDA_VISIBLE_DEVICES="", no CUDA context, no launch, no GPU, no server contacted): test_page_head_offset_alignment_441.py 13 passed + 14 subtests in 0.07 s test/registered/unit/mem_cache/ 940 failed / 803 passed -- the 940 are the unchanged PRE-EXISTING baseline on this base (b786858 lacks the sgl-project#585 conftest); passes moved 796 -> 803, exactly the 7 new pins. ruff + codespell clean; the shell script passes bash -n; edited Python files byte-compile. The C++ guard is NOT compiled here (no CUDA build in a hermetic run). Its predicate is pinned arithmetically and its wiring by source inspection; a compile rides the next kernel build.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…hybrid-GDN family stops being resize-only ANCESTRY CHECK FIRST, as asked, and it passes. The 5 routes and the 21-test resize suite both come from 470b88e (2026-08-04), which IS in this branch's ancestry AND on the serving line 5fed8a6. No train branch touches unified_radix_cache.py, and MERGE_TRAIN_2026-08-17 lists fix/717-rebuild as merging CLEAN (held for its own review boot). So the sgl-project#545 conclusions were not missing train-carried changes. PREMISE: WHY THE STUBS EXISTED. The open question was whether attach on this cache is a GROUP operation. It is: _symmetrize_prefetch_capacity enters an all_reduce across DCP/TP ranks to derive the prefetch limit from the MIN host pool, and its own guard refuses a rank-local early return because that "would leave the other ranks in the all_reduce with no partner". A single-rank attach would hang. That turned out NOT to be a blocker. attach_hicache_storage fans out through FanOutCommunicator (tokenizer_control_mixin.py:125,:360) to EVERY rank and merges the results, so the group runs it together, and the scheduler refuses a non-idle scheduler by name first. The stubs were unimplemented, not blocked. BUILT, mirroring the shipped HiRadixCache pair: same validation with no side effects on refusal, same named refusals, same "same backend is success, a DIFFERENT backend is refused rather than silently swapped" rule (a swap would strand every page written under the old backend), plus _symmetrize_prefetch_capacity AFTER the config is applied -- the limit is the cross-rank MIN and can only be derived once each rank knows storage is on. DETACH ORDER IS THE CONTRACT, taken from HiRadixCache: drain the control queues BEFORE tearing the controller down, or acks and releases can no longer be matched to their nodes and host pages and locks leak; drain again after to sweep what the shutdown produced. The drain is LOCAL (None limits = everything on this rank) because the steady-state path derives its counts from an all_reduce and a detach may not depend on a collective its peers may already have left. A detached tier's pages become MISSES, never corruption -- keys are content-addressed, the same argument sgl-project#703 uses for drops. NO SILENT PARTIAL CAPABILITY (sgl-project#268): the MAMBA/state component is COVERED, not refused. _get_hybrid_storage_attach_kwargs passes cache_controller.mem_pool_host.entries, which spans every component the controller owns -- the same set the boot-time attach passes -- so a hybrid attach is whole rather than KV-only wearing a success message. Pinned. Tests, hermetic (CUDA_VISIBLE_DEVICES="", no server, no CUDA): test_unified_attach_detach_545.py 16 passed -- SIBLING to the resize file, not merged into it: that file owns the resize authority, one authority per behaviour (my own sgl-project#536 rule). RED-FIRST: restoring the stubs fails 15 of 16. + the existing resize suite: 37 passed together. test/registered/unit/mem_cache/ 940 failed / 819 passed -- the 940 are the unchanged pre-existing baseline on this base (lacks the sgl-project#585 conftest); passes moved 803 -> 819, exactly the 16 new pins. No regressions. ruff + codespell clean. ACCEPTANCE UPDATED in NOTE_545: attach/detach on a hybrid-GDN model are now EXPECTED TO SUCCEED with the state component covered; the previous "expect the named refusal" acceptance is struck through as superseded. STILL OPEN, named not fixed: the ENOSPC injection test, and tokenizer_control_mixin.py:370's own "# TODO: partial rollback if failed" -- if some ranks attach and others do not, nothing rolls back. The fan-out merges results so the caller learns it failed, but the group can be left inconsistent. That gap predates this change. Desk only, no boot, no model load, no serving contact.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…tach, and ENOSPC injection
1. PARTIAL ROLLBACK (the pre-existing TODO at tokenizer_control_mixin.py:370).
A mixed fan-out result left the group HALF-ATTACHED -- some ranks running
storage threads with a backend bound, others not -- and reported it as a clean
failure. That is exactly the state the detach contract exists to prevent.
Now the terminal state is all-attached or all-detached, never mixed: on a mixed
result the coordinator detaches the group, and if that rollback fails anywhere
the response NAMES the stranded ranks rather than reporting clean failure.
Three things it needed:
* A RANK ON THE REPLY. FanOutCommunicator.handle_recv appends results in
ARRIVAL order, so list position does not identify a rank -- "ranks 0 and 2
are stranded" was literally unsayable. Attach/Detach outputs now carry
`rank` (flat world rank pp_rank*tp_size+tp_rank), stamped in a WRAPPER so
every return path gets it; stamping at each `return` would let a
later-added path ship unstamped (-1) and silently break the naming.
Uses self.ps.tp_rank, NOT self.tp_rank -- the Scheduler keeps its parallel
identity on the ParallelState wrapper and the bare attribute does not
exist (the file's own comment records that trap).
* A GROUP DETACH, not a targeted one: detach is idempotent by construction
(it asks the controller to clean up even when enable_storage is already
False, precisely to sweep partial-attach leftovers) and the communicator
offers no rank-addressed send.
* COLLECTIVE-FREE, per this ticket's own rule: the detach path drains with
local (None) limits and enters no all_reduce, so a rank whose peers have
already left a collective cannot hang on it.
The verdict is NEVER flipped to success; rollback only changes what the message
can tell you.
2. ENOSPC INJECTION at the syscall boundary. Technique reused from the
canonical store's three-site injection; none of its code, which lives on an
unmerged train branch.
Pinned: a write hitting ENOSPC returns False AND the key is genuinely not
readable (False is only honest if the page is really absent, or the tree
believes a page is backed and the next prefetch resolves to nothing); no torn
page is ever visible, because the page appears only at os.replace -- a failure
before it leaves the final path absent, a failure at it leaves prior content
intact; the watermark REFUSES AT THE DOOR when a cap is configured rather than
failing mid-write with the IO already spent; and the tier still works after.
ONE PIN HAD TO BE REBUILT TO BE HONEST. The reservation-leak check first
asserted that a later write still fits after five failed ones. It COULD NOT
FAIL: with a cap in force the evictor simply EVICTS to admit, so a leaked
reservation causes extra eviction rather than a refusal, and the pin passed
with `abort` removed. It now asserts on _total_bytes directly, which is what
distinguishes released from leaked. The mutation that previously failed 1 pin
now fails 2.
Tests, hermetic (CUDA_VISIBLE_DEVICES="", no server, no CUDA):
test_attach_partial_rollback_545.py 9 passed
MUTATION: dropping the rollback fails 4, including the mixed-state pin
test_hicache_enospc_545.py 11 passed
MUTATION: removing abort + tmp cleanup fails 2
test/registered/unit/managers/ 13 failed / 2217 passed -- failures unchanged
from the 13-failure baseline, passes 2208 -> 2217, exactly the 9 new pins
test/registered/unit/mem_cache/ 940 failed / 830 passed -- failures
unchanged from the pre-existing 940 baseline (this base lacks the sgl-project#585
conftest), passes 819 -> 830, exactly the 11 new pins
ruff + codespell clean; scheduler.py ruff count unchanged at its
pre-existing 94 (verified against the HEAD version).
Branch head moves to this commit; the merge-train doc is not carried on this
branch (it lives in the wt-reconcile / wt-706 worktrees), so the new head is
recorded here rather than by editing another strand's tree.
Desk only, no boot, no model load, no serving contact.
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.
Possibly due to the conflicts between #578 and #576