-
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 #13451
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 ## 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/) [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/13451
Note: Links to docs will display an error until the docs builds have been completed. ❌ 2 New FailuresAs of commit f657e26 with merge base 1b4968f ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This pull request was exported from Phabricator. Differential Revision: D80293301 |
This PR needs a
|
…graph pass instead of source transform" ## 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/) [ghstack-poisoned]
This pull request was exported from Phabricator. Differential Revision: D80293301 |
…graph pass instead of source transform" ## 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/) [ghstack-poisoned]
@SS-JIA has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
…graph pass instead of source transform" ## 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/) [ghstack-poisoned]
This pull request was exported from Phabricator. Differential Revision: D80293301 |
…graph pass instead of source transform" ## 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/) [ghstack-poisoned]
This pull request was exported from Phabricator. Differential Revision: D80293301 |
…graph pass instead of source transform" ## 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/) [ghstack-poisoned]
This pull request was exported from Phabricator. Differential Revision: D80293301 |
74a45cd
into
gh/SS-JIA/287/base
Stack from ghstack (oldest at bottom):
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
backends/vulkan/patterns
folder to store fusable graph patternsDifferential Revision: D80293301