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
set_dspark_layers_to_capture (kimi_linear.py:797) requires an explicit list of layer indices to capture; passing None (the sentinel meaning 'capture defaults') raises ValueError. Unlike some models, Kimi-Linear has no default capture set, so callers must name the layers.
Source
Thrown at python/sglang/srt/models/kimi_linear.py:797
quant_config=quant_config,
prefix=maybe_prefix(prefix, "lm_head"),
)
else:
self.lm_head = PPMissingLayer()
logit_scale = getattr(self.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:
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,
inputs_embeds: Optional[torch.Tensor] = None,
pp_proxy_tensors: Optional[PPProxyTensors] = None,
) -> torch.Tensor:
hidden_states = self.model(
input_ids,
positions,
forward_batch,View on GitHub (pinned to 0132848349)
Solutions
- Pass an explicit list, e.g. set_dspark_layers_to_capture([24, 48])
- Default unset CLI options to a concrete layer list (or skip calling the API entirely)
- Validate layer ids against model.config.num_hidden_layers before calling
Example fix
# before
model.set_dspark_layers_to_capture(args.capture_layers) # None when flag omitted
# after
if args.capture_layers:
model.set_dspark_layers_to_capture(list(args.capture_layers)) Defensive patterns
Strategy: validation
Validate before calling
assert layer_ids is not None and len(layer_ids) > 0
Type guard
def valid_capture_layers(ids) -> bool:
return isinstance(ids, (list, tuple)) and len(ids) > 0 and all(isinstance(i, int) for i in ids) Prevention
- Normalize optional CLI args: either a concrete list or skip the API call
When it happens
Trigger: Calling model.set_dspark_layers_to_capture(None) or passing an uninitialized list[int] variable that evaluates to None.
Common situations: Adapting generic training-hook code that assumes a default layer set exists; optional CLI arg for capture layers left unset and forwarded verbatim.
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 +
- --enable-linear-replayssm-spec with DSPARK/DFLASH requires a
- DSPARK requires explicit layer_ids for aux hidden capture.
- DSPARK aux hidden capture requires PP=1.
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/af2c9b2c729ef337.
Report an issue: GitHub.