FlashInfer CUDA Kernel Integration for Decode Attention with Attention Weights#65
Open
vihangp wants to merge 2 commits intoawslabs:mainfrom
Open
FlashInfer CUDA Kernel Integration for Decode Attention with Attention Weights#65vihangp wants to merge 2 commits intoawslabs:mainfrom
vihangp wants to merge 2 commits intoawslabs:mainfrom
Conversation
added 2 commits
March 16, 2026 12:52
…returns attention weights
mseeger
requested changes
Mar 16, 2026
Contributor
mseeger
left a comment
There was a problem hiding this comment.
Your PR seems to be touching a lot of files. Please check this:
- Put your changes on top of the current
mainbranch. This should resolve almost all the changes in existing files of the project - Are you sure you need all the new files? They seem to be taken from
flashinfer. Could we not makeflashinfera dependence, and then only copy files here which need a change?
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
This PR vendors FlashInfer's CUDA primitives into keys_values/csrc/ and builds custom prefill and decode kernels that return per-position attention weights — needed for H2O cache eviction. Standard attention libraries (Flash Attention, PyTorch SDPA) do not expose these weights during decode.
Key changes
Benchmark results (Qwen3-4B, A100, fp16, decode)
Batch size │ vs Eager (with weights) │ vs PyTorch SDPA (no weights |
4 │ 1.68-1.80x faster │ 0.96-1.17x (faster at 64K+) |
1 │ 0.60-0.85x │ 0.34-0.44x |
Prefill: 9-29x faster than eager, competitive with PyTorch SDPA.
Test plan