Skip to content

refactor: migrate compressed and sparse attention kernels. - #2804

Merged
XuZhang99 merged 3 commits into
xLLM-AI:mainfrom
XuZhang99:refactor/kernel-sparse-attention
Nov 20, 2026
Merged

XuZhang99 merged 3 commits into
xLLM-AI:mainfrom
XuZhang99:refactor/kernel-sparse-attention

Conversation

@XuZhang99

Copy link
Copy Markdown
Collaborator

Summary

  • Package Compressor, SparseAttnSharedkv, its AICPU metadata operator, and SparseFlashAttentionLse in xllm-kernel.
  • Bind the Python DSA/CSA and RoPE SFA paths at startup, including LSE statistics and caller-owned output buffers.

Validation

  • The CPU package suite passed 132 tests with 2 skipped.
  • Ascend 910B2 passed 168 model regression tests, including SFA-DCP remapping and CP/CSA indexing, and 11 focused cases with the legacy vendor directories hidden.
  • The full 498-case NPU suite passed on the preceding rebase. The last base update affected three unrelated VLM C++ files, and the kernel, Python, and relevant test sources were identical. NPU checks reused the existing OPP and native extension artifacts.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T13:22:18.126893Z 92dbf5f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 87b3df3f83

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@XuZhang99
XuZhang99 merged commit c07a39d into xLLM-AI:main Nov 20, 2026
2 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 92dbf5fbe6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +213 to +216
if ((socVersion_ != platform_ascendc::SocVersion::ASCEND910B) &&
(socVersion_ != platform_ascendc::SocVersion::ASCEND910_93)) {
OP_LOGE(opName_, "SOC Version[%d] is not support.", (int32_t)socVersion_);
return GRAPH_FAILED;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Align the shared-KV binding with its supported SoCs

On Ascend 950, this check always rejects the device, even though sparse_attn_sharedkv_def.cpp:133 registers ascend950 and the kernel entry point includes an arch35 implementation. The new Python DSV4 adapter unconditionally dispatches shared-KV attention to this private operator, so DeepSeek-V4 execution fails during tiling on 950, including with the default window parameters. Provide consistent 950 tiling support or gate the registration and Python dispatch instead of exposing a backend that necessarily rejects the device.

Useful? React with 👍 / 👎.

aicNum_ * workspaceParams_->curMm1ResSize * MM1_RES_ELEM_SIZE;
workspaceSize_ += aicNum_ * workspaceParams_->vec1ResSize * V1_RES_ELEM_SIZE;

workspaceSize_ += 1024 * 1024 * 1024; // 1024:申请workspace大小

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove the unused 1 GiB compressor workspace reservation

For every nonempty compressor invocation, this adds 1 GiB after the library workspace and all three scratch buffers have already been counted. Both CompressorKernel::InitWorkspace and CompressorKernelPerf::InitWorkspace only address the pre-MM1, current-MM1, and vector regions; there is no corresponding use of this extra allocation. Consequently, even single-token DeepSeek-V4 decode requires more than 1 GiB of scratch and can encounter avoidable OOM failures when free HBM would otherwise accommodate the actual buffers. Remove the fixed padding or explicitly size any additional required region.

Useful? React with 👍 / 👎.

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