sgl-project/sglang · error · ValueError
DFLASH requires explicit layer ids for aux hidden capture.
Error message
DFLASH requires explicit layer ids for aux hidden capture.
What it means
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.
Source
Thrown at python/sglang/srt/models/qwen3_5_text.py:125
def get_input_embeddings(self) -> nn.Embedding:
return self.model.embed_tokens
def get_embed_and_head(self):
return self.model.embed_tokens.weight, self.lm_head.weight
def set_embed_and_head(self, embed, head):
del self.model.embed_tokens.weight
del self.lm_head.weight
self.model.embed_tokens.weight = embed
self.lm_head.weight = head
torch.cuda.empty_cache()
torch.cuda.synchronize()
def set_dflash_layers_to_capture(self, layers_to_capture: list[int]):
if not self.pp_group.is_last_rank:
return
if layers_to_capture is None:
raise ValueError(
"DFLASH requires explicit layer ids for aux hidden capture."
)
self.capture_aux_hidden_states = True
self.model.set_dflash_layers_to_capture(layers_to_capture)
@torch.no_grad()
def forward(
self,
input_ids: torch.Tensor,
positions: torch.Tensor,
forward_batch: ForwardBatch,
input_embeds: Optional[torch.Tensor] = None,
pp_proxy_tensors: Optional[PPProxyTensors] = None,
**kwargs,
) -> Union[torch.Tensor, PPProxyTensors]:
if self.is_mrope_enabled:
positions = forward_batch.mrope_positions
View on GitHub (pinned to 0132848349)
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
Example fix
# before model.set_dflash_layers_to_capture(None) # after model.set_dflash_layers_to_capture([0, 2, 4, 6])
Defensive patterns
Strategy: validation
Validate before calling
layers = spec_config.dflash_capture_layers assert layers is not None and len(layers) > 0, "set dflash capture layers"
Type guard
def has_capture_layers(cfg) -> bool:
return isinstance(getattr(cfg, 'dflash_capture_layers', None), list) and len(cfg.dflash_capture_layers) > 0 Prevention
- Always pass an explicit layer list when enabling DFLASH
- Validate spec config before model init
When it happens
Trigger: 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.
Common situations: 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.
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
- DFLASH speculative decoding only supports CUDA and NPU devic
- Currently DFLASH speculative decoding does not support dp at
- Currently DFLASH speculative decoding only supports pp_size
- DFLASH speculative decoding requires setting --speculative-d
- DFLASH requires --speculative-dflash-block-size to be positi
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/0b779e643cedf428.
Report an issue: GitHub.