sgl-project/sglang · error · ValueError
DFLASH sliding_attention layers require config.sliding_windo
Error message
DFLASH sliding_attention layers require config.sliding_window.
What it means
Raised by get_dflash_attention_sliding_window_size when the config declares sliding_attention layers (via layer_types) but no sliding_window value is present. SGLang needs the window size to build sliding-window attention for those draft layers; it also falls back to swa_window_size for Nemotron-35-style drafts before giving up.
Source
Thrown at python/sglang/srt/speculative/dflash_utils.py:419
raise ValueError(
"DFLASH config.layer_types must be a sequence of attention type strings."
)
return layer_types
def get_dflash_attention_sliding_window_size(config: Any) -> Optional[int]:
layer_types = get_dflash_layer_types(config)
if layer_types is None or "sliding_attention" not in layer_types:
return None
text_config = _get_text_config(config)
sliding_window = _cfg_get(
text_config, "sliding_window", _cfg_get(config, "sliding_window")
)
if sliding_window is None and is_nemotron_35_draft_config(config):
sliding_window = _get_dflash_config(config).get("swa_window_size")
if sliding_window is None:
raise ValueError(
"DFLASH sliding_attention layers require config.sliding_window."
)
# HF sliding windows include the current token; SGLang stores window_left.
return int(sliding_window) - 1
def _cfg_get(config: Any, key: str, default: Any = None) -> Any:
if isinstance(config, dict):
return config.get(key, default)
return getattr(config, key, default)
def _get_text_config(config: Any) -> Any:
if config is None:
return None
if isinstance(config, dict):
return config.get("text_config", config)View on GitHub (pinned to 0132848349)
Solutions
- Add sliding_window (int) to the model's config.json / text_config.
- If it is a Nemotron-35-style draft, ensure dflash_config.swa_window_size is set (it's used as fallback).
- Remove "sliding_attention" from layer_types if the draft is meant to be full-attention only.
Example fix
# before
# config.json: {"layer_types": ["full_attention", "sliding_attention"], ...} (no sliding_window)
# after
# config.json: {"layer_types": ["full_attention", "sliding_attention"], "sliding_window": 4096, ...} Defensive patterns
Strategy: validation
Validate before calling
tc = getattr(config, 'text_config', config)
lt = getattr(tc, 'layer_types', None) or getattr(config, 'layer_types', None)
if lt and any(t == 'sliding_attention' for t in lt):
sw = getattr(tc, 'sliding_window', None) or getattr(config, 'sliding_window', None)
if sw is None:
raise ValueError('sliding_attention layers declared but sliding_window missing') Prevention
- When adding sliding_attention to layer_types, always pair it with an integer sliding_window.
- For Nemotron-35-style drafts, verify dflash_config.swa_window_size exists as fallback.
When it happens
Trigger: get_dflash_attention_sliding_window_size(config) where layer_types contains "sliding_attention" but config.sliding_window / text_config.sliding_window is None and the config is not a Nemotron-35 draft (or lacks dflash_config.swa_window_size).
Common situations: Model repo config.json lists sliding_attention layers but omits sliding_window; a custom draft model adapter that doesn't propagate sliding_window into the text_config; older checkpoints that name the field differently.
Related errors
- DFLASH config.layer_types must be a sequence of attention ty
- 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
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/f4a55a79a6b625c0.
Report an issue: GitHub.