[ET-VK] Support exporting graphs with symbolic shape ops + update view to accept sym_size args#10980
Merged
Merged
Conversation
…w to accept sym_size args ## Context The ultimate goal is to be able to export the transformer models with dynamic shapes enabled so that batched prefill can be done. With transformer models, when dynamic shapes are turned on, `sym_size` operators appear in the graph which are used to determine the `seq_len` of the inputs, i.e. how many tokens are being passed into the input sequence. The `sym_size` operator accepts a tensor and a dim, and extracts the size of the tensor at the specified dim as a symbolic integer. In the transformer model, the `seq_len` symint is used as an argument to `view` operators. This PR enables exporting graphs with symbolic integer nodes and in particular the `sym_size` operator, as well as handling when symints are used in a list of ints. # Changes * Miscellaneous fixes to fix errors that show occur when symint nodes are encountered * Add C++ implementation of symint nodes and add registration for it * Enable the view operator to handle when the sizes arg includes symints Differential Revision: [D75019798](https://our.internmc.facebook.com/intern/diff/D75019798/) [ghstack-poisoned]
SS-JIA
added a commit
that referenced
this pull request
May 19, 2025
…w to accept sym_size args ## Context The ultimate goal is to be able to export the transformer models with dynamic shapes enabled so that batched prefill can be done. With transformer models, when dynamic shapes are turned on, `sym_size` operators appear in the graph which are used to determine the `seq_len` of the inputs, i.e. how many tokens are being passed into the input sequence. The `sym_size` operator accepts a tensor and a dim, and extracts the size of the tensor at the specified dim as a symbolic integer. In the transformer model, the `seq_len` symint is used as an argument to `view` operators. This PR enables exporting graphs with symbolic integer nodes and in particular the `sym_size` operator, as well as handling when symints are used in a list of ints. # Changes * Miscellaneous fixes to fix errors that show occur when symint nodes are encountered * Add C++ implementation of symint nodes and add registration for it * Enable the view operator to handle when the sizes arg includes symints Differential Revision: [D75019798](https://our.internmc.facebook.com/intern/diff/D75019798/) ghstack-source-id: 284928657 Pull Request resolved: #10980
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/10980
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit ecbdd6b with merge base 9663bfb ( FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
Contributor
|
This pull request was exported from Phabricator. Differential Revision: D75019798 |
trviv
approved these changes
May 20, 2025
471b89c
into
gh/SS-JIA/228/base
88 of 92 checks passed
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.
Stack from ghstack (oldest at bottom):
Context
The ultimate goal is to be able to export the transformer models with dynamic shapes enabled so that batched prefill can be done.
With transformer models, when dynamic shapes are turned on,
sym_sizeoperators appear in the graph which are used to determine theseq_lenof the inputs, i.e. how many tokens are being passed into the input sequence. Thesym_sizeoperator accepts a tensor and a dim, and extracts the size of the tensor at the specified dim as a symbolic integer.In the transformer model, the
seq_lensymint is used as an argument toviewoperators.This PR enables exporting graphs with symbolic integer nodes and in particular the
sym_sizeoperator, as well as handling when symints are used in a list of ints.Changes
Differential Revision: D75019798