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

Add ONNX export support for ModernBERT #2131

Merged
merged 7 commits into from
Jan 7, 2025
Merged

Add ONNX export support for ModernBERT #2131

merged 7 commits into from
Jan 7, 2025

Conversation

xenova
Copy link
Contributor

@xenova xenova commented Dec 19, 2024

What does this PR do?

This PR adds ONNX export support for ModernBERT, added to transformers in huggingface/transformers#35158. It uses torch.compile decorators for certain functions, which is not supported in torch.onnx.export (with dynamo=False), so I introduced a model loader context manager to disable this when the model is being loaded. Note that this cannot happen in a model patcher since by then, the model class has already been created.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

Who can review?

@xenova xenova marked this pull request as ready for review December 20, 2024 15:17
@xenova
Copy link
Contributor Author

xenova commented Dec 20, 2024

Now works with sentence-transformers & transformers models 👍

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@echarlaix echarlaix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks a lot @xenova

@xenova xenova merged commit 72498dd into main Jan 7, 2025
59 of 60 checks passed
@xenova xenova deleted the add-modernbert-onnx branch January 7, 2025 19:23
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.

3 participants