feat(cambricon): add flash attention KV-cache provider - #969
Merged
Conversation
19 tasks
baominghelly
force-pushed
the
feat/cambricon-flash-attn-with-kvcache
branch
from
September 3, 2026 02:10
6e71e4b to
c7c7836
Compare
baominghelly
marked this pull request as ready for review
September 3, 2026 02:27
voltjia
requested changes
Sep 3, 2026
Collaborator
There was a problem hiding this comment.
这个文件和所在文件夹先不引入了,有需要的话先放入 src/linked/torch/cambricon/ops/flash_attn_with_kvcache/flash_attn.cc 的 namespace detail 里面吧。
Contributor
Author
There was a problem hiding this comment.
已修改,放入common文件夹中
baominghelly
force-pushed
the
feat/cambricon-flash-attn-with-kvcache
branch
from
September 3, 2026 07:14
c7c7836 to
4a750ac
Compare
voltjia
approved these changes
Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
flash_attn_with_kvcache.flash-attnextension (flash_attn_2_bang*.so) and call itsmha_varlen_fwdentry point.Motivation
Cambricon model inference needs FlashAttention decoding against an existing KV cache. The existing linked implementation covered NVIDIA only, so Cambricon could not select the linked slot used by the model operator manifest.
Type of Change
feat— new feature / new operator / new platformfix— bug fixperf— performance improvement (no behavioral change)refactor— code restructuring without behavior changetest— adding or fixing tests onlydocs— documentation onlybuild/ci— build system or CI configurationchore— tooling, formatting, or other non-code changes!in the Conventional Commits prefix or aBREAKING CHANGE:footer)Platforms Affected
WITH_CPU)WITH_NVIDIA)WITH_ILUVATAR)WITH_METAX)WITH_CAMBRICON)WITH_MOORE)WITH_ASCEND)WITH_TORCH)Smoke Test Result
Not run — the repository's official Cambricon smoke suite was not run. A fresh slot-specific Cambricon linked build and operator test were run instead.
Test Results on Supported Platforms
opstarget passed; official smoke not run12 passedfortest_flash_attn_with_kvcache.pyTargeted pytest output
Benchmark / Performance Impact
N/A - no benchmark was run.
Notes for Reviewers
flash-attnPython distribution and itsflash_attn_2_bang*.solibrary.cache_batch_idx; dense cache mode does.src/common/op_utils/paged_kv_cache.h. The header intentionally depends on ATen because its current consumers are linked Torch FlashAttention providers; this scope is documented inline.clang-format --dry-run --Werrorandgit diff --checkpassed.alltarget also attempts repository examples; those examples failed to link against the installed InfiniRT because it lacksTensorView::ToString(). The testedinfiniopsandopstargets built successfully.