{"record":{"id":"af2c9b2c729ef337","repo":"sgl-project/sglang","slug":"dspark-requires-explicit-layer-ids-for-aux-hidden-af2c9b","errorCode":null,"errorMessage":"DSPARK requires explicit layer_ids for aux hidden capture.","messagePattern":"DSPARK requires explicit layer_ids for aux hidden capture\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/models/kimi_linear.py","lineNumber":797,"sourceCode":"                quant_config=quant_config,\n                prefix=maybe_prefix(prefix, \"lm_head\"),\n            )\n        else:\n            self.lm_head = PPMissingLayer()\n        logit_scale = getattr(self.config, \"logit_scale\", 1.0)\n        self.logits_processor = LogitsProcessor(config=config, logit_scale=logit_scale)\n        self.capture_aux_hidden_states = False\n\n    def get_input_embeddings(self):\n        return self.model.embed_tokens\n\n    def set_dspark_layers_to_capture(self, layer_ids: list[int]) -> None:\n        if self.pp_group.world_size > 1:\n            raise NotImplementedError(\"DSPARK aux hidden capture requires PP=1.\")\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.dspark_layers_to_capture = list(layer_ids)\n\n    @torch.no_grad()\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    ) -> torch.Tensor:\n        hidden_states = self.model(\n            input_ids,\n            positions,\n            forward_batch,","sourceCodeStart":779,"sourceCodeEnd":815,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/kimi_linear.py#L779-L815","documentation":"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.","triggerScenarios":"Calling model.set_dspark_layers_to_capture(None) or passing an uninitialized list[int] variable that evaluates to None.","commonSituations":"Adapting generic training-hook code that assumes a default layer set exists; optional CLI arg for capture layers left unset and forwarded verbatim.","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"],"exampleFix":"# before\nmodel.set_dspark_layers_to_capture(args.capture_layers)  # None when flag omitted\n# after\nif args.capture_layers:\n    model.set_dspark_layers_to_capture(list(args.capture_layers))","handlingStrategy":"validation","validationCode":"assert layer_ids is not None and len(layer_ids) > 0","typeGuard":"def valid_capture_layers(ids) -> bool:\n    return isinstance(ids, (list, tuple)) and len(ids) > 0 and all(isinstance(i, int) for i in ids)","tryCatchPattern":null,"preventionTips":["Normalize optional CLI args: either a concrete list or skip the API call"],"tags":["kimi-linear","dspark","argument-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}