{"record":{"id":"6a055a35febf711e","repo":"sgl-project/sglang","slug":"the-flashkda-kda-prefill-backend-requires-the-fl","errorCode":null,"errorMessage":"The 'flashkda' KDA prefill backend requires the flash_kda module, which is not installed. Install it from source:\\n    pip install git+https://github.com/MoonshotAI/FlashKDA.git","messagePattern":"The 'flashkda' KDA prefill backend requires the flash_kda module, which is not installed\\. Install it from source:\\\\n    pip install git\\+https://github\\.com/MoonshotAI/FlashKDA\\.git","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/layers/attention/linear/kernels/kda_flashkda.py","lineNumber":22,"sourceCode":"\nfrom sglang.srt.layers.attention.linear.kernels.kernel_backend import (\n    LinearAttnKernelBase,\n)\n\n# FlashKDA chunk size. Sequences shorter than this fall back to Triton.\n_FLASHKDA_CHUNK_SIZE = 64\n\n# FlashKDA's max sequence length, Batches whose longest sequence exceeds this\n# fall back to Triton for the whole batch.\n_FLASHKDA_MAX_SEQ_LEN = 2048\n\n\ndef _load_flash_kda():\n    \"\"\"Import the optional ``flash_kda`` CUTLASS module.\"\"\"\n    try:\n        import flash_kda\n    except ImportError as e:\n        raise ImportError(\n            \"The 'flashkda' KDA prefill backend requires the flash_kda module, \"\n            \"which is not installed. Install it from source:\\n\"\n            \"    pip install git+https://github.com/MoonshotAI/FlashKDA.git\"\n        ) from e\n    return flash_kda\n\n\ndef _triton_fallback(\n    q,\n    k,\n    v,\n    g,\n    beta,\n    ssm_states,\n    cache_indices,\n    query_start_loc,\n    A_log=None,\n    dt_bias=None,","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/layers/attention/linear/kernels/kda_flashkda.py#L4-L40","documentation":"The optional flash_kda CUTLASS module (MoonshotAI FlashKDA) is not installed; the 'flashkda' KDA prefill backend lazily imports it on first use and raises ImportError with install instructions.","triggerScenarios":"Selecting the flashkda KDA prefill backend without having installed the flash_kda package (it is not part of standard sglang dependencies).","commonSituations":"Fresh environment or Docker image that omits the source-only flash_kda dependency; new deployment enabling --linear-attn-backend flashkda.","solutions":["pip install git+https://github.com/MoonshotAI/FlashKDA.git","Fall back to triton or cutedsl prefill backend if you cannot build the CUTLASS extension","Ensure CUDA toolchain matches the build requirements of FlashKDA"],"exampleFix":"# before\n# flash_kda missing\n# after\npip install git+https://github.com/MoonshotAI/FlashKDA.git","handlingStrategy":"try-catch","validationCode":"try:\n    import flash_kda  # noqa\n    flashkda_ok = True\nexcept ImportError:\n    flashkda_ok = False\nif not flashkda_ok:\n    linear_attn_prefill_backend = 'triton'","typeGuard":"null","tryCatchPattern":"try:\n    _load_flash_kda()\nexcept ImportError as e:\n    logger.warning('flashkda unavailable (%s); using triton prefill', e)\n    use_flashkda = False","preventionTips":["Pre-install flash_kda in the serving image if the backend is required","Probe optional deps at startup and fall back"],"tags":["sglang","flashkda","kda","missing-dependency","pip-install"],"backgroundTag":"missing-optional-dependency","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}