[TORCH][MLIR] Added _sdpa_flash_attention op#4417
Open
keshavvinayak01 wants to merge 14 commits intollvm:mainfrom
Open
[TORCH][MLIR] Added _sdpa_flash_attention op#4417keshavvinayak01 wants to merge 14 commits intollvm:mainfrom
keshavvinayak01 wants to merge 14 commits intollvm:mainfrom
Conversation
Signed-off-by: Keshav Vinayak Jha <keshavvinayakjha@gmail.com>
Signed-off-by: Keshav Vinayak Jha <keshavvinayakjha@gmail.com>
Signed-off-by: Keshav Vinayak Jha <keshavvinayakjha@gmail.com>
Signed-off-by: Keshav Vinayak Jha <keshavvinayakjha@gmail.com>
2. Fixed op signature 3. Added DecomposeComplexOps template for (flash_attn, flash_attn_for_cpu) -> sdpa rewrite. 4. Lit test to check correct decomposition. Signed-off-by: Keshav Vinayak Jha <keshavvinayakjha@gmail.com>
Signed-off-by: Keshav Vinayak Jha <keshavvinayakjha@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR adds support for the _scaled_dot_product_flash_attention and _scaled_dot_product_flash_attention_for_cpu operations in the Torch-MLIR dialect. These operations are decomposed into the existing scaled_dot_product_attention operation.
Key Changes:
- Added decomposition patterns to convert flash attention ops to standard scaled dot product attention
- Registered the new operations in the ODS generator
- Added comprehensive test coverage for both new operations
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/Dialect/Torch/Transforms/DecomposeComplexOps.cpp | Implements decomposition pattern template for both flash attention operations |
| include/torch-mlir/Dialect/Torch/IR/GeneratedTorchOps.td | Defines the two new flash attention operation signatures and parsing/printing logic |
| projects/pt1/python/torch_mlir/jit_ir_importer/build_tools/torch_ods_gen.py | Registers the new operations with their type signatures |
| test/Dialect/Torch/decompose-complex-ops.mlir | Adds test cases verifying decomposition behavior for both operations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Keshav Vinayak Jha <keshavvinayakjha@gmail.com>
Signed-off-by: Keshav Vinayak Jha <keshavvinayakjha@gmail.com>
Signed-off-by: Keshav Vinayak Jha <keshavvinayakjha@gmail.com>
Signed-off-by: Keshav Vinayak Jha <keshavvinayakjha@gmail.com>
Signed-off-by: Keshav Vinayak Jha <keshavvinayakjha@gmail.com>
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.
Following the discussion at iree-org/iree-turbine#1224