{"record":{"id":"520bbd6c028b2387","repo":"sgl-project/sglang","slug":"invalid-version-self-fa-impl-ver","errorCode":null,"errorMessage":"Invalid version: {self.fa_impl_ver=}","messagePattern":"Invalid version: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/layers/attention/flashattention_backend.py","lineNumber":300,"sourceCode":"                )\n            else:\n                from sglang.kernels.ops.attention.flash_attention_v4 import (\n                    flash_attn_varlen_func,\n                    flash_attn_with_kvcache,\n                )\n\n                self._get_fa_runtime_policy = None\n\n            self._get_scheduler_metadata = None\n            if get_exec().deterministic.enable_deterministic_inference:\n                # Must precede the first kernel compile.\n                from sglang.kernels.ops.attention.flash_attn.cute.batch_invariance import (\n                    set_batch_invariant,\n                )\n\n                set_batch_invariant(True)\n        else:\n            raise ValueError(f\"Invalid version: {self.fa_impl_ver=}\")\n\n        self.flash_attn_varlen_func = flash_attn_varlen_func\n        self.flash_attn_with_kvcache = flash_attn_with_kvcache\n\n        # Store head info for precomputing FA3 scheduler metadata\n        self.head_dim = model_runner.model_config.head_dim\n        self.num_attention_heads = (\n            model_runner.model_config.hf_text_config.num_attention_heads\n            // model_runner.ps.tp_size\n        )\n        self.num_kv_heads = model_runner.model_config.get_num_kv_heads(\n            model_runner.ps.tp_size\n        )\n        _softcapping = getattr(\n            model_runner.model_config.hf_text_config, \"attn_logit_softcapping\", None\n        )\n        self.has_softcap = _softcapping is not None and _softcapping > 0.0\n","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/layers/attention/flashattention_backend.py#L282-L318","documentation":"FlashAttentionBackend dispatches among FA2/FA3/FA4 implementations based on self.fa_impl_ver; any unrecognized value falls into the else branch and raises. The version is auto-detected from installed flash-attn/flash-attn-3/cute packages or forced via env/args.","triggerScenarios":"Constructing FlashAttentionBackend when fa_impl_ver was set to something other than 2, 3 or 4 — e.g. manually overriding the version env var, or an auto-detection path that returned an invalid sentinel after a partial/broken flash-attn install.","commonSituations":"Mixing flash-attn versions (pip flash-attn + flash-attn-3 + cute-dsl combos), stale SGLANG env overrides like SGLANG_FLASHATTENTION_VERSION=5, or upgrading SGLang against an unsupported flash-attn build.","solutions":["Unset/fix any override such as SGLANG_FLASHATTENTION_VERSION so it is 2, 3, or 4","Reinstall a compatible flash-attn package matching the SGLang version requirement","Let auto-detection pick the version (remove manual pinning) and retry startup"],"exampleFix":"# before\nexport SGLANG_FLASHATTENTION_VERSION=5\n# after\nunset SGLANG_FLASHATTENTION_VERSION  # or set to 2/3/4","handlingStrategy":"validation","validationCode":"ver = int(os.environ.get('SGLANG_FLASHATTENTION_VERSION', '0') or 0)\nassert ver in (0, 2, 3, 4), f'bad FA version override {ver}'","typeGuard":null,"tryCatchPattern":"try:\n    backend = FlashAttentionBackend(...)\nexcept ValueError as e:\n    if 'Invalid version' in str(e):\n        os.environ.pop('SGLANG_FLASHATTENTION_VERSION', None)\n        backend = FlashAttentionBackend(...)  # re-init with autodetect","preventionTips":["Don't hard-pin FA version env vars across upgrades","Smoke-test attention backend init before long runs"],"tags":["flash-attention","version","init","sglang"],"backgroundTag":"invalid-library-version","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}