sgl-project/sglang · error · ValueError
{layer_id=} not in full attention layers: {self.full_attenti
Error message
{layer_id=} not in full attention layers: {self.full_attention_layer_id_mapping.keys()} What it means
Hybrid KV pool layer remapping error: _transfer_full_attention_id was given a layer_id that is not a full-attention layer registered in full_attention_layer_id_mapping. Hybrid models (e.g. sliding-window + full attention, or linear-attention hybrids) store full-attention layers in a sub-pool indexed by a compact remapped id, so an unknown id cannot be translated.
Source
Thrown at python/sglang/srt/mem_cache/memory_pool.py:3879
def get_state_layer_ids(self):
"""Global layer id per mamba state entry, aligned with get_state_buf_infos()."""
return self.mamba_pool.get_state_layer_ids()
def get_state_slice_outer_counts(self):
"""Get the row count preceding each mamba state slice axis."""
return self.mamba_pool.get_state_slice_outer_counts()
def get_state_conv_shard_groups(self):
"""Per-tensor conv sub-block dims (GDN) aligned with the state list."""
return self.mamba_pool.get_state_conv_shard_groups()
def maybe_get_custom_mem_pool(self):
return self.full_kv_pool.maybe_get_custom_mem_pool()
def _transfer_full_attention_id(self, layer_id: int):
if layer_id not in self.full_attention_layer_id_mapping:
raise ValueError(
f"{layer_id=} not in full attention layers: {self.full_attention_layer_id_mapping.keys()}"
)
return self.full_attention_layer_id_mapping[layer_id]
def register_layer_transfer_counter(self, layer_transfer_counter: LayerDoneCounter):
self.layer_transfer_counter = layer_transfer_counter
# The layer-wise wait logic is executed at the Hybrid LinearPool level;
# no additional wait is needed in the full_kv_pool
self.full_kv_pool.register_layer_transfer_counter(None)
def _wait_for_layer(self, layer_id: int):
if self.layer_transfer_counter is not None:
self.layer_transfer_counter.wait_until(layer_id - self.start_layer)
def get_key_buffer(self, layer_id: int, scale: Optional[float] = None):
self._wait_for_layer(layer_id)
layer_id = self._transfer_full_attention_id(layer_id)
if scale is not None:View on GitHub (pinned to 0132848349)
Solutions
- Check the model's full_attention_layer_id_mapping (log self.full_attention_layer_id_mapping.keys()) and only pass ids present there
- Fix the construction of the hybrid pool so full-attention layer ids from the model config match the mapping
- Update the caller (transfer scheduler loop) to skip non-full-attention layers
Example fix
// before
self._transfer_full_attention_id(layer_id) # layer_id from a sliding-window layer
// after
if layer_id in self.full_attention_layer_id_mapping:
self._transfer_full_attention_id(layer_id) Defensive patterns
Strategy: type-guard
Validate before calling
if layer_id not in pool.full_attention_layer_id_mapping:
raise ValueError(f'{layer_id} is not full-attention; skipping transfer') Type guard
def is_full_attention_layer(pool, layer_id: int) -> bool:
return layer_id in pool.full_attention_layer_id_mapping Prevention
- Derive transfer layer lists from full_attention_layer_id_mapping, never hardcode
- Add unit tests asserting mapping covers exactly the model's full-attention layers
When it happens
Trigger: Calling transfer/async-transfer APIs (e.g. HiCache layer transfer scheduling) with a layer_id belonging to a non-full-attention (sliding/linear) layer, or a layer id mismatch after model config changes altered the full-attention layer set.
Common situations: Running hierarchical cache / KV transfer on a hybrid attention model; a model definition whose full_attention_layer_ids list disagrees with the layers actually iterated; version changes in how hybrid layer ids are enumerated.
Related errors
- layer_id={layer_id} does not have an index V cache (either d
- layer_id={layer_id} is not a sparse attention layer; sparse
- layer.layer_id={layer.layer_id} does not have an index V cac
- layer.layer_id={layer.layer_id} is not in the K-only sparse
- v_cache must be provided
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/119aa78a37166fe7.
Report an issue: GitHub.