Skip to content

Conversation

SS-JIA
Copy link
Contributor

@SS-JIA SS-JIA commented Aug 15, 2025

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

  • 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

…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]
Copy link

pytorch-bot bot commented Aug 15, 2025

🔗 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 Failures

As of commit f657e26 with merge base 1b4968f (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 15, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D80293301

Copy link

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

…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]
@facebook-github-bot
Copy link
Contributor

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
Copy link
Contributor Author

SS-JIA commented Aug 15, 2025

@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]
@facebook-github-bot
Copy link
Contributor

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]
@facebook-github-bot
Copy link
Contributor

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]
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D80293301

@facebook-github-bot facebook-github-bot merged commit 74a45cd into gh/SS-JIA/287/base Aug 16, 2025
102 of 106 checks passed
@facebook-github-bot facebook-github-bot deleted the gh/SS-JIA/287/head branch August 16, 2025 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants