{"record":{"id":"b6231b1c37410fa4","repo":"sgl-project/sglang","slug":"cross-attention-is-not-supported-in-the-hpc-ops-at","errorCode":null,"errorMessage":"Cross attention is not supported in the hpc_ops attention backend.","messagePattern":"Cross attention is not supported in the hpc_ops attention backend\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/layers/attention/attention_registry.py","lineNumber":265,"sourceCode":"\n    return CutlassMLABackend(runner)\n\n\n@register_attention_backend(\"trtllm_mha\")\ndef create_trtllm_mha_backend(runner):\n    if runner.use_mla_backend:\n        raise ValueError(\"trtllm_mha backend can only be used with non-MLA models.\")\n    from sglang.srt.layers.attention.trtllm_mha_backend import TRTLLMHAAttnBackend\n\n    return TRTLLMHAAttnBackend(runner)\n\n\n@register_attention_backend(\"hpc_ops\")\ndef create_hpc_ops_backend(runner):\n    if runner.use_mla_backend:\n        raise ValueError(\"hpc_ops backend can only be used with non-MLA models.\")\n    if runner.model_config.is_encoder_decoder:\n        raise ValueError(\n            \"Cross attention is not supported in the hpc_ops attention backend.\"\n        )\n    if get_spec().speculative_algorithm is not None:\n        raise ValueError(\n            \"hpc_ops backend does not support speculative decoding for now.\"\n        )\n    from sglang.srt.layers.attention.hpc_ops_backend import HPCOpsAttnBackend\n\n    return HPCOpsAttnBackend(runner)\n\n\n@register_attention_backend(\"intel_amx\")\ndef create_intel_amx_backend(runner):\n    from sglang.srt.layers.attention.intel_amx_backend import IntelAMXAttnBackend\n\n    return IntelAMXAttnBackend(runner)\n\n","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/layers/attention/attention_registry.py#L247-L283","documentation":"The hpc_ops backend implements self-attention only; encoder-decoder models (runner.model_config.is_encoder_decoder true) also need cross-attention over encoder KV, which hpc_ops does not provide. The factory fails fast at backend creation rather than crashing mid-forward.","triggerScenarios":"Launching an encoder-decoder model (Whisper, T5-style, encoder-decoder VLMs) with --attention-backend hpc_ops.","commonSituations":"Using hpc_ops as a fast NPU backend but pointing the server at an encoder-decoder checkpoint; config templates that set a fixed attention backend across heterogeneous models.","solutions":["Remove the hpc_ops backend override and use a backend that supports cross-attention (e.g. the default/fallback attention backend)","Keep encoder-decoder models on their default auto-selected backend"],"exampleFix":"# before\n--attention-backend hpc_ops --model whisper-large\n# after\n--model whisper-large  # default backend handles cross-attention","handlingStrategy":"validation","validationCode":"if model_runner.model_config.is_encoder_decoder and server_args.attention_backend == \"hpc_ops\":\n    raise SystemExit(\"hpc_ops has no cross-attention; use the default backend\")","typeGuard":"def is_encoder_decoder(cfg) -> bool:\n    return bool(getattr(cfg, \"is_encoder_decoder\", False))","tryCatchPattern":null,"preventionTips":["Screen encoder-decoder checkpoints against backend capability lists at config load","Never inherit backend overrides across different model types in shared launch templates"],"tags":["attention-backend","hpc-ops","encoder-decoder","cross-attention","npu","sglang"],"backgroundTag":"unsupported-feature-combination","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}