Skip to content

Fix BaseCache metric - #170

Merged
comaniac merged 1 commit into
mainfrom
cody/fix
Feb 9, 2024
Merged

comaniac merged 1 commit into
mainfrom
cody/fix

Conversation

@comaniac

@comaniac comaniac commented Feb 9, 2024

Copy link
Copy Markdown
Contributor

As title.

@comaniac
comaniac merged commit cba5027 into main Feb 9, 2024
@comaniac
comaniac deleted the cody/fix branch February 9, 2024 01:23
timethink pushed a commit to timethink/sglang that referenced this pull request Mar 9, 2025
rucnyz added a commit to rucnyz/sglang that referenced this pull request Jun 2, 2026
…tasks + T35 verify

Audit verdict per T (the 16 pending PLAN §3/§4 items):

DONE (covered by existing impl + tests):
  * T29 SGLANG_KV_POLICY_MODULE → _load_eviction_scorer exists;
    verify/t38/ stage C1 pins resolver
  * T32 all-rank atomic actions → tokenizer-server fanout exists;
    verify/t15/run_dp2_real.py exercises multi-rank wire
  * T35 authoritative_tier → baselines/base.py + new verify/t35/
    (8 stages: all residence combinations + empty-raises)

STRUCTURAL (compile-time invariant, no dedicated verify needed):
  * T19 atomic unit visibility → page_aligned() called in insert
    path at unified_radix_cache.py:574/599/731; run-time pin
    deferred to integration_stress flavor B

PARTIAL (impl half done):
  * T24 HASH_COLLISION → detection live with pair-dedupe; webhook
    firing pending ("T24 webhook pending" log) → sgl-project#182
  * T25 idempotent endpoints → migrate ✓, threshold ✓, pause/hint
    gated on T21/T40

OPEN — new tracking tasks created:
  * sgl-project#180  T18 state-dump single-snapshot read-lock
  * sgl-project#181  T21 PUT /aginfer/program_paused endpoint
  * sgl-project#182  T24 wire HASH_COLLISION webhook firing
  * sgl-project#183  T30+T39 proxy disconnect (paired)
  * sgl-project#184  T40 F2 hint emitter (daemon → sglang)
  * sgl-project#185  T41 F5 SESSION_END-for-PAUSED handler

OPEN — already tracked elsewhere:
  * T26 (HiCache/Mooncake EMA) → sgl-project#172 (T13 deferred)
  * T27 hint clear ordering → blocks on T40 (sgl-project#184)
  * T28 should_write_through → sgl-project#178

OUT OF SCOPE:
  * T31 harbor /aginfer/session_end — lives in harbor/client,
    not in sglang/daemon codebase

PLAN.md updated with per-T status notes referencing the audit
date + task IDs.  verify/t35/ added (8 stages, all green).
Vinsmoke86 referenced this pull request in t-head/sglang-for-sail Nov 12, 2026
…ory budget

Why:
The decode-side req-to-token pool pre-allocates extra slots
(disaggregation_decode_extra_slots plus per-request ping-pong slots) and a
role-switch launch builds HybridMambaDecodeReqToTokenPool on the prefill server
too, while _handle_max_mamba_cache only counted max_running_requests slots. The
mamba pool was therefore sized under the real demand and decode startup OOMed.
The same under-charging exists on the v0.5.23 line, so the fix is still needed
there; this commit migrates the change from the v0.5.21 series (PR #170).

How:
- Deduct pre-allocated decode slots and the per-request slot multiplier from the
  request bound used for the mamba budget.
- Deduct the EAGLE intermediate_ssm scratch of pre-allocated requests.
- Scale per-slot mamba bytes and replayssm ring bytes by (L + Ln) / L when nextn
  draft layers are appended to the request pool.
- Exempt the unified-memory path, which charges pre-allocation once via
  UnifiedHybridReqToTokenPool and keeps mamba_spec_state_size at max_num_reqs.
- Non PD-decode paths derive identical budgets as before.

v0.5.23 adaptations (behaviour-preserving):
- The per-slot term uses extra_per_slot (replayssm ring bytes plus the newer
  extra mamba cache bytes) where the v0.5.21 change used
  replayssm_ring_per_slot, so the additional state bytes on this line stay
  charged and the nextn ring scaling still propagates.
- The spec-state reservation keeps this line's reserves_spec_state gate, which
  already folds the PD-prefill exemption into the spec/replayssm condition.

Dependency:
None beyond the v0.5.23 adaptation line; no new package or kernel dependency.

Test:
- Single squashed commit; the diff was reconciled hunk by hunk against the
  v0.5.21 source change and the conflict points are recorded in the migration
  handoff notes.
- Syntax gate: python3.12 -m py_compile on the changed file passes (no unit test
  ships with this change, matching the source patch).
- Runtime gate: no-conflict-marker and forbidden-keyword grep over the added
  lines are clean.
- Suggested E2E by scope: PD-disaggregated hybrid mamba/linear-attention decode
  (GLM-class and Qwen-hybrid) with and without spec decoding, bf16 and fp8 KV
  cache, on PPU and NVIDIA backends -- compare the reported
  max_mamba_cache_size and decode pool build memory before/after; non-PD
  launches must show byte-identical budgets.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant