Repository navigation
misc: update SGLang package description - #659
Merged
Merged
Conversation
timethink
pushed a commit
to timethink/sglang
that referenced
this pull request
Mar 9, 2025
Closed
1 of 3 tasks
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 12, 2026
…registry, not asserted Cut 1. The memtier package (sgl-project#407) has been complete and INERT since it landed: audit sgl-project#421 found zero production importers, and its own __init__ still says "No consumer reads any of this yet". Nothing in a serving path ever constructed a TierRegistry. This makes the KV spill rung the first one that does. The rung spills to exactly one place, and the ORDER of any further sgl-project#224 park tier is a hardcoded rule: destinations_error() refuses a list whose first entry is not 'local', quoting a measurement in prose. That rule is right and it is the wrong KIND of statement -- a name check standing in for a capability check, with its evidence in a comment where nothing can re-derive it. sgl-project#407 says so itself, at the field that exists for this exact edge: TierTransport.stages_through: "sgl-project#224's `local` must be first law is exactly this edge ... recording it now is what lets that law stop being a hardcoded total order later." This is that later. kv_spill_tier_selection builds a registry whose FIRST tier is local host RAM and derives the ladder from measured capacity and cost. Local-first stops being asserted and becomes DERIVED -- and falsifiable: local_first_disagreement() reports when the hardcoded law and the measured ladder stop agreeing, and deliberately does NOT reorder, because the law encodes a physical constraint (a device D2H copy has nowhere else to land), so a cheaper-looking park tier is evidence of a bad number, not a reason. TierCapacity.reserved is populated from a live source for the first time. sgl-project#407 documents it as "bytes declared by other holders, read from the cross-process ledger" and nothing ever wrote it, so every headroom the registry could compute was the headroom of an empty machine. pinned_host_budget.registered_posts() IS that ledger -- the join is now made, and a second pinned pool correctly reduces this tier's headroom. Exhaustion is a NAMED refusal (the ledger half of sgl-project#659 b). A region shortfall is the moment the local tier is full, and it was recorded only as a pressure timestamp: the operator saw a decline with no statement of what was full or how full. The ladder now reports one line per tier with a provenance, renders ABSENCES with their reason rather than as a dash ("unknown" and "zero" lead to opposite decisions), and degrades to the next tier when one exists. BYTE-IDENTICAL by construction: in this cut the registry is an OBSERVER under the rung. The sgl-project#224 chain still picks the destination; nothing in the spill path changes. That is deliberate -- the registry's verdict has to be comparable against the hardcoded law before anything is allowed to depend on it. Also fixes a latent bug found by smoking the wiring rather than reading it: kv_session_host_bytes returns None (not a pair) when offload is off, and unpacking it directly raised inside the caller's blanket except -- an ordinary "no pool" presenting as an invisible skip. Tests: test_kv_spill_tier_selection_659, 13 tests, green. Every load-bearing assertion has a sibling arm producing the opposite verdict from the same function, so the falsifier is proven can-fail rather than asserted: - local_first_disagreement returns None on the measured ladder AND non-None when a park tier is given absurd caps (test_disagreement_is_reported_ rather_than_obeyed); - a full local tier declines alone, and degrades to tier 2 when present; - roomy vs crowded proves the reserved-from-posts join actually binds. Live smoke (desk code that never ran is unvalidated): the wiring executed and printed kv-spill ladder: host:CT999 (ram-local) headroom=0.61 GB [measured] bandwidth=absent (no D2H bandwidth probe recorded for this pool) against a pool of 8 regions x 100000 tokens x 1024 B with 2 occupied -- arithmetic correct, absence rendered, rate-limit holding on the second call. sgl-project#631 flip family: 1076 passed / 0 failed, inherited baseline unmoved. ruff + codespell clean. Ship config is untouched: it carries no --enable-kv-session-offload, so live_kv_spill_ladder returns None at its first line.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 12, 2026
…ws name a path this container cannot route to sgl-project#636's open leg (P2) closed red-first and sgl-project#659 cut 1 landed as the first live sgl-project#407 consumer. The shift's main finding is a refusal: the brief's preferred second tier, Rig-2 RAM over the 40G link, does not exist from this process -- the fast NICs are on unroutable subnets, both reachable paths measure 75 MB/s, and the far box has 8.6 GiB of swap-backed RAM against a 12.9 GB KV region. Booked as C24 with the measurements, because rig1.json claims 2.83 GB/s 'measured' for that tier and nothing may size against it unre-measured.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 12, 2026
… and the ladder now picks Cut 1 put the sgl-project#407 registry under the KV spill rung as an observer with one tier on it. This is the second rung and the moment the registry stops observing. The brief's preferred second tier does not exist on this rig: s41 measured Rig-2 RAM as unreachable (unroutable subnets, 75 MB/s on the only routable path, 8.6 GiB of swap-backed RAM against a ~12.9 GB region) and peer VRAM is closed by the standing REBALANCE verdict. The cheapest REAL second tier is a local filesystem, and it is registered as what it is: a tier, not a remote tier. Every metric on the entry is measured at registration against the directory the blobs actually take -- never read from memtier/profiles, whose remote rows describe a link this process cannot route to (register C24). Two measurement traps are avoided by construction and documented with their numbers: probing with zeros measured the ZFS compressor at 6.2 GB/s rather than the disk, and reading back a just-written file measures ARC rather than the medium. The probe writes incompressible bytes, ends in fsync, ranks on the WRITE rate, and records the read-back as the upper bound it is. The probe size is 256 MiB and the entry says why: a 64 MiB probe overstates this volume by 2.8x. The capacity is the operator's ceiling floored by df, in that order -- min(budget, free - headroom) -- so a generous budget on a nearly-full volume yields a small tier instead of a disk-full outage. Selection: the ladder now ranks the configured park tiers by measured bandwidth and refuses the rest by name, replacing tier_index=0. It is byte-identical wherever budgets allow -- with one healthy tier the ranking is degenerate and returns 0, which is what the hardcoded law returned -- and cut 1's falsifier still passes. Every input to that decision is rank-uniform, deliberately: the ask is a boot constant, the capacities were measured at registration rather than re-read, and the ranking is computed once and cached. There is no per-park try/except around the choice, because a rank that fell into one and parked, beside a rank that succeeded and declined, would diverge into the completion min-reduce and wedge the instance rather than error (register law 14). The sgl-project#224 park counters are read for the first time. They were complete and correct for three shifts while every reference in the tree was a write, so a park that failed and a park that never happened produced the same silence. They now feed the selection policy (a tier is charged for the parks it eats and is refused on health once it has eaten enough), the ladder's ledger line, and the dashboard, which gains a measured denominator for park occupancy. Tests: 17 new, each load-bearing assertion with a sibling arm producing the opposite verdict from the same function. sgl-project#631 flip family 1076 passed / 0 failed before and after. Adjacent kv-spill, spill-tier, tier-occupancy and hicache-bounds modules 112 passed. ruff and codespell clean on the new files.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 12, 2026
… the same disk 2.9x apart
The first live two-rank boot of the park tier falsified the group-uniformity
premise of the cut that preceded it, and it did so with numbers rather than
with an argument. Both ranks probed the SAME directory at the SAME instant and
registered:
TP0 bandwidth 2.41 GB/s [measured]
TP1 bandwidth 7.00 GB/s [measured]
a 2.9x spread, because the two probes contend with each other. The previous
design quantized bandwidth onto a 0.25 GB/s grid and argued that "the quantum
is coarser than the spread between ranks". It is not, and no absolute grid can
be: any fixed boundary between 2.41 and 7.00 splits ONE medium across two
buckets, after which two ranks order a two-tier ladder differently, park one
session to two places, and the completion min-reduce turns that into a hang
rather than an error (register laws 8 and 14).
The replacement is a RATIO test. The configured order stands unless a tier
measures at least PROMOTION_RATIO (4x) faster than the incumbent. A ratio
survives contention because contention scales every tier on a rank together:
two tiers on one medium measure ~1x apart on every rank and tie into the
configured order uniformly, while a genuinely different medium -- the refused
remote path at 0.075 GB/s against ~3 GB/s local, i.e. 40x -- clears the bar on
every rank. The residual exposure, a tier pair whose true ratio sits near the
threshold, is recorded on the constant rather than pretended away.
Also lands the registration report the first design was missing: each park
tier now logs what it RESOLVED at boot -- id, transport, measured capacity,
measured bandwidth and latency, volatility, and the tier it stages through --
so an entry built against the wrong directory or with an absent probe is
visible in the boot log instead of at the first shortfall (register law 12: an
identity bug shows up as a mechanism that is inert, not as a wrong answer).
That line is what produced the two numbers above.
Tests: the quantization test is replaced by one pinned to the measured pair
(neither 2.41 nor 7.00 may outrank the other) plus its sibling arm (0.075 vs
3.0 must promote, so the mechanism is not inert). 18 passed.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 12, 2026
…identity instrument can no longer pass vacuously
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 12, 2026
…l demands, not one
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 12, 2026
… unparks, identity_miss=0
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 12, 2026
…ep path asserts, and it is what blocked sgl-project#659's end-to-end proof
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 12, 2026
…ert its sentinels The crash that blocked sgl-project#659's end-to-end proof. PS2 hands the extend an out_cache_loc full of HOST SENTINELS (spill_extend_alloc returns make_sentinels), and exactly one thing in the tree diverts that tensor away from the KV write: _dcp_write_scatter's _sess_prefill_owner_write branch, reachable ONLY from the token-sharded DCP lane (forward_extend enters it under `if self.uneven_dcp`). On plain TP the backend still BUILDS the prefill-spill state -- _sess_mode is "plain", _sess_prefill_spill is computed, the staging carve is reserved -- and nothing complains. forward_extend then falls through to the stock set_kv_buffer and the sentinels go into store_kvcache: jit_kernel/csrc/elementwise/kvcache.cuh:112 Assertion `index >= 0 && index < size_limit` failed Arithmetic, from the crashing run: host_base=4097 against a 4096-row allocator, request boundary=2620 L=3012, so the 392 written indices are 6717..7108 against a size_limit of ~4097. Every row out of bounds, layer 0, both ranks. The admission gate could not have known -- it was never told which backend it was admitting onto. Fix, at the gate: prefill_spill_deep_gate takes backend_write_hook, derived from _sess_mode != "plain". That is replicated boot config, fixed before the first forward and identical on every rank, so the verdict needs no collective and the refusal is a NON-ADMISSION rather than a rank-local skip around one (law 14). Declining is bit-for-bit the pre-PS2 behaviour: the request stays queued and the fast lane retries it. Belt and braces: spill_extend_alloc raises in Python if it is ever reached on a plain backend. The two failures are not equivalent -- a RuntimeError names the cause and unwinds, while the device-side assert it replaces poisons the CUDA context and points the traceback at an all_reduce three frames from the mistake. NOT fixed here, booked instead: _admit_born_spilled_deep sets born_spilled_deep / prefill_spill_deep_taken and decrements prefill_spill_regions at schedule_policy.py:908-910, and add_one_req can still bail out afterwards (hybrid-SWA, dllm, truncation) without clearing them. That is a real flag leak of the sgl-project#501 family and it wants its own change with its own reproducer. Tests: 167 passed (9 new C26 pins with both arms + the kvso, tier-selection and park-tier suites unmoved). ruff error counts identical before and after on both edited files (8 and 93, all pre-existing); codespell clean.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 12, 2026
…rminal output before the streamer reads it C26 is proven on metal and closed: the probe boot that killed successor 42's instance ran the same pressure band to completion, with no device-side assert and no traceback. With the crash gone, a session got through the whole round trip alive for the first time -- and the round trip is not the problem. MEASURED (TP=2 on the two 3080s, probe_boot_v7.sh = v5 + --chunked-prefill-size 256, boot cd761ab): rid=s44-sat-3 spilled, PARKED to the file tier (33 blobs / 5939200 B), UNPARKED cleanly (identity_miss=0, zero failures, both ranks identical), then finished on host two seconds later -- and the HTTP client never received a byte. It blocked forever against a scheduler at #running-req: 0. 40 further requests did not release it; abort_request on the rid returned 200 and was a no-op, the req slot having already been freed. Zero "RESTORE complete" lines all boot, so the session never returned to the device and spec item 13 was never reachable. ROOT CAUSE, an alias. release_finished_spilled_req runs from inside the per-request loop of process_batch_result_decode (batch_result_processor.py: 932-938) and calls slot.batch.filter_batch() (kv_session_offload.py:5868). For a spill tick, batch IS slot.batch -- one object, two names -- and filter_batch rebinds reqs=[] when nothing survives (schedule_batch.py: 3273-3277). The enclosing loop finishes on the old list; ~100 lines later stream_output(batch.reqs) (batch_result_processor.py:805) reads the new, empty one and sends nothing, so the detokenizer never sees a finished chunk and the tokenizer manager's waiter never resolves. The fix already exists on the OTHER exit: the abort path has _stream_terminal (kv_session_spill_destination.py:1537-1546, 1562-1572), added by bcc72dd for sgl-project#552 under the comment "Without it the abort frees the memory and the caller hangs". The finish exit never got it. Contributing, not the wedge: restore was unreachable on this boot twice over -- an early return whenever a fast-lane request waits (4707-4712), and fits_now demanding remaining+4096 against a whole pool of 4096 -- so finishing on host was forced. The park is exonerated; _commit_unpark restores every flag and slot.batch survives intact. Laws 19 (a state has more than one exit) and 20 (a cleanup inside an iteration must not mutate what the iteration's output depends on) booked. Law 18 booked separately for an instrument defect caught before it could lie: the first driver named its TARGET in advance, the server parked a different request, and the driver computed the attribution term without gating on it. No fix in this commit, deliberately: the discriminating test is CPU-only and is specified in HANDOFF_688 sec.2a, and this corpus does not ship desk-written code. Docs only. codespell clean. Serving restored on 30030 at cd761ab.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 12, 2026
…EFORE the loop A session that finished while host-spilled never reached its client. The caller blocked forever against a scheduler at #running-req: 0, 40 further requests did not release it, and abort_request was a no-op because the req slot had already been freed (measured on metal by successor 44, rid=s44-sat-3, /spinning/evidence-631/s44/WEDGE_AFTER_UNPARK.txt). The mechanism is an alias. release_finished_spilled_req runs from inside process_batch_result_decode's per-request loop and calls slot.batch.filter_batch(). On a spill tick `batch` IS `slot.batch` -- one object under two names, because maybe_take_tick hands the scheduler the persistent batch and event_loop_normal passes it through unchanged. filter_batch REBINDS reqs (both branches), so the finished request is gone from the list stream_output reads ~100 lines later. Iteration was never at risk (enumerate captures the list object), which is why the loss was silent instead of an IndexError. Fix: bind reqs and return_logprob once, before the loop, and stream from that binding -- the same stream-then-filter ordering the disaggregation decode path already uses. return_logprob is snapshotted too because filter_batch recomputes it from the SURVIVING requests, so a finished request that asked for logprobs would otherwise be streamed without them. The emit deliberately does NOT go inside release_finished_spilled_req, which would have been the literal twin of the abort exit's _stream_terminal: under the overlap loops the result processor runs on batch.copy(), a list the release cannot reach, so an emit there would DOUBLE-stream at all three overlap dispatch sites (scheduler.py event_loop_overlap, the decoupled spill lane, and pause_generation's drain). Sibling sweep over every filter_batch call site: the pre-schedule reap (kv_session_offload.py:4520-4524) and the tick-batch drain (:4931-4934) are of the same silent-drop class but are reachable only for a request that is already finished(), hence already streamed -- latent, not live, and left alone rather than fixed with unvalidated defensive code. The prefill path, retract_decode, retract_all and pause_generation are clean; the park abort exit (_release_parked_req -> _stream_terminal) already has the correct ordering. Tests, red-first: the new test fails on the pre-fix tree (2 failed, verified by reverse-applying this patch) with the host-finished session absent from the emit, and passes with it. It drives the REAL result processor over the REAL release path and the REAL ScheduleBatch.filter_batch for the empty branch; the survivor branch filters CUDA tensors and cannot run on the CPU lane, so it uses a stand-in pinned by a source assertion that fails if filter_batch's rebinds ever change. Suite: 1092 passed (1088 + 4 new), 0 failed, via scripts/run_631_flip_family.sh -- which now collects the new file, since the list is explicit. Plus test_kv_session_offload_unit.py + test_kv_spill_destination_unit.py: 164 passed.
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 12, 2026
…izing, C30 deterministic x kvso C28 marked FIXED in b2f1801 and CLOSED ON METAL: the pressure band that wedged successor 44's client ran again on the fixed tree and the parked session COMPLETED with its output delivered (rid=s45-cohort-3, 33 blobs / 3760128 B on the file tier, identity_miss=0, cohort drained errors=0). Records the fix's design choice and why the literal _stream_terminal twin was rejected (it would double-emit on the three overlap dispatch sites), the sibling sweep over every filter_batch call site, and a correction: the loss is not confined to the empty-list branch. C29 (NEW): --kv-session-offload-restore-margin-tokens defaults to 4096 and is never sized against max_total_tokens, so on any boot whose pool is at or below the margin the restore gate cannot open by construction. That is why successor 44 saw zero "RESTORE complete" lines. Independent of C28; worked around by CONFIG in this shift's probe (margin 64) so the sizing defect stays visible and gets its own commit. C30 (NEW): --enable-deterministic-inference and --enable-kv-session-offload cannot both be on. kv-session-offload refuses every backend but flashinfer, so HANDOFF_688's prescribed triton does not boot at all; flashinfer is the only backend satisfying both and silently disables the radix cache. The resulting instance boots, declares itself ready, serves its warmups and then admits NOTHING: a trivial 8-token generate hung 55 s, zero Decode batch lines all boot, py-spy showed TP1 spinning in add_one_req while rank 0 reported num_queue_reqs 0. One-variable attribution: the same boot without those two flags served in 0.36 s and reproduced the park on the first attempt. Byte-identity across a park is recorded as UNPROVEN and NOT ATTRIBUTABLE: the control arm also diverged from the reference, which is the driver's own "this run separates nothing" outcome, and determinism cannot be used to fix that while kv-session-offload is on (C30).
efschu
added a commit
to efschu/htsglang
that referenced
this pull request
Aug 12, 2026
…yte-identity not attributable (C30); restore reached (C29)
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
as titled cc @merrymercy @Ying1123 @hnyls2002
Modification
as titled
Checklist
pre-commit run --all-filesor other linting tools are used to fix potential lint issues.