sgl-project/sglang · error · ValueError
DSPARK requires explicit layer_ids for aux hidden capture.
Error message
DSPARK requires explicit layer_ids for aux hidden capture.
What it means
DSPARK's aux hidden capture needs to know exactly which decoder layers' hidden states to capture; unlike some speculative paths it cannot infer them. If layer_ids is None (the caller omitted the argument) after the PP and last-rank checks, this ValueError is raised and capture_aux_hidden_states is never set.
Source
Thrown at python/sglang/srt/models/kimi_k3.py:2892
)
else:
self.lm_head = PPMissingLayer()
logit_scale = getattr(config, "logit_scale", 1.0)
self.logits_processor = LogitsProcessor(config=config, logit_scale=logit_scale)
self.capture_aux_hidden_states = False
def get_input_embeddings(self):
return self.model.embed_tokens
def set_dspark_layers_to_capture(self, layer_ids: list[int]) -> None:
if self.pp_group.world_size > 1:
# Capture layers living on non-last PP ranks would be silently
# skipped (the flag is only set on the last rank).
raise NotImplementedError("DSPARK aux hidden capture requires PP=1.")
if not self.pp_group.is_last_rank:
return
if layer_ids is None:
raise ValueError(
"DSPARK requires explicit layer_ids for aux hidden capture."
)
self.capture_aux_hidden_states = True
self.model.dspark_layers_to_capture = list(layer_ids)
@torch.no_grad()
def forward(
self,
input_ids: torch.Tensor,
positions: torch.Tensor,
forward_batch: ForwardBatch,
input_embeds: Optional[torch.Tensor] = None,
inputs_embeds: Optional[torch.Tensor] = None,
pp_proxy_tensors: Optional[PPProxyTensors] = None,
) -> torch.Tensor:
embeds = input_embeds if input_embeds is not None else inputs_embeds
hidden_states = self.model(
input_ids, positions, forward_batch, embeds, pp_proxy_tensorsView on GitHub (pinned to 0132848349)
Solutions
- Pass an explicit list of layer ids, e.g. set_dspark_layers_to_capture([0, 1, 2]) matching the DSPARK draft's tdt/esvd layer choices.
- Upgrade the DSPARK runtime/spec worker to a version that supplies layer_ids for Kimi K3.
- Validate layer_ids against model.config.num_hidden_layers before calling.
Example fix
# before model.set_dspark_layers_to_capture(None) # after model.set_dspark_layers_to_capture([0, 1, 2])
Defensive patterns
Strategy: validation
Validate before calling
assert layer_ids is not None and len(layer_ids) > 0, "DSPARK requires explicit layer_ids" assert all(0 <= i < model.config.num_hidden_layers for i in layer_ids)
Type guard
def valid_layer_ids(layer_ids, num_layers) -> bool:
return layer_ids is not None and all(isinstance(i, int) and 0 <= i < num_layers for i in layer_ids) Prevention
- Always pass explicit capture layers when configuring DSPARK.
- Cross-check layer ids against config.num_hidden_layers.
When it happens
Trigger: Calling set_dspark_layers_to_capture(None) or omitting layer_ids from the DSPARK/spec worker when wiring up Kimi K3 — the method explicitly rejects None even though the signature types it as list[int].
Common situations: A DSPARK integration/spec-worker version that doesn't pass layer_ids; user scripts calling the capture API directly without layer selection; default-argument path after an sglang upgrade changed the call convention.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- DSpark requires --speculative-dspark-block-size to be positi
- DSpark speculative_num_draft_tokens must be >= 2 (= gamma +
- DSPARK aux hidden capture requires PP=1.
- Unknown match_type: '{match_type}'. Must be 'BFS' or 'PROB'.
- Kimi-K3 DCP + DSPARK currently requires SGLANG_RAGGED_VERIFY
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/b318b4f842689251.
Report an issue: GitHub.