Skip to content

Conversation

@SS-JIA
Copy link
Contributor

@SS-JIA SS-JIA commented May 19, 2025

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_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

…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
@pytorch-bot
Copy link

pytorch-bot bot commented May 19, 2025

🔗 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 (image):

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.

@facebook-github-bot facebook-github-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 May 19, 2025
@facebook-github-bot
Copy link
Contributor

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

@SS-JIA SS-JIA added the release notes: vulkan Changes to the Vulkan backend delegate label May 19, 2025
@facebook-github-bot facebook-github-bot merged commit 471b89c into gh/SS-JIA/228/base May 20, 2025
88 of 92 checks passed
@facebook-github-bot facebook-github-bot deleted the gh/SS-JIA/228/head branch May 20, 2025 16:10
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 release notes: vulkan Changes to the Vulkan backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants