{"record":{"id":"688f6f2a8623db62","repo":"sgl-project/sglang","slug":"flashattention-4-cute-is-not-available-install-fl-688f6f","errorCode":null,"errorMessage":"FlashAttention-4 CUTE is not available. Install flash-attn-4 with its CUDA/CUTE dependencies, or run from a source tree where the vendored FA4 package is importable.","messagePattern":"FlashAttention-4 CUTE is not available\\. Install flash-attn-4 with its CUDA/CUTE dependencies, or run from a source tree where the vendored FA4 package is importable\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"python/sglang/kernels/ops/attention/flash_attention_v4_sm120.py","lineNumber":112,"sourceCode":"    sinks: Optional[torch.Tensor] = None,\n    num_splits: int = 1,\n    pack_gqa: Optional[bool] = None,\n    score_mod: Optional[Callable] = None,\n    aux_tensors: Optional[list] = None,\n    q_descale: Optional[torch.Tensor] = None,\n    k_descale: Optional[torch.Tensor] = None,\n    v_descale: Optional[torch.Tensor] = None,\n    sfq: Optional[torch.Tensor] = None,\n    sfk: Optional[torch.Tensor] = None,\n    sfv: Optional[torch.Tensor] = None,\n    rel_bias: Optional[torch.Tensor] = None,\n    rel_bias_prep_cache: Optional[dict] = None,\n    return_softmax_lse: bool = False,\n    out: Optional[torch.Tensor] = None,\n    **_: object,\n):\n    if _flash_attn_varlen_func is None:  # pragma: no cover\n        raise ImportError(\n            \"FlashAttention-4 CUTE is not available. Install flash-attn-4 with \"\n            \"its CUDA/CUTE dependencies, or run from a source tree where the \"\n            \"vendored FA4 package is importable.\"\n        ) from _flash_attn_import_error\n\n    _validate_out_contract(out)\n    q, k, v, qv = [_maybe_contiguous(t) for t in (q, k, v, qv)]\n    if qv is None and q.shape[-1] == 256 and k.shape[-1] == 256 and v.shape[-1] == 256:\n        # The vendored hd256 kernel assumes dense Q/K/V strides.\n        q, k, v = [t.contiguous() for t in (q, k, v)]\n    q, qv, mla_head_padding = _pad_mla_q_heads(q, qv, v, pack_gqa)\n    if qv is not None and num_splits < 1:\n        # FA4 MLA does not implement split-KV; auto mode must use one split.\n        num_splits = 1\n    cu_seqlens_q, cu_seqlens_k = [\n        _maybe_contiguous(t) for t in (cu_seqlens_q, cu_seqlens_k)\n    ]\n    seqused_q, seqused_k = [_maybe_contiguous(t) for t in (seqused_q, seqused_k)]","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/kernels/ops/attention/flash_attention_v4_sm120.py#L94-L130","documentation":"Same as the FA4 import guard: the sm120 FA4 varlen wrapper lazily imports the flash-attn-4 CUTE package and raises ImportError with the original failure chained if it is unavailable.","triggerScenarios":"Calling flash_attn_varlen_func / flash_attn_with_kvcache from flash_attention_v4_sm120 when the FA4 package import failed at module load.","commonSituations":"Missing or broken flash-attn-4 install; running an installed wheel without vendored FA4 sources; wrong environment/venv.","solutions":["Install flash-attn-4 with CUDA/CUTE deps or run from the sglang source tree","Inspect e.__cause__ for the underlying import failure","Sanity-check the import in the same Python env before launching the server"],"exampleFix":"# before\n# ImportError at first attention call\n# after\npip install flash-attn-4 --no-build-isolation\npython -c 'import sglang.kernels.ops.attention.flash_attention_v4_sm120'","handlingStrategy":"validation","validationCode":"from sglang.kernels.ops.attention import flash_attention_v4_sm120 as fa\\nassert fa._flash_attn_varlen_func is not None, 'flash-attn-4 not importable'","typeGuard":null,"tryCatchPattern":"try:\\n    out = fa.flash_attn_varlen_func(...)\\nexcept ImportError as e:\\n    log.error('FA4 unavailable: %s', e.__cause__); use_fa4 = False","preventionTips":["Preflight the FA4 import at server startup","Pin flash-attn-4 in the environment manifest"],"tags":["flash-attention","fa4","sm120","import-error","missing-dependency"],"backgroundTag":"optional-dependency-not-installed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}