{"record":{"id":"38ac38a74e79e826","repo":"sgl-project/sglang","slug":"cp-attention-for-non-fia-path-on-ascend-is-not-yet","errorCode":null,"errorMessage":"CP attention for non-FIA path on Ascend is not yet implemented. Set ASCEND_USE_FIA=1 to use FIA-based CP attention.","messagePattern":"CP attention for non-FIA path on Ascend is not yet implemented\\. Set ASCEND_USE_FIA=1 to use FIA-based CP attention\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/hardware_backend/npu/attention/ascend_backend.py","lineNumber":1403,"sourceCode":"                        v_cache,\n                        sinks,\n                        self.forward_metadata.extend_seq_lens,\n                        block_tables,\n                        self.forward_metadata.seq_lens,\n                        layer.scaling,\n                        layer.sliding_window_size,\n                        layer.tp_q_head_num,\n                        layer.tp_k_head_num,\n                    )\n                return attn_out\n\n            if is_cp_mode:\n                if self.use_fia:\n                    attn_output = self.do_cp_attn_fia(\n                        q, k_cache, v_cache, layer, forward_batch\n                    )\n                else:\n                    raise NotImplementedError(\n                        \"CP attention for non-FIA path on Ascend is not yet implemented. \"\n                        \"Set ASCEND_USE_FIA=1 to use FIA-based CP attention.\"\n                    )\n                return attn_output\n\n            if self.use_fia:\n                if self._can_use_tnd(layer):\n                    \"\"\"FIA supports multi-bs in the current version of CANN\"\"\"\n                    q = q.reshape(-1, layer.tp_q_head_num, layer.qk_head_dim)\n                    num_token_padding = q.shape[0]\n                    if num_token_padding > forward_batch.num_token_non_padded_cpu:\n                        q, k, v = [\n                            data[: forward_batch.num_token_non_padded_cpu]\n                            for data in [q, k, v]\n                        ]\n                    attn_output, _ = torch_npu.npu_fused_infer_attention_score(\n                        query=q,\n                        key=k_cache.view(","sourceCodeStart":1385,"sourceCodeEnd":1421,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/hardware_backend/npu/attention/ascend_backend.py#L1385-L1421","documentation":"On Ascend NPUs, context-parallel (CP) attention in the extend path is only implemented for the FIA (Flash Infer Ascend-style) algorithm. If CP mode is active and ASCEND_USE_FIA is not enabled, the backend raises NotImplementedError with the exact env var to set.","triggerScenarios":"Running an extend forward with context parallelism enabled on Ascend while self.use_fia is False — i.e. ASCEND_USE_FIA unset/0 — so the non-FIA CP branch is reached.","commonSituations":"Enabling CP (e.g. large-context deepseek/long-context serving with context parallel) on Ascend without ASCEND_USE_FIA=1; a deployment copied from a non-FIA Ascend config then scaled to CP.","solutions":["Set ASCEND_USE_FIA=1 in the server environment and restart","If FIA is unsuitable for your model, disable context parallelism on Ascend until non-FIA CP is implemented","Verify the env var reaches the scheduler/worker processes (not stripped by a launcher)"],"exampleFix":"# before\nASCEND_USE_FIA=0 python -m sglang.launch_server ... --cp-size 4\n# after\nASCEND_USE_FIA=1 python -m sglang.launch_server ... --cp-size 4","handlingStrategy":"validation","validationCode":"import os\nif cp_size > 1 and platform is ascend:\n    assert os.environ.get(\"ASCEND_USE_FIA\", \"0\") == \"1\", (\n        \"Ascend CP attention requires ASCEND_USE_FIA=1\")","typeGuard":null,"tryCatchPattern":"try:\n    attn_output = backend.forward_extend(...)\nexcept NotImplementedError as e:\n    if \"ASCEND_USE_FIA\" in str(e):\n        raise SystemExit(\"Restart with ASCEND_USE_FIA=1 or disable --cp-size\") from e\n    raise","preventionTips":["Set ASCEND_USE_FIA=1 whenever using CP on Ascend","Validate env vars in launch wrappers before spawning workers","Track Ascend backend support matrix for non-FIA paths"],"tags":["ascend","npu","context-parallel","fia","not-implemented","huawei"],"backgroundTag":"feature-not-implemented","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}