Repository navigation
Add support for OpenAI API : offline batch(file) processing - #699
Merged
Merged
Conversation
merrymercy
requested changes
Jul 27, 2024
15 of 29 tasks
Ying1123
approved these changes
Jul 29, 2024
Contributor
Author
|
Finish accuracy and throughput test, it is ready to merge. |
timethink
pushed a commit
to timethink/sglang
that referenced
this pull request
Mar 9, 2025
…ect#699) Co-authored-by: hnyls2002 <[email protected]>
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…it was switched off
On 2026-08-16 the server sat wedged for 52+ minutes while /health returned 200.
TWO independent blind spots produced that, and the second had not been named.
## 1. /health answers "is the process up", not "is work moving". Known.
## 2. The shipped watchdog is blind to admission wedges BY CONSTRUCTION
create_scheduler_watchdog (managers/scheduler_components/invariant_checker.py:
536-540) wires:
get_counter = lambda: scheduler.forward_ct
is_active = lambda: (scheduler.is_initializing
or scheduler.cur_batch_for_debug is not None)
It arms only WHILE A BATCH EXISTS. An admission wedge is exactly the state where
no batch exists while work is pending (#running-req: 0 on 90.6% of prefill
rounds in the specimen). So is_active is False for the entire wedge and the
timer never starts. The watchdog is not slow -- it is switched off, which is why
a 52-minute wedge produced no alarm from either mechanism.
## The signal
Progress is ANY ONE of three counters advancing over a sliding window:
prefill_chunks the only one that moves in a long pure-prefill run, where a
640-chunk prompt completes nothing for minutes
decode_steps moves in pure decode, where no chunk is admitted
completions moves when requests finish
Requiring all three would call a healthy pure-prefill server wedged; requiring
only completions would do the same. The rule is disjunctive precisely because
that is the trap.
## The refusals, which are what make the alarm worth listening to
- AN IDLE BOX IS NOT A WEDGE. Zero progress with zero pending work is a server
with nothing to do. The progress counters are IDENTICAL to the wedge's; only
queue depth and pending tokens separate them. Alarming here is how a real
alarm gets ignored.
- A DELIBERATE PAUSE IS NOT A WEDGE. A flip is 2.0-4.2 s of legitimate silence
(sgl-project#690); an inhibited sample suppresses the verdict rather than tripping it.
- A COUNTER RESET IS NOT A WEDGE. After a restart the counters return to zero,
so a negative delta means restarted, not stalled. Reading it as a wedge would
make every restart trigger another.
- A COLD START IS NOT JUDGED. Fewer than two samples yields unknown.
## Wiring and policy
build_liveness_is_active replaces the shipped gate: it arms whenever WORK IS
PENDING rather than when a batch happens to exist -- the exact inversion of the
failure above, and the condition that actually distinguishes a wedge from an
idle box.
Escalation is defined rather than implied: confirmations consecutive wedged
windows before an alarm, restart_after_alarms before a restart, and a
restart_cooldown_s so a wedge that SURVIVES a restart does not become a restart
loop. Restart can be disabled outright.
to_monitoring_dict exposes the deltas and pending counts alongside the verdict,
deliberately: an operator who sees only "wedged" cannot tell an admission wedge
from a stalled forward pass, and those need different responses.
## Test results
252 passed, hermetic (CUDA_VISIBLE_DEVICES="", no clock), ruff + codespell
clean. Every threshold is a deployment input.
test_progress_liveness_699.py (16): the 16:23 specimen as a CAN-FAIL PROOF
(health 200 + zero progress + nonzero pending must alarm); idle refused; pure
prefill and pure decode both healthy; deliberate pause; cold start; counter
reset; confirmations; the restart policy and its cooldown; restart disabled;
pending tokens alone meaning work; the replacement gate arming during the wedge
where the shipped one is silent; the monitoring dict; and window sliding so
stale progress cannot keep a dead server looking alive.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…l attributes
Follow-up: the binding needed code reading, not a live scheduler. Verified
against /spinning/wt-678-deploy.
WHAT EXISTS:
scheduler.forward_ct monotone; += 1 at the TOP of
run_batch (scheduler.py:6933), so it
counts batch ATTEMPTS
len(scheduler.waiting_queue) pending requests (:7538, :7725)
len(scheduler.running_batch.reqs) running requests (:7539, :7726)
load_inquirer._get_num_pending_tokens() pending tokens (load_inquirer.py:54-72,
sums req.seqlen over the waiting queue
plus the chunked remainder)
WHAT DOES NOT EXIST, and it changes what the signal can promise: there is NO
monotone completion, decode-step or committed-chunk counter.
metrics_reporter.num_generated_tokens is reset every reporting interval
(metrics_reporter.py:849, :1080), so it cannot carry a delta across a window.
CORRECTION TO MY OWN CLAIM. I told the coordinator "forward_ct alone is NOT
sufficient". That was overstated. forward_ct IS sufficient for the 16:23 wedge:
no batch forms, so it never increments, and the defect was purely the is_active
gate. Where it is genuinely insufficient is the RETRY-LOOP shape -- a batch that
re-runs without committing anything advances ATTEMPTS while nothing progresses,
which is exactly the sgl-project#701 self-deadlock silhouette. Separating those needs a
committed-chunk counter, and that is a one-line instrumentation ask rather than
a redesign.
The binding is therefore honest about its reach: it fills the attempt signal
from a real monotone attribute and leaves completions/decode_steps at ZERO
rather than inventing motion it cannot observe. A test states that limit
explicitly rather than hiding it.
SchedulerBinding holds attribute paths as DATA, not lambdas, so a binding can
be asserted against a synthetic object hermetically and a rename in the tree
surfaces as a refusal. A stale binding raises: a binder that quietly returns a
frozen counter reads as a PERMANENT wedge, the worst failure available to a
wedge detector.
21 tests (5 new), hermetic, ruff + codespell clean. Live can-fail on a real
wedge remains a window item.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…-chunk, the failure is per-total
A chunked request's own committed prefix fills the pool its own next chunk must
allocate from, and it cannot evict itself to make room. Analysis, hermetic
falsifier, and priced options. NO BUILD -- the recommendation touches admission
policy and is held for GO.
## (a) Reachability, at file:line in the deploy tree
1. Each committed chunk LOCKS its prefix. radix_cache.py:546 --
cache_unfinished_req ends with inc_lock_ref(new_last_node), moving the
prefix from evictable to PROTECTED.
2. The admission budget EXCLUDES protected space. schedule_policy.py:809-825 --
rem_total_tokens is available_size() + evictable_size(). Nothing protected
counts.
3. So every chunk shrinks the budget its own successor is checked against. The
request eats its own runway, one locked chunk at a time.
4. Eviction cannot recover it. radix_cache.py:569-575 -- evict walks
evictable_leaves only, and the request's own prefix is locked. THE REQUEST
CANNOT EVICT ITSELF TO FUND ITSELF.
THE TREE ALREADY KNOWS. schedule_policy.py:993-995 names it: "the prefill input
must transiently fit the device. If not, this is the DEEP case (PS2) -> reject,
today's wedge/wait behaviour", and the born-spill admission logs that it admits
a request whose "full lifetime would wedge". What was missing is the arithmetic
saying exactly when.
THE CONDITION. With budget A at admission and chunk C, a request of length L
commits chunks until A - k*C < C, so a single request deadlocks IFF L > A. The
sharp edge: ADMISSION IS PER-CHUNK, THE FAILURE IS PER-TOTAL. Concurrently the
condition is on the SUM -- several individually-admissible requests deadlock
collectively, which no per-request check catches. It presents as a hang rather
than a reject because the request gets MOST OF THE WAY first (the falsifier
shows >= pool - C committed before stalling).
## (b) Falsifier
Hermetic, no GPU. Pins: a fitting request completes; L > pool self-deadlocks
after near-complete progress; the threshold is the POOL not the chunk (a bigger
chunk changes granularity, not outcome); and two individually-admissible
requests deadlock COLLECTIVELY.
## (c) Options, priced
A admission gate (refuse unless full L fits, and RESERVE it)
stops wedge: yes | serves L>pool: NO | needs: nothing
cost: refuses long prompts; reservation held for the lifetime, so
long-prompt concurrency drops sharply
B self-evictable prefix to host (sgl-project#703 composes)
stops wedge: yes | serves L>pool: YES | needs: the host tier
cost: host traffic; USELESS WITHOUT HOST BUDGET -- the falsifier shows it
still deadlocking at zero budget, so sgl-project#703 is a real dependency
C preempt/retract another request
does not help the single-request case: the only holder IS the victim
A subtlety the model makes explicit: the gate must RESERVE the full length, not
merely check it. Checking without reserving lets two requests both pass and then
collide -- the very shape it exists to stop.
## Recommendation: A first as a safety property, then B as a capability
The reasoning is about failure SHAPE, not throughput. A wedge is the worst
available outcome because it is SILENT -- sgl-project#699 established that /health reports
200 through it and the watchdog is disarmed by the very condition that defines
it. A refusal is loud, diagnosable and attributable. Converting a silent wedge
into a noisy refusal is a strict improvement EVEN WHEN THE REFUSAL IS
UNWELCOME, and option A does that with no new subsystem.
A alone is not a sufficient end state: it makes prompts longer than the device
pool permanently unservable, and on this rig a 327,680-token context against a
436,278-token pool leaves no room for a second concurrent long prompt. B follows
because it is the only option that keeps SERVING the request, and it is exactly
what sgl-project#703's host tier is for. They are complementary, not alternatives.
269 tests green, hermetic, ruff + codespell clean. Traffic hold honoured.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 16, 2026
…ch had already refuted ## The retraction My sgl-project#701 section concluded "admission is per-chunk, the failure is per-total". That premise is FALSE. schedule_policy.py:1464 gates the FULL lifetime at first admission: if total_tokens >= self.rem_total_tokens: ... return AddReqResult.NO_TOKEN So a single request longer than the pool is REFUSED, not admitted-then-wedged, and my falsifier's headline case modelled a defect the shipped code prevents. Worse: the retraction already existed ON THIS BRANCH. Commit 845ac92 ("[sgl-project#701] Slice-3 rework: retract the mechanism story, close the real holes") had verified :1464, retracted exactly this story in its design doc, module docstring and both test files, and closed the real defect. I re-derived the refuted version without reading it. I searched the deploy tree for the mechanism but never checked whether sgl-project#701 was already owned and answered. ## What the real defect is, per the work that already exists 1. Paper-evictable funds an admission the evictor cannot honour: schedule_policy.py:734-737 -- rem_total_tokens includes full_evictable_size() while the allocator recovers only MAMBA-recoverable bytes. Gate passes; later relief frees 0. 2. The missing reservation is CROSS-PASS. PrefillAdder is rebuilt each pass and reserves only remaining DECODE, so a resident chunked request's remaining PREFILL is represented nowhere later. Later admissions spend its committed future, and the deadlock needs TWO ACTORS -- which is why a single-request analysis could never find it. ## Duplicates deleted planner/chunked_admission.py already provides ChunkedCommitmentLedger, decide_chunked_admission, effective_rem_total_tokens, defer-age tracking and idle-flip blocking, with tests in planner/ AND managers/ -- the latter running against the REAL PrefillAdder, which is strictly better evidence than the toy model I wrote. So I deleted my duplicate managers/chunked_admission.py and my planner/chunked_deadlock.py rather than keep a second, weaker account. ## The one genuinely additive piece, kept A monotone committed_chunks counter on the EXISTING ledger's spend() -- the single commit path. It lets the sgl-project#699 detector separate a retry loop (attempts advancing, nothing committing) from real progress, which forward_ct cannot do because it counts ATTEMPTS (scheduler.py:6933). Not rewound by release(): a progress counter that goes backwards reads as a restart to any watcher. progress_liveness gains an `attempts` field and retry_loop_detection, binding forward_ct to attempts and the ledger's committed_chunks to the commit signal. When the ledger is absent the commit signal stays at ZERO rather than borrowing the attempt count -- an invented commit would make a retry loop look like progress, which is the failure being hunted. ## sgl-project#702 noise floor (window 0b6c7db) A-vs-A spread is 14.1%, clean single-stream prefill ~1,820 tok/s. Rungs predicting less than +14.1% are NOT FINDINGS and are now flagged below_noise_floor: [28,17,19] (+12.0%) is disqualified outright. The recommended picks are unaffected -- [42,11,11] (+81.8%) and [44,10,10] (+100%) clear it widely. Also noted: 1,820 tok/s single-stream against 3,307 implied by the pipelined stage times is consistent with one stream not filling a 3-stage pipeline, so single-stream figures must not be substituted for pipelined ones. 237 tests green, hermetic, ruff + codespell clean.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…th-200 cannot see
The existing watchdog fires when forward_ct stops advancing while a batch
exists. The measured wedge defeats BOTH halves of that: chunked prefill kept
running so forward_ct ADVANCED, and cur_batch_for_debug stayed non-None -- for
31.64 s during which a TEN-token prompt produced no first token, with 0 running
and 1 queued. Health-200 is blind for the same reason. An 8-arm run put every
TTFT between 11.87 s and 62.65 s with NOT ONE arm under 3 s, so this is the
serving floor rather than an outlier.
The signal is therefore QUEUE AGE VERSUS PROGRESS, never batch existence or
forward count -- and PROGRESS means a request reached its FIRST TOKEN.
Completions are the wrong clock (a long generation legitimately produces none
for minutes) and forward passes are the wrong clock for the reason above.
THRESHOLD 20 s, from the specimen rather than round: the fastest observed wedge
arm was 11.87 s and healthy short-prompt TTFT on this rig is sub-second, so 20 s
sits above ordinary scheduling latency and below every wedge measured.
CORROBORATION IS OPTIONAL BY DESIGN. The PHASE-POLICY IDLE-LOCKED TERMS line is
reported when present, but the detector fires WITHOUT it: the wedge class is
broader than the phase-policy path, and a detector that only fired alongside a
policy log would miss every wedge arising anywhere else.
Tests, hermetic (CUDA_VISIBLE_DEVICES=""):
the 31.64 s specimen alarms; the sampled 2 s sequence stays silent early and
alarms by the end; threshold boundary qualifies at equality
busy box with slow prefill is SILENT ......... CAN-FAIL, and the important
one: a detector that cried wolf on long prefills would be filtered out
exactly as health-200 was
empty queue silent however long idle; fires without corroboration; reports it
when present; every detail quotes its terms
-> 9 passed + 13 subtests. ruff clean.
CAN-FAIL PROVEN BY MUTATION IN BOTH DIRECTIONS, because a detector fails two
ways: a never-alarms mutant fails 6 of 9, a cries-wolf mutant (alarming while
requests are running) fails 9 of 9. Reverted and re-verified 9 passed.
Pure function, not yet wired to the watchdog thread: it needs a
first-token-progress clock the scheduler does not currently expose, and adding
that touches the serving path. Wiring is a separate change with its own review;
this is the decision rule, testable and complete on its own.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…ndle
THE SPECIMEN, 2026-08-17 14:48:22, on a boot whose warmup generation never
reached a first token:
arming tp_to_pp: decode bundle complete: 0 reqs decoded in 183.6 s
(13777 tok prefill waiting) -- exit condition: decode drained
The tp phase was entered with NOTHING decoding, sat 183.6 s (released by the
180 s decode-stall cap), and left claiming completion. Six such cycles in one
boot.
`bundle_at_phase_entry` is `running_bs` AT ENTRY (:2093), so 0 means the bundle
was never resident: there was no work to drain and the visit accomplished
nothing. The sentence was the defect -- a drained bundle and an empty visit
produced the SAME words, differing only by a number that reads as a quantity
rather than as a verdict, so a log scan showed "complete" either way.
LEAVING IS STILL CORRECT and is unchanged: a decode layout with nothing to
decode should yield to prefill. The direction stays TP_TO_PP in both cases;
only the diagnosis differs. This is a wording change in the sense that a wrong
instrument reading is a wording change.
WHY IT MATTERS BEYOND WORDING. The sgl-project#699 admission-wedge detector fired 17 times
on this same boot -- "1 queued, 0 running, and NO first token for 288.0s. Work
is admissible and nothing is serving it" -- and recorded "no phase-policy
corroboration seen". An empty decode phase standing beside a non-empty backlog
IS that corroboration: it is the layout's own evidence that work is queued which
nothing is making runnable. The vacuous message was withholding it, so the two
instruments could not be put together. The new line names ADMISSION as the
suspect and points at sgl-project#731 and at the sgl-project#699 line by number.
Also corrected: the healthy path said "{bundle} reqs decoded", but that number
is the count AT ENTRY, not the number decoded. It now says "{bundle} req bundle
drained", which is what it measures.
TESTS test/registered/unit/managers/test_vacuous_decode_exit_730.py, 6 passed,
built on the specimen's own numbers (13777 tok, 183.6 s). Mutation-proven:
restoring the vacuous branch turns 4 red. Can-fails pin that a REAL drain still
reads as completion, that the two paths never share a verdict word, and that a
running bundle is still refused mid-flight -- a fix that renamed the healthy
path would make every green window look like a defect.
REGRESSION managers 19 failed / 2415 passed against a baseline of 19 / 2409
captured on the reverted tree: ZERO new failures, +6 are these.
NOTE FOR THE TRAIN, unrelated to this fix: the desk train's managers baseline is
19, against 12 on train/0817-exec. The extra seven are
test_kv_arena_handle_retention_631 (7) and test_kv_arena_span_ops_631 (1), with
test_collective_family_siblings_610 at 3 rather than 2 -- pre-existing on this
composition and not touched here.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 17, 2026
…utover
THE CAUSAL CHAIN, measured 2026-08-17 across two boots:
the carry re-homed a request into running_batch/running_mbs[0] and left
waiting_queue untouched
-> the request existed TWICE: resident (invisible to the policy as
runnable) and queued (counted)
-> _pending_prefill_tokens summed the queue and the resident set without
excluding their intersection, billing the same prompt twice:
51,369 -> 102,307 tokens across one cutover, within rounding of 2x
-> the inflated backlog drove the flip policy past its threshold
-> six cutovers, FLIP-CARRY announcing a resident carry while the policy
read `running bs 0`, the sgl-project#699 detector reporting "1 queued, 0 running",
and the warmup generation never served.
THE FLIP CHURN WAS A SYMPTOM. Six cutovers looked like a flip defect and were
not one: the policy responded correctly to a number that was wrong. Nobody
should "fix" the churn separately.
THREE PARTS, because the defect has three surfaces:
1. STATE -- the carry now CONSUMES what it re-homes
(`_consume_carried_from_waiting_queue`). After a cutover the resident set
owns the request and the queue must not also claim it. Both edges pinned: a
request that is ONLY queued stays untouched, and a carry over an
already-consumed queue is a no-op rather than a corruption. Bookkeeping
never raises into a cutover (sgl-project#715 lesson).
2. NUMBER -- `_pending_prefill_tokens` de-duplicates at the INTERSECTION. Not a
blanket "count each rid once anywhere": a request genuinely holding budget in
two places is a real state a future reader may need to see, and a global
dedup would make that class silent the way this one was. Exactly one overlap
is excluded, and only this one. The sgl-project#713(a) resident term did not create the
duplicate state -- the carry did -- but a counter that sums two sets without
excluding their intersection is the second half, and that half is mine.
3. GUARD -- `duplicate_resident_reqs` gains the waiting queue in its universe.
It compared batches against each other and never consulted the queue, so it
reported "no duplicates" meaning "none of the kind I look for". Queue-side
hits carry a `queued:` prefix so the 2026-08-09 resident-vs-resident specimen
and this one stay distinguishable.
Plus the hardening: `_arriving_prefill_tokens` asserted "ARRIVED but not yet on
the queue" and enforced nothing. Its only inflight-bearing call site is
pre-queue so the invariant holds today, but an asserted-never-checked invariant
is exactly how this double count stayed silent, so it is checked now.
TESTS 18 passed. Mutation-proven THREE ways, each caught: removing the carry's
call site, removing the counter's dedup, and removing the guard's queue
universe.
TWO OF THOSE TESTS WERE VACUOUS FIRST, and both are worth recording:
* the carry test called the helper directly, so deleting the call from
`install_resident_set` left everything green -- the helper worked and nothing
used it. It now drives the real entry point.
* the counter test's duplicate had `extend_range=None`, which the sgl-project#713(a) term
skips by design, so the resident side contributed 0 and the intersection was
never exercised. The duplicate is now made countable on purpose.
Both were found by running the mutations rather than by reading the tests.
REGRESSION managers + mem_cache: 19 failed / 3588 passed against a captured
baseline of 19 -- ZERO new failures. Ruff: scheduler.py 94 errors before and
after, all pre-existing; the other two files clean.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 25, 2026
… installed
CLASS: a term whose input is produced by the very transition it governs.
W37-D/d4, four consecutive lines:
arming pp_to_tp: DRAINED ... 2 req decoding
RESIDENTS RELEASED for pp_to_tp: 7 request(s) retracted
SEAM RE-ADMISSION: 7 put back at the FRONT of the waiting queue
arming tp_to_pp: pending prefill 18586 tok > 0 (... nothing decoding)
"Nothing decoding" one line after "7 retracted". 102 flips, GPU 98/47/57%,
exactly ONE output token per flip cycle, 0 completions in 7 minutes.
SIBLINGS SWEPT ON THE READING-MOMENT AXIS, before fixing my instance. Terms
gated `running_bs > 0` fail SAFE (a manufactured 0 makes them not fire). The
dangerous ones are those that fire BECAUSE it is 0, and there are five:
demand_prefill_tokens (mine), the idle determination, the starved dwell-bypass,
and both flip-threshold shortcuts. All five now read ONE authority,
`decode_work_bs()` = running_bs + retracted-but-unfinished.
THE DISCRIMINATOR IS OUTPUT TOKENS, and it is what separates the three metal
specimens a fix here must satisfy at once:
d2 wedge 7 queued, none ever started -> decode_work 0 -> demand FIRES
d3 pingpong 2 genuinely decoding -> decode_work 2 -> demand SILENT
d4 thrash 7 retracted at n=2..13 -> decode_work 7 -> demand SILENT
Per-rid evidence they are mid-flight and not restarts: rid be636087 read
n=2,3,4,...,13 across epochs, strictly increasing (sgl-project#775 refuted).
COMPLETION-PROGRESS CLOCK (sgl-project#699 extension). Thrash is neither wedge nor
progress: ADMISSION-WEDGE measures first-token age and first tokens DID arrive;
liveness measures progress and decode_steps DID advance; health returns 200.
Nothing measured completions per unit time. thrash_verdict() fires on
decode-advancing + completions-flat + work-pending + not-inhibited. SIX PINS,
both directions: fires on the d4 shape, silent when completions advance, when
no work is pending, when nothing decodes (that is a wedge, another rung), while
a flip pause is claimed, and below the sample floor.
STALE-GATE BLIND FALSE POSITIVE, mine: 24 firings on a HEALTHY boot devalue the
alarm into noise. The CONDITION was wrong, not just the threshold -- a cutover
legitimately checks nothing when no device-tier I/O was queued (W37-D read
checked=0 on 24 cutovers and 2/3/8 on twelve others, one healthy boot). Now
gated on the controller actually having traffic in flight, threshold 2 -> 4.
HARNESS INDIKATOR: the load driver reported spec_accept_length=None for three
windows because it read /v1/chat/completions, which carries no meta_info at
all. The server knew the number the whole time (measured 1.9184 by hand).
Driver routed to native /generate and now records accept_length, accept_rate,
verify_ct and cached_tokens. Fix the driver, not the field.
sgl-project#859 CUT 2 -- DISCOVERY-DIFF, DEFAULT-INVERTED. Cut 1 validates declarations
somebody remembered to write and cannot find an omission. Cut 2 discovers what
the cutover ASSIGNS (ast over its own source, incl. setattr) and fails on
anything unaccounted for; undeclared IS the failure. The reading-moment axis is
part of the declaration now: MUTATED_STATE maps each cutover-mutated field to
the window in which reading it is honest, and a test refuses any policy term
firing on a raw `running_bs` zero without a coherent accessor. Two can-fail
pins prove the discovery sees a planted assignment and a planted setattr.
Gate: 8 failed / 4291 passed / 2 skipped / 356 subtests in 720.79s, failure set
BYTE-IDENTICAL to the known 8 by name, zero unexpected. ruff: zero delta on
every touched file.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 25, 2026
…ark transport batches W37-G (boot_w37g_0825_1326.log, pin 0be4ff4) proved the #861j doors open on metal -- SEAM TRANSPORT ADMITTED x3, TP decode formed at bs 5-6 with accept ~2.4-2.7, per-rid tokens strictly rising -- and exposed the next gap: all 27 TP transport batches recomputed cold (#cached-token: 0, the sgl-project#783 dark-radix shape defeating the premise at runtime) while the conformance count stayed 0, because layout_conformance.work_layout_verdict -- built after W37-D's 258 identical batches -- had ZERO callers. Desk-written- never-executed, in the instrument meant to falsify exactly this shape. * metrics_reporter: _note_work_layout wired into report_prefill_stats before the logging-rank gate (counters are rank-local); phase from the same authority as the phase label, strict from purity_of, fully try/except'd. Decode side deliberately not wired -- named in the docstring, not omitted silently. * scheduler: the admission that rides the exemption stamps batch.is_seam_transport from the same transport_only local that spends the seam stamps, so the claim cannot drift from the admission. * layout_conformance: the restore excuse is now cached_tokens > 0 (was AND new_tokens <= 0, which would have flagged every legitimate read-through -- a real restore still computes >=1 token per request). The defect signature is cached == 0, W37-D and W37-G both. Red-proven in a temp worktree at HEAD: the cold-transport batch through the REAL report_prefill_stats counts 0 ("the detector for exactly this shape has no caller") and the build-site pin finds no transport mark; green on this tree. Can-fails: genuine partial restore stays silent, ordinary prefill-in-tp still flags, prefill-in-pp never flags. Tests: test_tp_decode_formation_861j.py 13/13 (dark-radix arm added), scoped impact 130/130 (conformance/economy/band/forward-pass/exemption/ servability), ruff delta 0, codespell delta 0. Full serial managers battery: 8 failed / 4320 passed / 2 skipped / 356 subtests in 722.41s (/tmp/861k_gate2.log), cards VISIBLE -- the Tier-2 managers gate is not hermetic and CVD="" flips its verdict in both directions. Failure set identical BY NAME to the standing 8: staging_reserve_631 x4, rank_prefill_log::TestCollectiveClock x1, hisparse_unit x2, draft_cuda_graph_removal x1. Unexpected names: none. WURZEL. Klasse: desk-written-never-executed -- an instrument built, unit- tested against hand-made inputs, and never wired to the path it judges, so it reports green by never running; test-only coverage is what HIDES it. Geschwister, swept tree-wide by AST over python/sglang/srt (143 instrument- shaped defs, references counted outside the def line), sweep validated in both directions (it lists work_layout_verdict with metrics_reporter.py masked and goes silent with it wired): 10 members with zero production callers. Three are load-bearing and all in managers -- * progress_liveness.py: the WHOLE sgl-project#699 module has zero production importers (only its test file), including thrash_verdict (#861e), which has exactly one reference repo-wide, its own def line, and no test at all. That is the detector for "decode advances, completions do not" -- the W37-D/W37-G shape and the sgl-project#857 acceptance discriminator. * corridor_guard.phase_corridor_verdict (sgl-project#784): 7 test call sites, zero production callers; the constants are imported widely, the verdict is not. Zukunfts-Check: OWED and specified, not built here -- the sweep becomes a registered test that fails when an instrument-shaped def has no production caller, with an allowlist carrying an owner and a reason per dark entry. Filed as #861l so this commit stays the wiring change. Full list and file:lines in /spinning/gpu-arb/NOTE_861fg.md.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Aug 25, 2026
…ument surface
#861k wired one dark instrument. This closes its CLASS.
THE ROOT IS NOT "no check existed". test/registered/unit/test_unwired_features_421.py
already carries both the doctrine ("a reachability assertion is the only kind
of test that can see the gap between 'the unit works' and 'the product uses
it'") and the AST machinery. Its hole is its SHAPE: it is ENUMERATIVE -- one
hand-written pin per feature that the sgl-project#421 audit had already found. Every
instrument built after that audit is outside its reach BY CONSTRUCTION, which
is exactly how four of them went dark under a fully green suite:
work_layout_verdict (#861k), thrash_verdict (#861e), phase_corridor_verdict
(sgl-project#784), and the whole progress_liveness module (sgl-project#699).
This adds the EXHAUSTIVE complement: one AST pass over python/sglang, every
instrument-shaped def (147 of them), dark = the name appears nowhere in
production outside its own def line. The dark set must EQUAL a declared
allowlist, so a newly-dark instrument fails a gate run instead of waiting for
a metal boot to not-report something. Both files stay: sgl-project#421 pins named
absences with per-feature reasoning, this pins the membership of the set.
12 declared entries, each with a reason that must open with DARK (the class,
with a named owner) or EXEMPT (not an instrument) -- itself asserted. Three
EXEMPT (an upstream fp8 debug helper; two offline GGUF audit entry points,
one of which names its test caller in its own docstring). Nine DARK, filed
with owners, the two load-bearing ones being:
* progress_liveness.thrash_verdict (#861e) -- before this gate it had ONE
reference repo-wide, its own def line, and no test either. Its docstring
describes W37-D verbatim ("decode_steps STRICTLY INCREASING, completions
FLAT"), i.e. the W37-G shape and the sgl-project#857 acceptance discriminator. Its
whole module is dark with it: nothing in production imports
sglang.srt.managers.progress_liveness, so sgl-project#699's assess(),
sample_from_scheduler() and build_liveness_is_active() are dark too --
the module written because "/health answers is the process up, not is
work moving" and "the watchdog is blind to admission wedges BY
CONSTRUCTION" was never installed. The job is today done out-of-process
by serving-liveness-monitor.sh: one payload, two movers, the in-process
one inert. Reconciliation owed with the wiring.
* corridor_guard.phase_corridor_verdict (sgl-project#784) -- 7 test call sites, zero
production callers. The module's CONSTANTS are imported in four places,
which is what makes it read as live; its verdict is computed by nobody.
THE GATE WAS TESTED AGAINST A KNOWN STATE IN BOTH DIRECTIONS BEFORE ITS
NUMBERS WERE USED, AND IT FAILED THE FIRST TIME. Indexing only ast.Name and
ast.Attribute, it called three LIVE checkers dark --
Scheduler._check_layout_policy_conformance, _check_layout_conformance and
PhaseFlipRuntime._census_ownership_audit -- all three reached through this
tree's deliberate getattr(self, "<name>", fallback)(...) idiom, where the
callee name exists only as a string literal. A gate that accuses live code is
worse than no gate. String constants now count as references, and the idiom
is pinned by a synthetic dispatch case so the defect cannot return.
Direction check: the sweep lists work_layout_verdict with metrics_reporter.py
masked and goes silent with it wired -- delta exactly one name.
Can-fail proofs are executable, not prose: four synthetic-tree cases (unwired
reported / wired silent / same-module caller counts as wired / string
dispatch counts as wired) plus a guard-the-guard assertion that the walk
found >100 instruments at all. The gate also fired unprompted on its first
real run, on jit_kernel/tests/kv_canary/_invariants.py::assert_all -- fixed
in the PATH filter ("/tests/", which the sgl-project#421 helper's "/test/" walks past)
rather than by an allowlist entry, because that file is not production source
and allowlisting it would have recorded a fiction.
Tests: 8/8 new, plus test_unwired_features_421.py 6/6 unaffected (14 passed
in 89.9s). No production file touched, so the #861k managers battery
(8 failed / 4320 passed, standing set by name) still stands. ruff, codespell,
black, isort: clean.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Sep 26, 2026
…switch SGLANG_WEG2_TOLD_PACED, default off) Risk named by PX (4d216bb makes told > 0 again, first time since 16.09.): a follower registers its read of the told span when the told arrives and busy-waits for it in admission (weg2_store_told.admission, sleep(0.002) up to WAIT_CAP_S=60 s) -- in the scheduler thread, so the whole stage stops, every other request in pipeline flight with it (user order 24.09.: HiCache never slows a running prefill/decode). A follower cannot defer alone: on the carrierless form the told arrival IS the membership signal (rank-local planning), a follower skip is the W27 width split. A group-wide told=0 fallback would have to be PP0's decision on the followers' read state, and no follower->PP0 channel is live on this form (sgl-project#1175's return trip has no caller, the output ring runs only on passes with a batch, the sgl-project#1268 home hop belongs to the idle vote). Paced form, PP0-authoritative and wireless: Weg2StoreTold(paced=True) is a READ-AHEAD (followers register now, nobody admits); Weg2StoreAdmit follows once PP0's window has passed -- PP0 admits in that pass, followers in the pass that absorbs it (single-phase lag unchanged). While the window runs PP0 skips the rid (weg2_store_told_pending) and admits everything behind it. Window = min(cap, max(1.25 x PP0 own read, told x 1 s/100k)); cap 10 s, below the sgl-project#699 admission-wedge 20 s. Told 0 stays single-phase. Followers follow the object flag, never their own env. Residual: a follower slower than the window takes the unchanged bounded wait (named WAIT EXCEEDED). Off: byte-identical (pp0_publish/absorb/intake paths unchanged). Tests: test_weg2_store_told_paced_1416e.py 9 new (simulated PP3 ring with the plan lag: request B behind a told>0 request A is admitted on all ranks while A's followers read, zero sleep on every stage, A on every rank for the same PP0 pass with the same cap; off-form characterised: followers sleep ~their read; cap is the deadline; residual + named refusal; abort in the window; followers ignore their env; Admit before the request). Mutant "window ignored" -> 3 failed. Affected files (told_1400, paced_1416e, prefetch_deferral_1068, intake_stall_xsn272, p_intake_h91a): 87 passed (test27b.sh, incg queue, CUDA_VISIBLE_DEVICES=""). UNIFY (UN6, Operator 26.09.): pick of desk/27b-pprefix2-0926 (d4d7cf5, PX2) after MZ, clean. dup_defs_gate: 0 new. test27b.sh: store_told_paced_1416e 9 passed; store_told_1400 + prefetch_deferral_1068 + admission_intake_713 + unify_s5_intake_once + intake_stall xsn272/xsn288 + p_intake_h91a: 32 failed / 75 passed -- the SAME 32 failures on df82145 (pre-pick archive, 32 failed / 66 passed): prefetch_deferral_1068 31x "retry() exceed maximum number of retries", xsn288 test_abort_forgets_and_wake_resets_source_ratchet. No new red.
efschu
pushed a commit
to efschu/htsglang
that referenced
this pull request
Sep 26, 2026
…follower read acks, told=0 for every rank at the Frist (SGLANG_WEG2_TOLD_GROUP_FALLBACK, default off) A follower slower than the #1416e pacing window fell into the admission busy-wait (stage stopped) and then "sgl-project#1400 STORE-TOLD WAIT EXCEEDED" (group death); a short read died as "STORE-TOLD MISMATCH". A follower may not skip alone (W27 width split), so PP0 needs the followers' read state. Channel: follower -> PP0 Weg2ToldReadAck(rank, seq, reads=[(rid, own_prefix)]) on its own gloo tag 1416 (world cpu group, size-then-payload like the sgl-project#1268 home hop). PP0 keeps one standing ObjectRecvFrame per follower driven by the new ObjectRecvFrame.poll() (completion-flag read, no join, no WARNING per expiry); the follower's isends are parked (ParkedWait), one message in flight, completion read as a flag -- nothing blocks a pass. A half-posted frame marks the stream dead (PP0's Frist then decides). PP0 verdict per paced rid: all acks == told -> Admit(told) at once (before the window); any ack != told -> Admit(0); Frist passed -> Admit(0). Frist = min(window + 2 s, 12 s) from the read-ahead, never later than intake + 16 s (sgl-project#699 wedge = 20 s); SGLANG_WEG2_TOLD_FALLBACK_{GRACE,CAP,TOTAL}_S. Admit(0) carries the instance attr fallback=1; PP0 and every follower cut their read via tree.release_aborted_request (rows + mamba pools back through the host release queue -> arena reader refs returned by _free_arena_rows), drop records, span pin and twin mark; all admit at told=0 with cap 0. Wire off = byte-identical: the markers (ack on the paced read-ahead, fallback on the Admit) are instance attributes set only on the armed path; followers follow the wire, never their env. Effective only with SGLANG_WEG2_TOLD_PACED. Under the switch a parked rid (TK path 4) keeps its paced entry until re-queued instead of being dropped. Tests (test27b.sh, CUDA_VISIBLE_DEVICES=""): - test_weg2_told_group_fallback_pf.py 18 passed: ring (slow follower -> told 0 everywhere, same pass, no sleep, ledger op_refs 0; fast acks -> told before the window; declined read -> told 0 at once; absolute/twin; parked; abort; Frist values; follower never alone; wire-not-env), golden digest of the switch-off behaviour == pre-PF head 2bddf04 (unset and "0"), ObjectRecvFrame.poll quiet/non-blocking, channel error paths, hermetic 3-process real-gloo run (slow PP2 -> told 0 on all three, fast rid admitted on real gloo acks, op_refs 0, no admission sleep, publish <= 250 ms) and the switch-off gloo run (WAIT EXCEEDED, no fallback state). - gate: told 1400/hold_tk/paced_1416e/positive_tk, twin_defer, p_intake_h91a, 968, idle vote 1268 x3, orphan_prefetch_1272, pp_chain_receiver, prefetch_deferral_1068 + new file: 241 passed. - mutants_pf_told_fallback.sh: 14/14 killed.
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.
Thank you for your contribution, we really appreciate it. The following instructions will help improve your pull request and make it easier to receive feedback. If there are any items you don't understand, don't worry. Just submit the pull request and ask the maintainers for help.
Motivation
I want to support this OpenAI batch API functionally OpenAI Batch API Doc .
Running example
In this PR, we can support SGlang backend running behind the example code provided by OpenAI in the provided link seamlessly.
The frontend code is
and the return result is
Notes
Here we can also support text completion; this feature(Batch API) can work together with parallel sampling.
Beyond adding Batch API, we can further reorder/reschedule the request in the file to do further
The basic design now is that the output line order may not match the input line order. we can use the custom_id field which will be present in each line of the output file, and allow map requests in input to results in output.
Modification
cc @merrymercy @Ying1123 @hnyls2002 for CR
Checklist
pre-commit run --all-filesor other linting tools are used to fix potential lint issues.