sgl-project/sglang · critical · RuntimeError
{st.upper()} state index length mismatch: prefill={len(src_i
Error message
{st.upper()} state index length mismatch: prefill={len(src_indices)}, dst={len(dst_indices_local)} What it means
Extra-state index lists (e.g. position/request-indexed components like C128_STATE) must match in length between prefill and decode; truncation would silently misalign rows and corrupt KV, so _requires_exact_state_index_match types raise instead of warn.
Source
Thrown at python/sglang/srt/disaggregation/mooncake/conn.py:1361
):
raise RuntimeError(
f"PD Disaggregation does NOT support PD different TP sizes for non-MLA {st.upper()} hybrid models yet."
)
src_indices = list(indices)
dst_indices_local = list(dst_indices)
if (
st == StateType.C128_STATE
and len(src_indices) == 0
and len(dst_indices_local) == 0
):
continue
if len(src_indices) != len(dst_indices_local):
# These components are position- or request-indexed:
# truncating silently misaligns rows and corrupts KV.
# Paged SWA/DSA tolerate a 1-page drift -> keep the
# lenient truncation below.
if self._requires_exact_state_index_match(st):
raise RuntimeError(
f"{st.upper()} state index length mismatch: "
f"prefill={len(src_indices)}, dst={len(dst_indices_local)}"
)
logger.warning(
f"len(prefill_state_indices) = {len(src_indices)}, len(dst_state_indices) = {len(dst_indices_local)}"
)
if len(src_indices) > len(dst_indices_local):
src_indices = src_indices[: len(dst_indices_local)]
else:
dst_indices_local = dst_indices_local[: len(src_indices)]
rc = (
self._send_kvcache_generic(
mooncake_session_id=req.mooncake_session_id,
src_data_ptrs=src_data_ptrs,
dst_data_ptrs=dst_data_ptrs,
item_lens=src_item_lens,
prefill_data_indices=np.array(src_indices, dtype=np.int32),
dst_data_indices=np.array(dst_indices_local, dtype=np.int32),View on GitHub (pinned to 0132848349)
Solutions
- Check scheduler/allocator logs for why state index counts diverged (failed allocs, preemption on one side)
- Restart both instances to reset allocator state
- Ensure identical chunking/request scheduling config on both sides
Defensive patterns
Strategy: try-catch
Try / catch
catch RuntimeError mentioning 'index length mismatch'; drop the room's requests and alert — do not retry the same corrupted state
Prevention
- Watch allocator preemption/failure counters on both sides
- Alert on any state-index divergence before corruption spreads
When it happens
Trigger: len(src_indices) != len(dst_indices_local) for an exactly-matched StateType during maybe_send_extra.
Common situations: Allocator drift producing different row counts per rank, scheduler divergence between PD sides, or earlier silent truncation bugs now surfaced.
Related errors
- Page size mismatch: prefill server has page_size={info.page_
- KV cache dtype mismatch: prefill server has kv_cache_dtype={
- --enable-unified-memory does not support different prefill /
- PD KV layout mismatch on the whole-envelope path: prefill ha
- Mamba state layouts differ between prefill and decode (src i
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/7bae6b4aa2805746.
Report an issue: GitHub.