{"record":{"id":"25d2cc7a6109b411","repo":"sgl-project/sglang","slug":"f-flash-attention-version-fa-ver-is-not-supporte","errorCode":null,"errorMessage":"f\"flash attention version {fa_ver} is not supported.\"","messagePattern":"f\"flash attention version (.+?) is not supported\\.\"","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/layers/attention/backends/flash_attn.py","lineNumber":449,"sourceCode":"                    ver=fa_ver,\n                )\n                return out_tensor, softmax_lse\n            out_tensor = flash_attn_varlen_func_op(\n                q=query,\n                k=key,\n                v=value,\n                cu_seqlens_q=None,\n                cu_seqlens_k=None,\n                max_seqlen_q=max_seqlen_q,\n                max_seqlen_k=max_seqlen_k,\n                softmax_scale=self.softmax_scale,\n                causal=self.causal,\n                return_softmax_lse=False,\n                ver=fa_ver,\n            )\n            return out_tensor\n\n        raise ValueError(f\"flash attention version {fa_ver} is not supported.\")\n\n    def forward_varlen(\n        self,\n        query: torch.Tensor,\n        key: torch.Tensor,\n        value: torch.Tensor,\n        *,\n        cu_seqlens: torch.Tensor,\n        max_seqlen: int,\n        cu_seqlens_host: tuple[int, ...] | None = None,\n    ) -> torch.Tensor:\n        del cu_seqlens_host\n        output = flash_attn_varlen_func(\n            query,\n            key,\n            value,\n            cu_seqlens_q=cu_seqlens,\n            cu_seqlens_k=cu_seqlens,","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/layers/attention/backends/flash_attn.py#L431-L467","documentation":"FlashAttention.forward dispatches among flash-attention kernel versions (fa_ver); if the requested version is not one of the implemented dispatch branches, it raises ValueError naming the unsupported version.","triggerScenarios":"Calling forward with a fa_ver not covered by the dispatch branches (e.g. an experimental integer set via config/env override, or set by version autodetection after upgrading flash-attn).","commonSituations":"Setting a custom attention version flag for a kernel this SGLang version predates; upgrading flash-attn so autodetection picks an unsupported major; hand-editing config with a bad ver integer.","solutions":["Check the dispatch branches in flash_attn.py forward() and remove the override so a supported ver is used","Downgrade flash-attn to a major version supported by this SGLang release, or upgrade SGLang","If you genuinely need the new version, add a dispatch case and verify numerics"],"exampleFix":"# before\nout = impl.forward(q, k, v, meta)  # fa_ver=5 unsupported\n# after: remove override / use supported version\nout = impl.forward(q, k, v, meta)  # fa_ver resolves to 4","handlingStrategy":"fallback","validationCode":"SUPPORTED_FA_VERS = {2, 3, 4}  # mirror the dispatch branches in flash_attn.forward\nassert fa_ver in SUPPORTED_FA_VERS, f\"fa_ver {fa_ver} unsupported\"","typeGuard":null,"tryCatchPattern":"try:\n    out = impl.forward(q, k, v, meta)\nexcept ValueError as e:\n    if \"flash attention version\" in str(e):\n        out = impl.forward(q, k, v, meta)  # without the ver override","preventionTips":["Don't hardcode experimental fa_ver values in config","Pin a flash-attn version compatible with your SGLang release"],"tags":["flash-attention","version-mismatch","dispatch","config"],"backgroundTag":"unsupported-library-version","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}