sgl-project/sglang · error · NotImplementedError
{debug_name}: non-sequential write current_start={current_ch
Error message
{debug_name}: non-sequential write current_start={current_chunk_start} global_end={self._global_end} cur={None if self._cur is None else self._cur.g0} What it means
The packed cache only supports two write modes: rewriting the current chunk, or appending at exactly self._global_end. Any other current_chunk_start is a non-sequential write and raises NotImplementedError with diagnostics of the expected vs. given positions.
Source
Thrown at python/sglang/multimodal_gen/runtime/layers/kvcache/qvg_packed_cache.py:311
# rewrite current chunk in place (denoise step)
if cend != self._cur.g1:
raise NotImplementedError(
f"{debug_name}: current-chunk rewrite size changed"
)
self._write(self._cur, key, value, head_slice)
elif current_chunk_start == self._global_end:
# advance: finalize current chunk, start a new one
if self._cur is not None:
self._segments.append(self._cur)
is_sink = current_chunk_start < self.sink_tokens
if self._chunk_tokens == 0:
self._chunk_tokens = num_new
self._cur = self._new_bf16_segment(current_chunk_start, cend, is_sink)
self._write(self._cur, key, value, head_slice)
self._global_end = cend
self._pack_and_evict()
else:
raise NotImplementedError(
f"{debug_name}: non-sequential write current_start="
f"{current_chunk_start} global_end={self._global_end} "
f"cur={None if self._cur is None else self._cur.g0}"
)
local_end = min(self._global_end, self.cache_size)
if self.global_end_index_int is not None:
self.global_end_index_int = self._global_end
self.local_end_index_int = local_end
else:
self.global_end_index.fill_(self._global_end)
self.local_end_index.fill_(local_end)
vk, vv = self._reconstruct(current_chunk_start, recent_window_tokens)
return CausalAttentionKVView(
k=vk,
v=vv,
local_start_index=0,View on GitHub (pinned to 0132848349)
Solutions
- Align current_chunk_start with cache._global_end for appends
- To overwrite history, drain/reset the cache back to that position first
- Serialize writers so chunks are produced strictly in order
Example fix
# before cache.update_and_get_attention_kv(k, v, current_chunk_start=older_start) # after cache.update_and_get_attention_kv(k, v, current_chunk_start=cache._global_end)
Defensive patterns
Strategy: validation
Validate before calling
assert current_chunk_start == cache._global_end or (cache._cur and current_chunk_start == cache._cur.g0), 'non-sequential write'
Try / catch
try:\n cache.update_and_get_attention_kv(k, v, current_chunk_start=s)\nexcept NotImplementedError as e:\n if 'non-sequential write' in str(e):\n cache.rewind_to(s)
Prevention
- Serialize writers to a single sequential producer
- Reset/rewind the cache before replaying history
When it happens
Trigger: update_and_get_attention_kv with current_chunk_start not equal to self._cur.g0 (rewrite) nor self._global_end (append) — e.g. writing into the middle of history or rewinding past the current chunk.
Common situations: Rollback/replay logic in realtime pipelines attempting to overwrite an older chunk; multiple writers interleaving out of order; incorrect global position bookkeeping after an eviction/pack pass.
Related errors
- Invalid {debug_name} write range: local=[{local_start_index}
- QVGPackedCausalKVCache does not support pinned-sink (longliv
- LingBot causal sequence sharding currently requires kv_cache
- {self.__class__.__name__}.apply should not be called.
- page-major layout has no per-layer contiguous regions; KV tr
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/11d9e23f53f00b45.
Report an issue: GitHub.