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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

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.

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