Skip to content

[Attentions][Fix] Rename block sparse attention - #571

Open
Napkin-AI wants to merge 5 commits into
sgl-project:mainfrom
Napkin-AI:rename_block_sparse_attn
Open

[Attentions][Fix] Rename block sparse attention #571
Napkin-AI wants to merge 5 commits into
sgl-project:mainfrom
Napkin-AI:rename_block_sparse_attn

Conversation

@Napkin-AI

@Napkin-AI Napkin-AI commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Description

Rename aclnnBlockSparseAttention to aclnnAdaBlockSparseAttention as specified in MindIE-SD.
Add an option to build only the attentions module.

Motivation

Operator name aclnnBlockSparseAttention in sgl-kernel-npu conflicts with CANN version >= 9.0.0; using block sparse attention backend in sglang with a pre-build package may lead to runtime error.

Environment:

  • sglang 0.5.12
  • torch 2.8.0
  • torch_npu 2.8.0.post4
  • CANN 9.0.0

How to reproduce

sglang generate --model-path Wan-AI/Wan2.2-T2V-A14B-Diffusers --prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage." --height 720 --width 1280 --tp-size 4 --sp-degree 2 --num-gpus 8 --num-frames 81 --num-inference-steps 40 --port 30088 --dit-cpu-offload False --attention-backend "block_sparse_attn" --attention-backend-config "sparsity=0.9,skip_first_steps=0"

Logs:

Exception: Error executing request 1204916e-f39e-4e22-a53c-32b8e6947945: call aclnnBlockSparseAttention failed, detail:EH9999: Inner Error!
EH9999[PID: 1691925] 2026-06-25-19:05:47.389.310 (EH9999):  get device uuid failed, deviceId = 0, runtime result = 207000[FUNC:ReportCallError][FILE:log_inner.cpp][LINE:148]
        TraceBack (most recent call last):
       The inputLayout attrs only support TND/BNSD.[FUNC:GetInputLayout][FILE:block_sparse_attention_tiling.cpp][LINE:180]
       GetBsaTiling failed[FUNC:TilingBlockSparseAttention][FILE:block_sparse_attention_tiling.cpp][LINE:813]
       BlockSparseAttention do tiling failed, ret is -1.
       Check NnopbaseExecutorDoTiling(executor) failed
       Check NnopbaseExecutorTilingAndUpdateBinInfo(executor) failed
       Check NnopbaseExecutorMatchCache(executor) failed
       Check NnopbaseRunForWorkspace(*executor, workspaceSize) failed

The line "The inputLayout attrs only support TND/BNSD." indicates using operator from CANN and can be found here:

https://gitcode.com/cann/ops-transformer/blob/9.0.0/attention/block_sparse_attention/op_host/block_sparse_attention_tiling.cpp line 180.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request renames the block_sparse_attention module and its associated classes, functions, and files to ada_block_sparse_attention across the codebase. It also introduces a new attentions build option in build.sh. The feedback suggests improving the build script by introducing an ONLY_BUILD_ATTENTIONS_MODULE variable to maintain consistency with other existing 'only build' options, enhancing readability and maintainability.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread build.sh
@ping1jing2 ping1jing2 self-assigned this Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants