feat(nvidia): add flash_attn_with_kvcache#818
Merged
Conversation
flash_attn_with_kvcache
voltjia
marked this pull request as ready for review
July 25, 2026 09:20
19 tasks
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_kvcacheAPI with the InfiniOps trailing-output convention.flash_attn_2_cudaextension without a submodule.Motivation
Decode attention needs to update an existing KV cache and consume it in the same kernel. PyTorch SDPA and the existing varlen FA2 operator do not expose this fused mutation contract. This operator follows Dao FlashAttention's public
flash_attn_with_kvcacheinterface, with InfiniOps outputs placed last.N/A - no linked issue.
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 changesPlatforms Affected
WITH_CPU)WITH_NVIDIA)WITH_ILUVATAR)WITH_METAX)WITH_CAMBRICON)WITH_MOORE)WITH_ASCEND)WITH_TORCH)Smoke Test Result
Test Results on Supported Platforms
0f6af3ereadelfchecks remain pending; standard smoke intentionally excludes this second provider operatorStatic validation
Benchmark / Performance Impact
N/A - this PR adds an existing provider kernel and makes no comparative performance claim.
Notes for Reviewers
flash::mha_fwd_kvcachesymbol before linking. The Python extension has no SONAME, so InfiniOps links by exact basename and installs an$ORIGIN/..runtime search path.k_cacheandv_cacheare mutable and follow the upstream in-place append behavior.return_softmax_lseparameter is retained for parameter-order alignment, but this first representative integration supports onlyfalse; a second trailing LSE output is intentionally out of scope.operator-pruned test and verifies the installed library's
NEEDEDandRUNPATHentries withreadelf -d.