{"record":{"id":"f4a55a79a6b625c0","repo":"sgl-project/sglang","slug":"dflash-sliding-attention-layers-require-config-sli","errorCode":null,"errorMessage":"DFLASH sliding_attention layers require config.sliding_window.","messagePattern":"DFLASH sliding_attention layers require config\\.sliding_window\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/speculative/dflash_utils.py","lineNumber":419,"sourceCode":"        raise ValueError(\n            \"DFLASH config.layer_types must be a sequence of attention type strings.\"\n        )\n    return layer_types\n\n\ndef get_dflash_attention_sliding_window_size(config: Any) -> Optional[int]:\n    layer_types = get_dflash_layer_types(config)\n    if layer_types is None or \"sliding_attention\" not in layer_types:\n        return None\n\n    text_config = _get_text_config(config)\n    sliding_window = _cfg_get(\n        text_config, \"sliding_window\", _cfg_get(config, \"sliding_window\")\n    )\n    if sliding_window is None and is_nemotron_35_draft_config(config):\n        sliding_window = _get_dflash_config(config).get(\"swa_window_size\")\n    if sliding_window is None:\n        raise ValueError(\n            \"DFLASH sliding_attention layers require config.sliding_window.\"\n        )\n\n    # HF sliding windows include the current token; SGLang stores window_left.\n    return int(sliding_window) - 1\n\n\ndef _cfg_get(config: Any, key: str, default: Any = None) -> Any:\n    if isinstance(config, dict):\n        return config.get(key, default)\n    return getattr(config, key, default)\n\n\ndef _get_text_config(config: Any) -> Any:\n    if config is None:\n        return None\n    if isinstance(config, dict):\n        return config.get(\"text_config\", config)","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/speculative/dflash_utils.py#L401-L437","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"# before\n# config.json: {\"layer_types\": [\"full_attention\", \"sliding_attention\"], ...}  (no sliding_window)\n# after\n# config.json: {\"layer_types\": [\"full_attention\", \"sliding_attention\"], \"sliding_window\": 4096, ...}","handlingStrategy":"validation","validationCode":"tc = getattr(config, 'text_config', config)\nlt = getattr(tc, 'layer_types', None) or getattr(config, 'layer_types', None)\nif lt and any(t == 'sliding_attention' for t in lt):\n    sw = getattr(tc, 'sliding_window', None) or getattr(config, 'sliding_window', None)\n    if sw is None:\n        raise ValueError('sliding_attention layers declared but sliding_window missing')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["speculative-decoding","dflash","sliding-window","hf-config"],"backgroundTag":"missing-config-field","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}