Skip to content

[Perf] scheduler: Plan hybrid Mamba extend batches without host-device syncs - #45472

Merged
hanming-lu merged 1 commit into
mainfrom
oss-sync-f52cabc470
Oct 21, 2026
Merged

hanming-lu merged 1 commit into
mainfrom
oss-sync-f52cabc470

Conversation

@metamergebot

@metamergebot metamergebot commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

With the overlap scheduler, every implicit host-device sync in extend planning waits for the forward that is already running, so the scheduler cannot get ahead of the GPU. On hybrid Mamba models with --mamba-radix-cache-strategy extra_buffer or extra_buffer_lazy, planning one extend batch synced several times per batch and once more per request. Counted with torch.cuda.set_sync_debug_mode on the extend scheduling path:

  • HybridReqToTokenPool.alloc indexed two device mappings with a Python list (a pageable copy each).
  • _mamba_radix_cache_v2_req_prepare_for_extend read each request's ping-pong slot id with .item(), and prepare_for_extend then copied the ids, mask and seqlens back to the device from pageable memory.
  • The lazy strategy's "is the other ping-pong entry free" checks, the ping-pong frees (free_mamba_cache, streaming-session release) and kv_mamba_slots all read -1 flags off the device buffer.
  • Clearing a ping-pong entry assigned the Python int -1 into a CUDA tensor, a pageable copy that blocks the host until the stream drains.
  • MambaPool.clear_slots and the ReplaySSM fresh-row reset wrote zeros through list or expanded-tensor indexing.
  • _get_multimodal_mask used torch.isin, which switches to a unique()-based path (and syncs on its count) once there are enough placeholders.

#43637 removes two of these sites (the list index in alloc and the device-side track indices in prepare_for_extend) by keeping per-request device views; this PR covers the same two sites with a single gather from the pool mapping, plus the remaining ones above, so the two overlap on those hunks.

Modifications

  • ReqKvInfo.mamba_ping_pong_empty mirrors on the host which entries of the ping-pong buffer hold no slot. _alloc_ping_pong_buffer sets it with the buffer, set_mamba_ping_pong_slot flips it on every write, and every reader of buf != -1 (lazy prepare in schedule_batch.py, the batch result processor, free_mamba_cache, StreamingSession release, kv_mamba_slots) reads the flags instead. free_mamba_cache frees every surviving entry by position, with no device mask. The MLX auxiliary-state pool and model runner set and clear the flags with the buffer like the CUDA pool.
  • prepare_for_extend records each request's track position (_MambaRadixCacheV2TrackEntry.track_position) and gathers the slot ids on the device from req_index_to_mamba_ping_pong_track_buffer_mapping with one advanced index (_gather_mamba_track_indices); set_mamba_track_indices_from_reqs uses the same gather. Track positions, mask and seqlens are staged pinned and copied non_blocking.
  • HybridReqToTokenPool.alloc writes its two mappings through a device row index (async_h2d); ReplaySSM fresh rows reset through index_fill_; MambaPool.clear_slots zeroes with index_fill_ on every branch, the fused conv kernel staying the fast path; set_mamba_ping_pong_slot clears an entry with fill_(-1).
  • UnifiedMambaPool sets replayssm_spec_write_pos like MambaPool, so alloc() reads it as a plain attribute instead of getattr.
  • embed_mm_inputs sorts the placeholder ids once on the host and _get_multimodal_mask looks them up with searchsorted; an empty placeholder tensor is an assertion.

Behaviour is unchanged: the same slots are tracked, freed and cleared; only where the bookkeeping is read and how the writes reach the device change.

Tests

New and updated unit tests (all CPU, base-a-test-cpu):

  • test_mm_chunked_embedding_unit.py: the searchsorted mask equals the broadcast compare and torch.isin on host-sorted placeholders, including a repeated placeholder and int32 ids, at sizes on both sides of torch.isin's sort threshold.
  • test_unified_tri_pool.py: over a CPU unified pool, the mapping rows equal the request buffers after alloc(), donate and set, and the device gather equals the per-request .item() reads it replaces; the hand-built kv fixture sets the flags with the buffer.
  • test_mamba_checkpoint_depth.py: the track position is taken before the ping-pong swap, for both starting positions.
  • test_batch_result_processor_mamba_boundary.py: calls the production set_mamba_track_indices_from_reqs with no pinning shim; the boundary fixture sets the flags.

Run locally on CPU: the four files above plus test_mamba_capacity.py, test_batch_result_processor_spec_grammar.py, test_mamba_unittest.py and test_unified_radix_cache_core.py (the other callers that build ping-pong fixtures) pass.


CI States

Latest PR Test (Base): ✅ Run #39535630535
Latest PR Test (Extra): ❌ Run #39535630343
Latest PR Test (AMD ROCm 10): ❌ Run #39535630284

…e syncs

With the overlap scheduler every implicit host-device sync in extend planning
waits for the running forward, so the scheduler cannot get ahead of the GPU.
On hybrid Mamba models with the extra_buffer / extra_buffer_lazy radix cache
strategy, planning one extend batch synced several times per batch and once
per request:

- HybridReqToTokenPool.alloc indexed two device mappings with a Python list.
- _mamba_radix_cache_v2_req_prepare_for_extend read each request's ping-pong
  slot id with .item(); prepare_for_extend then copied the ids, mask and
  seqlens back to the device from pageable memory.
- The lazy strategy's "is the other ping-pong entry free" checks, the
  ping-pong frees and the pool-stats slot count all read -1 flags off the
  device buffer.
- Clearing a ping-pong entry assigned the Python int -1 into a CUDA tensor,
  a pageable copy that blocks the host until the stream drains.
- MambaPool.clear_slots and the ReplaySSM fresh-row reset wrote zeros through
  list or expanded-tensor indexing.
- _get_multimodal_mask used torch.isin, which switches to a unique()-based
  path (and syncs on its count) once there are enough placeholders.

Changes:

- ReqKvInfo.mamba_ping_pong_empty mirrors on the host which entries of the
  ping-pong buffer hold no slot. _alloc_ping_pong_buffer sets it with the
  buffer, set_mamba_ping_pong_slot flips it on every write, and every reader
  of `buf != -1` (lazy prepare, batch result processor, free_mamba_cache,
  streaming-session release, kv_mamba_slots) reads the flags instead.
  free_mamba_cache frees every surviving entry by position, with no device
  mask.
- prepare_for_extend records each request's track position and gathers the
  slot ids on the device from the ping-pong mapping with one advanced index
  (_gather_mamba_track_indices); set_mamba_track_indices_from_reqs uses the
  same gather. Track positions, mask and seqlens are staged pinned and copied
  non_blocking.
- HybridReqToTokenPool.alloc writes its mappings through a device row index
  (async_h2d); ReplaySSM fresh rows reset through index_fill_;
  MambaPool.clear_slots zeroes with index_fill_ on every branch, the fused
  conv kernel staying the fast path; set_mamba_ping_pong_slot clears an entry
  with fill_(-1).
- UnifiedMambaPool sets replayssm_spec_write_pos like MambaPool, so alloc()
  reads it as a plain attribute instead of getattr.
- embed_mm_inputs sorts the placeholder ids once on the host and
  _get_multimodal_mask looks them up with searchsorted.

Tests: the mask equals the broadcast compare and torch.isin; the device
gather equals the per-request reads over a CPU unified pool whose mapping
rows are checked against the request buffers after alloc, donate and set;
the track position is taken before the ping-pong swap; the boundary test
calls the production set_mamba_track_indices_from_reqs without a pinning
shim; the hand-built kv fixtures set the flags with the buffer.

Co-authored-by: Shiyan Deng <[email protected]>
@metamergebot

Copy link
Copy Markdown
Collaborator Author

This port clears our bar on c425f16f3a4d3a0b936c3dd0fc761918799bf166: every base-a and base-b job is green.
base-c and the accelerator suites are reported but not gated, because they run
on scarce hardware and upstream merges through them routinely.

gate✓ lint✓ build✓ A✓ B✓ C 8✓✗1⏳1 other✓ · accel ✗amd,npu

@luccafong @merrymercy @842974287 — could one of you take a look and merge it if you are happy? Nothing else is waiting on our side.

@hanming-lu
hanming-lu merged commit 740d5f9 into main Oct 21, 2026
330 of 346 checks passed
@hanming-lu
hanming-lu deleted the oss-sync-f52cabc470 branch October 21, 2026 18:56
detain pushed a commit to detain/sglang that referenced this pull request Oct 29, 2026
…nked prefill (sgl-project#45435)

(cherry picked from commit 32c2678)

SUPERSEDES our entry-119 production half (0fe3740, adapted from the
never-merged sgl-project#39526 head). Where the two collided we took the UPSTREAM
form per the sync-by-port ledger rule:

- mix_with_running: our _mamba_track_for_mixed helper rebuilt the decode
  tails' mamba_track_indices from the reqs (real slot ids, mask False).
  Upstream instead pads the tails with -1 and, on extra_buffer_lazy,
  calls running_batch.mamba_lazy_undo_prealloc_at_boundary() BEFORE the
  merge: a decode batch whose boundary step rode a mixed forward gives
  the freshly prealloc'd slot back (the mixed step writes no decode
  checkpoint and its result path never frees it -- entry 119 leaked the
  slot). New ReqKvInfo.mamba_untracked_decode_batch_idx + the
  batch_result_processor gate keep the finish-path radix insert alive
  for exactly that batch. Helper and its _mamba_track_for_mixed caller
  deleted as dead code.
- entry-119's split of set_mamba_track_indices_from_reqs into
  mamba_track_indices_from_reqs stays ONLY because its freed_rows guard
  is in upstream's shape too; the next pick (sgl-project#45472) rewrites that
  function and will resolve it there.
- OUR test_schedule_batch_mixed_mamba_track.py (entry-222's 7-case
  port of sgl-project#39526-head expectations): the two cases that pinned the
  superseded tail semantics were retargeted to the merged form
  (tail index -1; lazy tail gives the boundary slot back, flips
  next_track_idx to the empty entry, and records
  mamba_untracked_decode_batch_idx). Other five cases unchanged.
- sgl-project#45435's own new test file applies clean: 6P/2sub on this tree.
- test_schedule_batch_out_of_place.py get_exec stub applied clean.

Batteries CVD=9: spec dir 335P/11S/180sub (2 new S = sgl-project#45491's
skipUnless class), mamba_donated 16P/14sub, track_state_dtype 8P/9sub,
mixed_mamba_track 7P, out_of_place+brp_boundary trio green; sgl-project#45435 new
file 6P/2sub.

(cherry picked from commit fe3a1218147ccdc10fd185d8937422832524a259)
detain pushed a commit to detain/sglang that referenced this pull request Oct 29, 2026
…e syncs (sgl-project#45472)

(cherry picked from commit 740d5f9)

DEFAULT-ON perf: hybrid Mamba extend batching loses its host-device
syncs -- track slot ids are gathered on the device via the new
_gather_mamba_track_indices (mapping[req_pool_indices, positions]) from
the renamed _MambaRadixCacheV2TrackEntry.track_position; prepare_for_extend's
track tensors go through pinned non-blocking copies; the ping-pong
empty-state gets a host mirror ReqKvInfo.mamba_ping_pong_empty consumed by
mamba_lazy_prealloc_at_boundary / mamba_lazy_spec_prepare /
batch_result_processor / pool_stats_observer / streaming_session;
memory_pool clear_slots/alloc row-indexing becomes async_h2d +
index_fill_; set_mamba_ping_pong_slot is polymorphic (tensor fills,
int -1 empties); free path frees by the empty mirror. mm-side:
_get_multimodal_mask switches torch.isin -> searchsorted over the now
sorted placeholder set.

UNIONS / DEVIATIONS vs this tree (every consumer of the changed
_MambaRadixCacheV2TrackEntry contract audited):
- schedule_batch.py conflict: our entry-119 split of
  set_mamba_track_indices_from_reqs into mamba_track_indices_from_reqs
  (returning (positions, indices) for the also-already-superseded
  _mamba_track_for_mixed) is UNDONE here; upstream's single function
  wins, with the entry-168/234-era freed_rows -> -1 guard carried
  forward verbatim (upstream's own version of the guard is identical).
  The is_pin_memory_available pinning delta is subsumed by upstream's
  async_h2d, which applies the same predicate internally. No callers of
  the removed split name remain (spec_utils imports the wrapper).
- mm_utils.py conflict: upstream builds pad_values from
  item.padding_values() -- the plural sentinel-set API is NOT in this
  tree (our MultimodalDataItem.set_pad_value computes a single
  pad_value). Resolved as the UNION: upstream's SORTED invariant
  (required by the searchsorted _get_multimodal_mask in mm_schedule.py)
  over OUR scalar per-item pad_value source. The single caller feeds
  only embed_mm_inputs' tensor, so the sortedness contract is closed.
- test_mamba_donated_alloc_ratio.py (our entries 197/216): the
  kv=SimpleNamespace stub gains mamba_ping_pong_empty=[False, True]
  mirroring its [0, -1] buffer -- the contract change's required test
  adaptation (16P/14sub pin restored, red at pre-adoption proof).
- unified_memory_pool.py: replayssm_spec_write_pos=None added at the
  line our UnifiedMambaPool.__init__ drifts it (was getattr-defensive;
  the direct attribute read is safe: MambaPool always defines it).
- Upstream's own transient survives: sgl-project#45435's
  test_mix_with_running_mamba_track.py still reads e.track_index and
  is red AT THIS COMMIT exactly as upstream shipped it 10-21 morning;
  the adjacent next commit (sgl-project#45670, upstream 68623ca) retargets it
  to track_position + _gather_mamba_track_indices and restores green.

Batteries CVD=9 (post-sgl-project#45670 final tree): spec dir 335P/11S/180sub,
mamba_donated 16P/14sub, track_state_dtype 8P/9sub,
mixed_mamba_track 7P; managers dir sweep 995P/3S/908sub with the
pre-existing base test_mm_process_config single-process contamination
pair unchanged; mem_cache dir +1P/+2sub (upstream's new
test_unified_tri_pool cases), attention dir byte-identical vs base.

(cherry picked from commit ce3d32122d044e1a893d8d03bc72aea1e790103b)
detain added a commit to detain/sglang that referenced this pull request Oct 29, 2026
…gl-project#45472/sgl-project#45670 from port-spec-mamba-merged (entries 261-264)

ONE docs commit for the four picks per the mandated interlock (the tree is
shipped-red between sgl-project#45472 and sgl-project#45670 -- entry-119 SUPERSESSION and the
DEFAULT-ON sgl-project#45472 hot-path change are recorded across 262/263 as one unit).

Mandated records in the entries: entry-119 superseded by upstream sgl-project#45435/
sgl-project#45472 (freed_rows guard + pin-memory predicate carried forward; the
59MB-slot leak is what the new lazy-undo gives back; 59MB-slot context
unchanged); sgl-project#45472 default-ON on the mixed-chunk hot path -> TTFT/decode
measure + per-round admission interplay owed at restart (entry-198
precedent); GPU-debt: mixed-chunk mamba checkpoint e2e at real page-64,
track-state numerics parity vs pre-port.

Battery at tip afc7dca (all EXACT vs worker predictions): spec dir
335P/11S/180sub; mamba_donated 16P/14sub; track_state_dtype 8P/9sub;
mixed_mamba_track 7P; new spec test file collects 2 (GPU-gated); managers
dir re-pinned 995P/2F/3S/908sub (base 988P/2F/3S/904sub; the 2F are the
pre-existing order-dependent test_mm_process_config pair, reproduced at
base).
detain added a commit to detain/sglang that referenced this pull request Oct 29, 2026
…k-274, wanted_stack LANDED marks, CAVEATS docs-only ledger items

(A) Header: STACK line 260->274; three wave lines (+spec-mamba-2026-10-28
(pr45491+pr45435+pr45472+pr45670), +admission-2026-10-28(pr46272*+
pr43484*+pr46496*+pr46643*+pr45607*+pr45789*), +parsers-2026-10-28
(pr44124+pr45631+pr45855+pr46167)); tip line -> 2714457; updated
261-274 headline block (entry-119 SUPERSEDED by upstream sgl-project#45435/sgl-project#45472;
classic-pool mamba admission gate w/ upstream ImportError CAUGHT;
UNCONDITIONAL latch reset = TTFT watch; coder-parser union; logits
trilogy as CONTRACT UNIT; 14 picks, 0 integrator conflicts).

(B) wanted_stack.txt: FAM-A5 + FAM-B234 blocks deleted -> LANDED records
(chain shas, interlock audit, supersession + behavior-change pointers
into entries 261-270); SECTION-B sgl-project#44124/trilogy blocks -> LANDED;
sgl-project#37958/sgl-project#45559 block -> DONE (verdict now in CAVEATS).

(C) DOCS-ONLY LEDGER ITEMS: CAVEATS gains the sgl-project#37958/sgl-project#45559 VERIFIED-
INERT bullet (two independent hard gates, coarse-barrier fallback,
do-not-re-litigate-at-merge-sgl-project#5 line, revisit condition = dropping NEXTN
or HiCache) and the dated C0b/C0c corrections (sgl-project#44030 obsolete rationale,
sgl-project#44858 REVERSED by sgl-project#45289 [ported-pending wt-moe], sgl-project#44115 permanent N/A,
10-28 open-status re-verification list, no-pin-moves note: 0.7.2/0.4.9
floor unchanged) with the C0a tick (sgl-project#37625/sgl-project#37941/sgl-project#39727 still
outstanding; only sgl-project#43927/sgl-project#44849 partially satisfied). C0b/C0c/C8 marked
DONE in wanted_stack; C0a stays open.
detain added a commit to detain/sglang that referenced this pull request Oct 30, 2026
…entries 122,198,200,211,215,220,267,268,305

Re-plants the scheduler.py fork-hunks (replant/...managers__scheduler.py.fork-hunks.patch)
onto the post-sgl-project#46977 admission structure. tp_worker marker consumed (15/23 B4 markers
still on the tree; per-file counts, damage-state from entry 310's map).

PER-HUNK DECISIONS (all VERIFIED against the merged tree, not taken on faith):
- entry 122 (sgl-project#40458): grammar-sync overlap disable RE-PLANTED for mixed mode
  (is_decode() OR is_mixed()) + the fork's trimmed comments; upstream's
  host-draft-only arm was the pre-sgl-project#40458 form (origin/main verified: absent).
- entry 220 (sgl-project#39765, OPEN port): _has_pending_mamba_cache_update + the early
  pop_and_process/short-circuited disable-overlap RE-PLANTED into
  event_loop_overlap; the require_mlp_sync/disable/extra-buffer gate verbatim.
- entry 198 (sgl-project#37612): THE CATCHER — B3-5 landed the raiser; the
  try/except MambaCowAllocError around init_next_round_input (res=NO_TOKEN,
  request stays queued; the revert block + unconditional alloc_group_end were
  already in the merged tree = the no-leak halves VERIFIED PRESENT) RE-PLANTED
  with the import. COW component test re-anchored to the #46970x kv_storage
  seam the B3-5 replant moved _state() behind (stub was the pre-split
  mamba_allocator shape).
- entry 268 (sgl-project#46643, OPEN port -- VERIFIED NEVER MERGED: git log
  12dc623..2a6c204 --grep 46643 = ZERO; only sgl-project#45491/sgl-project#45435/sgl-project#45472/sgl-project#45670
  of the briefed merged-list arrived in-range): the UNCONDITIONAL batch_is_full
  clear RE-PLANTED on the scheduler side, subsuming the entry-198 hybrid-SSM
  arm and the priority-preemption/is_empty arms (policy side lands in B4-3).
- entry 267 (sgl-project#46496): retract_decode new_token_ratio FLOOR clamp RE-PLANTED.
- entry 211: triton_load_watch.prewarm_device_loads(self.model_worker) line
  RE-PLANTED between install() and mark_serving_started (the utils-side
  function survived the merge; only the call site was dropped).
- entry 200 (sgl-project#43527) CAPACITY PAIR RE-PLANTED: model_runner
  .logical_max_total_num_tokens passes allocator= again (the configurator's
  PageInterleavePoolAllocator -> allocator.size branch SURVIVED the merge
  byte-identical, so the merged tree had the fork predicate with upstream's
  consumer-side multiplications = DOUBLE-COUNT); the three scheduler
  * kv_shard_widening multipliers back to the fork form (pool-stats shape,
  load_inquirer, and the init_req one-page-per-shard subtraction);
  tp_worker drops page_interleave_shard_size x + import. Upstream's
  invariant-checker hunk: OBSOLETE (the constructor no longer takes
  max_total_num_tokens -- absorbed by refactor).
- entry 215 (sgl-project#44351/sgl-project#44401/sgl-project#44420): VERIFIED ALREADY PRESENT at the merge
  (filter_batch-every-step + reset ride, num_held_rows, budget_state FIRST
  statement, PD-gate deletion all byte-compare to the fork form) -- DEDUPED,
  no edit. Entry 107's local early-revision of sgl-project#40940 stays superseded
  (entry 215 rule), and its re-plant here would double-count.
- entry 220's/305's pause-window busy accounting + write_fence_stream +
  is_empty arm: VERIFIED PRESENT (entry 305 landed patch-identical via
  sgl-project#46127; the fence assignment is the B3-2 controller half) -- DEDUPED.

TEST FIXTURE RE-ANCHORS (not B2's: no markers, pure new-upstream-contract
drift, per the entry-198 fixture-adaptation precedent): the two hybrid-ssm
admission stubs gain disagg_prefill_bootstrap_queue=None (upstream's
routing-key bootstrap_queue arg in calc_priority arrived in-range).

PRUNE vs BREAKAGE (managers −523sub audit): the three managers test files
vanished in-range (test_schedule_policy_dfs_weight, test_scheduler_batch_is
_full_latch, test_uno_token_accounting) were ALL deleted by upstream's OWN
sgl-project#45672 prune (3438ed6). Two are byte-identical upstream copies = zero
fork delta. The third carried a 3-line fork comment/stub delta whose
SEMANTICS the re-planted unconditional clear pins: its case was the
is_empty-arm mirror of test_scheduler_hybrid_ssm_admission_latch (present,
green, hybrid_swa/non-hybrid arms included) -- NOT re-homed, recorded.

ACTUALS (damage -> after, CVD=9, prod venv, PYTHONPATH=python, per-file):
  test_scheduler_hybrid_ssm_admission_retry   4F -> ** 4P **
  test_scheduler_hybrid_ssm_admission_latch   3F -> ** 4P **
  test_mamba_prefill_cache_boundary  2F/12subF -> ** 5P/12sub EXACT (220 pin) **
  test_scheduler_retract_ratio                1F -> ** 2P EXACT (267 pin) **
  test_scheduler_init_req_max_new_tokens      1F -> ** 10P/6sub **
  test_scheduler_grammar_mixed_tail_sync      1F -> ** 4P **
  adjacent scheduler-stub files (held_row, running_batch_finished,
  pause_generation, disagg_idle, dp_converted, hicache_events) 56P/64sub
  UNMOVED -- no regression from the clear/catcher/capacity edits.
Lint: ruff format + F821/E9 clean on all five files; imports OK (no GPU
execution, no push).

Co-Authored-By: OpenCode <[email protected]>
detain added a commit to detain/sglang that referenced this pull request Oct 30, 2026
…s 94,95,119,122,169,215,262,263,265 (re-plant + verified-absorbed)

3 markers consumed (batch B4 total now 23-1-3=19; briefing's '20' was the
session-1 census -- true tree count is 23, per the B3 census lesson).

RE-PLANTED (batch_result_processor.py, from its fork-hunks patch):
- _logprob_rows_to_host tensor-or-placeholder converter + 3 call sites
  (the mixed-batch per-row mixed-type class; damage: 3F).
- Entry 265 (sgl-project#46272, OPEN port -- VERIFIED NOT MERGED in-range): the
  decoding_req_ids lazy {id(r)} set replacing the three O(B) 'req in
  batch.decoding_reqs' scans in the prefill-result loop. The entry-265
  interlock holds: the re-planted set feeds the SAME branch that
  mamba_untracked_decode_batch_idx gates, and that gate landed byte-
  present upstream via sgl-project#45435 (schedule_batch x3 + brp x1 references
  audited) -- the byte-count invariant of the merge point is preserved.

VERIFIED-ABSORBED (markers consumed, NO edits -- the merged tree already
carries the semantics, hunk-a-hunk against the 309-tip):
- schedule_batch.py (no fork-hunks patch existed; tsv DRIVER class was
  TRIAGE-UNION all-mechanical, so the audit was semantic): sgl-project#45435's
  mamba_lazy_undo_prealloc_at_boundary x2, _mamba_track_for_mixed DELETED
  (0 refs) with upstream's -1 tail padding + freed_rows->-1 guard carried
  VERBATIM (entry 263(a)), sgl-project#45472's _gather_mamba_track_indices x3 +
  pinned async_h2d track tensors + mamba_ping_pong_empty host mirror x4 +
  the collapsed single set_mamba_track_indices_from_reqs, holds_kv x4
  (sgl-project#44401), untracked_decode_batch_idx x3. Entry 119's supersession by the
  sgl-project#45435 upstream form CONFIRMED (32c2678 in-range per git log
  12dc623..2a6c204 -- this is the merge's own absorption of our
  entry-262 pick).
- mm_utils.py: entry 263(b)'s UNION was superseded IN-RANGE by upstream
  landing the plural padding_values() (pad_values or (pad_value,) --
  exactly the fork's scalar source degenerate case) with the sorted
  invariant; _get_multimodal_mask (mm_schedule.py:655) is the sgl-project#45472
  searchsorted no-sync form fed by that sortedness contract.
- brp's _mamba_can_cache_finished_req gate + mamba_ping_pong_empty mirror
  consumption x2 + the two rich FINISH_ABORT sites + the
  untracked_decode_batch_idx advance gate: PRESENT upstream.

TEST RE-ANCHORS (mixed_mamba_track, contract-driven, per entry 198's
fixture-adaptation precedent; NOT production):
- CacheInitParams tree_components kwarg -> tree_slots_of((FULL, MAMBA))
  (#46970x: slots drive components),
- allocator.state = req_to_token_pool.state -- production's equivalent is
  the configurator's runner_state() bind (kv_cache_configurator:553); a
  manual classic build must bind too or ensure_mamba_capacity (#46970x
  seam) reads state=None (diagnosed: NOT a fork-delta loss, NOT
  upstream-own -- upstream binds in prod; fixture bypass),
- backend._state_ids identity IdSpace stub (runner_ids seam; classic
  pools index slots directly -- matches production for this config).

ACTUALS (damage -> after, CVD=9, prod venv, per-file):
  test_schedule_batch_mixed_mamba_track 7F -> ** 7P EXACT (262 pin) **
  test_batch_result_processor_mixed_token_ids_logprob 3F -> ** 3P **
  brp family (mamba_boundary, spec_grammar) + mix_with_running: 33P/17sub
  GREEN incl. the entry-265 quartet proof.
  DIR: unit/managers 1025P/83F/9S/427sub -> ** 1048P/48F/9S/439sub **
  (remaining 48F = prefill_adder 39F + dcp_logical 7F [both B4-3's pricing
  reconciliation] + the two known order-dependent test_mm_process_config
  F's [env class, reproduce at base]).
Lint: ruff format + F821/E9 clean; 3 EOF-marker artifacts the merge left
(schedule_batch/mm_utils/brp trailing comments) resolved by the marker
removals. No GPU; no push.

Co-Authored-By: OpenCode <[email protected]>
detain added a commit to detain/sglang that referenced this pull request Oct 30, 2026
…46977 pricing reconciliation (entries 177,266,268,269,270 + 217)

2 markers consumed (schedule_policy.py, scheduler.py). B4 tree count now 15.
prefill_budget.py needed NO edit: sgl-project#46643's fix(1) (available_chunk_tokens
capped by real free KV minus the one-page over-ask, defer-not-force) SURVIVED
the merge byte-identical in the base class -- deduped with evidence (diff
309-tip vs HEAD shows only upstream's additive state_slot plumbing).

DECISION TABLE (per-hunk, sgl-project#46977 new admission pricing vs entries 265..270):
- entry 177 prefill_chunk_alignment: RE-PLANTED as-is -- kwarg + attribute +
  _align_prefill_chunk (LCM w/ kv_shard_granule) verbatim; the new tree's
  add_chunked_req grew a kv_shard_granule floor (upstream) that idempotently
  composes with the LCM (both floor-to-multiple); scheduler-side get_kvcache
  read RE-PLANTED too (dropped at the merge = the held_row/adder TypeErrors).
- entry 266 sgl-project#43484 classic-pool slot ledger: RE-ADAPTED. The unified half is
  SUPERSEDED-BY-EQUIVALENT: sgl-project#46977 moved the exact fork ledger onto the budget
  (ChainPrefillBudget.rem_state_slots = mamba_allocator.schedulable +
  mamba_evictable; debit rem -= state_slot_tokens//cost in reserve(); gate via
  budget_state's state_slots_exhausted()) -- factor 1, charge == reserve //
  cost, byte-for-byte identical semantics; the adder-side twin was DROPPED to
  avoid a double ledger. The CLASSIC half SURVIVES as fork delta (the
  base-class budget never sees state): isinstance(HybridReqToTokenPool) gate
  (NOT hasattr -- MagicMock discipline, 266(c) preserved), per-req charge
  1 + mamba_initial_tracking_slots (PR-bug math substitution kept, 266(a)),
  budget_state gate on the FULL charge (< per_req), add_one_req required-slot
  check incl. the defer_staged mamba branch, and slot-unit DEBIT threading at
  all five commit sites + _commit_prefill_admission.
- entry 267: (B4-1) done. entry 268 fix(2): RE-PLANTED -- the
  second-unfinished-chunk guard now applies to ALL policies (the merged
  shortest-prefill-first-only restriction was upstream's own pre-sgl-project#46643 form;
  git log: sgl-project#46643 never merged). sgl-project#45789's policy-reopening term stays the
  recorded PROVEN NO-OP (270(i)); test re-pins ..._is_unconditional.
- entry 269 page-align: RE-PLANTED verbatim at its 3 sites, composed with
  sgl-project#46977's floor_chunked_tokens (DCP grid) as page-align-then-grid-then-fork.
- entry 270 fork-split: RE-PLANTED (gate on get_exec().mamba.enable_mamba_
  extra_buffer + SGLANG_SPLIT_PREFILL_AT_MAMBA_FORK on our env -- the env
  union landed complete at the merge, environ.py untouched), incl. the
  continuation/commit/new-chunk/ignore-eos sites, the larger-host-hit
  re-clamp (270's fork cut lands AFTER page-align, order-safe), the
  truncation_align_size threading from scheduler (270(iii): _align_prefill_chunk
  call KEEPS its default arg deliberately), and the 'no other prefill may
  take its slot' return.
- entry 217 (PrefillAdder closes admission on retraction): the
  finish_storage_prefetch_admission sites VERIFIED PRESENT (retraction/discard
  x2) -- DEDUPED, no edit.
- entry 265: the brp required-slot block's defer/NO_TOKEN shape above; id-set
  half was B4-2.

BEHAVIOR (DEFAULT-ON) reaffirmed for the owed restart-watch: sgl-project#45472's
sync-free planning (B4-2 verified in-tree) + sgl-project#46643's UNCONDITIONAL per-round
admission re-runs (re-planting this cluster) are the two entry-198-class
behavior changes owed TTFT/starvation A/B at the prod restart (still banned;
zero GPU execution this session).

TEST RE-ANCHORS (upstream rewrites of these files silently dropped the
fork's fixture halves -- restored from the 309-tip versions, each pinned by
entry 215/266's own text): held_row's _Adder.add_chunked_req truncation_
align_size kwarg + get_kvcache allocator stub (entry-177 pair, upstream
sgl-project#46980 rewrite dropped them); dcp_logical's pools NS gains state=None
(#46970x _InitializedPools field) and test_scheduler_consumers_receives
_logical_capacity re-adapted to the new seams (pool-stats via the storage
shape, invariant checker's capacity kwarg REMOVED upstream, load_inquirer
direct) -- same anti-double-widening intent, kv_shard_widening=4 fixture
obsolete by design after the B4-1 re-plant.

ACTUALS (damage -> after, CVD=9, prod venv, per-file):
  test_prefill_adder   7F/32subF (39F storm) -> ** 71P/0F/94sub **
  test_dcp_logical_capacity 1F/6subF -> ** 5P/6sub **
  test_scheduler_held_row_admission (regressed by my scheduler wiring, then
  repaired) -> ** 1P/2sub EXACT (215 pin) **
  hybrid_ssm latch+retry family ** 9P ** (entry-198's '8P' + B4-1's case)
  DIR: unit/managers 1048P/48F/9S/439sub -> ** 1055P/3F/9S/474sub **
  (3F = the two order-dependent test_mm_process_config ENV F's [reproduce
  at base] + test_io_struct 1F [diagnosed B4-5, fixture half]).
Lint: ruff format + F821/E9 clean. No GPU; no push.

Co-Authored-By: OpenCode <[email protected]>
detain added a commit to detain/sglang that referenced this pull request Oct 30, 2026
…re-plant) SESSION 2B COMPLETE

Entry 312 records: the 5 cluster commits (9bd9007..5cde7a5) with per-
cluster batteries; THE sgl-project#46977 RECONCILIATION DECISION TABLE (per-hunk
survive-as-is / re-adapt / supersede, incl. the git-log proof that the
spec-mamba four arrived in-range while the admission six NEVER merged --
correcting the briefing's dedupe list, and sgl-project#46643 fix(1)'s reconcile as
already-merged base-PrefillBudget form = the reason prefill_budget.py got
ZERO B4 edits); the entry-200 CAPACITY-PAIR restoration (our configurator's
allocator.size branch survived -> upstream's consumer-side multiplications
double-counted -> model_runner allocator= kwarg + tp_worker/scheduler
subtractive forms re-planted; invariant-checker hunk OBSOLETE by upstream
refactor); the io_struct NEEDS-ATTENTION VERDICT (upstream's own
pointer_head guard vs stale fork stub -- test-side one-field re-anchor,
matching sibling stubs); the -523sub PRUNE-vs-BREAKAGE audit (all three
vanished managers files died to upstream's OWN sgl-project#45672 prune, two byte-
identical to origin/main, the third's fork delta subsumed by sgl-project#46643 --
recorded, not re-homed); the B3 cross-note closures (MambaCowAllocError
CATCHER landed; 216/217 admission interplay VERIFIED absorbed); the 2err
population correction (replayssm_ring_fold pruned by sgl-project#44690, gdn cutedsl
probe lives in the kernels zone, the spec dir's real err was merge damage,
now 0err); the runner-zone finds the damage map missed (_init_model_hooks
BOOT-INTEGRITY loss -- real decode-runner builds AttributeError, and
component_manager's dropped residency half that parallel_executor already
CALLS: both re-planted, 7F+crash-class closed); the true marker census (23
tree-carried, NOT the briefing's 20 -- B3 lesson applied; ALL consumed,
B4=0, B1/B2/B5 diff-audited intact).

GATES: trailing_endpoint ** 17P = 17P ** re-verified post-B4 (DoD-d, B3's
gate unmoved). DoD(e) diff audit: ZERO mem_cache/ files changed, ZERO in
qsa/moe-quant zones (moe_hook diff is marker-removal-only).

NEW PINS: unit/managers 1009P/81F/9S/412sub/2err -> 1056P/2F/9S/474sub (2F
= the two documented order-dependent mm_process_config ENV F's; the dir's
2err never reproduced -- population is the spec row's); unit/spec
363P/20F/21S/238sub/2err -> 388P/0F/21S/238sub/0err EXACT over 7
consecutive full-dir runs. OWED RESTART-WATCH REAFFIRMED: sgl-project#45472's
sync-free planning (verified present, upstream form) + sgl-project#46643's
unconditional per-round admission re-runs (re-planted) ride the entry-201
restart; entry-198's TTFT/starvation measure STILL OWED.

Header: STACK -> qwennext-stack-312+merge5-b4-2026-10-29; +merge5-b4 wave
tag; tip -> 5cde7a5; entries 1-312; INTEGRATION OWED annotated B4
LANDED (boot ban STAYS). wanted_stack: UNTOUCHED (no S-item changed by B4
findings -- recorded here). ENV debts recorded NOT-fixed: pcie_vocab_gather
GPU suite (27F identical at the merge commit), openai 2.6.1<2.8.0
serving_responses import (upstream's own beam.py), imageio (whole diffusion
import chain). NOTHING PUSHED; tree clean; zero GPU execution; zero prod
boots all session.

Co-Authored-By: OpenCode <[email protected]>
detain added a commit to detain/sglang that referenced this pull request Nov 11, 2026
…idecar x3: reduce-binding DI folded into _hit_query_controller ONE place (fork sites + the named-window case the reword missed; b3 named-window seam CLEARED, 7P/6sub), prefill_memory_budget: fork tri-chain pin re-homed onto live API (chain budget type + whole admission; can_reserve fence and rules.window retired with prod, clip numerics covered by the managers pricing family; _FloatChainPolicy import dead upstream), hybrid_pool_assembler: _DsaStrategy import consumed (upstream deleted the class into _KvStrategy, tests renamed in-kind), hicache_file_lru: upstream 9-line fold NOT adopted with recorded reason (pins sgl-project#48421 collapsed-mask layout the fork collective diverged from on purpose; 46P/27sub), mamba_donated x2: exhausted-pool chunk-boundary test re-homed (skip-recorder era idiom) + docstring marker consumed, b3 lazy_in_place x2 CLEARED by re-targing sgl-project#45472-era test onto the current mask-taking API (MethodType-bound _alloc_tracking_slots, state-slots stub, 21P/17sub). RESIDUAL (reported, not fixed out-of-zone): explicit_budget x5 -- upstream's merge-sgl-project#6 _kv_budget_index_bytes narrows the KV-budget deduction to KEY_ROWS and documents 'DSA indexers sit on top', voiding the entry-219 hicache-size ceiling the fork test pins; contiguity/stub residuals fixed, the contract call is the orchestrator's
detain added a commit to detain/sglang that referenced this pull request Nov 11, 2026
…+ re-plant era CLOSED at b86b7c9 (125/125 markers; grep census ZERO verified at this tree): header STACK epoch 321-2026-10-30 -> 329-2026-11-10 (supersession note kept) + +merge6-era-closeout-2026-11-10 trailer line + entries-count 1-329; tip/HEAD re-pinned (era CODE TIP b86b7c9 NAMED with the full wave chain, superseded values dea2641/e9f0ae1838/065fdcdf33/b7c656f69f/5cde7a5ede kept, docs tip recorded as this wave) + a prominent ** LIVE/BOOT STATE ** line (main checkout detached @ 2d87757 = the ONLY boot-validated state, 9b 16:58:52 warm all-needles-hit per prod-health-2026-11-10.txt; era branch CPU-green but NOT BOOTED -- switching prod = operator-chosen checkout + the entry-326 boot-watch). ENTRY 324: imports+bootfix trunk wave -- sgl-project#48781 require_attn_tp_gather->dp_attention relocation invisible to markers, base_runner deletion-only fix unmasking the 145E/32E/31E collection cascade (1dcc2d6); THEN the operator-live crash: maybe_init_router_registration read tokenizer_ipc_name before init_ipc_channels at OUR fork's entry-201 init order, call moved back to upstream's position, RED(2F)/GREEN(2P) test_tokenizer_manager_init_order.py, family scan clean + report-only carry (10a1c08). ENTRY 325: RE-PLANT ERA TABLE b1 12 / b3 18 / b4 39 / b5 17 / b2 23 / b6 16 = 125/125 per-wave dispositions (compressed from the commit bodies, all shas cited) + the NINE ERA CATCHES with FULL CREDIT: _rope_cache_key 10/11-arg universal get_rope crash (15 spec F were its fingerprints), PLE file-backend env registration gap (AttributeError every boot), COW-catcher doubled-staging-arm cascade bug, stat_loggers DI test restored from its corrupted merge hybrid, w13 refined-grid mis-key, the budget-contract decision (fork accounting RESTORED, evidence 106.9GB/100GB = the entry-317 leak shape; INDEXER collective order verified), verify-gate SUBSUME pick (sgl-project#44047 eats sgl-project#42779, both intents preserved), mm_process_config ambient-widths root-cause (validators now state the full 8-way layout), TLFIX twin re-pinned 282/285. ENTRY 326: BATTERY RE-PIN TABLE -- era pins managers 1307P/0F, spec 406P/0F, server_args 496P/0F, sampling 252P/0F, distributed 213P/0F, mem_cache 2965P/24F (the ACCEPTED device-only 24-node list over 8 files), cargo 966P/0F/1-ignored, five registration/wheel gates rc=0 + the PATH-TO-BOOTABLE statement: CPU-proven vs GPU-window debt -- first-boot needles incl. the sampling.cuh-vs-0.7.2 JIT arbitration (if it JIT-fails, wheel-trio-then-pin per S-FI073, never a lone re-pin), autotune caches SHOULD hit warm (no retune owed on 0.7.2), entry-322 verify-at-boot quartet, and the still-riding 321-era watches (sgl-project#45472/sgl-project#46643 TTFT+starvation, first-delta tool-stream latency). ENTRY 327: WHEELS & VENV RECORD -- pairing matrix (FI 0.7.2 HELD, sgl-kernel 0.4.10/0.4.10 era-consistent with the RETIRED-rule cross-ref, torch/cutlass-dsl MATCH), blake3 1.0.11 INSTALLED with ZERO-DRIFT PROOF (0 battery lines vs ~380; matrix re-read unchanged; negative-shim prefix-sim causality) + no-pip/uv-note (operator lane), the two tree-side wheel reverts with reachability + residual-symbol evidence, check_dockerfile_wheel_pins re-green, FI-0.7.3 adoption contract restated with post-era facts (upstream code now expects 0.7.3 in one reported JIT path; tree HELD 0.7.2; first boot arbitrates), dist-name/module-name note sglang_kernel/sgl_kernel. ENTRY 328: INCIDENT RECORD 2026-11-10 ~16:4x-16:58, honest narrative -- re-plant waves landed into the EDITABLE-IMPORT working tree while :30000/:30001 ran; 9b died ~pre-16:50 (cause UNVERIFIABLE from the user acct, /root logs unreadable; worker-respawn-importing-changed-code is the LEADING MECHANISM, stated AS SUCH); the operator restart hit the init-order crash = the era's flagship find; recovery = merge6-era-backup @ b069e6a + detached checkout 2d87757, 9b re-booted WARM 16:58:52 all needles hit, 9d NEVER dropped (Nov 3, HTTP 200); NEW ERA LAW: working tree = prod import path, integration by branch ref-move ONLY; b2's emergency-freeze WIP 7ccf76a (author 16:55:02) kept in range and completed as C1 -- provenance note. ENTRY 329: BACKFILL AUDIT RECORD -- window 2026-08-10..2026-10-27, universe 2714 = 1830 in-tree / 255 already-documented / 628 NEW REJECTS / 1 NEW-INTERESTING; method one-liners; the qwen4-main-squashed side-branch class discovery (REJECT-MERGED-TO-SIDE-BRANCH x44 -- future sweeps MUST filter by base; orchestrator's "206" NOT FOUND in the artifacts, 44 recorded as verified); sgl-project#36043 NVFP4 skinny GEMM SM120 full paragraph (closed-unmerged, absent-tree-verified, W4A4 M<=16 = our exact decode cell, BENCHMARK-BEFORE-PORT -> S-36043-BENCH filed); artifact paths. EVALUATED: the 671-line DOCS-BLOCK.txt inserted VERBATIM as its own dated block (165 dropped list-commas tidied at insertion, noted once at the block head; nothing else reflowed). DATED CORRECTIONS where the waves superseded 322/323-era operational text: the header PROD-BOOT-FORBIDDEN bullet and entry 323's WHEEL DRIFT + STATE lines get [11-10 ERA-CLOSE CORRECTION] annotations (classes closed, wheel landed, ban now purely the operator gate); marker-zone math re-verified against the wave ledgers (121-at-merge vs 125 recount stands correct; planted == consumed per zone). WATCH LIST: era-close block appended (sgl-project#36043 bench-gated; sgl-project#42790/sgl-project#40916 arrived-via-merge6 noted; sgl-project#43703 revert-trap cross-ref from entry 323; sgl-project#45520 STILL-OPEN re-confirmed at era close -- zero in-window refs, b5 verified the fail-safe layer intact; bootfix's report-only get_tokenizer_worker_class/entrypoints wiring carry). Docs-only: NO .py touched; check_registered_tests rc=0 re-run against this tree. NOTHING PUSHED; the live tree was NOT touched by this wave (ref-move integration follows with HEAD/status equality proofs).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

apple-silicon memory-pool run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants