{"record":{"id":"962a79938d81e089","repo":"sgl-project/sglang","slug":"dflash-requires-explicit-layer-ids-for-aux-hidden-962a79","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_moe.py","lineNumber":1104,"sourceCode":"        self.capture_aux_hidden_states = True\n        if layer_ids is None:\n            num_layers = self.config.num_hidden_layers\n            self.model.set_eagle3_layers_to_capture(\n                [\n                    2,\n                    num_layers // 2,\n                    num_layers - 3,\n                ]\n            )  # Specific layers for EAGLE3 support\n        else:\n            self.model.set_eagle3_layers_to_capture([val + 1 for val in layer_ids])\n\n    def set_dflash_layers_to_capture(self, layer_ids: List[int]):\n        if not self.pp_group.is_last_rank:\n            return\n\n        if layer_ids is None:\n            raise ValueError(\n                \"DFLASH requires explicit layer_ids for aux hidden capture.\"\n            )\n\n        self.capture_aux_hidden_states = True\n        self.model.set_dflash_layers_to_capture([val + 1 for val in layer_ids])\n\n    def load_weights(\n        self, weights: Iterable[Tuple[str, torch.Tensor]], is_mtp: bool = False\n    ):\n        stacked_params_mapping = [\n            # (param_name, shard_name, shard_id)\n            (\"qkv_proj\", \"q_proj\", \"q\"),\n            (\"qkv_proj\", \"k_proj\", \"k\"),\n            (\"qkv_proj\", \"v_proj\", \"v\"),\n            (\"gate_up_proj\", \"gate_proj\", 0),\n            (\"gate_up_proj\", \"up_proj\", 1),\n        ]\n","sourceCodeStart":1086,"sourceCodeEnd":1122,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/qwen3_moe.py#L1086-L1122","documentation":"Same DFLASH guard as other Qwen models: enabling aux hidden state capture for DFLASH speculative decoding requires an explicit list of layer ids; None is rejected.","triggerScenarios":"Calling Qwen3MoeForCausalLM.set_dflash_layers_to_capture(None) on the last pipeline rank while enabling DFLASH.","commonSituations":"DFLASH/spec config missing the capture-layer list when serving a Qwen3-MoE model.","solutions":["Pass explicit layer indices, e.g. via --dflash-capture-layers","Verify the spec algorithm config computes layer ids before model init","Update to a config where capture layers default to a computed set"],"exampleFix":"# before\nmodel.set_dflash_layers_to_capture(None)\n# after\nmodel.set_dflash_layers_to_capture([0, 1, 2, 3])","handlingStrategy":"validation","validationCode":"if layer_ids is None: raise SystemExit(\"specify --dflash-capture-layers\")\nmodel.set_dflash_layers_to_capture(layer_ids)","typeGuard":"def valid_layer_ids(x) -> bool:\n    return isinstance(x, list) and all(isinstance(i, int) and i >= 0 for i in x) and len(x) > 0","tryCatchPattern":null,"preventionTips":["Always configure explicit capture layers with DFLASH"],"tags":["dflash","speculative-decoding","qwen3-moe"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}