{"record":{"id":"1d5e470c473cf4a3","repo":"sgl-project/sglang","slug":"unknown-flash-attention-version-ver","errorCode":null,"errorMessage":"Unknown flash attention version {ver}","messagePattern":"Unknown flash attention version (.+?)","errorType":"validation","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/attention/flash_attention.py","lineNumber":221,"sourceCode":"            softmax_scale=softmax_scale,\n            causal=causal,\n            window_size=window_size,\n            softcap=softcap,\n            num_splits=num_splits,\n            pack_gqa=pack_gqa,\n            sinks=sinks,\n            score_mod=score_mod,\n            aux_tensors=aux_tensors,\n            sfq=sfq,\n            sfk=sfk,\n            sfv=sfv,\n            rel_bias=rel_bias,\n            rel_bias_prep_cache=rel_bias_prep_cache,\n            return_softmax_lse=return_softmax_lse,\n            out=out,\n        )\n    else:\n        raise RuntimeError(f\"Unknown flash attention version {ver}\")\n\n\ndef flash_attn_varlen_func(\n    q,\n    k,\n    v,\n    cu_seqlens_q,\n    cu_seqlens_k,\n    max_seqlen_q=None,\n    max_seqlen_k=None,\n    seqused_q=None,\n    seqused_k=None,\n    page_table=None,\n    softmax_scale=None,\n    causal=False,\n    qv=None,\n    q_descale=None,\n    k_descale=None,","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/attention/flash_attention.py#L203-L239","documentation":"flash_attn_with_kvcache dispatches across FA2/FA3 implementations based on the ver argument; any value other than the recognized versions falls through to raise RuntimeError(f\"Unknown flash attention version {ver}\").","triggerScenarios":"Calling flash_attn_with_kvcache(..., ver=X) where X is not a supported version constant (e.g. a string like '3' instead of 3, or an unsupported number).","commonSituations":"Passing ver read from config/env as a string; version mismatch after upgrading sglang where supported version set changed.","solutions":["Pass a supported integer version (e.g. 2 or 3) for ver","If ver comes from config, cast to int and validate against supported versions before calling","Check the function's signature/docstring for the currently accepted ver values in your sglang version"],"exampleFix":"// before\nout = flash_attn_with_kvcache(..., ver=int(os.getenv('FA_VER', '3')) if False else '3')\n// after\nout = flash_attn_with_kvcache(..., ver=3)","handlingStrategy":"type-guard","validationCode":"assert ver in (2, 3), f'unsupported flash attention version {ver!r}'","typeGuard":"def is_supported_fa_ver(ver) -> bool:\\n    return isinstance(ver, int) and ver in (2, 3)","tryCatchPattern":null,"preventionTips":["Normalize ver to int at config load","Whitelist supported versions before dispatch"],"tags":["flash-attention","version-dispatch","attention","invalid-argument"],"backgroundTag":"unsupported-library-version-specified","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}