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 #1631

Closed

Conversation

titaiwangms
Copy link
Contributor

@titaiwangms titaiwangms commented Feb 20, 2025

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 [dynamo exporter] Support string indynamic_shapes [dynamo exporter] Support string in dynamic_shapes Feb 20, 2025
@titaiwangms titaiwangms marked this pull request as ready for review February 20, 2025 19:53
@titaiwangms
Copy link
Contributor Author

titaiwangms commented Feb 20, 2025

Some CI tests are failing with docker huggingface issues.

@titaiwangms
Copy link
Contributor Author

Replaced by #1639

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