{"record":{"id":"3083cb312003fdcc","repo":"sgl-project/sglang","slug":"dspark-requires-explicit-layer-ids-for-aux-hidden","errorCode":null,"errorMessage":"DSPARK requires explicit layer_ids for aux hidden capture.","messagePattern":"DSPARK requires explicit layer_ids for aux hidden capture\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/models/bailing_moe_v3.py","lineNumber":1665,"sourceCode":"        return self.model.decoder_attention_types\n\n    def get_input_embeddings(self) -> nn.Module:\n        return self.model.word_embeddings\n\n    def set_dspark_layers_to_capture(self, layer_ids: List[int]) -> None:\n        \"\"\"Configure per-layer hidden-state capture for DSpark.\n\n        The target model exposes the final ``hidden_states + residual`` of each\n        requested layer so the DSpark draft can project them into its context KV\n        cache. ``layer_ids`` are raw target decoder layer indices (e.g.\n        ``[1, 11, 23, 29, 35]``); capture happens after layer ``i`` runs, so no\n        ``+1`` offset is applied (in contrast to the DFlash convention used by\n        models that capture before the layer runs).\n        \"\"\"\n        if not self.pp_group.is_last_rank:\n            return\n        if layer_ids is None:\n            raise ValueError(\n                \"DSPARK requires explicit layer_ids for aux hidden capture.\"\n            )\n        self.capture_aux_hidden_states = True\n        self.model.capture_aux_hidden_states = True\n        self.model.layers_to_capture = list(layer_ids)\n\n    def forward(\n        self,\n        input_ids: torch.Tensor,\n        positions: torch.Tensor,\n        forward_batch: ForwardBatch,\n        inputs_embeds: Optional[torch.Tensor] = None,\n        pp_proxy_tensors: Optional[PPProxyTensors] = None,\n    ) -> Union[torch.Tensor, PPProxyTensors]:\n        hidden_states = self.model(\n            input_ids=input_ids,\n            positions=positions,\n            inputs_embeds=inputs_embeds,","sourceCodeStart":1647,"sourceCodeEnd":1683,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/bailing_moe_v3.py#L1647-L1683","documentation":"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).","triggerScenarios":"Calling model.set_dspark_layers_to_capture(None) or invoking DSPARK without specifying capture layers on the last PP rank.","commonSituations":"Integrating DSPARK training/distillation and forgetting to configure capture layers; copying DFlash setup code that omits layer_ids.","solutions":["Pass an explicit list, e.g. set_dspark_layers_to_capture(layer_ids=[i for i in range(num_layers) if condition])","Check your DSPARK config for the capture-layer specification before calling the API"],"exampleFix":"# before\nmodel.set_dspark_layers_to_capture(None)\n# after\nmodel.set_dspark_layers_to_capture(layer_ids=[5, 11, 17, 23])","handlingStrategy":"validation","validationCode":"assert layer_ids is not None and len(layer_ids) > 0, \"DSPARK needs explicit layer_ids\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass explicit layer indices for DSPARK capture"],"tags":["dspark","hidden-states","capture","bailing"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}