{"record":{"id":"0b779e643cedf428","repo":"sgl-project/sglang","slug":"dflash-requires-explicit-layer-ids-for-aux-hidden-0b779e","errorCode":null,"errorMessage":"DFLASH requires explicit layer ids for aux hidden capture.","messagePattern":"DFLASH requires explicit layer ids for aux hidden capture\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/models/qwen3_5_text.py","lineNumber":125,"sourceCode":"    def get_input_embeddings(self) -> nn.Embedding:\n        return self.model.embed_tokens\n\n    def get_embed_and_head(self):\n        return self.model.embed_tokens.weight, self.lm_head.weight\n\n    def set_embed_and_head(self, embed, head):\n        del self.model.embed_tokens.weight\n        del self.lm_head.weight\n        self.model.embed_tokens.weight = embed\n        self.lm_head.weight = head\n        torch.cuda.empty_cache()\n        torch.cuda.synchronize()\n\n    def set_dflash_layers_to_capture(self, layers_to_capture: list[int]):\n        if not self.pp_group.is_last_rank:\n            return\n        if layers_to_capture is None:\n            raise ValueError(\n                \"DFLASH requires explicit layer ids for aux hidden capture.\"\n            )\n        self.capture_aux_hidden_states = True\n        self.model.set_dflash_layers_to_capture(layers_to_capture)\n\n    @torch.no_grad()\n    def forward(\n        self,\n        input_ids: torch.Tensor,\n        positions: torch.Tensor,\n        forward_batch: ForwardBatch,\n        input_embeds: Optional[torch.Tensor] = None,\n        pp_proxy_tensors: Optional[PPProxyTensors] = None,\n        **kwargs,\n    ) -> Union[torch.Tensor, PPProxyTensors]:\n        if self.is_mrope_enabled:\n            positions = forward_batch.mrope_positions\n","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/qwen3_5_text.py#L107-L143","documentation":"DFLASH aux-hidden capture requires the caller to pass an explicit list of transformer layer indices. The model refuses to enable capture_aux_hidden_states when layers_to_capture is None because DFLASH cannot infer which layers' hidden states to capture.","triggerScenarios":"Calling model.set_dflash_layers_to_capture(None) (or an API like init_dflash_support that forwards a None layers argument) on a Qwen3.5 text model on the last PP rank.","commonSituations":"Server args enable DFLASH/speculative aux-hidden capture but --dflash-capture-layers (or equivalent spec config) was not set, so None is forwarded to the model.","solutions":["Set the explicit layer ids flag, e.g. --dflash-capture-layers 0,2,4 or the corresponding speculative-decoding config field","If invoking programmatically, pass a concrete list[int] instead of None","Check that the caller upstream (e.g. EAGLE/DFLASH worker) is configured to compute layer indices before calling"],"exampleFix":"# before\nmodel.set_dflash_layers_to_capture(None)\n# after\nmodel.set_dflash_layers_to_capture([0, 2, 4, 6])","handlingStrategy":"validation","validationCode":"layers = spec_config.dflash_capture_layers\nassert layers is not None and len(layers) > 0, \"set dflash capture layers\"","typeGuard":"def has_capture_layers(cfg) -> bool:\n    return isinstance(getattr(cfg, 'dflash_capture_layers', None), list) and len(cfg.dflash_capture_layers) > 0","tryCatchPattern":null,"preventionTips":["Always pass an explicit layer list when enabling DFLASH","Validate spec config before model init"],"tags":["dflash","speculative-decoding","hidden-states","qwen3"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}