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 aux-hidden-state capture requires the caller to pass an explicit list of layer indices; passing layer_ids=None is rejected (unlike DFlash conventions where defaults may apply).

Source

Thrown at python/sglang/srt/models/bailing_moe_v3.py:1665

        return self.model.decoder_attention_types

    def get_input_embeddings(self) -> nn.Module:
        return self.model.word_embeddings

    def set_dspark_layers_to_capture(self, layer_ids: List[int]) -> None:
        """Configure per-layer hidden-state capture for DSpark.

        The target model exposes the final ``hidden_states + residual`` of each
        requested layer so the DSpark draft can project them into its context KV
        cache. ``layer_ids`` are raw target decoder layer indices (e.g.
        ``[1, 11, 23, 29, 35]``); capture happens after layer ``i`` runs, so no
        ``+1`` offset is applied (in contrast to the DFlash convention used by
        models that capture before the layer runs).
        """
        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.capture_aux_hidden_states = True
        self.model.layers_to_capture = list(layer_ids)

    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,
    ) -> Union[torch.Tensor, PPProxyTensors]:
        hidden_states = self.model(
            input_ids=input_ids,
            positions=positions,
            inputs_embeds=inputs_embeds,

View on GitHub (pinned to 0132848349)

Solutions

  1. Pass an explicit list, e.g. set_dspark_layers_to_capture(layer_ids=[i for i in range(num_layers) if condition])
  2. Check your DSPARK config for the capture-layer specification before calling the API

Example fix

# before
model.set_dspark_layers_to_capture(None)
# after
model.set_dspark_layers_to_capture(layer_ids=[5, 11, 17, 23])
Defensive patterns

Strategy: validation

Validate before calling

assert layer_ids is not None and len(layer_ids) > 0, "DSPARK needs explicit layer_ids"

Prevention

When it happens

Trigger: Calling model.set_dspark_layers_to_capture(None) or invoking DSPARK without specifying capture layers on the last PP rank.

Common situations: Integrating DSPARK training/distillation and forgetting to configure capture layers; copying DFlash setup code that omits layer_ids.

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


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/3083cb312003fdcc. Report an issue: GitHub.