-
Notifications
You must be signed in to change notification settings - Fork 689
[ET-VK] Move rotary embedding custom op to be handled via graph pass instead of source transform #13465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…instead of source transform Pull Request resolved: #13451 ## Motivation Be able to test Vulkan lowering via optimum-executorch. ## Context Currently, ET-VK implements rotary embeddings via a custom op. This op is currently inserted into Transformer models by replacing Rotary Embedding modules with a custom module that executes the custom op via a source transform. The source transform approach makes it cumbersome to lower LLMs to Vulkan, since it requires the export logic to apply the source transform before calling `torch.export()`. This in turn makes it difficult to integrate Vulkan lowering into optimum-executorch, which tries to use a common export + lowering logic for all lowering paths. As an alternative, leverage `SubgraphMatcher` to detect fusable patterns and fuse the rotary embedding graph pattern into the custom op as part of the Vulkan delegate's graph passes. This removes the requirement to apply a custom source transform just for Vulkan. ## Changes * Introduce the `backends/vulkan/patterns` folder to store fusable graph patterns * Introduce a fusable graph pattern for rotary positional embeddings * Update partitioner logic to automatically include nodes that are part of a fusable graph pattern * Introduce a pass to fuse known patterns into custom ops / custom op sequence * Remove vulkan rotary embedding source transform ghstack-source-id: 303387281 Differential Revision: [D80293301](https://our.internmc.facebook.com/intern/diff/D80293301/)
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/13465
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 14 Pending, 1 Unrelated FailureAs of commit fea6c7a with merge base 7fbca4d ( NEW FAILURE - The following job has failed:
BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
…instead of source transform (pytorch#13465) ## Motivation Be able to test Vulkan lowering via optimum-executorch. ## Context Currently, ET-VK implements rotary embeddings via a custom op. This op is currently inserted into Transformer models by replacing Rotary Embedding modules with a custom module that executes the custom op via a source transform. The source transform approach makes it cumbersome to lower LLMs to Vulkan, since it requires the export logic to apply the source transform before calling `torch.export()`. This in turn makes it difficult to integrate Vulkan lowering into optimum-executorch, which tries to use a common export + lowering logic for all lowering paths. As an alternative, leverage `SubgraphMatcher` to detect fusable patterns and fuse the rotary embedding graph pattern into the custom op as part of the Vulkan delegate's graph passes. This removes the requirement to apply a custom source transform just for Vulkan. ## Changes * Introduce the `backends/vulkan/patterns` folder to store fusable graph patterns * Introduce a fusable graph pattern for rotary positional embeddings * Update partitioner logic to automatically include nodes that are part of a fusable graph pattern * Introduce a pass to fuse known patterns into custom ops / custom op sequence Differential Revision: [D80293301](https://our.internmc.facebook.com/intern/diff/D80293301/) Co-authored-by: ssjia <ssjia@devvm5117.ash0.facebook.com>
This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #13451 by @SS-JIA
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/287/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/287/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/main
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/287/orig
@diff-train-skip-merge