Skip to content
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

[dynamo exporter] Support string in dynamic_shapes #1639

Merged
merged 7 commits into from
Feb 21, 2025

Conversation

titaiwangms
Copy link
Contributor

Describe your changes

With pytorch/pytorch#146321, torch.onnx.export(.., dynamo=True) now can support string in dynamic_shapes, which fits better with Olive driven with configuration.

Major changes:

  • Add support for string in dynamic_shapes
    • Move dynamic_shapes pre-process to io_config.py (like dynamic_axes)
    • Get rid of the post-process of making [str, int, int] -> torch.export.Dim(str, max=int, min=int). torch.onn.export(..., dynamo=True) can now take string.
    • Leverage Optimum to auto-generate dynamic_shapes when Optimum models is requested.
    • KV cache support

Pitfall:

  • When dynamic_shapes targets kwargs, both of them need to follow the order of model.forward signature. onnx/conversion.py provides naive approach to sort them, but users should be aware of this.

Minor changes:

  • Move onnxscript (released) to the official requirement.txt
  • dynamic_shapes with string is supported since torch 2.7

Checklist before requesting a review

  • Add unit tests for this change.
  • Make sure all tests can pass.
  • Update documents if necessary.
  • Lint and apply fixes to your code by running lintrunner -a
  • Is this a user-facing change? If yes, give a description of this change to be included in the release notes.
  • Is this PR including examples changes? If yes, please remember to update example documentation in a follow-up PR.

(Optional) Issue link

@titaiwangms titaiwangms changed the title Titaiwang/support custom axis [dynamo exporter] Support string in dynamic_shapes Feb 21, 2025
@jambayk jambayk merged commit ba7e187 into main Feb 21, 2025
27 checks passed
@jambayk jambayk deleted the titaiwang/support_custom-axis branch February 21, 2025 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants